Skip to content

Commit b0b3fb4

Browse files
authored
Merge pull request #2364 from willend/main
Re-enable a few tests on the nightlies
2 parents 20c0f9c + 65d9131 commit b0b3fb4

6 files changed

Lines changed: 113 additions & 53 deletions

File tree

mcstas-comps/contrib/SNS_source_analytic.comp

Lines changed: 75 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -809,84 +809,124 @@ INITIALIZE
809809
fprintf (stderr, "Error opening file\n");
810810
exit (-1);
811811
} else {
812-
printf ("%s\n", "File opened...");
812+
MPI_MASTER(
813+
printf ("%s\n", "File opened...");
814+
);
813815
}
814816
/* spectral parameters */
815817
while ((fgets (line, linelength, fp) != NULL) && (strchr (line, '#') != NULL)) {
816-
printf ("%s", line);
818+
MPI_MASTER(
819+
printf ("%s", line);
820+
);
817821
}
818822
kk = sscanf (line, " %le %le %le %le %le %le %le %le %le %le %le %le %le %le", &para_sp[0], &para_sp[1], &para_sp[2], &para_sp[3], &para_sp[4], &para_sp[5],
819823
&para_sp[6], &para_sp[7], &para_sp[8], &para_sp[9], &para_sp[10], &para_sp[11], &para_sp[12], &para_sp[13]);
820824

821825
/* a parameter of emission time distribuation */
822826
while ((fgets (line, linelength, fp) != NULL) && (strchr (line, '#') != NULL)) {
823-
printf ("%s", line);
827+
MPI_MASTER(
828+
printf ("%s", line);
829+
);
824830
}
825831
kk = sscanf (line, " %le %le %le %le %le %le %le %le %le %le", &para_a[0], &para_a[1], &para_a[2], &para_a[3], &para_a[4], &para_a[5], &para_a[6], &para_a[7],
826832
&para_a[8], &para_a[9]);
827833
if (kk != 10) {
828-
printf ("para_a: insufficient number of data entries read\n");
834+
MPI_MASTER(
835+
printf ("para_a: insufficient number of data entries read\n");
836+
);
829837
_ABORT ();
830838
}
831839

832840
/* b parameter of emission time distribuation */
833841
while ((fgets (line, linelength, fp) != NULL) && (strchr (line, '#') != NULL)) {
834-
printf ("%s", line);
842+
MPI_MASTER(
843+
printf ("%s", line);
844+
);
835845
}
836846
kk = sscanf (line, " %le %le %le %le %le %le %le %le %le %le", &para_b[0], &para_b[1], &para_b[2], &para_b[3], &para_b[4], &para_b[5], &para_b[6], &para_b[7],
837847
&para_b[8], &para_b[9]);
838848
if (kk != 10) {
839-
printf ("para_b: insufficient number of data entries read\n");
849+
MPI_MASTER(
850+
printf ("para_b: insufficient number of data entries read\n");
851+
);
840852
_ABORT ();
841853
}
842854

843855
/* R parameter of emission time distribuation */
844856
while ((fgets (line, linelength, fp) != NULL) && (strchr (line, '#') != NULL)) {
845-
printf ("%s", line);
857+
MPI_MASTER(
858+
printf ("%s", line);
859+
);
846860
}
847861
kk = sscanf (line, " %le %le %le %le %le %le %le %le %le %le", &para_R[0], &para_R[1], &para_R[2], &para_R[3], &para_R[4], &para_R[5], &para_R[6], &para_R[7],
848862
&para_R[8], &para_R[9]);
849863
if (kk != 10) {
850-
printf ("para_R: kk=%d insufficient number of data entries read\n", kk);
864+
MPI_MASTER(
865+
printf ("para_R: kk=%d insufficient number of data entries read\n", kk);
866+
);
851867
_ABORT ();
852868
}
853869

854870
/* to parameter of emission time distribuation */
855871
while ((fgets (line, linelength, fp) != NULL) && (strchr (line, '#') != NULL)) {
856-
printf ("%s", line);
872+
MPI_MASTER(
873+
printf ("%s", line);
874+
);
857875
}
858876
kk = sscanf (line, " %le %le %le %le %le %le %le %le %le %le", &para_to[0], &para_to[1], &para_to[2], &para_to[3], &para_to[4], &para_to[5], &para_to[6],
859877
&para_to[7], &para_to[8], &para_to[9]);
860878
if (kk != 10) {
861-
printf ("para_R: insufficient number of data entries read\n");
879+
MPI_MASTER(
880+
printf ("para_R: insufficient number of data entries read\n");
881+
);
862882
_ABORT ();
863883
}
864884

