Compilers

Gnu

The Gnu Compiler Collection compilers are free, open-source tools. Additional tools included are the gdb debugger and the gprof performance profiler. Gnu documentation can be found here.

The default Gnu compilers on Rivanna are typically fairly old.  Newer versions can be invoked through an appropriate module. The compilers are:

  • Fixed-format Fortran: gfortran [options] filename.f
  • Free-format Fortran: gfortran [options] filename.f90
  • C: gcc [options] filename.c
  • C++: g++ [options] filename.cpp or g++ [options] filename.cxx

A list of compiler options can be obtained by invoking the compiler with the -help option. For example: gfortran -help

More information is available from the manpage, e.g.: man g++

For available versions, please run

module spider gcc

It is important to load the correct module if you want to use more advanced features available in newer standards, particularly for C++ and Fortran.  The default system-wide version is several years old.

module load gcc

It may be necessary to use an older compiler for programs using GPGPUs.

Intel

The Intel Linux Fortran and C/C++ compilers are for x86-64 processor-based systems running Linux. These compilers have specific optimizations for Intel architectures. The University has floating network licenses for the Intel compiler suite as well as for the Math Kernel Libraries.

Click here for Intel C/C++ and Fortran compiler documentation.

The Intel compilers are accessed on the Rivanna cluster by using the modules software to dynamically set the appropriate environmental variables (e.g. PATH and LD_LIBRARY_PATH). To initalize your environment to use the Intel compilers, use the command: module load intel.

  • Fortran fixed format: ifort [options] filename.f
  • Fortran free format: ifort [options] filename.f90
  • C: icc [options] filename.c
  • C++: icpc [options] filename.cpp or: icpc [options] filename.cxx

A list of compiler options can be obtained by invoking the compiler with the -help option, e.g.: ifort -help

To see the available versions, run

module spider intel

Then load the appropriate module

module load intel

(for the default version).

If you are encountering a segmentation fault in Fortran code, recompile with the flag -heap-arrays added. 

If you still experience segmentation violations, recompile with g -CB (for debugging and bounds checking respectively) and run the program under the control of a debugger.  Once the program is debugged, be sure to remove the -g and certainly the -CB flags and recompile with -O or -O -ipo. If that works, try -O3 or -O3-ipo for a higher level of optimization.

If mathematical libraries are needed, we strongly recommend the Intel Math Kernel Libraries (MKL). They provide LAPACK, BLAS, and a number of other libraries. They are highly optimized, especially for Intel architecture, and they automatically work with the compiler. The Intel module for any version loads the MKL that is compatible with that compiler. The module script sets an environment variable MKL_DIR (with MKLROOT as a synonym). This variable can be used in scripts and makefiles. For example, in a [mM]akefile: LIBS=-L$(MKLROOT).

The MKL consists of a number of libraries, and which ones to link is not always obvious.  In newer Intel compilers a flag -mkl can be added for both compiler and linker.  However, that does not always suffice, so Intel provides a link line advisor at their site. Remember that default integers are 32 bits even on 64-bit systems. MKL includes Scalapack.

The Intel compiler should also be used, along with its companion Intel MPI, for Intel Many-Integrated Core systems.  To compile for MIC architectures use the flag -xMIC-AVX512 on your compile line.

PGI

The PGI Server Compilers and tools are licensed for Linux systems.

The PGI compilers are accessed on the HPC cluster by using modules to dynamically set the appropriate environmental variables (e.g. PATH and LD_LIBRARY_PATH). To initialize your environment to use the PGI compilers, use the command 

module load pgi

After you have modified your environment to access the PGI compilers, you can invoke the compiler on a source code file in one of the following ways.

  • Fortran fixed format: pgf90 [options] filename.f
  • Fortran free format: pgf90 [options] filename.f90
  • C: pgcc [options] filename.c
  • C++: pgCC [options] filename.cpp or pgCC [options] filename.cxx

A list of compiler options can be obtained by invoking the compiler with the -help option, e.g.: pgf90 –help

More information is available from the manpage, e.g.: man pgf90

PGI provides a very capable debugger, pgdbg. In its default mode, it is graphical, and it requires that an X server run on the user's local desktop machine. It may be run in command-line mode with the -text option; see the manpage for a full list of options. As with all debuggers, the user's program must be compiled with the -g flag in order to enable debugging. If you wish to use the graphical debugger and do not have or want to install an X11 server, you can also use FastX. Another option for a graphical debugger is TotalView.