Class Information: 2016
- Instructor: Prof. Paul Tackley, room NO H9.1, firstname.lastname@example.org, 044 633-2758
- Schedule: NO F39, 15:15-17:00 Mondays from 26.09-19.12.2014, excluding 28.11 & 12.12 (11 classes)
- Grading: 3 KP on weekly assignments (hand in to ETHFortran@gmail.com); 1 KP (optional) on a semester project - writing a program for a scientific application to be agreed upon individually.
- Project: Some instructions on the optional 1 KP project are here.
- Description: FORTRAN 95 is a modern programming language that is specifically designed for scientific and engineering applications. This course gives an introduction to programming in this language, and is suitable for students who have only minimal programming experience, for example with MATLAB scripts. The focus will be on Fortran 95, but differences to Fortran 77 will also be covered for those working with already-existing codes. A hands-on approach will be emphasised rather than abstract concepts, using example scientific problems relevant to Earth science.
- Computing requirements: A computer is needed during lectures. Please bring your own laptop with a suitable Fortran95 compiler installed (see below; installation help will be available in the first class). A computer is also needed to finish the weekly assignments.
- Books etc.: There is no required book, but a book might be useful. Class notes (posted here each week) + free online tutorials listed below + a free reference manual (such as the one listed below downloadable as PDF from Intel) might be sufficient. If you would like a book, two that get good reviews are: "Fortran 95/2003 for Scientists and Engineers" by Stephen J. Chapman, or "Modern Fortran Explained" by Michael Metcalf, John Reid, and Malcolm Cohen (the previous version "Fortran 95/2003 Explained" would also be fine for this course). Alternatively, look in a good technical bookstore for something that seems well written and easy to follow.
Fortran 95 compilers
The most convenient way to do the exercises might be on your own computer after installing a compiler. The main choices are listed below. gfortran is the most universal/popular, is completely free and can be used on Windows, MacOSX or Linux. For Windows, the silverfrost compiler seems to work well: this is free on your own computer, but on an ETH-owned machine it would be necessary to buy a license. Possibly the best compiler is the one by Intel, which works on Windows, MacOSX and Linux. ETH has a site license for it that employees can use, but unfortunately this isn't available for masters students. A drawback is that your computer must be networked so it can connect to the central ETH license server.
gfortran: Developed by the GNU,
the free software foundation. See http://gcc.gnu.org/wiki/GFortran.
- Linux: Recent version will have it on the installation disk
- MacOSX: Install (i) Xcode (from App Store), (ii) XCode command line tools, (iii) gfortran from http://hpc.sourceforge.net. A good guide to this process is here.
- Windows: I recommend using gfortran inside the cygwin environment (www.cygwin.com)
silverfrost (for Windows): free for personal use, download from http://www.silverfrost.com/.
Intel Fortran Compiler: ETH employees (e.g. doctoral students) can download from ides.ethz.ch. Documentation here.
Useful editors that highlight Fortran syntax: emacs or xemacs (unix-based); for MacOSX: aquamacs (here)
Free resources on the internet
1. A manual. A good one is the Intel Fortan Language Reference Manual.
3. General information and/or pages of links to relevant sites
4. Unix tutorials
Topics to be covered
- History of fortran
- Language elements
- Data types and declaration
- Arithmetic expressions
- Intrinsic (built-in) procedures (functions)
- Simple input and output
- Derived data types
- Arrays (including dynamically-allocated)
- Logical and comparison expressions
- Control statements (conditionals, loops etc.)
- Program units (functions, subroutines, modules)
- Complicated input and output, interactive and to files
- Character processing
- Useful mathematical libraries
Class schedule and handouts (including exercises)
||History, basics, simple programs
||More basics, interactive I/O, do loops, functions&subroutines
||Modules, ascii file I/O, Array functions, assumed size arrays.
||1-D diffusion equation
||Precision, namelists, formatted I/O.
||2-D diffusion equation.
||Derived types. Binary I/O. Keyword&optional arguments. where, forall. Character string manipulation.
||Streamfunction. Upwind advection. 2-D advection-diffusion.
||Iterative & multigrid solvers. Jacobi & Gauss-Seidel iterations. Program 2D Poisson solver.
||Pointers. Generic procedures, operators and overloading.
||Convection (2-D, infinite-Pr).
||Makefiles. Writing fast code (optimisation).
||Finite (low) Prandtl number convection.
||Review, Fortran 2003&2008 features, discussion