Simulation course
FYSM350
7.2.-16.5.2006


Fortran 90/95/2003
Tuesdays lecture: 12.15-14.00 in MaD202
Thursdays lecture 12.15-14.00 in Fys2
Language: english
Lecturer:
Vesa Apaja email: firstname.lastname@gmail.com
Synopsis:
The goal is to learn to write simulation routines in Fortran – the number crunchers, not the GUI's.
After introduction to the basic properties of the language we will also examine a few real simulation codes:
how they work, why certain choices have been made etc.
Some object oriented features are introduced, paying attention to good programming habits
and how to write programs that run fast.


Grading: passed or not

Requirements:


Recommended:

Some free compilers for Intel/AMD platforms: Intel fortran-95 compiler (Linux)  gnu fortran-95 compiler (Linux or Windows) 
Check out the screenshot of the gnu fortran (g95) compiler :^)
Unfortunately Intel compiler for Windows is only an evaluation copy (licensed till March). But you can use g95 in Windows as well.


Course material (pdf format) : HERE
HOMEWORK I
HOMEWORK II Your Boss has written a few f90 programs late last night.
They have mistakes - as usual - and now the Boss wants you to fix them.
Some mistakes are just typos, but some are more subtle.
You are not allowed to rewrite the programs from scratch – your Boss would not like to see last nights work thrown away and you want to get paid also next year.
Fix the following programs: Send the working versions to Vesa along with comment lines that describe what was wrong and why it was wrong.
Broken 0 "This one contains only simple mistakes."
Broken 1 "This seemed to be such a simple task, I don't know why it gives these strange numbers."
This one is voluntary, except for those who didn't attend 60% of the lectures:
Broken 2 : "Pointers! I think there is something wrong with my random integers, too."
GENERAL INSTRUCTIONS FOR DEBUGGING:


Sample programs: Programs marked with * describe frequently used features
GET ALL SAMPLES LISTED BELOW: Tarred and gzipped or Zipped
* Basic data types and the unique behaviour of intrinsic function cmplx
*
Simple subroutine

*
Storage order of array element in memory
* Sending a function to a subroutine as an argument
* Array inquiry 1 : lbound, ubound and size
* Save attribute and allocatable arrays
Assumed size arrays
Assumed shape arrays and use of an interface
Array inquiry 2: behaviour with assumed shape arrays
Use of make and Makefile (expand make_example.tar in a directory)

* More simple reading of data
Reading and writing of binary data
* Namelist: reading of named parameters
*
Example of the namelist input file
*
matrix manipulation using builtin functions
Test for matmul speed vs. manual multiplication
Self-defined data types
Computing with self-defined data types: overloading operator "+"
*
Preprocessor example

FORALL structure
* SELECT CASE structure
How to "use" only designated parts of a module
Scope of variables 1: What variables does an “external” subroutine see?
Scope of variables 2: What variables does a "contained" subroutine see?
LAPACK95 example: Solution of the hydrogen Schrödinger equation in matrix form
Mandelbrot set: complex arithmetics is simple





External material:
CSC (Finland) web page about f90/f95

Fortran 90 intrinsic functions
Mersenne Twister random number generator homepage
Mersenne_Twister.f90 (f95 version of the original C code) provides module mt95

Last modified 18.03.2006 (VA)