Compiling Programs
There are different C compilers like Intel, gcc and pgi. In general Intel compilers are recommended as they are optimized for Intel processors that are on Saguaro cluster.

For example:
‘source.c’ contains your source code.

To compile a C-program using the Intel compilers:

There are different FORTRAN compilers like Intel, gnu and pgi. In general Intel compilers are recommended as they are optimized for Intel processors that are on Saguaro cluster..

Sample Fortran source program:

To compile a Fortran-program using the Intel compilers:
Output can be viewed.

Intel compilers can be used to compile and run the OpenMP programs. Below is an example of a sample program:

To compile the OpenMP program using Intel compilers:
Output of the program with 2 threads on a requested nodes.

MPI (Message Passing Interface ) is a communication protocol which is language independent, standard for developing high performance parallel programs using the API (Application Programming Interface). We have installed MPICH2 and OpenMPI implementations of MPI standard. Different flavors using Intel, gnu and pgi compilers with MPICH2 and OpenMPI are available. You can use different wrapper scripts such as mpicc, mpicxx, mpif77 and mpif90 to compile and link automatically your programs. As a general rule, we recommend using the MPI implementation with latest Intel compilers.

The example MPI program in C++ :

The above program can be compiled with loading the latest openmpi moudule:
mpicc for C, mpicxx for C++, mpif90 for FORTRAN

The compiled program can be run by requesting 2 processors with –np flag:

Since the MPI process rank 1 buffer is not set because of the ‘if’ statement it is set to some random value. You should be careful about assigning values to your array elements before using them. Here it is shown to highlight the issue.

Note: Examples shown above do not use any compiler optimization flags. They should be included to run your programs efficiently.