Compiling Codes

1.  Available compilers

On the SISSA/Democritos computing infrastructure three compiler suites are available in various versions:

  • Intel® Compiler Suite Professional Edition for Linux
  • PGI Cluster Development Kit
  • GNU Compiler Collection

All three suites provide compilers for C, C++ and Fortran 77/90/95 programming languages and various serial debugging tools. You're encouraged to try all the three suites. The general advice is to use the Intel software for production as it usually provides the best performance. However, agressive optimization techniques and loose syntax control make Intel compilers unfit to test the correctness and portability of a code. For this purpose we suggest the use of GNU software.

Important! Please use only interactive sessions on the masternode (hg1) to compile your software, unless you really know what you are doing.

2.  Compiling serial codes

To compile your serial code you will need to know which is the command that invokes the serial compilers in each suite. The table below provides you with a quick reference.

LanguageCC++Fortran 77Fortran 90/95

The first step required is to load the corresponding module, so for example, if you wanted to compile your C++ code with the PGI compilers you should type

$ module load pgi

and then perform the actual compiling by calling the C++ compiler with a command like

$ pgCC myprog.cpp -o myprog

The standard syntax for compiling serial codes that applies to all three suites is the following

$ compiler [compiler options] sourcefile.lang -o exefile [linker options].

For in depth compiler documentation use the manpages, e.g.

$ man ifort

will display the manual pages for the Intel Fortran Compiler.

3.  Compiling parallel codes

3.1  Codes using MPI - base

To compile a MPI based parallel code you will need to load the appropriate environment module which will provide so called wrappers to enable you to compile your codes without bothering to take care of the various MPI related dependencies. This compiler wrappers have a standard name in all MPI distributions, which are the following

  • mpicc for C programs
  • mpiCC for C++ programs
  • mpif77 for Fortran77 programs
  • mpif90 for Fortran90/95 programs

The standard MPI distribution for the SISSA/Democritos infrastructure is OpenMPI which supports all interconnection networks available and all the three aforementioned compiler suites. To load it you need to load the appropriate module

$ module load openmpi

or if you want a different version the specific module, e.g.

$ module load openmpi/1.3/pgi/7.2-5

The module will provide all the necessary links to the MPI libraries. To compile your code from the command line type something like

$ mpif90 mympicode.f90 -o mympiexe

The general syntax is the same as in the serial case

$ mpiXXX [compiler options] sourcefile.lang -o exefile [linker options].

In case you're not sure which compiler is wrapped by OpenMPI you can make it display the compiler version by typing something like

$ mpiCC -V


$ mpiCC -v

3.2  Codes using MPI - advanced

Different MPI distributions are available on the SISSA/Democritos infrastructures, namely MVAPICH2 and LAM-MPI. The first works only with Infiniband equipped nodes, the second works using only TCP/IP via Ethernet 1Gbit network. These distributions are NOT intended for production and you are warned NOT to use them unless you really know what you're doing. We kindly ask you to notify us if you're intending to use them.

The compilation of the codes works in the same way as with OpenMPI, the only difference is that LAM-MPI provides only one wrapper for the Fortran compilers which is mpif77. No mpif90 is available.

Please note that LAM-MPI and MVAPICH2 were compiled only with the Intel Compilers version 10.1.

3.3  Codes using OpenMP