Skip to content

Compiling software

This page describes how to compile custom code for the HPC or other RCC systems using compilers on our login and compute nodes.

Although the RCC provides a large number of built-in, precompiled software packages on our systems, many users will need to compile custom code into an executable program before submitting it to the Slurm scheduler. For this, we provide compiler libraries on our systems.

The three most commonly used compilers on our systems include:

  1. Intel compilers
  2. GNU compilers
  3. Portland Group (PGI) compilers


For a comprehensive list of compilers that the RCC supports, refer to our software catalog

Each compiler includes executables to compile C, C++, and Fortran sourcecode. These are the three most commonly used languages for HPC computing. We also support Java, Python (which can be compiled to C using cython), and other languages.

In addition, we provide commonly used libraries for each of the compilers, including OpenMPI, NetCDF, and others.

Compilation Overview#

The general workflow for compiling an application on our systems is as follows:

  1. Copy source files into your home directory on our system.
  2. Import compiler paths using environment modules
  3. Load linked libraries
  4. Compile code using Intel, GNU, or PGI compiler
  5. Run application or submit job

Tutorial: trap.c#

Below is a tutorial for compiling a C program on the HPC login node using the Intel compiler with the MPI libraries for a simple program, trap.c. This script is a convenient example of how parallel execution on the HPC works.

The trap.c script is a classical trapezoid integration that uses MPI. The script calculates the integral of a function using a composite trapezium rule, and each node calculates it subpart for the entire domain. You do not need to understand the mechanics of what the script does in order to follow this tutorial.

Login to the HPC and copy the example trap.c into your home directory:

$ cp /gpfs/research/software/examples/trap.c ~/trap.c

We will use the intel compiler to compile the code (although you could alternatively use the PGI or GCC compilers).

First, import the Intel compiler module into your environment using environment modules. This will enable access to the Intel compiler executable commands:

$ module load intel

After running this command, try running icc --version. You should see something similar to the following:

$ icc --version
icc (ICC) 2021.2.0 20210228
Copyright (C) 1985-2021 Intel Corporation.  All rights reserved.


If you see a Command not found error, ensure that you have run the module load intel command first.

Next, load the MPI libraries:

$ module load mvapich2

With both the compiler module and the parallelization libraries loaded, you can now compile your trap.c code into an executable:

$ mpicc -o trap trap.c -lm

This command will show no output when run, but if your run ls after it completes, you will see a new executable file appear: trap.

This file is ready to be executed in an MPI environment, specifically the HPC. To run compiled programs on the HPC, see our tutorial for submitting HPC jobs

Compiler Reference#

This page provides an example using the Intel compiler. For a more comprehensive overview of all the compiler commands and options available, refer to our software documentation