CFD FORTRAN programs

Hello,

I’m reading ‘Computational Fluid Dynamics for Wind Engineering’ by R. Panneer Selvam.
Imagine my surprise seeing that all program listings in the book are written in F77 with implicit typing.
First edition dates 2022!
Apparently the time stood stil in some academic circles.
No wonder that most CFD programs nowadays are written in C++.

Roger

I agree that the code in books and papers should be more modern. Even if most CFD programs are currently written in C++, the field is so active that there are still many Fortran codes in this area. In 2024 there was a long Reddit thread Why fortran is still used for CFD?

Thanks for the links!

The same goes for the Bible of panel methods: Low-Speed Aerodynamics. The programs are also in Fortran 77, and written mainly by students during their class.

Another famous book, Aircraft Control and Simulation: Dynamics, Controls Design, and Autonomous Systems, provides a rather confusing mix of (outdated) Fortran and Matlab.

It wasn’t time that stood still so much as Fortran for far to long. Beginning in the late 1980’s CFD began moving to unstructured grid systems and solvers. Prior to that most CFD codes used structured (logically) Cartesian body fitted grids that mapped perfectly to Fortran’s one native container class (arrays). The move to unstructured grids brought with it the need for data structures and algorithms that could support data that was not contiguously aligned in memory like an array. That meant that geometric searching and sorting algorithms became critical for constructing efficient solvers. This in turn meant that things like lists, trees, hash maps etc became almost as important as linear and non-linear matrix solvers. The infrastructure in C++ that grew around the STL and other things like the BOOST libraries provided these ADTs in a manner that made them feel like they were intrinsic to the language. Fortran (and by Fortran I mean the Standards Committees and the compiler developers) for whatever reason never recognized (or maybe refused to recognize) the importance of non-array containers and ADTs to modern computational algorithms. Plus many Engineering programs in most universities in the US abandoned a programming language requirement (almost always Fortran) as part of the curricula. Therefore, most engineers introduction to programming was not Fortran but MatLab. These coupled with the notion that Fortran was out-dated led to a move to C++ and sadly, I don’t see anyway for Fortran to return to its former place in scientific programming as long as no attempt is made to build the features that forced engineers and other scientists to move away from Fortran into the language so they at least feel like they are integral part of the language (even if they are just a separate library). This is coming from someone who did CFD (and later Finite Elements which the Fortran community also lost to C++ for much the same reasons as CFD) for around 40 years.

6 Likes

The code for this book has been uploaded to

One could write a program that takes a repo of fixed source form code with the .f suffix and translates it to a repo of free source form code with the .f90 suffix.

1 Like

In my recent work, I tried to make a strong case for Fortran by comparing it with other widely used scientific programming languages, including Python, MATLAB, C, and C++. I highlighted Fortran’s advantages in numerical computing, performance, and ease of optimization for scientific workloads.

I also explored how modern Fortran, with constructs like do concurrent, simplifies parallel programming compared to legacy Fortran and traditional serial approaches. Many perceive Fortran as outdated, but recent advancements have made it much easier to write clean, efficient, and parallelized code without the complexity of older parallel paradigms. This section of my work demonstrates how do concurrent makes modern Fortran intuitive while maintaining its performance benefits.

The last two sections of my work focus on comparing Fortran’s do concurrent with OpenMP. I examined the performance trade-offs and ease of implementation between the two, showing that Fortran’s built-in parallel features offer a simple yet effective way to achieve concurrency. Additionally, I justified the use of the freely available DISLIN Fortran graphical library for visualization, demonstrating how it enables high-quality plotting with minimal effort—often in just a single line of code.

The work can be accessed here, and the corresponding GitHub repository.

6 Likes

Actually, I started doing this a few years ago but for some reason abandoned it.
I’ll see if I can resurrect what I did. I have my own tool that can do the conversion of the entire archive in less than a second or two.

1 Like

You mean, a showcase of software migration, to highlight partner in fpt by @Jcollins et al.?

Thanks for the link :slightly_smiling_face: the task that you are suggesting is technically valid, but I believe that in this case it’s best to take a legal perspective. It is likely that the author of this repo has committed copyright infringement. Therefore, doing work on it isn’t the best idea. Sure, in an ideal world the publisher might incorporate the modernized code into the next edition, but we can’t rule out the possibility of a lawsuit.

