doc: modernize modulefile code examples

Modernize and simplify modulefile code examples in documentation:

* Follow coding convention defined for the project
* Use simple "#%Module" file signature, no "1.0" suffix needed
This commit is contained in:
Xavier Delaruelle
2023-08-22 22:04:24 +02:00
parent 47568ac0cb
commit e072167ce3
13 changed files with 31 additions and 41 deletions

View File

@@ -1,4 +1,4 @@
#%Module1.0
#%Module
set version 1.0
set threadingmodel nothreads

View File

@@ -1,4 +1,4 @@
#%Module1.0
#%Module
set version 1.0
set threadingmodel openmp

View File

@@ -1,4 +1,4 @@
#%Module1.0
#%Module
set version 1.0
set threadingmodel pthreads

View File

@@ -1,4 +1,4 @@
#%Module1.0
#%Module
set version 2.0
set threadingmodel nothreads

View File

@@ -1,4 +1,4 @@
#%Module1.0
#%Module
set version 2.0
set threadingmodel openmp

View File

@@ -1,4 +1,4 @@
#%Module1.0
#%Module
set version 2.0
set threadingmodel pthreads

View File

@@ -1,4 +1,4 @@
#%Module1.0
#%Module
##
## foo

View File

@@ -1,4 +1,4 @@
#%Module1.0
#%Module
##
## foo

View File

@@ -1,4 +1,4 @@
#%Module1.0
#%Module
set version 1.0
set moduledir [file dirname $ModulesCurrentModulefile]

View File

@@ -1,4 +1,4 @@
#%Module1.0
#%Module
set version 2.0
set moduledir [file dirname $ModulesCurrentModulefile]

View File

@@ -15,8 +15,8 @@ sh:
.. code-block:: sh
module ()
{
module ()
{
eval "$(/some/path/modulecmd sh "$@")"
}
@@ -69,7 +69,7 @@ csh: (overwrite existing file)
How to use the module command from Makefile?
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
To make use of the ``module`` command from a Makefile, the shell initialization script should first be sourced within Makefile rule to define the ``module`` function in that context. Environment variable ``MODULESHOME`` may help to locate the shell initialization script in a generic way, like done in the following example:
To make use of the ``module`` command from a Makefile, the shell initialization script should first be sourced within Makefile rule to define the ``module`` function in that context. Environment variable ``MODULESHOME`` may help to locate the shell initialization script in a generic way, like done in the following example:
.. code-block:: Makefile
@@ -130,15 +130,12 @@ import the environment changes performed by a shell script within a
How do I specify the *default* modulefile for some modulefile directory?
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Modules usually uses the the highest lexicographically sorted :ref:`modulefile(4)` under the directory, unless there is a ``.version`` file in that directory which has a format like the following where "native" is a modulefile (or a sub-directory) in that directory. It's also possible to set the default with a ``.modulerc`` file with a **module-version** command.
Modules usually uses the the highest lexicographically sorted :ref:`modulefile(4)` under the directory, unless there is a ``.version`` file in that directory which has a format like the following where ``native`` is a modulefile (or a sub-directory) in that directory. It's also possible to set the default with a ``.modulerc`` file with a **module-version** command.
.. code-block:: tcl
#%Module1.0#####################################################################
##
## version file for Perl
##
set ModulesVersion "native"
#%Module
set ModulesVersion native
I don't want a *default* modulefile for the directory?
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@@ -76,9 +76,9 @@ variable "version" passed to it by the stub file. It also handles defining
the help procedure and the whatis text, and the conflict with itself.
Note that the "common" file does **NOT** start
with the Modules magic "#%Module1.0"; this will keep "common" from showing
with the Modules magic "#%Module"; this will keep "common" from showing
up in "module avail fooA". The "1.0" and "2.0" files do need to start with
the magic "#%Module1.0" tag so the module command will "see" them. Because
the magic "#%Module" tag so the module command will "see" them. Because
of this, the "module avail fooA" command will just show the 1.0 and 2.0
versions as expected.
@@ -121,7 +121,7 @@ defaults the version (e.g. if the user types "module load fooB" without
specifying the version of fooB.) The common file also handles defining
the help procedure and whatis text. When the command "module avail fooB" is issued,
the common file does not get listed (because it does not start with the magic
"#%Module1.0" tag), nor does the .generic file get listed (because it starts
"#%Module" tag), nor does the .generic file get listed (because it starts
with a period (".")), but the two 1.0 and 2.0 symlinks do get listed, just
as one wants.

View File

@@ -114,22 +114,22 @@ the *modulefile* is being loaded.
An example: Suppose that a full selection of *modulefiles* are needed for
various different architectures, but some of the *modulefiles* are not
needed and the user should be alerted. Having the unnecessary *modulefile*
be a link to the following notavail *modulefile* will perform the task
be a link to the following ``notavail`` *modulefile* will perform the task
as required.
.. code-block:: tcl
#%Module1.0
## notavail modulefile
##
proc ModulesHelp { } {
puts stderr "This module does nothing but alert the user"
#%Module
proc ModulesHelp {} {
puts stderr {This module does nothing but alert the user}
puts stderr "that the [module-info name] module is not available"
}
module-whatis "Notifies user that module is not available."
module-whatis {Notifies user that module is not available.}
set curMod [module-info name]
if { [ module-info mode load ] } {
if {[module-info mode load]} {
puts stderr "Note: '$curMod' is not available for [uname sysname]."
}
break
@@ -1487,21 +1487,15 @@ be loaded. Such a file would look like:
.. code-block:: tcl
#%Module1.0
##
## The desired version of X11
##
set ModulesVersion "R4"
#%Module
set ModulesVersion R4
The equivalent :file:`.modulerc` would look like:
.. code-block:: tcl
#%Module1.0
##
## The desired version of X11
##
module-version "./R4" default
#%Module
module-version ./R4 default
If the extended default mechanism is enabled (see
:envvar:`MODULES_EXTENDED_DEFAULT` in :ref:`module(1)`) the module version
@@ -1963,4 +1957,3 @@ Tcl was developed by John Ousterhout at the University of California
at Berkeley.
TclX was developed by Karl Lehenbauer and Mark Diekhans.