Running module use / module load in user-scripts results in /bin/sh: module: command not found
In payu, $MODULEHOMES/bin/modulecmd is used to run any module commands. The $MODULEHOMES/bin/modulecmd python load <module> generates commands that can be executed to run the module load command.
Payu PBS jobs are submitted with a format similar to qsub -- /path/to/env/bin/python /path/to/env/bin/payu-run. The qsub man page noted had the following for using -- to run commands:
When you run qsub this way, it runs the executable directly. It does not start a shell, so no shell initialization scripts are run, and execution paths and other environment variables are not set.
So the shell initialisation scripts might be what is setting up the module commands? I don't know if it possible to avoid using $MODULEHOMES/bin/modulecmd commands in envmod.py as modules need to be loaded in the same process that python is running (unless copying back the changes to environment in a subprocess call). However when running bash user-scripts should payu first run an shell initialisation script in the subprocess to setup module commands? My ~/.bashrc has the following which I've tested works for setting up the module command (at least on gadi - this might be platform specific?)
# Source global definitions (Required for modules)
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
This might not be a major issue, as workarounds is to specify any required modules in config.yaml, under modules: load:, or run a shell initialisation script or use modulecmd in the user-scripts.
Running
module use
/module load
in user-scripts results in/bin/sh: module: command not found
In payu,
$MODULEHOMES/bin/modulecmd
is used to run any module commands. The$MODULEHOMES/bin/modulecmd python load <module>
generates commands that can be executed to run themodule load
command.https://github.com/payu-org/payu/blob/6ee85bb34a6476ccf0031b7131b8ac406edfb532/payu/envmod.py#L102-L108
Payu PBS jobs are submitted with a format similar to
qsub -- /path/to/env/bin/python /path/to/env/bin/payu-run
. Theqsub
man page noted had the following for using--
to run commands:When you run qsub this way, it runs the executable directly. It does not start a shell, so no shell initialization scripts are run, and execution paths and other environment variables are not set.
So the shell initialisation scripts might be what is setting up the
module
commands? I don't know if it possible to avoid using$MODULEHOMES/bin/modulecmd
commands inenvmod.py
as modules need to be loaded in the same process that python is running (unless copying back the changes to environment in asubprocess
call). However when running bash user-scripts should payu first run an shell initialisation script in the subprocess to setup module commands? My~/.bashrc
has the following which I've tested works for setting up the module command (at least ongadi
- this might be platform specific?)This might not be a major issue, as workarounds is to specify any required modules in
config.yaml
, undermodules: load:
, or run a shell initialisation script or usemodulecmd
in the user-scripts.