Skip to content

CEOAS Software

Spack

Spack is an open-source package manager that simplifies both building and deploying software with multiple different compilers and runtimes. While other software management solutions (such as modules) help with the runtime portion, Spack vastly simplifies the work required to support the array of C/C++ compilers (gcc, icc, icx, nvc), Fortran compilers (gfortran, ifort, ifx, nvfortran), and MPI implementations (OpenMPI, Intel MPI) that researchers require to compile and run a wide variety of models.

Activating Spack

Although users can run Spack on their own if they'd prefer to, CEOAS has a shared install of Spack located at /local/ceoas/opt/spack with multiple preconfigured environments and software stacks available for use. Activating the CEOAS Spack install can be done by sourcing the appropriate setup-env file at /local/ceoas/opt/spack/current/share/spack/. For example, to activate it under bash, simply run:

. /local/ceoas/opt/spack/current/share/spack/setup-env.sh

(Note that the space after the dot and before the leading slash is required.)

The first time you activate Spack, it may take quite some time. Spack does a significant amount of user initialization and filesystem operations on first run. After the first activation, future activations will be much faster.

Listing and loading environments

Ideally, most users will use the preconfigured environments instead of loading individual packages by hand. To list the available environments, run spack env list. For example:

[olsont@shell ~]$ spack env list
==> 10 environments
    default                     gcc-openmpi-cuda12-aarch64  intel-openmpi-cpu-x86
    gcc-openmpi-cpu-x86         gcc-openmpi-cuda12-x86      nvhpc-openmpi-cuda11-x86
    gcc-openmpi-cuda11-aarch64  intel-intelmpi-cpu-x86
    gcc-openmpi-cuda11-x86      intel-intelmpi-cuda11-x86
The general naming convention is <compiler>-<mpi>-<gpu>-<architecture>. Environments built without a GPU runtime use cpu. x86 is the Intel/AMD architecture and aarch64 is the ARM architecture. Breaking down an example, gcc-openmpi-cuda12-aarch64 uses the GNU compilers with OpenMPI and CUDA 12 built for ARM servers. Similarly, intel-intelmpi-cpu-x86 uses the Intel OneAPI compilers with Intel MPI and no GPU support built for Intel/AMD servers. For Fortran users in particular, it's critically important to use the correct environment because Fortran binaries and libraries are not compatible across different compilers.

To load a given environment, simply run spack env activate <environment>. Unlike environment managers such as Conda, Spack does not change your prompt to indicate the activate environment by default. If you'd like it to, you can add the -p flag as spack env activate -p <environment>.

Listing and inspecting packages

Once you've loaded an environment, you can run spack find to list all the packages available in that environment. Spack includes all the requisite dependencies in the environment and package listing, so for particularly large environments this can contain large amounts of extraneous information. Since most users will likely only care about the packages that are explicitly included in an environment, you can run spack find -x to only list those:

[olsont@shell ~]$ spack env activate -p gcc-openmpi-cpu-x86
[gcc-openmpi-cpu-x86] [olsont@brizo01 ~]$ spack find -x
==> In environment gcc-openmpi-cpu-x86
==> 5 root specs
-- no arch / no compilers ---------------------------------------
[+] gcc@14  [+] hdf5  [+] netcdf-c  [+] netcdf-fortran  [+] openmpi~cuda

-- linux-rocky9-sandybridge / %c,cxx,fortran=gcc@14.3.0 ---------
openmpi@5.0.8

-- linux-rocky9-sandybridge / %c,cxx=gcc@11.5.0 -----------------
gcc@14.3.0

-- linux-rocky9-sandybridge / %c,cxx=gcc@14.3.0 -----------------
ucx@1.18.1

-- linux-rocky9-sandybridge / %c,fortran=gcc@14.3.0 -------------
hdf5@1.14.6  netcdf-fortran@4.6.1

-- linux-rocky9-sandybridge / %c=gcc@14.3.0 ---------------------
netcdf-c@4.9.2
Spack divides the packages based on what platform they're built for (in this case linux-rocky9-sandybridge) and the compiler(s) used to build to package. Each package name is followed by @<version>. As you can see, this environment includes gcc 14.3, OpenMPI 5.0.8, and so forth.

Spack also provides a significant amount of installation customization options, mirroring what's available for manual compilation. To view how these options are set, you can run spack find -v to show it for all packages, or spack find -v <package> to only show a specific package:

[gcc-openmpi-cpu-x86] [olsont@shell ~]$ spack find -v netcdf-c
==> In environment gcc-openmpi-cpu-x86
==> 5 root specs
-- no arch / no compilers ---------------------------------------
[+] gcc@14  [+] hdf5  [+] netcdf-c  [+] netcdf-fortran  [+] openmpi~cuda

-- linux-rocky9-sandybridge / %c=gcc@14.3.0 ---------------------
netcdf-c@4.9.2+blosc+byterange+dap+fsync~hdf4~jna~logging+mpi+nczarr_zip+optimize+parallel-netcdf+pic+shared+szip+zstd build_system=autotools patches:=0161eb8

The tilde indicates a disabled option and the plus indicates an enabled option. If you want or need more detailed information on what a specific option does, simply run spack info <package>.

Using packages

Upon loading an environment, Spack will configure all the necessary environment variables such as PATH and LD_LIBRARY_PATH for the packages, so you generally will not need to do anything beyond that to use packages. However, certain build systems still require the user to explicitly set paths to certain libraries. While it's preferred to use the automated tools whenever possible (such as variables set by Spack, or programs such as nf-config), you can run spack location -i <package> to find the actual install path:

[gcc-openmpi-cpu-x86] [olsont@shell ~]$ spack location -i hdf5
/fs1/local/ceoas/opt/spack/spack-1.0.0/opt/spack/linux-sandybridge/hdf5-1.14.6-c5rdgnj55r6iv5watnka7agsi7q5dnko

It is highly recommended to use the command in scripts rather than running it once and copying the output. Doing so will make your scripts more flexible in case paths change in the future.

Requesting packages

If a package is needed in a Spack environment that isn't currently available, please send an e-mail to support@ceoas.oregonstate.edu to ask if it can be installed. Be aware that while some packages are quite simple to install and can be handled quite quickly, others may have more complex interactions with existing packages and dependency conflicts that can extend the time it takes to install.