Compiling Software

This page describes how to compile code for the HPC, Spear, or Condor using compilers on our login nodes.

Although the RCC provides a large number of built-in, precompiled software programs 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 compilation resources on our systems:

The three primary compiler suites on our systems include:

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

Each compiler includes executables to compile C, C++, and Fortran sourcecode. These are the 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 (see full list).

Compilation Overview

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

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

Example Job on the HPC

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

This script is a classic trapezoid integration that uses MPI. The script calculates the integral of a function using a composite trapezium rule, and each node calculates its 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 script into your home directory:

cp /panfs/storage.local/opt/examples/trap.c ~/trap.c

We will use the Intel compiler to compile the code (although you could easily use the PGI or GCC compilers). First, import the Intel compiler module into your environment. 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) 13.0.1 20121010
Copyright (C) 1985-2012 Intel Corporation.  All rights reserved.

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

Next, load the MPI libraries:

$ module load intel-mvapich2

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

$ mpicc -o trap-mpichv2 trap.c -lm

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

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

Compiler Reference

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