Skip to content

Commit 8359a03

Browse files
committed
Mask all printf/fprintf in INIT by MPI_MASTER();
1 parent b6582b6 commit 8359a03

1 file changed

Lines changed: 41 additions & 16 deletions

File tree

mcstas-comps/sources/ESS_butterfly.comp

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ INITIALIZE
317317
/* correction for projection along the beam / projection on the z=0 plane */
318318
cos_thermal=cos_beamport_angle;
319319
cos_cold=cos((fabs(internal_angle)-24.24)*DEG2RAD);
320-
//printf("cosines are %g %g internal angle %g\n",cos_thermal,cos_cold,fabs(internal_angle));
320+
321321
ColdWidths = ColdWidthSW;
322322
ThermalWidths = ThermalWidthSW;
323323
int j;
@@ -373,26 +373,36 @@ INITIALIZE
373373
C3_z=0;
374374
isleft=1;
375375
} else {
376-
fprintf(stderr,"%s: Sector %s is undefined, please use N, W, S or E!\n", NAME_CURRENT_COMP,sector);
376+
MPI_MASTER(
377+
fprintf(stderr,"%s: Sector %s is undefined, please use N, W, S or E!\n", NAME_CURRENT_COMP,sector);
378+
);
377379
exit(-1);
378380
}
379381
if (beamline > jmax || beamline <= 0 ) {
380-
fprintf(stderr,"%s: beamline no %i is undefined in sector %s, please use 1 <= beamline <= %i\n", NAME_CURRENT_COMP, beamline, sector, jmax);
382+
MPI_MASTER(
383+
fprintf(stderr,"%s: beamline no %i is undefined in sector %s, please use 1 <= beamline <= %i\n", NAME_CURRENT_COMP, beamline, sector, jmax);
384+
);
381385
exit(-1);
382386
}
383-
384-
printf("%s: Setting up for sector %s, beamline %i, global orientation angle is %g, internal angle %g\n", NAME_CURRENT_COMP, sector,beamline,orientation_angle,beamportangle);
387+
388+
MPI_MASTER(
389+
printf("%s: Setting up for sector %s, beamline %i, global orientation angle is %g, internal angle %g\n", NAME_CURRENT_COMP, sector,beamline,orientation_angle,beamportangle);
390+
);
385391
if (c_performance <= 0) {
386392
fprintf(stderr,"%s: Cold performance scalar of %g is not allowed. Please select 0 < c_performance\n", NAME_CURRENT_COMP, c_performance);
387393
exit(-1);
388394
}
389395
if (t_performance <= 0) {
390-
fprintf(stderr,"%s: Thermal performance scalar of %g is not allowed. Please select 0 < t_performance\n", NAME_CURRENT_COMP, t_performance);
396+
MPI_MASTER(
397+
fprintf(stderr,"%s: Thermal performance scalar of %g is not allowed. Please select 0 < t_performance\n", NAME_CURRENT_COMP, t_performance);
398+
);
391399
exit(-1);
392400
}
393401
if (Lmin>=Lmax || Lmin <= 0 || Lmax < 0) {
394-
fprintf(stderr,"%s: Unmeaningful definition of wavelength range!\nPlease select Lmin, Lmax > 0 and Lmax > Lmin.\n ERROR - Exiting\n",
402+
MPI_MASTER(
403+
fprintf(stderr,"%s: Unmeaningful definition of wavelength range!\nPlease select Lmin, Lmax > 0 and Lmax > Lmin.\n ERROR - Exiting\n",
395404
NAME_CURRENT_COMP);
405+
);
396406
exit(-1);
397407
}
398408
/* Figure out where to aim */
@@ -404,19 +414,28 @@ INITIALIZE
404414
coords_get(ToTarget, &tx, &ty, &tz);
405415
dist=sqrt(tx*tx+ty*ty+tz*tz);
406416
} else if (!target_index && !dist) {
407-
fprintf(stderr,"%s: Please choose to set either the dist parameter or specify a target_index.\nExit\n", NAME_CURRENT_COMP);
417+
MPI_MASTER(
418+
fprintf(stderr,"%s: Please choose to set either the dist parameter or specify a target_index.\nExit\n", NAME_CURRENT_COMP);
419+
);
408420
exit(-1);
409421
} else {
410422
tx=0; ty=0; tz=dist;
411423
}
412-
printf("%s: Focusing at rectagle sized %g x %g \n - positioned at location (x,y,z)=(%g m, %g m, %g m) \n", NAME_CURRENT_COMP, focus_xw, focus_yh, tx, ty, tz);
424+
MPI_MASTER(
425+
printf("%s: Focusing at rectagle sized %g x %g \n - positioned at location (x,y,z)=(%g m, %g m, %g m) \n", NAME_CURRENT_COMP, focus_xw, focus_yh, tx, ty, tz);
426+
);
413427
if (target_index) {
414-
printf(" ( from target_index %i -> distance %g )\n", target_index, dist);
428+
MPI_MASTER(
429+
printf(" ( from target_index %i -> distance %g )\n", target_index, dist);
430+
);
415431
} else {
416-
printf(" ( from dist parameter -> distance %g )\n", dist);
432+
MPI_MASTER(
433+
printf(" ( from dist parameter -> distance %g )\n", dist);
434+
);
417435
}
418-
printf("%s: Cold and Thermal brilliance performance multiplicators are c_performance=%g and t_performance=%g\n", NAME_CURRENT_COMP, c_performance, t_performance);
419-
436+
MPI_MASTER(
437+
printf("%s: Cold and Thermal brilliance performance multiplicators are c_performance=%g and t_performance=%g\n", NAME_CURRENT_COMP, c_performance, t_performance);
438+
);
420439
/* Calculate orientation matrix for the display and calculations */
421440
r11 = cos(DEG2RAD*orientation_angle);
422441
r12 = -sin(DEG2RAD*orientation_angle);
@@ -444,12 +463,18 @@ INITIALIZE
444463
Mwidth_t=(100.0*ThermalWidths[beamline-1]+0.7)/cos_thermal;
445464

