IMPORTANT: This course is partially copyright Dr J.S. Morgan, Computing Services Department, the University of Liverpool, and its presence here does NOT constitute permission to copy it for any reason or use other than attending the course or using it for personal study. The other part of the copyright is the author's. You may, of course, refer to these pages to see what they contain. If you want to take a copy for any other reason, please contact the author for permission. The intention is to release it into the "public domain", so it will not be charged for.
This is a basic introduction to modern Fortran. At the end of the course, students should be able to write significant programs in Fortran, and to be able to start working on existing programs written in modern Fortran (i.e. in the Fortran 90/95 style). It will not cover obsolete features of Fortran, some of the more advanced aspects, or most of the extensions introduced by Fortran 2003.
In addition to some computing skills, it is essential to know enough about matrices to understand Fortran arrays, and they are no longer taught in A-level Mathematics. For more information, see Matrix Prerequisites.
The first four lectures cover the essential concepts, syntax and use of modern Fortran.
3: Data Types and Basic Calculation
The next four lectures cover the main areas where Fortran is significantly more powerful than languages like C++, and are the key to using it effectively.
7: KIND, Precision and COMPLEX
The next three lectures are a description of how to use derived types as simple structures, and a description of Fortran I/O, which is very unlike all other current languages.
Normally, lectures 1 to 5 are given on the first day, 6 to 8 on the second, and 9 onwards (including some of the extra material) on the third. But the schedule and coverage may be varied to meet the needs of the audience.
These are practical exercises to use the facilities taught; some are questions to answer and others are exercises in writing programs.
Programs and data used in the practicals
These are programs and data used in the exercises. Anyone working through the exercises will need to download them.
Specimen answers to the exercises
These are some specimen answers, which may help if you get stuck with an exercise.
You are advised not to look at these until you are comfortable using the material in the previous lectures. See also the Old Fortran course below, which contains some explanation of older features the course ignores.
This lecture is a brief description of how to use data pointers in Fortran.
This lecture describes external names and how to use
make
and the linker on programs made up of multiple files
or modules.
13: External Names, Make and Linking
This lecture is an introduction of how to use C from Fortran and vice versa, using the portable facilities defined in Fortran 2003. Regrettably, the boundaries between safe use and unsafe usage cannot be explained simply, though using the facilities is not hard.
These lectures are unavoidably complicated, but they include information that may be needed for debugging and tuning.
16: Advanced Use Of Procedures
Programming in Fortran 90/95 by Steve Morgan and Lawrie Schonfelder (Fortran Market, PDF, $15)
Fortran 95/2003 Explained by Michael Metcalf, John Reid and Malcolm Cohen
There are also Fortran 90 versions of the above two books, which would cover most of what is taught here.
Fortran 90 Programming by Miles Ellis, Ivor Phillips and Thomas Lahey
Software Design and Development
Building, installing and running software
Unix: Introduction to the Command Line Interface
Python: Introduction for Programmers