why run module unload failed in modulefile?

471 Views Asked by At

I am a newbie.

I found an interesting thing about Environment modules. please see the following process.

my linux OS is redhat5.8. I have installed environment modules 3.2.10, tcl8.6.6,

  1. source init/csh successfully.
  2. I write a qq/{61_0, 61_1, 61_2} modulefile respectively.

take qq/61_0 as an example.

cat 61_0:

\#%Module1.0

set curNameVersion  [module-info name]

set curName [lindex [split $curNameVersion "/"] 0]

set var_name "61_PAT"   

set install_path /soft/qq/61_0

if { [module-info mode load] } {    

    puts stderr "loaded $curNameVersion"

    if { [info exists env($var_name)] } {  

        if { $env($var_name) != $install_path } {  

            puts stderr "rm loaded $curName"

            module unload $curName

        }

    }

}

setenv $var_name $install_path

puts stderr "done 61_0"


.
.

   61_1 modulefile is basically similar to 61_0 except set install_path /soft/qq/61_1 and puts stderr "done 61_1"

   61_2 modulefile is basically similar to 61_0 except set install_path /soft/qq/61_2 and puts stderr "done 61_2"

3.

^Linux^:  module add qq/61_0

loaded qq/61_0

done 61_0


^Linux^:  module add qq/61_1

loaded qq/61_1

rm loaded qq

loaded qq/61_0

done 61_0

done 61_1


^Linux^:  module add qq/61_2

done 61_0

done 61_0

done 61_0

..

...

done 61_0

done 61_0

done 61_2


4. 

^Linux^:  module list

Currently Loaded Modulefiles:

  1) qq/61_0   2) qq/61_1   3) qq/61_2

^Linux^:  echo $_LMFILES_ 

/software/qq/61_0:/software/qq/61_1:/software/qq/61_2

^Linux^:  echo $LOADEDMODULES 

qq/61_0:qq/61_1:qq/61_2

my question is:

  1. it should not load multi-version for the same tool qq, when load another version, it should module rm other firstly.
    although I have module unload in modulefile, but it looks like module unload $curName sentence not work
  2. when run 'module add qq/61_1', it means that, it will rm loaded qq/61_0 firstly, and then execute qq/61_0 modulefile, because it is unload for qq/61_0, it should not output line 'loaded qq/61_0'. but it output 'loaded qq/61_0'. why?
  3. why is there so many many output 'done 61_0' when run 'module add qq/61_2'?
  4. echo $LMFILES and echo $LOADEDMODULES have proven that it exists multi-version for the same tool, how to keep only load one version?

anybody can help me? Thanks in advance

1

There are 1 best solutions below

0
On

The issue you describe is coming from a bug affecting Modules version <= 3.2.10. Newer Modules version (> 3.2.10) or up-to-date "environment-modules" package on RedHat-like Linux distribution have fixed this issue:

With a fixed Modules version, the process you describe seems correct (tested on Modules 3.2.10 and greater on a Fedora system):

$ module add qq/61_0
loaded qq/61_0
done 61_0
$ module add qq/61_1
loaded qq/61_1
rm loaded qq
done 61_0
done 61_1
$ module list
Currently Loaded Modulefiles:
 1) qq/61_1  
$ module add qq/61_2
loaded qq/61_2
rm loaded qq
done 61_1
done 61_2
$ module list
Currently Loaded Modulefiles:
 1) qq/61_2