#!/usr/bin/bash # Each subjob runs for at most 1 minute. In 1 minute, we will run # exactly 2 iterations of our calculation. #SBATCH --time=1 # Each subjob typically does 2 iterations, and we want 8 iterations, so # we need 4 subjobs. The array here has 4 elements (1 to 4 inclusive), # of which at most 1 can run at a time (indicated by "%1"). #SBATCH --array=1-4%1 # Put the job ID in the checkpoint file name. checkpoint_file=job-stringing-$SLURM_ARRAY_JOB_ID.ckp # -N 8 -- number of iterations total # -n 2 -- number of iterations in this subjob # -c -- path to checkpoint file bash job-stringing-calculation.sh -N 8 -n 2 -c $checkpoint_file # The job script always reaches this point. At this point, we can be # sure that: # # * we've done another 2 iterations of our calculation; and # # * maybe we've reached iteration #8, and also the end of the of the # array job.