diff --git a/Advanced/FakeJobArray/FakeJobArray.sh b/Advanced/FakeJobArray/FakeJobArray.sh new file mode 100755 index 0000000..bc4a245 --- /dev/null +++ b/Advanced/FakeJobArray/FakeJobArray.sh @@ -0,0 +1,30 @@ +#!/bin/bash +#SBATCH --nodes 1 +#SBATCH --time 00:10:00 + +#This number is the number of jobs per nodes +#SBATCH --ntasks-per-node 16 + +# The real job array is this times the number of tasks per node +#SBATCH --array=1-2 + +for i in $(seq 1 ${SLURM_TASKS_PER_NODE}) +do + #computes the new task_id + TASK_ID=$(( ( ${SLURM_ARRAY_TASK_ID} - 1 ) * ${SLURM_TASKS_PER_NODE} + ${i} )) + + echo "${i} ${SLURM_ARRAY_TASK_ID} -> $TASK_ID" + #determine a new output file for the fake_task + OUTPUT_FILE=${SLURM_SUBMIT_DIR}/slurm-${SLURM_ARRAY_JOB_ID}_${SLURM_ARRAY_TASK_ID}__${TASK_ID}.out + + ### Add you script here with ${TASK_ID} as an argument + ### the & at the end is important !!! + + ./my_test_script.sh ${TASK_ID} > ${OUTPUT_FILE} 2>&1 & + + #stores the pids for the wait at the end + PIDs[$i]=$! +done + +wait ${PIDs[*]} + diff --git a/Advanced/FakeJobArray/my_test_script.sh b/Advanced/FakeJobArray/my_test_script.sh new file mode 100755 index 0000000..8bf47d7 --- /dev/null +++ b/Advanced/FakeJobArray/my_test_script.sh @@ -0,0 +1,8 @@ +task=$1 + +echo "Start ${task} $(date) on $(hostname)" +echo "I'm am fake task ${task} from JOB_ID ${SLURM_JOBID} - ${SLURM_ARRAY_TASK_ID}" + + +sleep 600 +echo "End ${task} $(date)"