# Best Way for a Physics Major to Learn Fortran?

• Programs
Gold Member
A physics major I'm mentoring has been invited to join a theory group that makes heavy use of FORTRAN in their calculations. The student already knows Python and is adept at using it including integrating diff eqs and solving various challenging 1st year physics type problems. This theory group uses FORTRAN for classic LAPACK, LINPACK, Numerical Recipes, and the like (more modern algorithms for the same kind of stuff) in highly optimized codes running on big, fast computers.

It's been 30 years since I learned FORTRAN, and while it is easy to Google up a number of different online learning options, most of the students I mentor are more on the experimental side, so I'm not really sure how to sort through the options and give good advice. In the absence of better advice, I'd tend to recommend learning the language with any source the student can stand then throwing a few problems at them to beat into submission with Numerical Recipes. But I'm hoping someone here has more concrete experience with the available options so the student can come up the learning curve over the Summer and hit the ground running with the research group when the Fall semester starts.

Mark44
Mentor
The student already knows Python and is adept at using it including integrating diff eqs and solving various challenging 1st year physics type problems.
After you become comfortable with one programming language, learning a second one is much easier. You already understand that basic concepts of iteration, making choices, calling functions/subroutines, and such -- it's then ust a matter of learning the syntax of doing these things in a different light.

This theory group uses FORTRAN for classic LAPACK, LINPACK, Numerical Recipes, and the like (more modern algorithms for the same kind of stuff) in highly optimized codes running on big, fast computers.
Sounds like he/she is already familiar with using numpy or one of the other computing libraries, so he/she most likely grasps how to set up the parameter prior to calling the routine you want.

I'd tend to recommend learning the language with any source the student can stand then throwing a few problems at them to beat into submission with Numerical Recipes.
This sounds like a reasonable approach to me.

I don't have any further advice, but it would be helpful to know what flavor of Fortran the theory group is using -- Fortran 77 (they have to be using a newer version, I would hope), Fortran 90, Fortran 95, or one of the newer versions such as Fortran '03, '08, or even '18? There are significant differences in this range of versions, not that I have much familiararity with anything past '95.

Despite what a lot of people think, Fortran has not gone away, and is used in a lot of scientific computing.

The best way is to use FORTRAN to solve problems of increasing complexity all summer. The more exposure your student gets, the better.

At least it is easier than when I was a student. When I learned, we had to go to a computer center, punch cards and have them read into a mainframe. IBM360. If we used more than 40 dollars in computer money, we had to ask the professor for more, if we had a good reason.

Now the student can learn on his computer at home; a starbucks or whatever, and have almost infinite computer resources.

It took me years to learn FORTRAN, but the exponential increase in knowledge occurred when I bought my first PC in 1992. My first software purchase (the same day) was a FORTRAN compiler. (In those days you could buy them for 400 dollars from COMPUSA). After that, I could immerse myself totally.

Mark44
Mentor
At least it is easier than when I was a student. When I learned, we had to go to a computer center, punch cards and have them read into a mainframe. IBM360. If we used more than 40 dollars in computer money, we had to ask the professor for more, if we had a good reason.
That was my experience as well, in a class using Fortran that I took in 1980. Fortunately I had had a class (using PL/C) several years before, so I understood the drill -- use a card punch machine to type the lines of your code, add JCL (job control language) cards to the front and back of your card deck, and submit your job. Come back the next day to see whether your code ran or not.

It took me years to learn FORTRAN, but the exponential increase in knowledge occurred when I bought my first PC in 1992. My first software purchase (the same day) was a FORTRAN compiler.
My first computer, an Apple //e, was in '82, and I bought my first PC in '87 (with a Commodore Amiga in between). By that time I was teaching classes in C and in Fortran, so I had the Mix C compiler (about $30) and the Lahey Fortran compiler (about$90, as I recall). Being able to write code on your own computer made all the difference in the world.

jtbell
Mentor
FORTRAN 77 was my first language as an undergraduate in the early 1970s. It was my only language during graduate school, where it was my "bread and butter" as a research assistant. For several years in the late 1980s and early 1990s I taught an introductory course in it. I'm surprised to see that the textbook is still available, in both FORTRAN 77 and FORTRAN 90 versions:

FORTRAN 77 for Engineers and Scientists with an Introduction to FORTRAN 90, 4th edition (Nyhoff and Leestma)

FORTRAN 90 for Engineers and Scientists, 1st Edition (Nyhoff and Leestma)

You can probably find other editions and versions on Amazon, including used copies, if you search a bit. It worked OK for me and my students, back then. It doesn't assume any programming experience, so it may be overkill for a student who already knows Python. On the other hand, it would probably make a decent reference, supplemented with web searches.

Last edited: