GNU Compilers

Overview

The GNU Compiler Collection supports a number of programming languages.

Several versions are available on the CSF – please see the table below.

Advice on programming in Fortran or C is currently beyond the scope of this webpage.

Restrictions on use

Code may be compiled on the login node, but aside from ‘very’ short test runs (e.g., one minute on fewer than 4 cores), executables must always be run by submitting to the batch system, SGE. If you need to do a bigger test than this then please use batch or qrsh (see below).

Set up procedure

This depends on which version you require.

Version Commands / compilers available Module required Additional Notes
9.3.0 gcc, g++, gfortran module load compilers/gcc/9.3.0
8.2.0 gcc, g++, gfortran module load compilers/gcc/8.2.0
6.4.0 gcc, g++, gfortran module load compilers/gcc/6.3.0
4.8.5 gcc, g++, gfortran None System default, used if no modulefile loaded
4.2.3 gcc, g++, gfortran module load compilers/gcc/4.2.3

By loading/swapping modules, the correct LD_LIBRARY_PATH will be set.

Running the application

Example Code Compilations

   gcc hello_world.c -o hello
       #
       # ...produces executable binary called "hello"...
       #

   gfortran hello_fworld.f77 -o f77hello
   gfortran hello_fworld.f95 -o f95hello
       #
       # ...produce executable binary called "f77hello" or "f95hello"...
       #

Serial batch job submission

To submit a single core batch job to SGE:

  • Make sure you have the correct module loaded if appropriate (see table above).
  • An example SGE qsub script for use with a binary executable called myfortranprog compiled by using the GNU compilers:
    #!/bin/bash --login
    #$ -cwd              # Use the current directory
    
    # Load the software
    module load compilers/gcc/6.4.0
 
    # Run the code
    ./myfortranprog
  • To submit:
     qsub jobscript
           #
           # where 'jobscript' is replaced with the name of your file
           #

Parallel batch job submission

Your code, and thus the resulting executable, must use either OpenMP and/or MPI in order to run in parallel. Please follow these links to find out how to submit batch of these types to SGE:

Testing via qrsh and batch

qrsh can be used to gain interactive access to a compute node (limited resources reserved for this). This is useful for both compilation and testing of your code. Example:

qrsh -l short
module load compilers/gcc/6.4.0
gcc hello_world.c -o hello
./hello

You can also add

#$ -l short

To your jobscript and this will then submit to a very small section of the cluster that has a maximum runtime of 1 hour. The short option is not valid for production runs, please submit those to the cluster in the usual way.

Further info

  • Online manuals available from the command line:
     man gcc
         # for the C/C++ compiler

     man gfortran
         # for the fortran compiler
  • GNU Compiler Collection website
  • If you require advice on programming matters, for example how to debug a code, or how to use MKL, please email its-ri-team@manchester.ac.uk

Last modified on May 3, 2022 at 11:11 am by