Hey Paul and Xavier,
Thank you much for the idea of using switch. I realized the core concept was to utilize two modulefiles, each with only `module use ...` commands, and I was able to adapt that to the situation I am dealing with. While I wasn't able to make it as simple as your examples, I was able to get it to work.
The complicating factor, for the curious, was that the initial login to the system sets up one of the module environments, but doesn't do so by loading a modulefile like the pivot/dir[12] modulefiles in Xavier's example. Introducing a `module load pivot/dir1` in to the login scripts would seem to solve the issue except that it could cause some problems for already established automatic user workflows that rely on `module purge` to start things off. Since those scripts won't know to load any of the pivot modulefiles, they no longer have a complete module environment. I just had to code pivot/dir2 (assuming pivot/dir1 does the same thing as login scripts) to deal with the possibility of pivot/dir1 not being loaded. At that point, `module switch pivot/dir[12]` can be used to swap back and forth as needed.
Thank you again!
David
________________________________
From: Xavier Delaruelle <xav...@gm...>
Sent: Thursday, July 15, 2021 10:16 AM
To: Environment Modules usage and discussion.
Subject: [EXTERNAL] Re: [Modules] `module use` when unloading a modulefile
Hello David,
Like Paul suggests, using "module switch" with 1 modulefile for each
modulepath to enable could do the job.
For instance, you have a "pivot/dir1" modulefile that enables the
"/tmp/dir1" modulepath directory and a "pivot/dir2" modulefile that
enables the "/tmp/dir2" modulepath directory.
I have made a small test with a module 3.2 version:
$ cat mp/pivot/dir1
#%Module
conflict pivot
module use /tmp/dir1
$ cat mp/pivot/dir2
#%Module
conflict pivot
module use /tmp/dir2
$ module load pivot/dir1
$ echo $MODULEPATH
/tmp/dir1:./mp:/usr/share/Modules/modulefiles:/etc/modulefiles:/usr/share/modulefiles
$ module switch pivot/dir2
$ echo $MODULEPATH
/tmp/dir2:./mp:/usr/share/Modules/modulefiles:/etc/modulefiles:/usr/share/modulefiles
When pivot/dir1 is loaded, the /tmp/dir1 modulepath is enabled. Then,
when you switch to pivot/dir2, pivot/dir1 is unloaded thus /tmp/dir1
modulepath is unset. Then pivot/dir2 is loaded so /tmp/dir2 modulepath
is enabled.
Regards,
Xavier
Le jeu. 15 juil. 2021 à 18:04, Paul FM <pau...@gm...> a écrit :
>
> Have you tried module switch ?
> Changing to the latest (4.8) would probably help.
> The latest version also has better man pages.
>
> Note - since modules are now pure TCL - (except one lib object that you can safely remove if it causes problems). It can be built on one platform and work on many (the same build can work on both BSD and Linux - if you remove
> /lib/libtclenvmodules.so
> - it is used to speed up some of the module functions, but is only used if there - I remove it [move it to NOT_USED/lib/ ], as the speed difference is minor and I want to make one module installation compatible over multiple version of Linux and FreeBSD).
>
>
> -- On 7/15/2021 10:48 AM, Shrader, David Lee via Modules-interest wrote:
> > Hello,
> >
> >
> > Is there a good way to effectively run `module use ...` when unloading a modulefile? I am working on a modulefile that pivots from one modules environment to another, and I'm trying to unuse paths and replacing those by using others upon load, and then do the reverse when removing the modulefile. The command `module unuse <path>` doesn't get reversed, but `module use <path>` does.
> >
> >
> > I am using modules version 3.2.11. I did find an old thread from 2013 where `module unuse ...` not being changed to `module use ...` on unload was discussed, but it doesn't look like anything has changed in what I have tried inside the modulefile.
> >
> >
> > In this version of environment modules, is there a way to get `module use ...` to not be reversed on unload? Conversely, is there a way to get `module unuse ...` to be reversible? Would a later version of environment modules provide a solution that I'm not able to implement with this version of environment modules?
> >
> >
> > Thank you so much for any help and suggestions,
> >
> > David
> >
> >
> > --
> > David Shrader
> > HPC-ENV High Performance Computing Systems
> > Los Alamos National Lab
> >
> >
> >
> > _______________________________________________
> > Modules-interest mailing list
> > Mod...@li...
> > https://lists.sourceforge.net/lists/listinfo/modules-interest
modules-interest List Signup and Options<https://lists.sourceforge.net/lists/listinfo/modules-interest>
lists.sourceforge.net
Manage your shell environment variables and aliases
> >
>
> --
> --------------------------------------------------------
> The views and opinions expressed above are strictly
> those of the author(s). The content of this message has
> not been reviewed nor approved by any entity whatsoever.
> --------------------------------------------------------
> Paul FM Info: http://paulfm.com/~paulfm/
- Paul F. Markfort - http://www.paulfm.com/~paulfm/<http://paulfm.com/~paulfm/>
paulfm.com
Home Page - Paul FM - Main Index
> --------------------------------------------------------
>
>
> _______________________________________________
> Modules-interest mailing list
> Mod...@li...
> https://lists.sourceforge.net/lists/listinfo/modules-interest
modules-interest List Signup and Options<https://lists.sourceforge.net/lists/listinfo/modules-interest>
lists.sourceforge.net
Manage your shell environment variables and aliases
_______________________________________________
Modules-interest mailing list
Mod...@li...
https://lists.sourceforge.net/lists/listinfo/modules-interest
modules-interest List Signup and Options<https://lists.sourceforge.net/lists/listinfo/modules-interest>
lists.sourceforge.net
Manage your shell environment variables and aliases
|