GCC 6.1.0

The GNU Compiler Collection (gcc) includes front ends for C, C++, Objective-C, Fortran, Java, and Ada, as well as libraries for these languages (libstdc++, libgcj,...). GCC was originally written as the compiler for the GNU operating system. The GNU system was developed to be 100% free software, free in the sense that it respects the user's freedom. The following compiler front-ends are available in this installation on BlueBEAR:

  • gfortran which supports the Fortran 77, 90 and 95 standards completely, parts of the Fortran 2003 and Fortran 2008 standards, and several vendor extensions. gfortran has replaced the g77 compiler, which stopped development before GCC version 4.0.
  • gcc, for the C language
  • g++ or c++ for the C++ language
  • gcj for Java

We recommend using a standard toolchain (such as IOMKL or FOSS) if you plan to build any software yourself, rather than building your own versions of these packages or relying on the Operating System's version.

Accessing the software

To load the module:

$ module load apps/gcc/v6.1.0

An example command to include in your job script:

gcc -o <output-file> <C-file>

Example: GCC Job

An example can be found at ${BB_EXAMPLES}/GCC/6.1.0/sbatch.sh. The example can be copied to a test directory and submitted to the batch system using sbatch.

$ cp -r ${BB_EXAMPLES}/GCC/6.1.0 ~/gcc-6.1.0-test
$ cd ~/gcc-6.1.0-test

Edit the sbatch.sh script according to your needs, then do:

$ sbatch sbatch.sh

Debugging Options

There are many options that can be specified to the compiler. For debugging, the most useful are:

  • -O0 to turn off all optimisation which allows more precise diagnosis of run-time errors.
  • -fbounds-check (gfortran only) to enable generation of run-time checks for array subscripts and against the declared minimum and maximum values.  It also checks array indices for assumed and deferred shape arrays against the actual allocated bounds.
  • -ffpe-trap= (gfortran only) which specifies that floating-point invalid, divide-by-zero, overflow, underflow and precision exceptions are enabled. If any such exceptions occur, execution is aborted with a core file which may be useful for debugging. This argument may be optionally followed by a comma-separated list of the exceptions to be trapped

More details of these, and other debugging options, are available in the man page for the compiler. It is important to understand that any compiler system only defines the correct operation of a correct program; errors such as out-of-bounds array references and uninitialised variable may be treated differently by different systems. All codes should be compiled and run with these options as part of the development cycle; in particular, codes that are being moved to this system from elsewhere and show different behaviour must be checked using these options.

To compile the program myprog.f90 with all of these options use the command

gfortran myprog.f90 -fbounds-check -ffpe-trap=invalid,zero,overflow,underflow,precision -O0

Accessing Previous Versions

Wherever possible, previous versions of this application will be retained for continuity, especially for research projects that require a consistent version of the software throughout the project. Such versions, however, may be unsupported by IT Services or the applications vendor, and may be withdrawn at short or no notice if they can no longer run on the cluster - for example, essential operating system upgrades may be incompatible with old versions.

The following previous versions of this software are available on this service:

Known Problems & Limitations

  • If you see the following error when running gfortran:

    ld.gold: fatal error: program: No space left on device

    Try adding these flags to your gfortran command:

    -Xlinker -no-posix-fallocate

Other Information

The Support Level for this software is An.

Visit the GCC website for more information.

Manual pages are available for all of the compilers, for example:

$ man gfortran

Last modified: 08 August 2017