[Modules] load and unload true at the same time
Manage your shell environment variables and aliases
Brought to you by:
xdelaruelle
From: Martin S. <si...@sf...> - 2010-11-06 19:46:20
|
Hi, basically all of our modulefiles start with set ld [module-info mode load] set rm [module-info mode remove] and then we do things depending on the values of $ld and $rm, e.g., loading/unloading of other prerequisite/conflicting modules. This never worked correctly since it never occurred to us that "module-info mode load" AND "module-info mode remove" could both be true at the same time. Example: ===<module1>=== #%Module@VER@# set ld [module-info mode load] set rm [module-info mode remove] module-verbosity "load: [module-info mode load] remove: [module-info mode remove] mode: [module-info mode]" if { $ld } { module unload module2 } if { $rm } { module load module2 } ===</module1>=== ===<module2>=== #%Module@VER@# set ld [module-info mode load] set rm [module-info mode remove] module-verbosity "load: [module-info mode load] remove: [module-info mode remove] mode: [module-info mode]" ===</module2>=== # module list No Modulefiles Currently Loaded. # module -v load module2 module2(5):VERB:4: load: 1 remove: 0 mode: load # module -v load module1 module1(5):VERB:4: load: 1 remove: 0 mode: load module2(5):VERB:4: load: 1 remove: 1 mode: load # module list Currently Loaded Modulefiles: 1) module1 # module -v unload module1 module1(5):VERB:4: load: 0 remove: 1 mode: remove module2(5):VERB:4: load: 1 remove: 1 mode: load # module list No Modulefiles Currently Loaded. When module1 is loaded it "unloads" (I do not know what the code actually does in this case) module2. In module2 then both [module-info mode load] and [module-info mode remove] are 1, see the module2(5):VERB:4: load: 1 remove: 1 mode: load line. Obviously this has nonsensical consequences depending on what we do within if { $ld } { ... } and if { $rm } { ... } blocks inside module2. The bug is in ModuleCmd_Load.c, line 129: if( load) g_flags |= M_LOAD; else g_flags |= M_REMOVE; The flags are or'd, i.e., when a module is loaded when the M_REMOVE flag is set in g_flags you end up with g_flags that have M_LOAD and M_REMOVE set at the same time. I am attaching a patch modules-3.2.8-load.patch that resolves the issue: # module list No Modulefiles Currently Loaded. # module -v load module2 module2(5):VERB:4: load: 1 remove: 0 mode: load # module -v load module1 module1(5):VERB:4: load: 1 remove: 0 mode: load module2(5):VERB:4: load: 0 remove: 1 mode: remove # module list Currently Loaded Modulefiles: 1) module1 # module -v unload module1 module1(5):VERB:4: load: 0 remove: 1 mode: remove module2(5):VERB:4: load: 1 remove: 0 mode: load # module list Currently Loaded Modulefiles: 1) module2 Since I am not familiar with the code I attach an alternative patch that saves the flags before overwriting and restores them at the end. I do not know why that should be necessary and believe that the simpler patch should be ok. Cheers, Martin -- Martin Siegert Head, Research Computing WestGrid/ComputeCanada Site Lead IT Services phone: 778 782-4691 Simon Fraser University fax: 778 782-4242 Burnaby, British Columbia email: si...@sf... Canada V5A 1S6 |