| 1 |
.. _module-info-name-return-basename: |
| 2 |
|
| 3 |
Return file basename on module-info name for full path modulefile |
| 4 |
================================================================= |
| 5 |
|
| 6 |
When module name is specified as a full pathname, the |
| 7 |
:mfcmd:`module-info name<module-info>` command used in modulefile was |
| 8 |
returning the file basename on Modules compatibility version. Starting version |
| 9 |
4 of Modules, the full pathname is returned when module is specified this way |
| 10 |
as once loaded this module is identified by its full pathname. This recipe |
| 11 |
describes a way to get back the behavior of Modules compatibility version for |
| 12 |
the ``module-info name`` modulefile command. |
| 13 |
|
| 14 |
Implementation |
| 15 |
-------------- |
| 16 |
|
| 17 |
Return file basename on :mfcmd:`module-info name<module-info>` for modules |
| 18 |
specified as full path modulefile is implemented by the use of a site-specific |
| 19 |
configuration that supersedes the definition of the :mfcmd:`module-info |
| 20 |
name<module-info>` command to return modulefile basename instead of full |
| 21 |
pathname. |
| 22 |
|
| 23 |
.. literalinclude:: ../../example/module-info-name-return-basename/siteconfig.tcl |
| 24 |
:language: tcl |
| 25 |
:caption: siteconfig.tcl |
| 26 |
:lines: 13-27 |
| 27 |
|
| 28 |
**Compatible with Modules v4.2+** |
| 29 |
|
| 30 |
Installation |
| 31 |
------------ |
| 32 |
|
| 33 |
Create site-specific configuration directory if it does not exist yet: |
| 34 |
|
| 35 |
.. parsed-literal:: |
| 36 |
|
| 37 |
$ mkdir \ |etcdir| |
| 38 |
|
| 39 |
Then copy there the site-specific configuration script of this recipe: |
| 40 |
|
| 41 |
.. parsed-literal:: |
| 42 |
|
| 43 |
$ cp example/module-info-name-return-basename/siteconfig.tcl \ |etcdir|\ / |
| 44 |
|
| 45 |
.. note:: |
| 46 |
|
| 47 |
Defined location for the site-specific configuration script may vary from |
| 48 |
one installation to another. To determine the expected location for this |
| 49 |
file on your setup, check the value of the ``siteconfig`` option on Modules |
| 50 |
version 4.3 or above:: |
| 51 |
|
| 52 |
$ module config siteconfig |
| 53 |
|
| 54 |
On older version of Modules, check the ``modulecmd.tcl`` script:: |
| 55 |
|
| 56 |
$ grep '^set g_siteconfig ' $MODULES_CMD |
| 57 |
|
| 58 |
Usage example |
| 59 |
------------- |
| 60 |
|
| 61 |
With an ``info/name`` modulefile that sets an environment variable with the |
| 62 |
result of the :mfcmd:`module-info name<module-info>` modulefile command: |
| 63 |
|
| 64 |
.. literalinclude:: ../../example/module-info-name-return-basename/modulefiles/info/name |
| 65 |
:caption: info/name |
| 66 |
|
| 67 |
Load ``info/name`` by its full pathname then check value of the environment |
| 68 |
variable set:: |
| 69 |
|
| 70 |
$ module load ./example/module-info-name-return-basename/modulefiles/info/name |
| 71 |
$ echo $MODNAME |
| 72 |
name |
| 73 |
|
| 74 |
.. vim:set tabstop=2 shiftwidth=2 expandtab autoindent: |