Parallel Spectral Numerical Methods/Fortran Programs and Getting Started on Windows

= Fortran Programs and Getting Started on Windows =

Example Programs
To do parallel programming using OpenMP or MPI (Message passing interface), we typically need to use a lower level language than Matlab such as Fortran. Another possible choice of language is C, however Fortran has superior array handling capabilities compared to C, and has a similar syntax to Matlab, so is typically easier to use for scientific computations which make heavy use of regular arrays. It is therefore useful to introduce a few simple programs in Fortran before we begin studying how to create parallel programs. A good recent reference on Fortran is Metcalf, Reid and Cohen. We recognize that most people will be unfamiliar with Fortran and probably more familiar with Matlab, C or C++, but we expect that the example codes will make it easy for anyone with some introductory programming background. A recent guide which describes how to write efficient parallel Fortran code is Levesque and Wagenbreth. Our programs are written to be run on the Flux cluster at the University of Michigan. More information on this cluster can be found at http://cac.engin.umich.edu/resources/systems/flux/ and at http://cac.engin.umich.edu/started/index.html. Below are four files you will need to run this.

  A makefile to compile the Fortran code on Flux in listing $$. This should be saved as  makefile. Before using the makefile to compile the code, you will need to type

module load fftw/3.2.1-intel

at the command line prompt once logged into Flux. Then place the makefile and heat.f90 in the same directory, the example files below assume this directory is

{${HOME}/ParallelMethods/Heat}

and type

make

to compile the file. Once the file is compiled type

qsub fluxsubscript

to get the cluster to run your program and then output the results. The programs that follow use the library FFTW to do the fast Fourier Transforms. More information on this library can be found at http://www.fftw.org/.

An example makefile for compiling a Fourier spectral Fortran heat equation program Code download

 The Fortran program in listing $$ – this should be saved as heat.f90

A Fortran Fourier spectral program to solve the heat equation using backward Euler timestepping Code download

 An example submission script to use on the cluster in Listing $$ – this should be saved as fluxsubscript. More examples can be found at http://cac.engin.umich.edu/resources/software/pbs.html. To use it, please change the email address from your_uniqname@umich.edu to an email address at which you can receive notifications of when jobs start and are finished.

An example submission script for use on Flux Code download

 A Matlab plotting script to generate Fig. $$ is in listing $$.

A Matlab program to plot the computed results Code download







Getting Started on Windows
To run these Programs on Windows you need Cygwin installed. Cygwin emulates a bash shell on windows. You also need the following packages for Cygwin: make, mpi, fftw3 (list incomplete). Below is the adapted make file, the others remain the same.

A makefile to compile the Fortran code in listing $$. This should be saved as  makefile instead of ($$). Then place the makefile and heat.f90 ($$) in the same directory. type

make

to compile the file. Once the file is compiled type

./heat.exe</tt>

to get your computer to run the program.

use the Matlab plotting script from above to get the picture.

An example makefile for compiling a Fourier spectral Fortran heat equation program Code download

Exercises

 * 1) Please read the resources on the web page http://cac.engin.umich.edu/started/index.html to learn how to use the Flux cluster.
 * 2) Modify the Fortran program for the 1-D heat equation to solve the Allen-Cahn equation, with your choice of time stepping scheme. Create a plot of the output of your run. Include the source code and plot in your solutions.
 * 3) Modify the Fortran program for the 1-D heat equation to solve the 2-D heat equation with your choice of time stepping scheme. Your program should save the field at each time step rather than putting all the fields in a single large array. Create a plot of the initial and final states of your run. Include the source code and plots in your solutions.