From a4c9b619754b0443c47a64939ee02923319089bf Mon Sep 17 00:00:00 2001 From: Konstantin Batkov Date: Thu, 28 Nov 2024 06:37:02 +0100 Subject: [PATCH] phits-run: parse cmd options --- bin/phits-run | 1 + mctools/phits/phits-run.sh | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 120000 bin/phits-run create mode 100755 mctools/phits/phits-run.sh diff --git a/bin/phits-run b/bin/phits-run new file mode 120000 index 0000000..76cc89a --- /dev/null +++ b/bin/phits-run @@ -0,0 +1 @@ +../mctools/phits/phits-run.sh \ No newline at end of file diff --git a/mctools/phits/phits-run.sh b/mctools/phits/phits-run.sh new file mode 100755 index 0000000..1832734 --- /dev/null +++ b/mctools/phits/phits-run.sh @@ -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