Skip to content

string_templates

batch.string_templates

ARRAY_SHIELDHIT_BASH module-attribute

ARRAY_SHIELDHIT_BASH = "#!/bin/bash\n{array_header}\nROOT_DIR={root_dir}\nWORK_DIR=$ROOT_DIR/workspaces/task_`printf %04d $SLURM_ARRAY_TASK_ID`\n\n# seed of RNG\nRNG_SEED=$SLURM_ARRAY_TASK_ID\n\n# main SHIELD-HIT12A input files\nINPUT_DIR=$ROOT_DIR/input\n\n# go to working directory\ncd $WORK_DIR\n\n# make symbolic links to all files from input folder\nln -s $INPUT_DIR/* .\n\nsig_handler()\n{{\n    echo \"BATCH interrupted\"\n    wait # wait for all children, this is important!\n}}\n\nFILE_TO_WATCH=$WORK_DIR/shieldhit_`printf %04d $SLURM_ARRAY_TASK_ID`.log\npython3 $ROOT_DIR/watcher.py \\\n    --filepath=$FILE_TO_WATCH\\\n    --sim_id={sim_id}\\\n    --task_id=$SLURM_ARRAY_TASK_ID\\\n    --update_key={update_key}\\\n    --backend_url={backend_url}\\\n    --verbose 1>watcher_$SLURM_ARRAY_TASK_ID.stdout 2>watcher_$SLURM_ARRAY_TASK_ID.stderr &\n\ntrap 'sig_handler' SIGUSR1\n\n# execute simulation\nsrun shieldhit -N $RNG_SEED $WORK_DIR &\n\nwait\n"

COLLECT_BASH module-attribute

COLLECT_BASH = '#!/bin/bash\n{collect_header}\nROOT_DIR={root_dir}\nINPUT_WILDCARD=$ROOT_DIR/workspaces/task_*/*.bdo\nOUTPUT_DIRECTORY=$ROOT_DIR/output\n\nmkdir -p $OUTPUT_DIRECTORY\n\ncd $OUTPUT_DIRECTORY\n\nconvertmc json --many "$INPUT_WILDCARD"\n\nCLEAR_BDOS={clear_bdos}\n\nif $CLEAR_BDOS; then\n    rm $INPUT_WILDCARD\nfi\n\npython3 $ROOT_DIR/result_sender.py --output_dir=$OUTPUT_DIRECTORY\\\n    --sim_id={sim_id} --update_key={update_key} --backend_url={backend_url}\n'

SUBMIT_SHIELDHIT module-attribute

SUBMIT_SHIELDHIT = '#!/bin/bash\nOUT=`mktemp`\nmodule load shieldhit\n\nROOT_DIR={root_dir}\ncd $ROOT_DIR\nmkdir -p $ROOT_DIR/workspaces/task_{{0001..{n_tasks}}}\nmkdir -p $ROOT_DIR/input\n\n\nINPUT_DIR=$ROOT_DIR/input\nARRAY_SCRIPT=$ROOT_DIR/array_script.sh\nCOLLECT_SCRIPT=$ROOT_DIR/collect_script.sh\n\nunzip -d $INPUT_DIR $ROOT_DIR/input.zip\nrm $ROOT_DIR/input.zip\n\nSHIELDHIT_CMD="sbatch --array=1-{n_tasks} {array_options} --parsable $ARRAY_SCRIPT > $OUT"\neval $SHIELDHIT_CMD\nJOB_ID=`cat $OUT | cut -d ";" -f 1`\necho "Job id: $JOB_ID"\n\nif [ -n "$JOB_ID" ] ; then\n    COLLECT_CMD="sbatch --dependency=afterany:$JOB_ID {collect_options} --parsable $COLLECT_SCRIPT > $OUT"\n    eval $COLLECT_CMD\n    COLLECT_ID=`cat $OUT | cut -d ";" -f 1`\n    echo "Collect id: $COLLECT_ID"\nfi\n'