Skip to content

Commit

Permalink
fluka-spawn sets initial random number seed
Browse files Browse the repository at this point in the history
  • Loading branch information
kbat committed Oct 25, 2024
1 parent 67fbf7f commit a4bc86a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions mctools/fluka/fluka-spawn.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
#!/usr/bin/env bash

INP=$1
NJOBS=$2

if [ $# -ne 2 ]; then
if [ $# -ne 3 ]; then
echo "FLUKA input file spawner"
echo " generates clones of the given input file with different random seeds"
echo ""
echo "Usage: $(basename $0) INP njobs"
echo " INP FLUKA input file"
echo " jobs Number of input files with different random seeds to generate"
echo " seed Random number seed offset. Will be incremented by 1 in each input file."
echo ""
echo "Homepage: https://github.com/kbat/mc-tools"
exit 1
fi

INP=$1
NJOBS=$2
SEED=$3

if [ ! -e "$INP" ]; then
echo "Can't open $INP"
exit 1
Expand All @@ -27,5 +29,6 @@ fi

for (( j=1; j<=$NJOBS; j++ )); do
NEWINP=$(basename $INP .inp)-spawn$j.inp
cat "$INP" | sed "s;^RANDOMI.*;RANDOMIZE 1.0 $j.0;" > $NEWINP
R=$((SEED + j))
cat "$INP" | sed "s;^RANDOMI.*;RANDOMIZE 1.0 $R.0;" > $NEWINP
done

0 comments on commit a4bc86a

Please sign in to comment.