-
Notifications
You must be signed in to change notification settings - Fork 0
/
creating-modulefiles.qmd
62 lines (45 loc) · 2.07 KB
/
creating-modulefiles.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Creating Modulefiles
## Sample module file
```bash
#%Module1.0####################################################################
proc ModulesHelp { } {
global _module_name
puts stderr "The $_module_name modulefile defines the default system paths and"
puts stderr "environment variables needed to use the $_module_name libraries and tools."
puts stderr ""
}
set _module_name [module-info name]
## Change to be user-specifc path
set approot /projects/stat/shared/$::env(USER)/software/libevent/2.1.11
module-whatis " Name: libevent"
module-whatis " Long name: libevent - An event notification library"
module-whatis " Version: 2.1.11"
module-whatis " Category: library"
module-whatis "Description: An event notification library"
module-whatis " URL: https://libevent.org/"
module-whatis ""
if { [ is-loaded gcc/7.2.0 ] } {} else { module load gcc/7.2.0 }
prepend-path PATH $approot
prepend-path LD_LIBRARY_PATH $approot/lib
prepend-path LD_RUN_PATH $approot/lib
prepend-path MANPATH $approot/man
prepend-path --delim " " LDFLAGS "-L $approot/lib"
prepend-path --delim " " CPPFLAGS "-I $approot/include"
prepend-path --delim " " CFLAGS "-I $approot/include"
```
- `prepend-path` by itself is for variables like `PATH` `LD_LIBRARY_PATH`, `LD_RUN_PATH`, `LIBRARY_PATH`, `CPATH`, `MANPATH` ...
- `prepend-path --delim " "` is for compiler flag variables like `LDFLAGS`, `CPPFLAGS`, `CFLAGS`, ...
- Module dependencies should be specified with:
```tcl
## Load module if not already loaded.
if { [ is-loaded <module> ] } {} else { module load <module> }
```
- `conflict <module>` emphasizes any modules that can't be loaded together
# Self-notes
- `$::env()` is part of TCL language and allows the TCL script/modulefile to access variables found in the `env array`.
- `$::env(HOME)` would return: /home/$USER
- `$::env(USER)` would return: $USER
- Details: https://wiki.tcl-lang.org/page/env
Useful references:
<https://cea-hpc.github.io/modules/docs/MC2_whitney_paper.pdf>
<https://www.acrc.bris.ac.uk/acrc/pdf/customising-environment-variables.pdf>