I modified the code to match the documentation, which is to keep parsing until it reaches a command. I checked all the way back to Slurm v2.0 and this has been the behaviour of sbatch for many years. This will be in v14.11.6, which we hope to release this week. There's a patch available here if you want it early:
https://github.com/SchedMD/slurm/commit/4e682555ddbda5e55390cf04a3fbacaf6e47d52d.patch

Quoting Hendryk Bockelmann <[email protected]>:
Hi Magnus and Andy,

from my side +1 for the
#SBATCH END-OF-OPTIONS
solution

On 21/04/15 14:44, Magnus Jonsson wrote:
A better approach would be to add to SLURM a "#SBATCH END-OF-OPTIONS" or
something similar to mark the end of sbatch options and that sbatch can
stop parsing from that point.

/Magnus

On 2015-04-21 14:40, Andy Riebs wrote:
Never mind; which I changed "#sbatch" to the correct "#SBATCH", I got 4
tasks. According to the man page, this is a bug. For now, I like
Magnus's suggestion :-)

On 04/21/2015 08:21 AM, Andy Riebs wrote:
Hendryk, what sbatch command line options are you using? How are you
determining that job 1 got 2 tasks? I just tried the following script,
and it correctly ran just 1 task:

$ cat test.sh
#!/bin/bash
#SBATCH --ntasks=1

srun hostname

#sbatch --ntasks=4

## end of script
$ sbatch test.sh
Submitted batch job 18720
$ cat slurm-18720.out
node09
$

For further discussion on this topic, please

1. Reply to the whole list, not just me
2. Indicate what OS and Slurm versions you are using
3. Provide a copy of your slurm.conf file with any sensitive
   information, like node names or IP addresses, removed

Andy

On 04/21/2015 07:50 AM, Hendryk Bockelmann wrote:
Hello,

is there a way to prevent slurm from parsing the whole jobscript for
#SBATCH statements?
Assume I have the following jobscript "job1.sh":

#!/bin/bash
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --job-name=job1

srun -l echo "slurm jobid $SLURM_JOB_ID named: $SLURM_JOB_NAME"

cat > job2.sh <<EOF
#!/bin/bash
#SBATCH --nodes=1
#SBATCH --ntasks=2
#SBATCH --job-name=job2

srun -l echo "slurm jobid \$SLURM_JOB_ID named: \$SLURM_JOB_NAME"
EOF

sbatch job2.sh


If I submit the job1.sh the resources are allocated such that 2 tasks
are given and not 1. I would like to have 1 task for the first job
(as in the very first lines) and then a different setting for the
created job ...

Thanx for any help,
Hendryk





--
Dr. Hendryk Bockelmann
Wissenschaftliches Rechnen
Abteilung Anwendungen

Deutsches Klimarechenzentrum GmbH (DKRZ)
Bundesstraße 45 a, D-20146 Hamburg, Germany

Phone: +49 40 460094-144
FAX:   +49 40 460094-270
Email: [email protected]
URL:   www.dkrz.de

Geschäftsführer: Prof. Dr. Thomas Ludwig
Sitz der Gesellschaft: Hamburg
Amtsgericht Hamburg HRB 39784


--
Morris "Moe" Jette
CTO, SchedMD LLC
Commercial Slurm Development and Support

Reply via email to