ARCHIVED: Compiling your C, C++, Fortran, and Java programs on Libra at IU

Note: UITS will retire Libra in spring 2009. Accounts are available on Quarry, a general-purpose Unix computing environment. For more, see ARCHIVED: About the Libra retirement.

On this page:


Available compilers

The following compilers are available on Libra:

  • IBM XL Fortran Enterprise Edition
  • IBM XL C/C++ Enterprise Edition
  • GNU C/C++
  • GNU Fortran 77
  • Java (32-bit and 64-bit)

Available subroutine libraries

Several scientific/numerical subroutine libraries are also available on Libra. You can call these within your Fortran or C programs if the libraries are linked at compile time. The following libraries are available:

  • GNU Scientific Library (GSL)
  • IBM Engineering and Scientific Subroutine Library (ESSL)
  • IBM Mathematical Acceleration Subsystem (MASS)
  • International Mathematical Subroutine Library (IMSL)
  • LAPACK Fortran Numerical Library

Compiling your program

To achieve optimal performance for your code, use the IBM XL C, C++, or Fortran compilers with the -qarch and -qtune flags specifying the platform on which they will be running: pwr5 for the SMP Power5 nodes (libra43, libra47, libra48, libra49, libra50), and ppc970 for the PowerPC970 JS20 Blades (libra01-libra42). You can also specify optimization levels (-O2, -O3, -O4, -O5, -qhot, and -qipa), but use caution at higher levels of optimization, since these may produce incorrect results. For more information about IBM C compilation, enter man xlc . For more information about IBM Fortran compilation, enter man xlf .

Examples

The following examples show how to compile serial programs and OpenMP parallel programs. Libra does not have MPI libraries installed and does not support MPI parallel applications, since it does not have a high-speed interconnect.

This example shows compilation of a serial Fortran program that calls subroutines in the IBM math library. It uses the IBM XL Fortran compiler with optimization level 2, and will be run on the JS20 Blades with the PowerPC970 processors:

xlf -qarch=ppc970 -qtune=ppc970 -O2 -o myprogram.exe -lm myprogram.f

This example shows compilation of a large-memory (64-bit) serial C program that will be run on the Power5 nodes:

xlc -qarch=pwr5 -qtune=pwr5 -q64 -o myprogram.exe myprogram.c

This example shows compilation of a parallel OpenMP Fortran 90 program that calls SMP ESSL subroutines:

xlf90_r -qsmp=omp -qarch=pwr5 -qtune=pwr5 -o myprogram.exe -lesslsmp myprogram.f

The program source code uses $OMP directives to demarcate parallel sections of the code. The re-entrant (thread-safe) version of the compiler is required, and any libraries linked to the application must be thread-safe (i.e., must guarantee to shared memory processes that use threads an independent function for each thread that makes the call). OpenMP programs should also be optimized for and run on the SMP Power5 nodes, libra43, libra47, libra48, libra49, libra50.