GNU Compilers

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

Availability and Restrictions

GNU Compiler is available on Oakley, Ruby, and Owens Clusters. The versions currently available at OSC are:

Version Oakley Ruby Owens notes
4.4.7 X# X#   Default version on Oakley and Ruby prior to 09/15/2015
4.8.4 X X    
4.8.5 X* X* X*# **See note below.
4.9.1 X X    
5.1.0 X      
5.2.0 X X    
6.1.0     X  
6.3.0 X X X Libraries have been built for this version
* : 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 gnu module loaded you will get either the system version or some other version, depending on what modules you do have loaded.

You can use module spider gnu  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 without restriction.

Usage

Usage on Oakley

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/4.8.4  to load GNU 4.8.4.

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 g77 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 OpenMPdirectives (except g77 and mpi77)
-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> .

Batch Usage

When you log into oakley.osc.edu you are actually logged into a linux box referred to as the login node. To gain access to the mutiple processors in the computing environment, you must submit your job to the batch system for execution. Batch jobs can request mutiple nodes/cores and compute time up to the limits of the OSC systems. Refer to Queues and Reservations and Batch Limit Rules for more info.  Batch jobs run on the compute nodes of the system and not on the login node. It is desirable for big problems since more resources can be used.

Interactive Batch Session
For an interactive batch session, one can run the following command:
qsub -I -l nodes=1:ppn=12 -l walltime=1:00:00
which gives you 12 cores ( -l nodes=1:ppn=12 ) with 1 hour ( -l walltime=1:00:00 ). You may adjust the numbers per your need.
Non-interactive Batch Job (Serial Run)
A batch script can be created and submitted for a serial or parallel run. You can create the batch script using any text editor you like in a working directory on the system of your choice. The following example batch script file will use the input file named hello.c  and the output file named hello_results
Below is the example batch script ( job.txt ) for a serial run:
#PBS -l walltime=1:00:00
#PBS -l nodes=1:ppn=12
#PBS -N jobname
#PBS -j oe
cd $PBS_O_WORKDIR
module load gnu
cp hello.c $TMPDIR
cd $TMPDIR
gcc -O3 hello.c -o hello
./hello > hello_results
cp hello_results $PBS_O_WORKDIR

In order to run it via the batch system, submit the job.txt file with the following command:

qsub job.txt
Non-interactive Batch Job (Parallel Run)
Below is the example batch script ( job.txt ) for a parallel run:
#PBS -l walltime=1:00:00
#PBS -l nodes=2:ppn=12
#PBS -N jobname
#PBS -j oe
cd $PBS_O_WORKDIR
module load gnu
mpicc -O3 hello.c -o hello
pbsdcp hello $TMPDIR
cd $TMPDIR
mpiexec hello > hello_results
pbsdcp -g hello_results $PBS_O_WORKDIR

Usage on Ruby

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/4.9.1  to load GNU 4.9.1.

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 g77 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 OpenMPdirectives (except g77 and mpi77)
-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> .

Batch Usage

When you log into ruby.osc.edu you are actually logged into a linux box referred to as the login node. To gain access to the mutiple processors in the computing environment, you must submit your job to the batch system for execution. Batch jobs can request mutiple nodes/cores and compute time up to the limits of the OSC systems. Refer to Queues and Reservations and Batch Limit Rules for more info. 

Interactive Batch Session
For an interactive batch session, one can run the following command:
qsub -I -l nodes=1:ppn=20 -l walltime=1:00:00
which gives you 20 cores (  -l nodes=1:ppn=20 )  with 1 hour (  -l walltime=1:00:00 ).  You may adjust the numbers per your need.
Non-interactive Batch Job (Serial Run)
batch script can be created and submitted for a serial or parallel run. You can create the batch script using any text editor you like in a working directory on the system of your choice. The following example batch script file will use the input file named  hello.c  and the output file named  hello_results
Below is the example batch script (  job.txt  ) for a serial run:
#PBS -l walltime=1:00:00
#PBS -l nodes=1:ppn=20
#PBS -N jobname
#PBS -j oe
cd $PBS_O_WORKDIR
module load gnu
cp hello.c $TMPDIR
cd $TMPDIR
gcc -O3 hello.c -o hello
./hello > hello_results
cp hello_results $PBS_O_WORKDIR

In order to run it via the batch system, submit the  job.txt  file with the following command:

qsub job.txt
Non-interactive Batch Job (Parallel Run)
Below is the example batch script (  job.txt  ) for a parallel run:
#PBS -l walltime=1:00:00
#PBS -l nodes=2:ppn=20
#PBS -N jobname
#PBS -j oe
cd $PBS_O_WORKDIR
module load gnu
mpicc -O3 hello.c -o hello
cp hello $TMPDIR
cd $TMPDIR
mpiexec ./hello > hello_results
cp hello_results $PBS_O_WORKDIR

Usage on Owens

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/4.8.5  to load GNU 4.8.5.

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 g77 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 OpenMPdirectives (except g77 and mpi77)
-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> .

Batch Usage

When you log into owens.osc.edu you are actually logged into a linux box referred to as the login node. To gain access to the mutiple processors in the computing environment, you must submit your job to the batch system for execution. Batch jobs can request mutiple nodes/cores and compute time up to the limits of the OSC systems. Refer to Queues and Reservations and Batch Limit Rules for more info. 

Interactive Batch Session
For an interactive batch session, one can run the following command:
qsub -I -l nodes=1:ppn=28 -l walltime=1:00:00
which gives you 28 cores (  -l nodes=1:ppn=28 )  with 1 hour (  -l walltime=1:00:00 ).  You may adjust the numbers per your need.
Non-interactive Batch Job (Serial Run)
batch script can be created and submitted for a serial or parallel run. You can create the batch script using any text editor you like in a working directory on the system of your choice. The following example batch script file will use the input file named  hello.c  and the output file named  hello_results
Below is the example batch script (  job.txt  ) for a serial run:
#PBS -l walltime=1:00:00
#PBS -l nodes=1:ppn=28
#PBS -N jobname
#PBS -j oe
cd $PBS_O_WORKDIR
module load gnu
cp hello.c $TMPDIR
cd $TMPDIR
gcc -O3 hello.c -o hello
./hello > hello_results
cp hello_results $PBS_O_WORKDIR

In order to run it via the batch system, submit the  job.txt  file with the following command:

qsub job.txt
Non-interactive Batch Job (Parallel Run)
Below is the example batch script (  job.txt  ) for a parallel run:
#PBS -l walltime=1:00:00
#PBS -l nodes=2:ppn=28
#PBS -N jobname
#PBS -j oe
cd $PBS_O_WORKDIR
module load gnu
mpicc -O3 hello.c -o hello
cp hello $TMPDIR
cd $TMPDIR
mpiexec ./hello > hello_results
cp hello_results $PBS_O_WORKDIR

Further Reading

See Also

Service: 
Technologies: 
Fields of Science: