Skip to content

Commit de3fa90

Browse files
authored
Merge pull request #2227 from mccode-dev/defer-srandom-until-init
2 parents e007fb1 + 5e4399c commit de3fa90

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

common/lib/share/mccode_main.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ int mccode_main(int argc, char *argv[])
3434
// init global _particle.randstate for random number use
3535
// during init(), finally() and display(). NOTE: during trace, a local
3636
// "_particle" variable is present and thus used instead.
37-
srandom(_hash(mcseed-1));
37+
//
38+
// PW: srandom deferred until init() since we did not read seed input from commandline
39+
//srandom(_hash(mcseed-1));
3840

3941
#ifdef USE_MPI
4042
/* *** print number of nodes *********************************************** */

mccode/src/cogen.c.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,6 +1484,8 @@ int cogen_section(struct instr_def *instr, char *section, char *section_lower,
14841484
if (!strcmp(section, "INITIALISE"))
14851485
{
14861486
cout(" DEBUG_INSTR();");
1487+
cout(" // Initialise rng");
1488+
cout(" srandom(_hash(mcseed-1));");
14871489
cout("");
14881490
/* default values for instrument parameters are set in mcreadparams */
14891491
cout(" /* code_main/parseoptions/readparams "

0 commit comments

Comments
 (0)