865885
printf ("\n");
866886
for (k = 0; k < 14; k++) {
867-
printf (" para_sp(%d)=%e\n", k, para_sp[k]);
887+
MPI_MASTER(
888+
printf (" para_sp(%d)=%e\n", k, para_sp[k]);
889+
);
868890
}
869-
printf ("\n");
891+
MPI_MASTER(
892+
printf ("\n");
893+
);
870894
for (k = 0; k < 10; k++) {
871-
printf (" para_a(%d)=%e\n", k, para_a[k]);
895+
MPI_MASTER(
896+
printf (" para_a(%d)=%e\n", k, para_a[k]);
897+
);
872898
}
873-
printf ("\n");
899+
MPI_MASTER(
900+
printf ("\n");
901+
);
874902
for (k = 0; k < 10; k++) {
875-
printf (" para_b(%d)=%e\n", k, para_b[k]);
903+
MPI_MASTER(
904+
printf (" para_b(%d)=%e\n", k, para_b[k]);
905+
);
876906
}
877-
printf ("\n");
907+
MPI_MASTER(
908+
printf ("\n");
909+
);
878910
for (k = 0; k < 8; k++) {
879-
printf (" para_R(%d)=%e\n", k, para_R[k]);
911+
MPI_MASTER(
912+
printf (" para_R(%d)=%e\n", k, para_R[k]);
913+
);
880914
}
881-
printf ("\n");
915+
MPI_MASTER(
916+
printf ("\n");
917+
);
882918
for (k = 0; k < 10; k++) {
883-
printf (" para_to(%d)=%e\n", k, para_to[k]);
919+
MPI_MASTER(
920+
printf (" para_to(%d)=%e\n", k, para_to[k]);
921+
);
884922
}
885923

