Skip to content

Commit

Permalink
lock and unlock mutex around fortran function calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Expander authored and Expander committed Apr 12, 2014
1 parent fcf69f1 commit cd2412e
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 33 deletions.
86 changes: 53 additions & 33 deletions meta/SelfEnergies.m
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,8 @@
double s1s = 0., s2s = 0., s1t = 0., s2t = 0.;
double s1b = 0., s2b = 0., s1tau = 0., s2tau = 0.;
LOCK_MUTEX();
ewsb2loop_(&rmtsq, &mg, &mst1sq, &mst2sq, &sxt, &cxt, &scalesq,
&amu, &tanb, &vev2, &gs, &s1s, &s2s);
ddstad_(&rmtsq, &rmbsq, &mAsq, &mst1sq, &mst2sq, &msb1sq, &msb2sq,
Expand All @@ -563,6 +565,8 @@
tausqtad_(&rmtausq, &mAsq, &msnusq, &mstau1sq, &mstau2sq, &sintau,
&costau, &scalesq, &amu, &tanb, &vev2, &s1tau, &s2tau);
UNLOCK_MUTEX();
if (!std::isnan(s1s * s1t * s1b * s1tau * s2s * s2t * s2b * s2tau)) {
result[0] = (- s1s - s1t - s1b - s1tau) * " <> CConversion`ToValidCSymbolString[SARAH`VEVSM1] <> ";
result[1] = (- s2s - s2t - s2b - s2tau) * " <> CConversion`ToValidCSymbolString[SARAH`VEVSM2] <> ";
Expand Down Expand Up @@ -632,6 +636,8 @@
double s1s = 0., s2s = 0., s1t = 0., s2t = 0.;
double s1b = 0., s2b = 0., s1tau = 0., s2tau = 0.;
LOCK_MUTEX();
ewsb2loop_(&rmtsq, &mg, &mst1sq, &mst2sq, &sxt, &cxt, &scalesq,
&amu, &tanb, &vev2, &gs, &s1s, &s2s);
ddstad_(&rmtsq, &rmbsq, &mAsq, &mst1sq, &mst2sq, &msb1sq, &msb2sq,
Expand All @@ -642,6 +648,8 @@
tausqtad_(&rmtausq, &mAsq, &msnusq, &mstau1sq, &mstau2sq, &sintau,
&costau, &scalesq, &amu, &tanb, &vev2, &s1tau, &s2tau);
UNLOCK_MUTEX();
// rescale T1 to get TS
const double sss = s1s * vev * cosb / " <> svevStr <> ";
const double ssb = s1b * vev * sinb / " <> svevStr <> ";
Expand Down Expand Up @@ -747,8 +755,11 @@
double s11b = 0., s12b = 0., s22b = 0.;
double s11tau = 0., s12tau = 0., s22tau = 0.;
double s11w = 0., s22w = 0., s12w = 0.;
double p2s = 0., p2w = 0., p2b = 0., p2tau = 0.;
int scheme = 0; // chooses DR-bar scheme from slavich et al
LOCK_MUTEX();
// two-loop Higgs corrections: alpha_s alpha_t, alpha_s alpha_b and
// alpha_b^2, alpha_t*2, alpha_b alpha_t
dszhiggs_(&rmtsq, &mg, &mst1sq, &mst2sq, &sxt, &cxt, &scalesq, &amu,
Expand All @@ -762,16 +773,9 @@
&costau, &scalesq, &amu, &tanb, &vev2, &scheme, &s11tau,
&s22tau, &s12tau);
result[0] = - s11s - s11w - s11b - s11tau; // 1,1 element
result[1] = - s12s - s12w - s12b - s12tau; // 1,2 element
result[2] = - s22s - s22w - s22b - s22tau; // 2,2 element
// calculate dMA, which is the two loop correction to take the DRbar
// psuedoscalar mass ( = -2m3sq/sin(2beta)) to the pole mass (as in
// Eq. (8) of hep-ph/0305127)
double p2s = 0., p2w = 0., p2b = 0., p2tau = 0.;
dszodd_(&rmtsq, &mg, &mst1sq, &mst2sq, &sxt, &cxt, &scalesq, &amu,
&tanb, &vev2, &gs, &p2s);
dszodd_(&rmbsq, &mg, &msb1sq, &msb2sq, &sxb, &cxb, &scalesq, &amu,
Expand All @@ -781,12 +785,18 @@
tausqodd_(&rmtausq, &fmasq, &msnusq, &mstau1sq, &mstau2sq, &sintau,
&costau, &scalesq, &amu, &tanb, &vev2, &p2tau);
UNLOCK_MUTEX();
const double dMA = p2s + p2w + p2b + p2tau;
// dMA contains two loop tadpoles, which we'll subtract
double tadpole[2];
" <> CreateTwoLoopTadpoleFunctionName[SARAH`HiggsBoson] <> "(tadpole);
result[0] = - s11s - s11w - s11b - s11tau; // 1,1 element
result[1] = - s12s - s12w - s12b - s12tau; // 1,2 element
result[2] = - s22s - s22w - s22b - s22tau; // 2,2 element
result[0] += - dMA * Sqr(sinb) + tadpole[0] / " <> vdStr <> ";
result[1] += + dMA * sinb * cosb;
result[2] += - dMA * Sqr(cosb) + tadpole[1] / " <> vuStr <> ";
Expand Down Expand Up @@ -855,6 +865,8 @@
double p2s = 0., p2w = 0., p2b = 0., p2tau = 0.;
LOCK_MUTEX();
dszodd_(&rmtsq, &mg, &mst1sq, &mst2sq, &sxt, &cxt, &scalesq, &amu,
&tanb, &vev2, &gs, &p2s);
dszodd_(&rmbsq, &mg, &msb1sq, &msb2sq, &sxb, &cxb, &scalesq, &amu,
Expand All @@ -864,6 +876,8 @@
tausqodd_(&rmtausq, &fmasq, &msnusq, &mstau1sq, &mstau2sq, &sintau,
&costau, &scalesq, &amu, &tanb, &vev2, &p2tau);
UNLOCK_MUTEX();
const double dMA = p2s + p2w + p2b + p2tau;
// see hep-ph/0105096 Eq. (9)
Expand Down Expand Up @@ -951,9 +965,15 @@
int loop = 2;
int scheme = 0; // selects DR-bar scheme
double s11w = 0., s12w = 0., s22w = 0.;
double s11tau = 0., s12tau = 0., s22tau = 0.;
double p2w = 0., p2tau = 0.;
double DMS[3][3] = {{ 0. }}, DMP[3][3] = {{ 0. }};
double DMSB[3][3] = {{ 0. }}, DMPB[3][3] = {{ 0. }};
LOCK_MUTEX();
// get alpha_s alpha_t pieces
effpot_(&loop, &rmt, &mg, &mst1sq, &mst2sq, &sxt, &cxt,
&scalesq, &tanb, &vevS, &lamS, &svevS, &as, &DMS, &DMP);
Expand All @@ -962,24 +982,8 @@
effpot_(&loop, &rmb, &mg, &msb1sq, &msb2sq, &sxb, &cxb,
&scalesq, &cotb, &vevS, &lamS, &svevS, &as, &DMSB, &DMPB);
// Make appropriate substitutions for elements following 0907.4682
// bottom of page 9
std::swap(DMSB[0][0], DMSB[1][1]);
std::swap(DMSB[0][2], DMSB[1][2]);
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
DMS[i][j] += DMSB[i][j];
}
}
// Corrections as in MSSM, not corrected for NMSSM,
// should be OK for MSSM states when S state is close to decoupled
double s11w = 0., s12w = 0., s22w = 0.;
double s11tau = 0., s12tau = 0., s22tau = 0.;
double p2w = 0., p2tau = 0.;
ddshiggs_(&rmtsq, &rmbsq, &fmasq, &mst1sq, &mst2sq, &msb1sq,
&msb2sq, &sxt, &cxt, &sxb, &cxb, &scalesq, &amu, &tanb,
&vev2, &s11w, &s12w, &s22w);
Expand All @@ -991,6 +995,19 @@
tausqodd_(&rmtausq, &fmasq, &msnusq, &mstau1sq, &mstau2sq, &sintau,
&costau, &scalesq, &amu, &tanb, &vev2, &p2tau);
UNLOCK_MUTEX();
// Make appropriate substitutions for elements following 0907.4682
// bottom of page 9
std::swap(DMSB[0][0], DMSB[1][1]);
std::swap(DMSB[0][2], DMSB[1][2]);
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
DMS[i][j] += DMSB[i][j];
}
}
const double dMA = p2w + p2tau;
// subtract two-loop tadpoles
Expand Down Expand Up @@ -1083,9 +1100,13 @@
double svevS = " <> vsStr <> " / root2;
int loop = 2;
double p2w = 0., p2tau = 0.;
double DMS[3][3] = {{ 0. }}, DMP[3][3] = {{ 0. }};
double DMSB[3][3] = {{ 0. }}, DMPB[3][3] = {{ 0. }};
LOCK_MUTEX();
// get alpha_s alpha_t pieces
effpot_(&loop, &rmt, &mg, &mst1sq, &mst2sq, &sxt, &cxt,
&scalesq, &tanb, &vevS, &lamS, &svevS, &as, &DMS, &DMP);
Expand All @@ -1094,6 +1115,15 @@
effpot_(&loop, &rmb, &mg, &msb1sq, &msb2sq, &sxb, &cxb,
&scalesq, &cotb, &vevS, &lamS, &svevS, &as, &DMSB, &DMPB);
// Corrections as in MSSM, not corrected for NMSSM,
// should be OK for MSSM states when S state is close to decoupled
ddsodd_(&rmtsq, &rmbsq, &fmasq, &mst1sq, &mst2sq, &msb1sq, &msb2sq,
&sxt, &cxt, &sxb, &cxb, &scalesq, &amu, &tanb, &vev2, &p2w);
tausqodd_(&rmtausq, &fmasq, &msnusq, &mstau1sq, &mstau2sq, &sintau,
&costau, &scalesq, &amu, &tanb, &vev2, &p2tau);
UNLOCK_MUTEX();
// Make appropriate substitutions for elements following 0907.4682
// bottom of page 9
std::swap(DMPB[0][0], DMPB[1][1]);
Expand All @@ -1105,16 +1135,6 @@
}
}
// Corrections as in MSSM, not corrected for NMSSM,
// should be OK for MSSM states when S state is close to decoupled
double p2w = 0., p2tau = 0.;
ddsodd_(&rmtsq, &rmbsq, &fmasq, &mst1sq, &mst2sq, &msb1sq, &msb2sq,
&sxt, &cxt, &sxb, &cxb, &scalesq, &amu, &tanb, &vev2, &p2w);
tausqodd_(&rmtausq, &fmasq, &msnusq, &mstau1sq, &mstau2sq, &sintau,
&costau, &scalesq, &amu, &tanb, &vev2, &p2tau);
const double dMA = p2w + p2tau;
DMP[0][0] += dMA * sinb2;
Expand Down
12 changes: 12 additions & 0 deletions templates/two_scale_model.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ using namespace @ModelName@_info;
#define INPUT(parameter) model->get_input().parameter
#define LOCALINPUT(parameter) input.parameter

#ifdef ENABLE_THREADS
std::recursive_mutex CLASSNAME::mtx_fortran;
#endif

#ifdef ENABLE_THREADS
#define LOCK_MUTEX() mtx_fortran.lock()
#define UNLOCK_MUTEX() mtx_fortran.unlock()
#else
#define LOCK_MUTEX()
#define UNLOCK_MUTEX()
#endif

CLASSNAME::@ModelName@(const @ModelName@_input_parameters& input_)
: Two_scale_model()
, @ModelName@_soft_parameters(input_)
Expand Down

0 comments on commit cd2412e

Please sign in to comment.