1. Home
  2. Docs
  3. Software
  4. Environment Modules
  5. EM in SLURM scripts

EM in SLURM scripts

Use of Environment Modules in SLURM scripts

The use of module purge command is recommended before the use of any modules in SLURM scripts.  

To use an existing module, you have to load before its usage and unload it at the end of the script.

The module command is not by default visible when using in a SLURM script. So, you have two choices:

  • the use of #!/bin/bash -l at the beginning to start a login shell, or
  • to add the line:
    . /etc/profile.d/modules.sh
    before any call of the module command.

An example of using mafft (v. 7.453) in a SLURM script:

#!/bin/bash -l

#SBATCH --partition=batch
#SBATCH --nodes=1
#SBATCH --mem=20000
#SBATCH --job-name="align_batch_threadn"
#SBATCH --output=align_batch.output
#SBATCH --mail-user=
#SBATCH --mail-type=ALL

module purge # unloads all previous loads
module load mafft/7.453
start=$SECONDS

mafft --thread 4  --globalpair --maxiterate 16  
--reorder /mnt/big/examples/example4/dataset_2.fa >  ~/student2_align.aln
                                                                  
duration=$(( SECONDS - start ))

echo "duration is : $duration  "

module unload mafft/7.453 #unloads mafft