Best Way for a Physics Major to Learn Fortran?

  • Programs
  • Thread starter Dr. Courtney
  • Start date
  • #1
Dr. Courtney
Education Advisor
Insights Author
Gold Member
2020 Award
3,289
2,447
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.
 

Answers and Replies

  • #2
34,549
6,260
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.
 
  • #3
234
173
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.
 
  • #4
34,549
6,260
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.
 
  • #5
jtbell
Mentor
15,722
3,858
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:
  • #6
Vanadium 50
Staff Emeritus
Science Advisor
Education Advisor
26,153
9,542
There is a school of thought that says that the key to programming is to know a bunch of languages. Many colleges set up their programs (no pun intended) this way, I think a better approach is to learn programming - e.g. data structures, algorithms, etc. Then it becomes much easier to pick up the implementation language,
 

Related Threads on Best Way for a Physics Major to Learn Fortran?

  • Last Post
Replies
2
Views
3K
  • Last Post
Replies
2
Views
896
  • Last Post
Replies
14
Views
3K
  • Last Post
Replies
9
Views
5K
  • Last Post
Replies
2
Views
2K
  • Last Post
3
Replies
50
Views
4K
  • Last Post
3
Replies
55
Views
8K
  • Last Post
2
Replies
28
Views
10K
Top