Last active
October 21, 2022 10:39
-
-
Save ftessier/7099aa0c6f9f7629d6e3 to your computer and use it in GitHub Desktop.
EGSnrc bash script to manually run jobs in parallel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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