Skip to content

Commit

Permalink
Fix lock file errors when using a BEAMnrc library
Browse files Browse the repository at this point in the history
Call beam_finish from beamlib_finish with a different ientry value of 3.
This signals that the BEAM source library is done and that there is no
need to call egs_pjo_finish, which tries to access the lock file for
regular BEAMnrc parallel runs.

Previously, while testing the uniform run control object in Mortran
apps, fort.* files were left behind in the DOSXYZnrc app folder when
using BEAMnrc libraries as a source of particles. This occurred whether
or not the simulation relied on a lock file. Interestingly, the problem
was noticed using gcc 7.5 on Ubuntu 18.04, but it does not occur with
gcc 4.8 on CentOS 7.

These spurious fort.* files contained error messages from the BEAM
library source, reporting a failure to rewind the lock file. The error
message was traced to the egs_pjob_finish routine attempting to rewind
and read the lock file.

The bug occurs because a BEAM library source does not create a lock
file, yet at the end of a parallel run beamlib_finish calls
beam_finish(ientry), with the same ientry=1 argument used in regular
BEAMnrc simulations (which create a lock file).

This bug does not affect the simulation results since it since it aborts
the parallel job when it was already done, with a call to $egs_fatal
which attempts to ouput an error message to an output file that is
already closed.
  • Loading branch information
mainegra authored and ftessier committed Mar 29, 2021
1 parent 67d4608 commit 7ab5e62
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions HEN_HOUSE/omega/beamnrc/beam_lib.mortran
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ subroutine beamlib_finish;
implicit none;
"write .egsdat file if requested"
call beam_write_dat;
call beam_finish(1);
"call with 1 to signify end of beam lib run"
call beam_finish(3);
"call with 3 to signify end of beam lib run"
return; end;

"below is a dummy xvgrplot subroutine for use with BEAM shared
Expand Down
18 changes: 15 additions & 3 deletions HEN_HOUSE/omega/beamnrc/beamnrc.mortran
Original file line number Diff line number Diff line change
Expand Up @@ -5016,10 +5016,10 @@ ITMAX=3+LNEXC+LNINC;

return; end;

subroutine beam_finish(ientry);
subroutine beam_finish(i_entry);
implicit none;

$INTEGER ientry,egs_open_file;
$INTEGER i_entry, ientry, egs_open_file;

;COMIN/SCORE,SOURCE,STACK,IO_INFO,RANDOM,USER,CMs,EGS-IO,UPHIOT,TIMING-INFO,
RWPHSP/;
Expand All @@ -5038,6 +5038,8 @@ $INTEGER I,I1,I2,I3,I4,IT,ITMAX,IERR,NUMIND,COVIND;

$DECLARE_TIMING_VARIABLES;

$LOGICAL is_beam_src;

external combine_results;

#ifdef HAVE_C_COMPILER;
Expand All @@ -5046,6 +5048,16 @@ integer n_job;
#endif;

is_finished = .false.;
is_beam_src = .false.;

"Calling from a BEAM source library"
IF (i_entry = 3)[
is_beam_src = .true.;
ientry = 1;
]
ELSE["Proceed as usual"
ientry = i_entry;
]

"*******************************************************************************
"
Expand Down Expand Up @@ -5485,7 +5497,7 @@ call egs_finish; " Finish the simulation "

#ifdef HAVE_C_COMPILER;
;
IF( n_parallel > 0 & ~is_finished ) [
IF( n_parallel > 0 & ~is_finished & ~is_beam_src ) [
call egs_pjob_finish(n_job);
IOUTLIST=egs_open_file(IOUTLIST,0,1,'.egslst');
IF( n_job = 0 ) [
Expand Down

0 comments on commit 7ab5e62

Please sign in to comment.