diff --git a/Dipolar-Gas-Simulator/submit_jobs.sh b/Dipolar-Gas-Simulator/submit_jobs.sh index be032de..bf39401 100644 --- a/Dipolar-Gas-Simulator/submit_jobs.sh +++ b/Dipolar-Gas-Simulator/submit_jobs.sh @@ -1,30 +1,31 @@ -# Define scan ranges (encoded as strings) -SCATTERING_LENGTH_RANGE="85" -POLAR_ANGLE_RANGE="0" -AZIMUTHAL_ANGLE_RANGE="0" +# ----------- Define scan ranges ----------- + +# Use space-separated or comma-separated floats/integers (can be bracketed) +SCATTERING_LENGTH_RANGE="[85.0]" +POLAR_ANGLE_RANGE="[0]" +AZIMUTHAL_ANGLE_RANGE="[0.0]" NUM_ATOMS_LIST="[90000]" CHUNK_SIZE=1 -# Convert parameter ranges into arrays -scatteringLengths=($(eval echo {$SCATTERING_LENGTH_RANGE})) -polarAngles=($(eval echo {$POLAR_ANGLE_RANGE})) -azimuthalAngles=($(eval echo {$AZIMUTHAL_ANGLE_RANGE})) -numAtoms=($(eval echo {$NUM_ATOMS_LIST})) +# ----------- Count total combinations for SLURM array ----------- + +# Strip brackets for Bash processing (for counting only) +scatteringLengths=($(echo "$SCATTERING_LENGTH_RANGE" | tr -d '[],')) +polarAngles=($(echo "$POLAR_ANGLE_RANGE" | tr -d '[],')) +azimuthalAngles=($(echo "$AZIMUTHAL_ANGLE_RANGE" | tr -d '[],')) +numAtoms=($(echo "$NUM_ATOMS_LIST" | tr -d '[],')) -# Calculate the total number of jobs (combinations of parameters) totalJobs=$((${#scatteringLengths[@]} * ${#polarAngles[@]} * ${#azimuthalAngles[@]} * ${#numAtoms[@]})) - -# Calculate the number of array jobs based on total jobs and chunk size numArrayJobs=$(( (totalJobs + CHUNK_SIZE - 1) / CHUNK_SIZE )) -# Print the total number of jobs and array jobs for debugging echo "Total number of jobs: $totalJobs" echo "Number of SLURM array jobs: $numArrayJobs" +echo "Running SLURM job array from 1 to ${numArrayJobs}" + +# ----------- Submit SLURM array job ----------- -# Create the SLURM job submission command sbatch --export=SCATTERING_LENGTH_RANGE="$SCATTERING_LENGTH_RANGE",POLAR_ANGLE_RANGE="$POLAR_ANGLE_RANGE",AZIMUTHAL_ANGLE_RANGE="$AZIMUTHAL_ANGLE_RANGE",NUM_ATOMS_LIST="$NUM_ATOMS_LIST",CHUNK_SIZE=$CHUNK_SIZE << EOF #!/bin/bash -########### Begin SLURM header ########### #SBATCH --partition=gpu-single #SBATCH --nodes=1 #SBATCH --ntasks-per-node=1 @@ -36,7 +37,6 @@ sbatch --export=SCATTERING_LENGTH_RANGE="$SCATTERING_LENGTH_RANGE",POLAR_ANGLE_R #SBATCH --error=simulation_%A_%a.err #SBATCH --output=simulation_%A_%a.out #SBATCH --array=1-${numArrayJobs} -########### End SLURM header ########## echo "Working Directory: $PWD" echo "Running on host $HOSTNAME" @@ -44,22 +44,18 @@ echo "Job id: $SLURM_JOB_ID" echo "Job name: $SLURM_JOB_NAME" echo "Number of nodes allocated to job: $SLURM_JOB_NUM_NODES" echo "Number of GPUs allocated to job: $SLURM_GPUS" +echo "SLURM task index: \$SLURM_ARRAY_TASK_ID" - -# Load module +# Load MATLAB module load math/matlab/R2023a -echo Directory is `pwd` +echo Directory is pwd echo "Initiating Job..." -# Inside SLURM job array -echo "Running SLURM job array from 1 to ${numArrayJobs}" - -# Start MATLAB job with the batch index +# Run MATLAB wrapper with this batch index matlab -nodisplay -nosplash -r "Scripts.run_hybrid_worker_wrapper(\$SLURM_ARRAY_TASK_ID)" -# notice for tests echo "Job terminated successfully" exit -EOF +EOF \ No newline at end of file