Lecture Notes on Fortran Programming

From Nano Group Budapest
Jump to navigation Jump to search

Scientific Programming

Solving a scientific problem by numerical methods implemented in a programming language is Scientific Programming. However, the big picture is usually omitted in regular programming courses since it is assumed to be beyond of scope or the author is not aware of it. Scientific programming is not just coding a numerical problem. In an ordinary scenario a scientist have to use a large supercomputer:

  1. Compile the code as optimized as possible
  2. Preprocess input
  3. Submit the computing job
  4. Postprocess result (output)

The 1st point involves deep knowledge of the architecture since the fastest code is architecture-specific. You may also have to set MPI-specific environment variables to tune the parallel performance. The 2nd and 4th points mean the transfer of input/ouput data to a computer and preparation needs advanced UNIX and scripting skills. The 3rd point needs knowledge of batch schedulers. Usually a scientist works on several different machines with different environments therefore a unified shell middleware environment can be useful. The developer of the application should be aware all of this. Scientific codes are run in parallel on a HPC system. A scientific application should read input and write output without any user intervention and be able to run in a scheduled batch system. It has to support basic checkpointing: regularly write out restart output files. This is crucial for restart or continuation jobs especially for long time runs. The developer also has to provide clear building instructions. Avoid too much automatism, a well-written makefile structure with some helper scripts is more than enough.

Coding with Style

Hungarian Notaion

Implicit Variables

Reusability

Version Control

GIT

Batch Scheduler

PBS

Parallel Environment

OMP

MPI

Fortran

Fortran is a hard core language for numerical programming. Nothing more nothing less. It is strongly influenced by high performance computing (HPC) and still the best and fastest way to do numerics in parallel on supercomputers. That is why this tutorial is written parallel programming in mind.

Compilation

Preprocessor

Linking

Makefile