Created
March 11, 2025 21:27
-
-
Save infotroph/4ad8a8411ddbd72b929ad23ac8f5e596 to your computer and use it in GitHub Desktop.
model launcher script to run PEcAn jobs as Slurm arrays
This file contains hidden or 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 | |
launchdir=$(dirname "$1") | |
logfile="$launchdir"/slurm_submit_log.txt | |
if [[ -z ${SLURM_ARRAY_TASK_ID} ]]; then | |
echo "SLURM_ARRAY_TASK_ID not set. Exiting." >> "$logfile" | |
exit 1 | |
fi | |
# joblist.txt has job script name on line 1, invocation dirs on lines 2-n | |
# => add 1 to each task ID to get its line number | |
jobscript=$(head -n1 "$launchdir"/joblist.txt) | |
task_line=$((SLURM_ARRAY_TASK_ID + 1)) | |
taskdir=`tail -n+"$task_line" "$launchdir"/joblist.txt | head -n1` | |
"$taskdir"/"$jobscript" >> "$logfile" 2>&1 | |
if [[ "$?" != "0" ]]; then | |
echo "ERROR IN MODEL RUN" >> "$logfile" | |
exit 1 | |
fi |
Also: Before getting too far into the weeds on editing this, evaluate whether we can adopt an existing framework - see especially future.batchtools
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Next steps
slurm_array_submit.sh
a wrapper around thelauncher.sh
wrapper that PEcAn already writes. Can we build array support into, say,setup_modellauncher()
instead?