Compiling Code

Most users running jobs will want to compile their sourcecode on our servers before running them or submitting them to MOAB and Condor. To this end, we provide a number of different compilers and libraries. For a full list and detailed documentation for each, refer to the software index.

The three primary compiler sets on our system include:

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

In addition, we provide commonly used libraries for each of the compilers, such as the OpenMPI Libraries or the NetCDF libraries.

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
  3. Load linked libraries
  4. Compile code using Intel, GNU, or PGI compiler
  5. Run application in Spear, MOAB (HPC), or submit on Condor

Example Job in HPC

Below is a tutorial for compiling a C program for the HPC using the Intel MPI Compiler. Other sytems, such as Spear or Condor, use a similar process.

First, download this example script and copy it to your HPC home directory: trap.c.txt

The trap.c example script is a classic trapezoid integration in an MPI context. The script calculates the integral of a function using a composite trapezium rule, and each node calculates it's subpart of the entire domain. It is a convenient example script that demonstrates how the HPC works.

Next, Login to the HPC via SSH and rename the file to trap.c:

$ mv ~/trap.c.txt ~/trap.c

We'll use the Intel compiler to compile the code, so we first need to import the Intel compiler executables into our shell. This command will enable access to the Intel compilers:

$ 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 sourced the file correctly.

Next, load the MPI library paths:

$ module load intel-mvapich2

Now, we can compile our trap.c code into an executable using the Intell MPI C compiler:

mpicc -o trap-mpichv2 trap.c -lm

This command should produce no output, but if you run ls after it completes, you should see a new executable file appear: trap-mpichv2. This file is ready to be executed in an MPI environment, specifically our HPC.

To run this in MOAB, we have provided a tutorial...