Can someone who knows more about copyrights than me (which is just about everybody) answer the following questions.

  1. If a listing of a full working code is published in a book, paper or journal article can we imply that it’s the author’s intent that the code can be copied and used as if its open source IF there are no published restrictions in the containing document. (see Numerical Recipes for an example of a very restrictive copyright applied to published source listings)

  2. I assume the publisher owns the copyright in most cases not the author so it would be the publisher that decides on appropriate use restrictions not the author. True?

1 Like

My advisor writes Fortran 77 to this day. It is amazing watching him code it in real time (doing all the things that are now considered bad practice). I wrote him a subroutine to use in his code once and he basically asked me to de-modernize it since he couldn’t get it to work in his code.

1 Like

A little more info on the Katz & Plotkin code. In Appendix D (page 546) of the second edition of Katz & Plotkin. the last line of the opening paragraph reads

In spite of this brevity these computer codes can help readers to construct their baseline algorithms upon which their customize computer programs can be developed

I guess there are a couple of ways to interpret this. a.) the authors are saying you can use the code as the basis for developing more complete and/or optimized versions of the code or b.) you can use the code as an example of how to implement the underlying theory in code. I presume most people would assume its b.) but the lack of specificity also opens up the possiblility they mean a.)

Also the Cambridge Press copyright in the front of the book says

Subject to statutory exception and the provisions of collective licensing agreements, no reproduction of any part may take place without written permission of Cambridge University Press

I presume statutory exception is local copyright law (and I presume the EU has different rules than the US). Not sure about the collective licensing agreements. I tried looking at the CUP website but didn’t find any reference to a licensing agreement.

1 Like

Ton Spek (Utrecht University, The Netherlands) wrote and continues to write on Platon, a helpful tool to check and edit X-ray diffraction data. Most of what the tool provides is a single FORTRAN77 file, (within the platon.f.gz archive distributed here) curated since 1980 by himself; close to 190k LOC – dedicated GUIs by CCDC Cambridge/UK and a IUCr website checkcif merely “harvest the results” if one doesn’t want to work on the CLI or in X11.

Maybe there is interest to invite him for the next FortranCon 202X?

1 Like

I think the answer to question 1 is no, you cannot assume it is open source. Grok agreed.

Here is a somewhat related question. The IMSL and NAG libraries are closed-source but have well-documented interfaces and public driver programs with output. Can you create and publish a library with the same calling sequences as those in a commercial library, as long as you don’t violate trademark by giving it the same name? Maybe it’s safer to look at the documentation of a library (here is the 2100-page manual IMSL Fortran Statistics library) for ideas of what functionality people have wanted but not to emulate the interfaces too closely. Wrappers for those codes in such a library can be created if someone wants a drop-in replacement for a commercial routine.

I am also not a lawyer (nor I’m Grok of course), but…

Doesn’t Google winning its case against Oracle in regards to the use of the Java API in early Android versions imply that APIs are not subject to copyright infringement?

So, one could actually have their own “My IMSL Libs”, recreating the APIs —provided that the “IMSL” term is avoided, since it’s a trademark.

I once implemented a new soil model in the Sandia CTH hydrocode. CTH (at the time not sure about now) was mostly fixed form Fortran 77 but with a few F90 improvements like allocatable arrays etc. I implemented the soil model in free form F90 and sent it to Sandia for possible inclusion in their production code base. Several months later I got an email from Sandia about some overflow issues and they sent me a copy of my code in the format that they had implemented in CTH. They had reversed engineered my code back into fixed format. I mentioned this to a Sandia employee who I had worked with previously on another project and he just laughed and said “The phrase “not invented here” was invented at Sandia”

1 Like

It is still in use and being developed, hopefully now in free source form.

Most but not all Fortran code in R is old, using fixed source form, do-continue instead of do-end do etc. I have thought about submitting PRs with modernized versions of the codes, but I wonder if keeping revised source codes in fixed format with the same file name (for a free format code one would typically change the suffix from .f to .f90) increases the chance of a PR being accepted, since the build process will be unchanged.