I am trying to construct a module file and I would like to include an if statement to check whether certain environment variables (e.g. PATH, LD_LIBRAY_PATH, PYTHON_PATH, ...) have already been set.
I have tried several different syntax options (after searching on here, official documentation and other forums) but when I then try:
module use modulefiles
module load mymodule
I keep getting ERROR:102: Tcl command execution failed
error. Here are a few of the options that I have tried:
i)
set myTools /path/to/my/Tools
if { info exists $LD_LIBRARY_PATH } {
setenv LD_LIBRARY_PATH $myTools/lib:$myTool/lib64:$LD_LIBRARY_PATH
} else {
setenv LD_LIBRARY_PATH $myTools/lib:$myTools/lib64
}
ii)
set myTools /path/to/my/Tools
if { [info exists $LD_LIBRARY_PATH] } {
setenv LD_LIBRARY_PATH $myTools/lib:$myTool/lib64:$LD_LIBRARY_PATH
} else {
setenv LD_LIBRARY_PATH $myTools/lib:$myTools/lib64
}
iii)
set myTools /path/to/my/Tools
if { $?LD_LIBRARY_PATH } {
setenv LD_LIBRARY_PATH $myTools/lib:$myTool/lib64:$LD_LIBRARY_PATH
} else {
setenv LD_LIBRARY_PATH $myTools/lib:$myTools/lib64
}
What is the correct syntax to check for the existence of environment variables that may have already been set, e.g. in a .cshrc
or .login
file?
Apologies if this is a basic question. I've done stuff like this before in the shell (mainly csh), but I am new to TCL and building module files, so any help and advice wold be greatly appreciated!
Thanks!