13

I'm trying to compile the "Global Climate Model" with the following commands.

module unload pgi gcc
module load gcc/4.6.3 pgi/11.8

When I execute them, the terminal replies with command not found.

What am I doing wrong? What is the right way to do this?

2
  • Can you explain what the "Global Climate Model" is? Where are you getting those instructions? – Oli Sep 10 '13 at 8:43
  • 1
    I would have put this reply in a comment but can't due to lacking reputation :( It appears that environment-modules is not available in 12.04, but from 12.10 on upwards: <packages.ubuntu.com/search?keywords=environment-modules> – tssch Mar 6 '14 at 15:43
29

Just to summarize the previous comments and answers and add a bit of first-hand installation experience:

You are looking for the module command provided by the Environment Modules package. It is a tool for modifying the shell environment (PATH but also aliases etc.) and common to many multi-user clusters like High-Performance Computing clusters.

The instructions you got were probably from some HPC cluster, since you want to run a global climate model. Read more about Environment Modules on HPC here.

Now for something actually Ubuntu-related: It is actually not that much of a pain to set up Environment Modules under Ubuntu. I just did it in under 10 minutes for Ubuntu 14.10 and the Bash shell.

As mentioned in other posts, you can install Environment Modules from the repos (package environment-modules).

Then you run add.modules. It will put a few lines into your shell initalization file, in this case ~/.bashrc:

case "$0" in
          -sh|sh|*/sh)  modules_shell=sh ;;
       -ksh|ksh|*/ksh)  modules_shell=ksh ;;
       -zsh|zsh|*/zsh)  modules_shell=zsh ;;
    -bash|bash|*/bash)  modules_shell=bash ;;
esac
module() { eval `/usr/Modules/$MODULE_VERSION/bin/modulecmd $modules_shell $*`; }
#module() { eval `/usr/bin/modulecmd $modules_shell $*`; }

You need to uncomment the last line and comment out or delete the second-last. This line defines the module command you were looking for. It effectively runs modulecmd bash plus the arguments you give it.

I have the feeling that this function is actually not very safe because it evaluates anything you supply it with in its arguments. Some users can perhaps comment on how to improve this.

You now just need to create some directory containing the so-called modulefiles and add it to $MODULEPATH, for example with module use /path/to/your/modulefiles. There are examples for modulefiles out there on the interwebs.

I find this a very handy tool not just for multi-user clusters. I use it for switching between different Python distributions.

5
  • 2
    I think this is should be the accepted answer to the question – credondo May 29 '15 at 8:41
  • example module files link is dead – muenalan Oct 12 '16 at 9:44
  • 1
    Requiring every user to run /usr/share/modules/bin/add.modules seems to be inconvenient. I added ". /etc/profile.d/modules.sh" to the beginning of the file /etc/bash.bashrc That might be a solution for users having bash as their login shell. Note, this was only needed for GUI login. SSH-login was already working before the change. What do you think, is this a good solution or do you recommend something else? – Erik Sjölund Oct 19 '16 at 12:07
  • I can see that the environment-modules package has historically changed the method to get the 'modules' function into your shell. On an older Red Hat system, there is /etc/profile.d/modules.sh that I must source to provide the modules function (I used rpm -ql environment-modules to understand what files were available). On Ubuntu, that would be dpkg-query -S /usr/share/modules - that will just help you understand what the package provides. – qneill May 3 '18 at 19:26
6

For those who "skim" (looking at you Seth): This is NOT A QUESTION ABOUT KERNEL MODULES. It's a question about manipulating shell environment variables using a tool called ENIRONMENT-MODULES. If you're at all familiar with kernel modules, you'll realize there is no standard kernel tool (script or otherwise) named "module." All the module manipulation tools abbreviate module as mod (lsmod, insmod, modprobe, etc). And there is no module named gcc.

Environment-modules (http://modules.sourceforge.net/) is yet another environment tool for switching execution environments in the shell. It helps people who need Python 2.4 and Python 2.7 on the same machine. Or it helps people manage Intel v. GNU compilers and libraries.

Unfortunately, environment-modules isn't a package for Ubuntu 12.04 LTS.

Options include installing from source (follow the link above), upgrading to 14.04 LTS, or looking at deb files. Of the three, I'd install from source. The deb file depends on libtcl8.6 which is in the same predicament, unavailable on 12.04LTS.

4

You're probably trying to use a software package that isn't installed on your machine. Of course I can't really be sure, but my guess would be that you're trying to use environment-modules. If that is correct, you could install environment-modules from the standard Ubuntu repositories.

But be aware that environment-modules is a rather old program. The homepage notes the last update of a helper tool as of 2011, the copyright notice doesn't go further up than 1999. So there's no guarantee that this software package works flawlessly with current Ubuntu versions. It might, but you can't be sure.

1
  • 2
    It's a huge pain to set up, but it works extremely well and is a de facto standard on multi-user clusters. – Emmet Mar 5 '14 at 18:53
0

It's not a case of module load not working, module load isn't a standard command in Ubuntu.

If you're trying to load an existing module, sudo modprobe <modulename> is the command you're looking for. And you can use rmmod or modprobe -r to unload a module.

4
  • Oli I'm getting these instructions from a global climate model "ECHAM6" user guide. The above mentioned lines 'module load' are mentioned in the manual to load the compiler from the terminal... – uzair mannan Sep 10 '13 at 15:21
  • 4
    He's trying to use the environment modules program (typically installed on clusters) that manages environment variables for different compilers, MPI implementations, etc. not load kernel modules. – Emmet Mar 5 '14 at 18:50
  • it actually does exist, we use it everyday in our company :P – Bruno Pereira Mar 6 '14 at 16:18
  • module is a tool used to change tool and libs version from one to the other, much like virtualenv is to python, but instead it changes your paths and variables to reflect other setups, eg: module load gcc-4.8 will load gcc-4.8, module load gcc-4.7 will load 4.7, etc – Bruno Pereira Mar 6 '14 at 16:21
0

simply add this to the first line of your script. Then the module command will be read by tsch.

#!/bin/tcsh

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.