1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
|
.. _tcl_modulefile_functions-label:
TCL Modulefile Functions
========================
Lmod reads modulefiles written in either Lua or TCL. Lmod has to
interpret the TCL modulefiles into Lua and then evaluate the Lua
file. So it is always faster to interpret Lua file rather than TCL
files.
Here are a list of TCL commands that are provided in addition to the
standard TCL language.
**add-property NAME value** :
See :ref:`lmodrc-label` for how to use this command.
**always-load A B C** :
Load one or more modules. When this command is used in a
modulefile that is being unloaded, this command has does nothing.
See the **load** command for the
**append-path NAME path** :
Append **path** to environment variable **NAME**.
**append-path** *--delim char* **NAME path** *priority* :
Append **path** to environment variable **NAME**.
Using the option *--delim char* to change the separator from ':' to
*char* . Also the last optional argument can specify a priority.
(See :ref:`path_priority-label` for details.)
**complete shell name arg1 arg2 ...** "
Bash and tcsh support the complete function. Note that the
shellName must match the name of the shell given on the Lmod
command. There is no error if the shell names do not match. The
command is ignored. See rt/complete/mf/tcl_spack/1.0.lua for an example.
**conflict A B** :
The current modulefile will only load if all listed modules are NOT loaded.
**depends-on A B** :
Loads all modules. When unloading only dependent modules are
unloaded. See :ref:`dependent_modules-label` for details.
**break** msg :
This command causes the evaluation of the
current modulefile to stop and all changed in the user's
environment to be ignored from the current modulefile. However,
all other modulefiles are evaluated.
In other words, this command does not stop the operation, where as
**exit** stops all evaluations. New in Lmod 8.6+
**Note** As of Lmod 8.6.16: break does nothing when unloading.
**exit** *number* :
Exits the module. No changes in the environment occur if this
command is found.
**extensions** "numpy/2.1 scipy/3.2" :
This module provides the following extensions. Place the list of
extensions as a single string.
**family NAME** :
A user can only have one family "name" loaded at a time. For
example family("compiler") would mean that a user could only have
one compiler loaded at a time.
**is-loaded NAME** :
Return true when module "NAME" is loaded.
**module** *command* *args* :
This command performs different actions depending on *command*:
**add** *A B* :
load one or more modules
**load** *A B* :
load one or more modules
**try-load** *A B* :
load one or more modules but does not report an error
if not found.
**load-any** *A B* :
load any one of the following modulefiles
**swap** *A B* :
unload *A* and load *B*
**switch** *A B* :
unload *A* and load *B*
**unload** *A B* :
unload one or more modules.
**del** *A B* :
unload one or more modules.
**rm** *A B* :
unload one or more modules.
**use** *path* :
Add *path* to MODULEPATH
**unuse** *path* :
remove *path* to MODULEPATH
**module-info** *string* :
This command returns different things depending what *string* is:
**mode** : is the current mode: "load", "remove" or "display"
**shell** : The current shell specified by the user
**shelltype** : It has the value of "sh", "csh", "perl", "python", "lisp", "fish", "cmake", or "r".
**flags** : always returns 0
**name** : The fullname of the module.
**user** : always returns 0.
**symbols** : always returns 0.
**specified** : User specified name on command line.
**module-whatis** *string* :
The whatis command can be called repeatedly with different strings.
See the Administrator Guide for more details.
**prepend-path NAME path** :
prepend to a path-like variable the value.
**prepend-path** *--delim char* **NAME path** *priority* :
prepend **path** to environment variable **NAME**.
Using the option *--delim char* to change the separator from ':' to
*char*. Also the last optional argument can specify a priority
which is a number. (See :ref:`path_priority-label` for details.)
**prereq A B**:
The current modulefile will only load if **any** of the listed modules are already loaded.
**pushenv NAME** *value* :
sets **NAME** to *value* just like **setenv**. In addition it
saves the previous value in a hidden environment variable. This
way the previous state can be returned when a module is unloaded.
**pushenv** ("FOO",false) will clear "FOO" and the pop will return
the previous value.
**remove-path NAME** *value* :
remove value from a path-like variable for both load and unload modes.
**remove-property NAME** *value* :
See :ref:`lmodrc-label` for how to use this command.
**reportError** *string* :
Report an error and abort processing of the modulefile.
**Note**: During unloading, this command reports the error message
but does not abort the processing of the modulefile. (as of Lmod 8.6.16+)
**require-fullname** :
Reports an error if the user specified name is not the fullname of
the module (e.g. **module load gcc/10.1** vs **module load gcc**.
Typically used in TCL modulefile as follows::
if { [ module-info mode load ] } {
require-fullname
}
**source-sh** *shellName* *shell_script* *arg1* ...
source a shell script as part of a module. Supported shellNames
are *sh*, *dash*, *bash*, *zsh*, *csh*, *tcsh*, *ksh*. When
loading, Lmod automatically converts the shell script into module
commands and saves the module commands in the environment. It
does this by sourcing the shell script string in a subshell and
comparing the environment before and after sourcing the shell
script string. When unloading, the saved module commands from the
environment are used. Aliases and shell functions are tracked.
Note that shell script string must not change between loading and
unloading as the full string is used to reference the saved
module commands.
Other shells could be supported with help from the community that
uses that shell. (New in version 8.6)
This feature was introduced in Tmod 4.6 and was shamelessly
studied and re-implemented in Lmod 8.6+.
**set-alias NAME** *value* :
Define an alias to **NAME** with *value*.
**setenv NAME** *value* :
Assigns to the environment variable "NAME" the value. Do not use this
function to assign the initial to a path-like variable. Use
**append_path** or **prepend_path** instead.
**unset-alias NAME** *value* :
Removes the **NAME** alias.
**unsetenv NAME** *value* :
unsets the **NAME** env. var.
**versioncmp** *version-string1* *version-string2* :
Returns -1, 0, 1 if the version string are less-than, equal or
greater than. Note that this command knows that 1.10 is newer than
1.8.
**is-avail** *name* :
Return 1 if the name is available for loading, 0 if not. (As of Lmod 8.6+)
**haveDynamicMPATH** :
This function tells that Lmod that this module has a dynamic
$MODULEPATH when building the spider cache. See
:ref:`spider_tool-label` for details.
TCL Modulefile Functions NOT SUPPORTED
--------------------------------------
**atleast** :
It is not possible to use the atleast function inside a TCL modulefile
**between** :
It is not possible to use the between function inside a TCL modulefile
**latest** :
It is not possible to use the latest function inside a TCL modulefile
TCL Global Variables
--------------------
The following TCL global variables are set inside modulefiles and
.modulerc and .version files.
**ModuleTool** : This is the string "Lmod". This works for Lmod
8.4.8+. This variable also exists in Tmod version 4.7 or greater
and reports "Modules".
**ModuleToolVersion** : This is the current version of Lmod. This
works for Lmod 8.4.8+ This variable also exists in Tmod version 4.7 or greater.
|