How to use environment modules in batch scripts#

module is a shell function which modifies shell environment after loading or unloading a module file. If you are using different shells as login shell and for job batch scripts (e.g. tcsh as login shell and your job scripts start with #!/bin/bash), you need to add an appropriate source command in your script before any invocation of the module function (otherwise the module: command not found. error message will result and the shell environment won’t be modified as intended):

# in bash or ksh script
source /etc/profile

# in tcsh or csh script
source /sw/etc/csh.levante