GNU Compilers

Fortran, C and C++ compilers produced by the GNU Project. 

Availability and Restrictions

Versions

The GNU Compiler Collection (GCC) are available on all our clusters. These are the versions currently available:

Version Pitzer Ascend Cardinal Notes
4.8.5 X#     **See note below.
7.3.0 X      
8.1.0 X      
8.4.0 X     The variant supporting OpenMP and OpenACC offload is available.
See the GPU offloading section below
9.1.0 X* X    
10.3.0 X X    
11.2.0 X X*    
11.3.0     X#  
12.3.0 X X X*  
13.2.0     X  
* Current Default Version
# System version
** There is always some version of the GNU compilers in the environment. If you want a specific version you should load the appropriate module. If you don't have a module loaded you will get either the system version or some other version, depending on what modules you do have loaded.

Modules

Systems Module Name
Pitzer and Ascend gnu
Cardinal gcc

You can use module spider <module name> to view available modules for a given machine. Feel free to contact OSC Help if you need other versions for your work.

To find out what version of gcc you are using, type gcc --version.

Access

The GNU compilers are available to all OSC users. If you have any questions, please contact OSC Help.

Publisher/Vendor/Repository and License Type

https://www.gnu.org/software/gcc/, Open source

Usage

Usage on Pitzer

Set-up

To configure your environment for use of the GNU compilers, run the following command (you may have to unload your selected compiler - if an error message appears, it will provide instructions): module load gnu.  The default version will be loaded. To select a particular GNU version, use module load gnu/version. For example, use module load gnu/8.1.0 to load GNU 8.1.0.

How to Compile

Once the module is loaded, follow the guides below for compile commands:

LANGUAGE NON-MPI MPI
Fortran 90 or 95 gfortran mpif90
Fortran 77 gfortran mpif77
c gcc mpicc
c++ g++ mpicxx

Building Options

The GNU compilers recognize the following command line options :

COMPILER OPTION PURPOSE
-fopenmp Enables compiler recognition of OpenMP directives (except mpif77)
-o FILENAME

Specifies the name of the object file

-O0 or no -O  option Disable optimization
-O1 or -O Ligh optimization
-O2 Heavy optimization
-O3 Most expensive optimization (Recommended)

 

 

 

 

 

 

There are numerous flags that can be used. For more information run man <compiler binary name>.

Known Issues

GCC 13 compilation errors due to missing headers

Type mismatch error

GNU compiler versions 10+ may have Fortran compiler errors like

Error: Type mismatch between actual argument at (1) and actual argument at (2) (REAL(4)/REAL(8))

that result in a error response during configuration

configure: error: The Fortran compiler gfortran will not compile files that call
the same routine with arguments of different types.

This can be caused when codes are using types that don't match the subroutine arguement types. The mismatches are now reject with an error to warn about future errors that may occur. It is bypassable by appending the -fallow-argument-mismatch arguement while calling gfortran.

Multiple definition error

GNU compiler versions 10+ may have C compiler errors like

/.libs/libmca_mtl_psm.a(mtl_psm_component.o): multiple definition of `mca_mtl_psm_component'

This is a common mistake in C is omitting extern when declaring a global variable in a header file. In previous GCC versions this error is ignored. GCC 10 defaults to -fno-common, which means a linker error will now be reported.  It is bypassable by appending the -fcommon to compilation flags.

Further Reading

See Also

Supercomputer: 
Service: 
Technologies: 
Fields of Science: