TABLE OF CONTENTS
42-slurm-configurable
DESCRIPTION
This example illustrates configurable PWTK support for the Slurm job scheduler.
For the other supported job schedulers, the usage is analogous, just replace SLURM & slurm strings with one of LSF & lsf, PBS & pbs, or LL & ll.
In PWTK, the batch shell script consists of four parts:
profile (always exists, set by slurm_profile) | head (optional, set by slurm_head) | pwtk (always exists, set internally by PWTK; here the PWTK script is executed) | tail (optional, set by slurm_tail)
and below we show how to set/configure them.
EXAMPLE SOURCE FILE
SOURCE
# Slurm profiles are typically defined in the ~/.pwtk/slurm.tcl # configuration file, which makes them globally available to the # user. # # A template of the slurm.tcl configuration file is avaiable in # $PWTK/config/slurm.tcl # # To use Slurm, a user should defined at least the 'default' profile. # Slurm profiles are defined with the ::pwtk::slurm_profile command # (such profiles are typically defined by the user in ~/.pwtk/slurm.tcl # as to be avialable in any PWTK script). slurm_profile default { #!/bin/sh #SBATCH --nodes=1 #SBATCH --ntasks=8 #SBATCH --time=6:00:00 } { # This is the PWTK specific profile associated with the default Slurm profile. # N.B. for --ntasks=8, a good default choice for ::pwtk::prefix is: prefix mpirun -np 8 } # let's define a profile for quick test calculations with ::pwtk::slurm_profile # (such profiles are typically defined by the user in ~/.pwtk/slurm.tcl # as to be avialable in any PWTK script) slurm_profile small-n-fast { #!/bin/sh #SBATCH --nodes=1 #SBATCH --ntasks=4 #SBATCH --time=00:30:00 } { prefix mpirun -np 4 } # the head part of the batch shell script is defined with ::pwtk::slurm_head # (this can be typically defined by the user in ~/.pwtk/slurm.tcl) slurm_head { # N.B. this is a shell-script snippet # "head" is a typical place where to load modules (if needed) module load QuantumESPRESSO/7.1-foss-2022a; # EDIT THIS # let's print the SLURM enviromental variables env | grep SLURM_ } # the tail part of the batch script is defined with ::pwtk::slurm_tail slurm_tail { # N.B. this is a shell script snippet echo "I am done. Please check the results of calculations." } # a given user-defined Slurm profile can be utilized via the # ::pwtk::SLURM command; the usage is: SLURM profileName script.pwtk SLURM small-n-fast scanpar-Si.pwtk # N.B. if the profileName is omitted, the "default" profile is used, i.e.: # # SLURM script.pwtk # # is equivalent to # # SLURM default script.pwtk # the ::pwtk::SLURM command is configurable, i.e., Slurm (sbatch) # options can be specified on the SLURM command line SLURM small-n-fast -t 00:10:00 --ntasks=2 { prefix mpirun -np 2 import eos-Si.pwtk }
REMARK
From the above examples, it can be deduced that the full syntax of the SLURM command is:
SLURM ?profileName? ?OPTIONS? script.pwtk
or
SLURM ?profileName? ?OPTIONS? { import script.pwtk; # PWTK script code here }
BEWARE
While the OPTIONS on the SLURM command-line are specified with the Slurm syntax (e.g. --ntasks=2), Tcl uses a different quoting than shell. Hence, if an option value includes a space or square brackets, it should be specified as:
{--nodelist=wn1, wn2, wn3, wn4}
or
{--nodelist=wn[1-4]}