Installing and Configuring LMOD

  • install lmod: $ spack install lmod . If it doesn’t work because spack is an unknown command: Did you set the $PATH variable correctly? Did you also re-source the .bashrc file to update your $PATH variable with $ source ~/.bashrc ?

  • create ~/.spack/modules.yaml file with the following content:

modules:
  enable::
    - lmod
  tcl:
    hash_length: 2
    naming_scheme: '${PACKAGE}/${VERSION}'

  lmod:
    hash_length: 0
    hierarchy:
      - mpi
    core_compilers:
      - 'gcc@7.4.0'

    all:
      environment:
        set:
          '${PACKAGE}_ROOT': '${prefix}'

    hierarchical_scheme: ['lapack']

    blacklist:
      - autoconf
      - automake
      - libsigsegv
      - m4
      - numactl
      - zlib
      - gmp
      - isl
      - lua-luafilesystem
      - lua-luaposix
      - mpc
      - mpfr
      - pkgconf
      - readline
      - libszip
      - bzip2
      - gdbm
      - inputproto
      - kbproto
      - libpthread-stubs
      - libx11
      - libxau
      - libxcb
      - libxdmcp
      - ncurses
      - openssl
      - sqlite
      - tk
      - util-macros
      - xcb-proto
      - xextproto
      - xproto
      - xtrans
      - bison
      - flex
      - gettext
      - help2man
      - libxml2
      - tar
      - xz
      - atk
      - binutils
      - cairo
      - damageproto
      - dbus
      - dri2proto
      - dri3proto
      - expat
      - fixesproto
      - font-util
      - fontconfig
      - freetype
      - gdk-pixbuf
      - glib
      - glproto
      - gobject-introspection
      - gperf
      - gtkplus
      - harfbuzz
      - icu4c
      - intltool
      - lcms
      - libbsd
      - libdrm
      - libffi
      - libjpeg-turbo
      - libmng
      - libpciaccess
      - libpng
      - libtiff
      - libxdamage
      - libxext
      - libxfixes
      - libxft
      - libxrender
      - libxshmfence
      - libxv
      - libxvmc
      - mesa
      - nasm
      - pango
      - pcre
      - perl-xml-parser
      - pixman
      - presentproto
      - py-mako
      - py-markupsafe
      - py-setuptools
      - renderproto
      - shared-mime-info
      - videoproto

In the blacklist section, you can add any library/program that you don’t want to see when you use module avail.

  • add this to the beginning of your ~/.bashrc file. It needs to be done before anything else.

#!/bin/bash

# for spack/modules autocompletion
source $SPACK_ROOT/share/spack/setup-env.sh

# NEEDS TO BE DONE AFTER PATH ADDITIONS AND BEFORE EVERYTHING ELSE

export LMOD_PATH=$SPACK_ROOT/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.4.0/lmod-7.8-w262ukcicv5oxbvf4sv5aqacf2adjxtk/lmod/7.8
source $LMOD_PATH/init/bash

# this path will be created once you install mpi version(s)
export MODULEPATH=$SPACK_ROOT/share/spack/lmod/linux-ubuntu18.04-x86_64/Core

if [ -d /etc/profile.d ]; then
 for i in /etc/profile.d/*.sh; do
   if [ -r $i ]; then
     . $i
   fi
 done
fi

export LMOD_CMD=$LMOD_PATH/libexec/lmod

The direcotry linux-ubuntu18.04-x86_64 may be different in your case, as well as the gcc-7.3.0 part and lmod-7.8-7xoal6tokagwidxziv3fspyhz5ojghdy/. Check how the directories are actually called on your system. Note also that this relies on the previously defined $SPACK_ROOT variable.

  • re-source your ~/.bashrc again with source ~/.bashrc and you’re ready to go! Anything you install now with spack will turn up as a module that you can load/unload.

Page last edited 2019-10-21