Skip to content

Commit e97dc85

Browse files
author
Robert McLay
committed
added documentation for mgrload()
1 parent b929b44 commit e97dc85

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

docs/source/050_lua_modulefiles.rst

+6
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ unset during unloading.
8282
**try_load** ("pkgA", "pkgB", "pkgC"):
8383
load all modules. No errors reported if unable to load.
8484

85+
**mgrload** (required, active_object):
86+
load a single module file. If required is true then error out if
87+
not found. If false then no message is generated. Returns true
88+
if successful. See :ref:`site_package_mgrload` for details.
89+
90+
8591
**always_load** ("pkgA", "pkgB", "pkgC"):
8692
load all modules. However when this command is reversed it does nothing.
8793

docs/source/250_site_package.rst

+31-1
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,34 @@ into any new version of Lmod.
8787

8888
There is no need to modify tcl2lua.tcl if you only add hook functions.
8989

90-
90+
.. _site_package_mgrload:
91+
92+
Using **mgrload** function
93+
~~~~~~~~~~~~~~~~~~~~~~~~~~
94+
95+
Suppose your site has an archecture state which controls the how the
96+
modules work. So you would like to unload all the current modules and
97+
then set an environment variable and reload. Here you want to use the
98+
**mgrload** function and not the **load** function. If you use the
99+
load function you loose the **depends_on** () state and whether a
100+
module was loaded by a user or was loaded by another module. The way
101+
this works is that you ask for the currently loaded modules with the
102+
**loaded_modules** function to get an array of "active" objects. So
103+
the following is the "AVX" architecture module::
104+
105+
if (mode() == "load") then
106+
local required = false
107+
local activeA = loaded_modules()
108+
109+
for i = 1,#activeA do
110+
io.stderr:write("Unloading: ",activeA[i].userName,"\n")
111+
unload(activeA[i].userName)
112+
end
113+
setenv("SITE_CURRENT_ARCH","avx")
114+
for i = 1,#activeA do
115+
io.stderr:write("loading: ",activeA[i].userName,"\n")
116+
mgrload(required, activeA[i])
117+
end
118+
end
119+
120+

0 commit comments

Comments
 (0)