John,
Well, that's not the behavior I see. If I add a new module 'C'
#%Module -*- tcl -*-
# Module 'C'
puts stderr "[module-info mode] [module-info name]"
# Do other stuff
and change 'A' to load 'C'
% module load A
load A
load C
It sets the mode to 'load' in both cases. It seems to me that it's
simply setting the mode incorrectly for the embedded unload. This makes
it impossible to write modulefile code to the what I need if I can't
tell what is happening with the module being processed.
In fact, I get this if I do a swtich:
% module switch A B
switch1 A
switch1 C
switch2 B
switch3 A
switch3 C
Now, I haven't been able to find out what switch1, switch2, and switch3
mean, exactly, but what looks like the embedded load/unload isn't
setting the mode, so it inherits whatever the initial mode was.
John Luton wrote:
> Not sure if this is your answer but modules is contrarian during unload
> - in other words an embedded load is a unload && a unload is a load (So
> what you are observing is correct).
>
>
>
>
> -----Original Message-----
> From: Mark E. Hamilton [mailto:mh...@sa...]
> Sent: Thursday, March 19, 2009 2:49 PM
> To: Mod...@li...
> Subject: [Modules] Problem unloading modules within a module.
>
> Hi,
>
> I have some modulefiles that must be unloaded if another modulefile is
> loaded. A simplified example is shown below. The intent is that if the
> user loads 'A' and 'B' is already loaded, 'B' will be unloaded first.
> The same goes for 'B'; if 'A' is already loaded it will be unloaded.
> Seems simple enough.
>
> #%Module -*- tcl -*-
> # Module 'A'
> puts stderr "[module-info mode] [module-info name]"
> if { [module-info mode load] } {
> if { [ is-loaded B ] } {module unload B}
> }
> # Do other stuff
>
>
> #%Module -*- tcl -*-
> # Module 'B'
> puts stderr "[module-info mode] [module-info name]"
> if { [module-info mode load] } {
> if { [ is-loaded A ] } {module unload A}
> }
> # Do other stuff
>
>
> However, when I try to load them the mode is always 'load', even though
> it seems that the second mode should be 'remove' (since it's due to the
> 'module unload command':
>
> % module load A
> load A
> load B
>
> % module load B
> load B
> load A
>
> % module load A B
> load A
> load B
> load B
> load A
>
> In fact, if I unload the module the mode is as I expect.
>
> sass8000% module unload B
> remove B
>
> Additionally, if somehow I get both A and B loaded at the same time
> (which happened during testing,) because the mode is 'load' it
> recursively tries to unload the same module until it reaches my open
> file limit, and then fails.
>
> Am I doing something wrong here? According to the man page the 'module'
> Tcl command is supposed to "permit(s) a modulefile to load or remove
> other modulefiles". I've tried 'module rm' and 'module remove' in the
> modulefiles as well with the same results.
>
--
----------------
Mark E. Hamilton
GAITS, Inc.
Sandia National Laboratory, NM.
505-844-7666
|