Skip to main content

Batch job submission script

Required files

Batch Submission Script

#!/bin/bash
for file in ./*
do
if test -d $file
then
cp run.slurm $file
cd $file
chmod +x ./run.slurm && sbatch ./run.slurm
cd ..
sleep 1s
fi
done

Submission script template

submit.sh
#!/bin/bash
#SBATCH --nodes=1 # Number of nodes
#SBATCH --ntasks-per-node=56 # Number of cores per node
#SBATCH --ntasks=56 # Total number of cores
#SBATCH --partition=g1_cae # Queue partition, must specify the correct partition
#SBATCH --job-name=sp-b1 # Job name
#SBATCH --output=sp-b%a.out.%A # Normal log output (%A parameter value is jobId, %a parameter is the number of the inp file)
#SBATCH --error=sp-b%a.err.%A # Error log output (%A parameter value is jobId, %a parameter is the number of the inp file)
#SBATCH -a 1-5 # 1-5 indicates the range of inp files


file=sp-b${SLURM_ARRAY_TASK_ID} # Prefix format for inp files
echo "${file}.inp run in `hostname`"
echo "This is job #${SLURM_ARRAY_JOB_ID}, with parameter $SLURM_ARRAY_TASK_ID"

abaqus job=${file} input=${file}.inp analysis cpus=$SLURM_NPROCS scratch=$SLURM_SUBMIT_DIR interactive
sleep 1

Operational steps

  1. Place all cases requiring batch submission into subdirectories within a single folder Structure example: Where 'test2' is the folder for batch job submission, and '1-4' represent subdirectories for individual job cases

  2. Place the first script mentioned above in 'test2', defaulting to '1.sh', and place the prepared job submission script 'run.slurm' in 'test2' Structure illustration:

  3. Execute 1.sh source 1.sh

  4. Script parsing

  5. Traverse all files in the current directory

  6. Check if the item is a directory

  7. Copy the submission script to the sub-case directory

  8. Add execution permissions to the submission script and submit the job Note: Place one case in each sub-case directory. Submission scripts requiring specified input files need to be modified.