Skip to content

Instantly share code, notes, and snippets.

@aguadopd
Created March 3, 2017 19:29
Show Gist options
  • Select an option

  • Save aguadopd/d9b0633ec1d72cd21682975a0e9b8719 to your computer and use it in GitHub Desktop.

Select an option

Save aguadopd/d9b0633ec1d72cd21682975a0e9b8719 to your computer and use it in GitHub Desktop.
Bash egs parallel - Running EGSnrc codes on multiple cores without a queuing system.
# Bash egs parallel - Running EGSnrc codes on multiple cores without a queuing system.
# https://plus.google.com/+FredericTessierPlus/posts/hRS9Rjztsy3
#!/bin/bash
#####################################################################################
#
# usage:
#
# egs-parallel <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 ($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 &"
sleep 10
done
# wait for completion and report
wait
echo --------------------------------------------------------------------------------
echo "SIMULATION COMPLETED ($command)"
echo
@aguadopd
Copy link
Author

aguadopd commented Feb 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment