Skip to Main Content

How to run FORTRAN 90 programs on maya


Running FORTRAN 90 programs on the cluster is similar to running any other serial job. Make sure you’ve read the tutorial for C programs first, to understand the basics.

Serial Example

Let’s try to compile this simple Fortran 90 program:

Download: ..code/hello_serial-f90/hello_serial.f90

To compile this using GCC and create the executable helloworld-f90-gcc, type:

[araim1@maya-usr1 hello_serial-f90]$ gfortran hello_serial.f90 -o hello_serial-f90-gcc
[araim1@maya-usr1 hello_serial-f90]$

Alternatively, to compile using Intel Fortran and create the executable helloworld-f90-pgi, type

[araim1@maya-usr1 hello_serial-f90]$ ifort hello_serial.f90 -o hello_serial-f90-intel
[araim1@maya-usr1 hello_serial-f90]$

Running this program should produce this output:

[araim1@maya-usr1 hello_serial-f90]$ ./helloworld-f90-gcc
Greetings, denizens of planet Earth!
[araim1@maya-usr1 hello_serial-f90]$ ./helloworld-f90-intel
Greetings, denizens of planet Earth!
[araim1@maya-usr1 hello_serial-f90]$ 

Parallel Example

We’ll assume that you already know the fundamentals of MPI execution from the C tutorial. Now let’s create the following program:

Download: ..code/hello_parallel-f90/hello_parallel.f90

Now we can compile the program with

[araim1@maya-usr1 hello_parallel-f90]$ mpif90 hello_parallel.f90 -o hello_parallel

The same compilation command should work even if you’ve changed the switcher to use a different MPI implementation and compiler. Running the compiled program is now exactly the same as running a C MPI program.