446465
if (tfocus_width && tfocus_time && tfocus_dist) {
447-
printf("%s: Using time focusing: Directing neutrons to this time-window:\n tfocus_width (%g s) wide at tfocus_time (%g s), tfocus_dist (%g m) downstream\n",NAME_CURRENT_COMP, tfocus_width, tfocus_time, tfocus_dist);
466+
MPI_MASTER(
467+
printf("%s: Using time focusing: Directing neutrons to this time-window:\n tfocus_width (%g s) wide at tfocus_time (%g s), tfocus_dist (%g m) downstream\n",NAME_CURRENT_COMP, tfocus_width, tfocus_time, tfocus_dist);
468+
);
448469
} else if (!tfocus_width && !tfocus_time && !tfocus_dist) {
449-
printf("%s: NOT using time focusing\n",NAME_CURRENT_COMP);
470+
MPI_MASTER(
471+
printf("%s: NOT using time focusing\n",NAME_CURRENT_COMP);
472+
);
450473
} else {
451-
fprintf(stderr,"%s: Unmeaningful combination tfocus_width (%g s), tfocus_time (%g s) and tfocus_dist (%g m): \n All must be either==0 (no time focusing) or !=0 (time focusing)\n ERROR - Exiting\n",
474+
MPI_MASTER(
475+
fprintf(stderr,"%s: Unmeaningful combination tfocus_width (%g s), tfocus_time (%g s) and tfocus_dist (%g m): \n All must be either==0 (no time focusing) or !=0 (time focusing)\n ERROR - Exiting\n",
452476
NAME_CURRENT_COMP, tfocus_width, tfocus_time, tfocus_dist);
477+
);
453478
exit(-1);
454479
}
455480

0 commit comments

Comments
 (0)