cea-hpc / modules

Environment Modules: provides dynamic modification of a user's environment
http://modules.sourceforge.net/
GNU General Public License v2.0
668 stars 102 forks source link

How to category software with prefix? #516

Closed link89 closed 7 months ago

link89 commented 7 months ago

For example, if there are libs named lib/elpa/2022.1, lib/plumed/2.6.0, dev/oneapi/2022.3.1, dev/cmake/2.23, app/cp2k/2023.2, in the same directory /software. I hope that I can group those packges by their prefix without eating it, to make it dispaly as the follow

=========/software/lib==========
lib/elpa/2022.1    lib/plumed/2.6.0
=========/software/dev==========
dev/oneapi/2022.3.1  dev/cmake/2.23
=========/software/app==========
app/cp2k/2023.2

Is it possbile?

xdelaruelle commented 7 months ago

This is not a recommended way as it is advised to have distinguished root module name, especially when you switch modules.

When you module switch plumed to change version of plumed software. If different software share the same root (for instance lib or app). By doing a module switch lib/plumed you may end up with something different than plumed software.

However what try to achieve may be possible by either:

link89 commented 7 months ago

Hi @xdelaruelle thank you for the advice. I am not mean to change the structure of modules but just change the way module avail display them by putting the modules with the same prefix in the same section.

=========/software==========
lib/elpa/2022.1    lib/plumed/2.6.0
=========/software==========
dev/oneapi/2022.3.1  dev/cmake/2.23
=========/software==========
app/cp2k/2023.2

So I don't think this should be configured in modulefiles but maybe some global environment variable to tell the module avail command to display .

xdelaruelle commented 7 months ago

Instead of having a single modulepath (/software) my suggestion is to make a modulepath per category:

$ module use /software/lib
$ module use /software/dev
$ module use /software/app

This way you get a section per category on module avail and module name are made simpler (no category prefix):

=========/software/lib==========
elpa/2022.1    plumed/2.6.0
=========/software/dev==========
oneapi/2022.3.1  cmake/2.23
=========/software/app==========
cp2k/2023.2

If you want to have the prefix in both modulepath sections and module name root there is no other choice than using either modulepath-label or module-virtual. It does not require that you change your modulefiles, but to add .modulerc files that will define the labels or virtual modules.