regexenvironment-modulesmodulefile

Environment Modules: can is-loaded look for a range of modulefile-names?


I'm getting started writing Environment Modules. I'm currently writing modulefiles that load the appropriate environment variables to run different versions of a program and want to display a warning if multiple modulefiles for the same program are loaded that might be conflicting.

So e.g. I have modulefiles named program100, program102, program200, program304 etc.

So far in my code it looks like

#%Module1.0#####################################################################
##

if { [module-info mode load] && [is-loaded program100 program102 program200 program304] } {
        puts stderr "Other modulefile for program is already loaded, modules might conflict"
}

I would like to replace the is-loaded command by something like is-loaded program* that matches any modulefiles starting with 'program' if that is possible.

Thank you for any help!


Solution

  • You may benefit from organizing your program modulefiles in a common program directory where all version-specific modulefiles lie in:

    program/100
    program/102
    program/200
    program/304
    

    With this organization you can designate all these modulefiles by the program name so your test could look like:

    #%Module1.0#######################################################################
    
    if { [module-info mode load] && [is-loaded program] } {
        puts stderr "Other modulefile for program is already loaded, modules might conflict"
    }