886924
if (sample_E == 0) {
887925
CItot = prepare_cumulative_spectral_function (csfE, Emin, Emax, para_sp);
888926
if (CItot <= 0.0) {
889-
printf (" choice of Emin and Emax gives zero neutron intensity\n");
927+
MPI_MASTER(
928+
printf (" choice of Emin and Emax gives zero neutron intensity\n");
929+
);
890930
_ABORT ();
891931
}
892932
// for(i=0;i<=1000;i++){
@@ -896,19 +936,29 @@ INITIALIZE
896936

897937
/* some checks */
898938
if (dist <= 0.0) {
899-
printf (" dist must be greater zero\n");
939+
MPI_MASTER(
940+
printf (" dist must be greater zero\n");
941+
);
900942
_ABORT ();
901943
} else if (focus_xw <= 0.0) {
902-
printf (" focus_xw must be greater zero\n");
944+
MPI_MASTER(
945+
printf (" focus_xw must be greater zero\n");
946+
);
903947
_ABORT ();
904948
} else if (focus_yh <= 0.0) {
905-
printf (" focus_yh must be greater zero\n");
949+
MPI_MASTER(
950+
printf (" focus_yh must be greater zero\n");
951+
);
906952
_ABORT ();
907953
} else if (p_power <= 0) {
908-
printf (" p_power must be greater zero\n");
954+
MPI_MASTER(
955+
printf (" p_power must be greater zero\n");
956+
);
909957
_ABORT ();
910958
} else if (n_pulses <= 0) {
911-
printf (" n_pulses must be greater zero\n");
959+
MPI_MASTER(
960+
printf (" n_pulses must be greater zero\n");
961+
);
912962
_ABORT ();
913963
}
914964

mcstas-comps/examples/Mantid/SNS_ARCS_Mantid/SNS_ARCS_Mantid.instr

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
* B. Fultz,"Design and operation of the wide angular-range chopper spectrometer ARCS at the
2525
* Spallation Neutron Source", Review of Scientific Instruments, 83 , 015114 (2012)</ul>
2626
*
27+
* %Example: Fermi_nu=420 Detector: Full_cyl_I=235445
28+
*
2729
* %Parameters
2830
* Fermi_nu: [Hz] Frequency of the Fermi chopper
2931
* T0_nu: [Hz] Frequency of the T0 chopper
@@ -261,6 +263,10 @@ AT(0,0,LS) RELATIVE mod
261263
COMPONENT sampleMantid = Spot_sample(radius_o=0.01, h=0.05, pack = 1,xwidth=0, yheight=0, zthick=0, Eideal=Edes,w=Et,two_theta=ttheta,n_spots=4)
262264
AT (0.0,0.0,0.0) RELATIVE Sample_Arm
263265

266+
COMPONENT Full_cyl= Monitor_nD(xwidth=5.98,yheight=3.2,restore_neutron=1,
267+
options="mantid banana, theta limits=[-28.0 135.38] bins=389 ,y limits=[-0.550 0.450] bins=128")
268+
AT (0,0,0.00005) RELATIVE Sample_Arm
269+
264270
COMPONENT nD_Mantid_0= Monitor_nD(xwidth=5.9817,yheight=3.2,restore_neutron=1, filename="this",
265271
options="mantid banana, theta limits=[-28.0 135.38] bins=389 ,y limits=[-0.550 0.450] bins=128, neutron pixel min=0 t, list all neutrons", restore_neutron=1)
266272
AT (0,0,0.00005) RELATIVE Sample_Arm

mcstas-comps/examples/SNS/Granroth_SNS_decoupled_poisoned/Granroth_SNS_decoupled_poisoned.instr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* Simple instrumentfile for estimating SNS brilliance, moderator is a the Granroth SNS_source applying linear interpolation in MCNPX tables.
1818
*
19-
* Example: filename=source_sct091_tu_02_1.dat Detector: Brillmon_I=7.11736e+12
19+
* %Example: filename=source_sct091_tu_02_1.dat Detector: Brillmon_I=7.11736e+12
2020
*
2121
* %Parameters
2222
* Lambda_min: [AA] Minimum wavelength produced at source

mcstas-comps/examples/SNS/SNS_ARCS/SNS_ARCS.instr

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
* B. Fultz,"Design and operation of the wide angular-range chopper spectrometer ARCS at the
2525
* Spallation Neutron Source", Review of Scientific Instruments, 83 , 015114 (2012)</ul>
2626
*
27-
* Example: -y Detector: Full_cyl_I=235445
28-
* (temporarily disabled on nightly test...)
27+
* %Example: -y Detector: Full_cyl_I=235445
2928
*
3029
* %Parameters
3130
* Fermi_nu: [Hz] Frequency of the Fermi chopper

mcstas-comps/examples/SNS/SNS_analytic_test/SNS_analytic_test.instr

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* Simple test instrument for the SNS_source component.
2020
* Refer to SNS <A href="http://neutrons.ornl.gov/instrument_systems/components/moderators.shtml">Source files.</A>
2121
*
22-
* Example: filename=source_sct091_tu_02_1.dat Detector: det_I=7.09416e+09
22+
* %Example: -y Detector: det_I=8.51297e+10
2323
*
2424
* %Parameters
2525
* filename: [string] Source file
@@ -48,8 +48,9 @@ INITIALIZE %{
4848

4949
#define LOADPATH_ STR(LOADPATH)
5050
sprintf(fullfile,"%s/%s",LOADPATH_,filename);
51-
printf("Using the input file: %s\n", fullfile);
52-
51+
MPI_MASTER(
52+
printf("Using the input file: %s\n", fullfile);
53+
);
5354
%}
5455

5556
TRACE

tools/Python/mctest/mctest.py

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -95,26 +95,30 @@ def save(self, infolder):
9595
text = json.dumps(self.get_json_repr(), indent=2)
9696
f = open(join(infolder, self.get_display_name()) + ".json", 'w').write(text)
9797
def load(self,testnb=0):
98-
jsonfile=os.path.join(os.path.dirname(self.localfile),self.get_display_name()+'.json')
99-
f = open(jsonfile, "r", encoding="utf-8")
100-
obj = json.load(f)
101-
# # Populate test
102-
self.displayname=obj['displayname']
103-
self.sourcefile=obj['sourcefile']
104-
self.localfile=obj['localfile']
105-
self.instrname=obj['instrname']
106-
self.testnb=obj['testnb']
107-
self.parvals=obj['parvals']
108-
self.detector=obj['detector']
109-
self.targetval=obj['targetval']
110-
self.testval=obj['testval']
111-
self.linted=obj['linted']
112-
self.compiled=obj['compiled']
113-
self.compiletime=obj['compiletime']
114-
self.didrun=obj['didrun']
115-
self.runtime=obj['runtime']
116-
self.errmsg=obj['errmsg']
117-
98+
jsonfile=pathlib.Path(os.path.join(os.path.dirname(self.localfile),self.get_display_name()+'.json'))
99+
if jsonfile.is_file():
100+
f = open(jsonfile, "r", encoding="utf-8")
101+
obj = json.load(f)
102+
# # Populate test
103+
self.displayname=obj['displayname']
104+
self.sourcefile=obj['sourcefile']
105+
self.localfile=obj['localfile']
106+
self.instrname=obj['instrname']
107+
self.testnb=obj['testnb']
108+
self.parvals=obj['parvals']
109+
self.detector=obj['detector']
110+
self.targetval=obj['targetval']
111+
self.testval=obj['testval']
112+
self.linted=obj['linted']
113+
self.compiled=obj['compiled']
114+
self.compiletime=obj['compiletime']
115+
self.didrun=obj['didrun']
116+
self.runtime=obj['runtime']
117+
self.errmsg=obj['errmsg']
118+
return True
119+
else:
120+
return False
121+
118122
def get_display_name(self):
119123
if self.testnb > 1:
120124
return self.instrname + "_%d" % self.testnb
@@ -251,8 +255,8 @@ def mccode_test(branchdir, testdir, limitinstrs=None, instrfilter=None, compfilt
251255
populated=[]
252256
for t in instrtests:
253257
if t.testnb >= 0:
254-
t.load(t.testnb)
255-
populated.append(t)
258+
if t.load(t.testnb)==True:
259+
populated.append(t)
256260
tests = tests + populated
257261
pass
258262

0 commit comments

Comments
 (0)