UMBC logo
UMBC High Performance Computing Facility
Please note that this page is under construction. We are documenting the 240-node cluster maya that will be available in Spring 2014. Currently, the cluster tara is still available. Please see the 2013 Resources Pages under the Resources tab.
How to run FORTRAN 77 programs on tara


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 90 program
      write(*,*) "Salutations, Earth."

Download: ../code-2010/hello_serial-f77/hello_serial.f
To compile this using GCC and create the executable helloworld-f77-gcc, type
[araim1@tara-fe1 hello_serial-f77]$ gfortran -ffixed-form hello_serial.f -o hello_serial-f77-gcc
[araim1@tara-fe1 hello_serial-f77]$ 
Alternatively, to compile using PGI Fortran and create the executable helloworld-f77-pgi, type
[araim1@tara-fe1 hello_serial-f77]$ pgf77 hello_serial.f -o hello_serial-f77-pgi
[araim1@tara-fe1 hello_serial-f77]$ 
Running this program should produce this message:
[araim1@tara-fe1 hello_serial-f77]$ ./hello_serial-f77-gcc
Salutations, Earth.
[araim1@tara-fe1 hello_serial-f77]$ ./hello_serial-f77-pgi
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:
      program hello_parallel

C     Include the MPI library definitons:                                                                                
      include 'mpif.h'

      integer numtasks, rank, ierr, rc, len, i
      character*(MPI_MAX_PROCESSOR_NAME) name

C     Initialize the MPI library:                                                                                        
      call MPI_INIT(ierr)
      if (ierr .ne. MPI_SUCCESS) then
         print *,'Error starting MPI program. Terminating.'
         call MPI_ABORT(MPI_COMM_WORLD, rc, ierr)
      end if

C     Get the number of processors this job is using:                                                                    
      call MPI_COMM_SIZE(MPI_COMM_WORLD, numtasks, ierr)

C     Get the rank of the processor this thread is running on.  (Each                                                    
C     processor has a unique rank.)                                                                                      
      call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr)

C     Get the name of this processor (usually the hostname)                                                              
      call MPI_GET_PROCESSOR_NAME(name, len, ierr)
      if (ierr .ne. MPI_SUCCESS) then
         print *,'Error getting processor name. Terminating.'
         call MPI_ABORT(MPI_COMM_WORLD, rc, ierr)
      end if

      print 30, "hello_parallel.f: Number of",numtasks,rank,name
 30   format (A,' tasks=',I3,' My rank=',I3,' My name=',A80,'')
C     Tell the MPI library to release all resources it is using:                                                         
      call MPI_FINALIZE(ierr)


Download: ../code-2010/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.