Skip to content

Commit

Permalink
Merge pull request #1731 from willend/main
Browse files Browse the repository at this point in the history
Fixes for #1728
  • Loading branch information
willend authored Oct 9, 2024
2 parents 3a52c4b + 9848907 commit 587f785
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 41 deletions.
18 changes: 9 additions & 9 deletions mcstas-comps/samples/PowderN.comp
Original file line number Diff line number Diff line change
Expand Up @@ -315,23 +315,23 @@ struct line_info_struct
ret = system(cmd);
if (ret != -1 && ret != 127) found = 1;
}
if (!found) {
// try with cif2hkl command from the system PATH
snprintf(cmd, 1024, "%s -o %s %s %s",
"cif2hkl", OUTFILE, options, infile);
ret = system(cmd);
if (ret != -1 && ret != 127) found = 1;
}
if (!found) {
// As a last resort, attempt with cif2hkl from $MCSTAS/bin
snprintf(cmd, 1024, "%s%c%s%c%s -o %s %s %s",
getenv(FLAVOR_UPPER) ? getenv(FLAVOR_UPPER) : MCSTAS,
MC_PATHSEP_C, "bin", MC_PATHSEP_C, "cif2hkl",
OUTFILE, options, infile);
ret = system(cmd);
if (ret != -1 && ret != 127) found = 1;
}
// ret = -1: child process could not be created
// ret = 127: shell could not be executed in the child process
if (!found) {
// try with any cif2hkl command from the system
snprintf(cmd, 1024, "%s -o %s %s %s",
"cif2hkl", OUTFILE, options, infile);
ret = system(cmd);
}

// ret = 127: shell could not be executed in the child process
if (ret == -1 || ret == 127) {
free(OUTFILE);
return(NULL);
Expand Down
18 changes: 9 additions & 9 deletions mcstas-comps/samples/Single_crystal.comp
Original file line number Diff line number Diff line change
Expand Up @@ -421,22 +421,22 @@ double tau; /* Length of (tau_x, tau_y, tau_z) */
if (ret != -1 && ret != 127) found = 1;
}
if (!found) {
// try with cif2hkl command from the system PATH
snprintf(cmd, 1024, "%s -o %s %s %s",
"cif2hkl", OUTFILE, options, infile);
ret = system(cmd);
if (ret != -1 && ret != 127) found = 1;
}
if (!found) {
// As a last resort, attempt with cif2hkl from $MCSTAS/bin
snprintf(cmd, 1024, "%s%c%s%c%s -o %s %s %s",
getenv(FLAVOR_UPPER) ? getenv(FLAVOR_UPPER) : MCSTAS,
MC_PATHSEP_C, "bin", MC_PATHSEP_C, "cif2hkl",
OUTFILE, options, infile);
ret = system(cmd);
if (ret != -1 && ret != 127) found = 1;
}
// ret = -1: child process could not be created
// ret = 127: shell could not be executed in the child process
if (!found) {
// try with any cif2hkl command from the system
snprintf(cmd, 1024, "%s -o %s %s %s",
"cif2hkl", OUTFILE, options, infile);
ret = system(cmd);
}

