Skip to Main Content

How to run FORTRAN 77 programs on maya


Running FORTRAN 77 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 77 program

Download: ..code/hello_serial-f77/hello_serial.f

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

[araim1@maya-usr1 hello_serial-f77]$ gfortran -ffixed-form hello_serial.f -o hello_serial-f77-gcc
[araim1@maya-usr1 hello_serial-f77]$ 

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

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

Running this program should produce this message:

[araim1@maya-usr1 hello_serial-f77]$ ./hello_serial-f77-gcc
Salutations, Earth.
[araim1@maya-usr1 hello_serial-f77]$ ./hello_serial-f77-intel
Salutations, Earth.

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-f77/hello_parallel.f

Compile your program with

mpif77 hello_parallel.f -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.