Skip to content

Commit

Permalink
phits-run: parse cmd options
Browse files Browse the repository at this point in the history
  • Loading branch information
kbat committed Nov 28, 2024
1 parent d3c87e6 commit a4c9b61
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions bin/phits-run
34 changes: 34 additions & 0 deletions mctools/phits/phits-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

usage()
{
echo "Usage: $(basename $0) file.inp [prefix] [njobs]"
echo " file.inp: PHITS input file. Must contain the 'rseed = RSEED' string in the [Parameters] section"
echo " prefix: temporary folder prefix"
echo " njobs: number of jobs to run. Default=number of cores (output of nproc)"
exit 1
}


test $# -eq 0 && usage
test $# -gt 3 && usage

inp=$1
if [ ! -e $inp ]; then
echo "ERROR: Can't open $inp"
usage
fi

if [ $# -ge 2 ]; then
prefix=$2
if [ $# -eq 3 ]; then
njobs=$3
else
njobs=$(nproc)
fi
else
prefix="case"
njobs=$(nproc)
fi

echo $inp $prefix $njobs

0 comments on commit a4c9b61

Please sign in to comment.