// ret = 127: shell could not be executed in the child process
if (ret == -1 || ret == 127) {
free(OUTFILE);
return(NULL);
Expand Down
29 changes: 16 additions & 13 deletions mcxtrace-comps/samples/PowderN.comp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
*
* Optional parameters:
* d_phi: [deg] Angle corresponding to the vertical angular range to focus to, e.g. detector height. 0 for no focusing.
* focus_flip: [1] Controls the sense of d_phi. If 0 d_phi is measured against the xz-plane. If !=0 d_phi is measured against zy-plane.
* focus_flip: [1] Controls the sense of d_phi. If 0 d_phi is measured against the xz-plane. If !=0 d_phi is measured against zy-plane.
* tth_sign: [1] Sign of the scattering angle. If 0, the sign is chosen randomly (left and right).
* pack: [1] Packing factor
* delta_d_d: [AA] Global relative Delta_d/d spreading when the 'w' column is not available. Use 0 if ideal.
Expand Down Expand Up @@ -194,7 +194,7 @@ SETTING PARAMETERS (
vector format={0,0,0,0,0,0,0,0}, vector mat_format={0,0,0,0,0},
radius=0, yheight=0, xwidth=0, zdepth=0, thickness=0,
pack=1, Vc=0, delta_d_d=0, p_inc=0.1, p_transmit=0.1,
DW=0, nb_atoms=1, d_phi=0, , tth_sign=0, p_interact=0,
DW=0, nb_atoms=1, d_phi=0, tth_sign=0, p_interact=0,
concentric=0, density=0, weight=0, barns=1, focus_flip=0)
OUTPUT PARAMETERS ()
/* X-ray parameters: (x,y,z,kx,ky,kz,phi,t,Ex,Ey,Ez,p) */
Expand Down Expand Up @@ -320,24 +320,27 @@ SHARE
if (ret != -1 && ret != 127) found = 1;
}
if (!found) {
// try with cif2hkl command from the system PATH
snprintf(cmd, 1024, "%s -o %s %s %s",
"cif2hkl", OUTFILE, options, infile);
ret = system(cmd);
if (ret != -1 && ret != 127) found = 1;
}
if (!found) {
// As a last resort, attempt with cif2hkl from $MCXTRACE/bin
snprintf(cmd, 1024, "%s%c%s%c%s -o %s %s %s",
getenv(FLAVOR_UPPER) ? getenv(FLAVOR_UPPER) : MCSTAS,
getenv(FLAVOR_UPPER) ? getenv(FLAVOR_UPPER) : MCXTRACE,
MC_PATHSEP_C, "bin", MC_PATHSEP_C, "cif2hkl",
OUTFILE, options, infile);
ret = system(cmd);
if (ret != -1 && ret != 127) found = 1;
}
// ret = -1: child process could not be created
// ret = 127: shell could not be executed in the child process
if (!found) {
// try with any cif2hkl command from the system
snprintf(cmd, 1024, "%s -o %s %s %s",
"cif2hkl", OUTFILE, options, infile);
ret = system(cmd);
// ret = 127: shell could not be executed in the child process
if (ret == -1 || ret == 127) {
free(OUTFILE);
return(NULL);
}

if (ret == -1 || ret == 127) return(NULL);

// test if the result file has been created
FILE *file = Open_File(OUTFILE,"r", NULL);
if (!file) return(NULL);
Expand Down Expand Up @@ -602,7 +605,7 @@ int calc_xsect(double k, double *q, double *my_s_k2, int count, double *sum,
#endif

for(line=line0; line<count; line++) {
if (q[line] <= 2*k*sinth) { /* q < 2*kf: restrict structural range */
if (q[line] <= 2*k) { /* q < 2*kf: restrict structural range */
*sum += my_s_k2[line];
if (Nq < line+1) Nq=line+1; /* determine maximum line index which can scatter */
} else break;
Expand Down
23 changes: 13 additions & 10 deletions mcxtrace-comps/samples/Single_crystal.comp
Original file line number Diff line number Diff line change
Expand Up @@ -435,24 +435,27 @@ SHARE
if (ret != -1 && ret != 127) found = 1;
}
if (!found) {
// try with cif2hkl command from the system PATH
snprintf(cmd, 1024, "%s -o %s %s %s",
"cif2hkl", OUTFILE, options, infile);
ret = system(cmd);
if (ret != -1 && ret != 127) found = 1;
}
if (!found) {
// As a last resort, attempt with cif2hkl from $MCXTRACE/bin
snprintf(cmd, 1024, "%s%c%s%c%s -o %s %s %s",
getenv(FLAVOR_UPPER) ? getenv(FLAVOR_UPPER) : MCSTAS,
getenv(FLAVOR_UPPER) ? getenv(FLAVOR_UPPER) : MCXTRACE,
MC_PATHSEP_C, "bin", MC_PATHSEP_C, "cif2hkl",
OUTFILE, options, infile);
ret = system(cmd);
if (ret != -1 && ret != 127) found = 1;
}
// ret = -1: child process could not be created
// ret = 127: shell could not be executed in the child process
if (!found) {
// try with any cif2hkl command from the system
snprintf(cmd, 1024, "%s -o %s %s %s",
"cif2hkl", OUTFILE, options, infile);
ret = system(cmd);
// ret = 127: shell could not be executed in the child process
if (ret == -1 || ret == 127) {
free(OUTFILE);
return(NULL);
}

if (ret == -1 || ret == 127) return(NULL);

// test if the result file has been created
FILE *file = Open_File(OUTFILE,"r", NULL);
if (!file) return(NULL);
Expand Down

0 comments on commit 587f785

Please sign in to comment.