matlabinputsbatch

sbatch command adds 0 to one of the inputs, causing an error


I submitted a batch job:

sbatch --job-name="mybatchjob-false1"     -o myoutfile_02aug2024-false1.txt     myshllscrpt24_02aug2024.sh myscriptfun_01aug2024 false NA 1 /20jul2024 true NA 8 8 2 /02aug2024

where myshllscrpt24_02aug2024.sh is a pretty standard .sh file:

#!/bin/bash

#SBATCH -n 24                    # <--- This job will require 24 cores
#SBATCH -N 1
#SBATCH -A genacc_q             # <--- Run in the genacc_q Slurm account; this is the default account if none specified
#SBATCH --mail-type="ALL"       # <--- Email your official FSU email address on all job events
#SBATCH -t 14-00:00:00             # <--- Kill this job after 14 days
#SBATCH --mem-per-cpu=4000M
#SBATCH -C "YEAR2015,intel"

module purge
module load matlab/2023b
matlab -batch "$1($2,'$3',$4,'$5',$6,'$7',$8,$9,$10,'$11')"

The last line calls one of a few functions that take 10 inputs (one of which is myscriptfun_01aug2024.m), so the sbatch command is calling to run

myscriptfun_01aug2024(false,'NA',1,'/20jul2024',true,'NA',8,8,'/02aug2024')

where '/20jul2024' is the subfolder from which I load input files and '/02aug2024' is the subfolder to which I save output files. I have checked that this command does run in an interactive job mode.

The sbatch command led to a failure, and I checked myoutfile_02aug2024-false1.txt:

{Unrecognized function or variable 'myscriptfun_01aug20240'.
} 

For some reason, it looks like the sbatch command adds a '0' at the end of the function name, leading a failure.

I would greatly appreciate any and all advice about what is wrong, and what to do.

Thank you!

Essentially, the sbatch command calls to run

myscriptfun_01aug2024(false,'NA',1,'/20jul2024',true,'NA',8,8,'/02aug2024')

where '/20jul2024' is the subfolder from which I load input files and '/02aug2024' is the subfolder to which I save output files. I have checked that this command does run in an interactive job mode.


Solution

  • The problem here is that the bash argument variables only work for single digits, $1 through $9. So, when you write $10, you're getting the first parameter with a 0 appended.

    Instead, use ${10} and ${11}.