User Manual

1 Getting Started

2 Managing Files

3 Software
3.1 Software modules
3.2 GUI software
3.3 MATLAB
3.4 Compiling
3.5 Linking

4 Running Jobs

5 XSEDE

6 GPU Computing

3.4 Compiling

By default, the 'gcc' software module will load when you login, providing the GNU compiler suite of gcc (C), g++ (C++), and gfortran (Fortran 77/90/95). To compile a simple (single source) program, you can use:

$ gcc -g -O2 -o myprogram myprogram.c
$ g++ -g -O2 -o myprogram myprogram.cpp
$ gfortran -g -O2 -o myprogram myprogram.f90

The -g and -O2 flags tell the compiler to generate debugging symbols and to use a higher level of optimization than the default.

Optionally, you can load the 'pgi' module to access the Portland Group compiler suite, including pgcc (C), pgCC (C++), pgf77 (Fortran 77) and pgf90 (Fortran 90), or the 'intel' module to access the Intel compiler suite, with icc (C), ifort (Fortran), and icpc (C++).

3.4.1 OpenMP and pthreads

Both the GNU and PGI compilers provide support for threaded parallelism using either the POSIX threads (pthreads) library or the OpenMP programming model.

To link against pthreads, append the -lpthread flag to your compile or link command. For OpenMP, use -fopenmp with the GNU suite, -mp with PGI, or -openmp with Intel.

3.4.2 MPI

The Message Passing Interface is the most commonly used library and runtime environment for building and executing distributed-memory applications on clusters of computers.

We provide the OpenMPI implementation of MPI. The 'openmpi' module loads by default, providing the OpenMPI library compilers for C (mpicc), C++ (mpicxx or mpic++), Fortran 77 (mpif77) and 90 (mpif90). These are wrappers for the GNU compilers that add MPI support. Simply use the MPI wrapper in place of the compiler you would normally use, so for instance:

$ mpicc -g -O2 -o mpiprogram mpiprogram.c

If you would like to use MPI with the PGI or Intel compilers, you can switch to the appropriate version of OpenMPI with a module swap command:

$ module swap openmpi openmpi/1.4.3-pgi
$ module swap openmpi openmpi/1.4.3-intel

Unfortunately, you cannot load several versions of MPI at the same time, because their environment variables will conflict.