The University of Sheffield
Sheffield-WRGRID

Programming

The operating system on iceberg provides full facilities for scientific code development, compilation and execution of programs. The development environment includes debugging tools provided by the Portland test suite, the distributed debugging tool DDT and the eclipse IDE.

Compilers

C and Fortran programs may be compiled using the GNU or Portland Group. The invoking of these compilers is summarized in the following table:

Language GNU Compiler PortlandCompiler
C gcc pgcc
C++ g++ pgCC
Fortran 77 g77 pgf77
Fortran90/95 pgf90

All of these commands take the filename containing the code to be compiled as one argument followed by numerous options. Details of these options may be found through the UNIX man facility, e.g. to find details about the Portland f90 compiler use:
man pgf90
Common options for the portland compilers are shown in the table below
Option Effect
-c Compile, do not link.
-o exefile Specifies a name for the resulting executable.
-g Produce debugging information (no optimization).
-Mbounds Check arrays for out of bounds access.
-fast Full optimisation with function unrolling and code
reordering.
-Mvect=sse2 Turn on streaming SIMD extensions (SSE) and SSE2 instructions. SSE2 instructions operate on 64 bit floating point data.
-Mvect=prefetch Generate prefetch instructions.
-tp k8-64 Specify target processor type to be opteron processor running 64 bit system.
-g77 libs Link time option allowing object files generated by g77 to be linked into programs (n.b. may cause problems with parallel libraries).


Compiling a Serial FORTRAN Program

Assuming that the Fortran 77 program source code is contained in the file mycode.f, to compile using the Portland group compiler type:
% pgf77 mycode.f
In this case the code will be output into the file a.out. To run this code issue:
% ./a.out
at the UNIX prompt. To add some optimization, when using the Portland group compiler, the –fast flag may be used. Also –o may be used to specify the name of the compiled executable, i.e.:
% pgf77 –o mycode –fast mycode.f
The resultant executable will have the name mycode and will have been optimized by the compiler.

Compilation of a Serial C Program

Assuming that the program source code is contained in the file mycode.c, to compile using the Portland C compiler, type:
% pgcc –o mycode mycode.c
In this case, the executable will be output into the file mycode which can be run by typing its name at the command prompt:
% ./mycode

Debugging

The Portland group debugger is a symbollic debugger for Fortran, C, C++ programs. It allows the control of program execution using breakpoints, single stepping and enables the state of a program to be checked by examinationof variables and memory locations.

The PGDBG debugger is invoked using the pgdbg command as follows: pgdbg arguments program arg1 arg2.. argn
Where, arguments may be any of the pgdbg command line arguments.
program is the name of the traget program being debugged, arg1, arg2,... argn are the arguments to the program.
To get help from pgdbg use:
pgdbg -help
The PGDBG GUI is invoked by default using the command pgdbg.
Note that in order to use the debugging tools applications must be compiled with the -g switch thus enabling the generation of symbolic debugger information.

Profiling

The PGPROF profiler enables the profiling of single process, multi process MPI or SMP OpenMP, or Programs compiled with the -Mconcur option. The generated profiling information enables the identification of portions of the application that will benefit most from performance tuning. Profiling generally involves three stages: