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
> >
>
> --
> --------------------------------------------------------
> 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/
> --------------------------------------------------------
>
>
> _______________________________________________
> Modules-interest mailing list
> Mod...@li...
> https://lists.sourceforge.net/lists/listinfo/modules-interest
|