FORTRAN - Lab 1
Goals
- To learn how to write FORTRAN programs to solve scientific problems.
Introductory Lecture. old PDF Copy of PowerPoint Lecture for FORTRAN 1 .
updated in 2024: pdf copy of PowerPoint Lecture for Fortran - Part 1 .
Handouts (paper or electronic)
Activities in Lab
- Open your terminal window, either in NXclient or using ssh (instructions), and log into eidolon.
- Type "ls" to confirm which files are in your home directory.
- Make a new directory called "fortran" (without the quotes).
- Then "cd" into the fortran directory.
- Run the Firefox web browser from within eidolon by typing "firefox &" .
- Then, copy the sounding input files for PortHardy and Darwin into the fortran folder by right-clicking in firefox over the name of the input file, and select Save Link As and then navigate into the fortran folder to save it there. Do it for both input files.
- Quit Firefox (or leave it open to view the lab pdf and HW instructions).
- In the terminal window, type "emacs wp01.f95 &", to invoke the program editor while creating a new file called wp01.f95.
- Learn basics of FORTRAN by following along with the instructor,
to start writing a FORTRAN program. Then finish writing most of it during lab.
- Compile and execute the code.
- Learn how to debug code.
Instructions
Homework Assignment.
You will write your fortran code in stages starting with the main program. This is the top-down approach to programming, where all the subroutines are initially stubs (empty). To
ensure that you do this, I ask that you give a different name to each
version of your code. You must get each version of the code
compiled and running, before you enhance the code to create the next
version. This is a method of version control
-- a good programming practice. This way, the marker can see all
the versions of your
code, can confirm that each version compiled and ran successfully, and
can mark each one separately. You will do most of this
"FORTRAN-1 HW" by following along with the instructor during the lab period.
Reading Assignment
- Skim chapters 2-4 of the following FORTRAN tutorials.
(courtesy of Stephen Brooks, Univ. of St. Andrews, Scotland. http://www-solar.mcs.st-and.ac.uk/%7Esteveb/course/course.html )
- Basics: program structure, data types, programming style, conditional statements, loops, arrays .
- Arithmetic expressions, intrinsic functions, simple input and output (I/O) .
- Characters, strings, print .
- Internal subroutines and functions .
- Modules .
- More about arrays, dynamic allocation of arrays, key words .
- More about I/O .
- Case statement .
- Read in the course pack the
3 papers on "Binary Calculations and Pitfalls", on how numbers are
stored in binary on computers, including the paper on "The higher
arithmetic".
- Read in the course pack
the Good Programming Practice paper by Chapman 2008 "Program Design",
which covers "Top-down Design Techniques" and "Flowcharts" .
-end-
Copyright © 2012, 2024 by Roland Stull.
UBC.