Skip to content

Instantly share code, notes, and snippets.

@ftessier
Last active October 21, 2022 10:39
Show Gist options
  • Save ftessier/7099aa0c6f9f7629d6e3 to your computer and use it in GitHub Desktop.
Save ftessier/7099aa0c6f9f7629d6e3 to your computer and use it in GitHub Desktop.
EGSnrc bash script to manually run jobs in parallel
#!/bin/bash
#####################################################################################
#
# usage:
#
# egs-parallel.sh <n> <command>
# n: number of jobs
# command: EGSnrc command you want to run in parallel
#
#####################################################################################
# parse command-line arguments for number of jobs and command to run
n=$1
shift
command="$@"
# launch EGSnrc jobs in parallel, in the background
echo
echo "egs-parallel.sh ($n jobs): $command"
echo --------------------------------------------------------------------------------
for j in `seq $n`; do
$command -b -P $n -j $j >/dev/null 2>&1 &
processid=`printf %5d $!`
echo "LAUNCHED $processid: $command -b -P $n -j $j &"
done
# wait for completion and report
wait
echo --------------------------------------------------------------------------------
echo "SIMULATION COMPLETED ($command)"
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment