SC24 BoF about Modern Fortran - Wed Nov 20

If you are at SC24, please consider attending the Birds of a Feather (BoF) “Applications, Libraries, and Tools in Modern Fortran (alt.fortran)”. Find the details below and on the SC24 event page.

Time: Wednesday, 20 November 2024, 12:15pm - 1:15pm EST
Location: B310

Description: Fortran plays a crucial role in numerous applications. This BoF provides a forum for Fortran developers to engage with the language’s modern programming features. With features introduced in recent language revisions, Fortran 2023 supports modern programming practices and high-performance computing (HPC). This BoF gathers developers from diverse domains to share experiences and explore Fortran’s evolving capabilities. After some brief presentations, the session will focus on an interactive discussion where audience members will be encouraged to share their own experiences and ask questions of our experts.

8 Likes

Some Fortran-related research of the OP is at https://crd.lbl.gov/divisions/amcr/computer-science-amcr/class/members/katherine-rasmussen/.

A lively discussion ensued on various topics. Muchly enjoyed.

3 Likes

Were the presentations or the discussions recorded?

Yes, but unfortunately are only made available for a brief period and only to conference attendees.

A good bit of the discussion was about education, that nobody is teaching Fortran anymore. I am at a University that supposedly has a pretty good CS program and I’m not sure they teach C anymore and it seems like they barely teach C++ to their majors. Majors start with Java, nonmajors with Python. This seems pretty standard. The physics department has two courses; the one taught by the older faculty member teaches them terrible C (and apparently now calls it “C++”) while the younger faculty member teaches Python. Engineering departments other than CS use Matlab. Some other departments teach some R and/or Python.

I’ve taught for-credit courses, short courses, and summer programs. I’ve taught Python, Fortran, and C++ to beginners in non-CS fields. (My C++ isn’t great but “better than you” is good enough for most students.) Nearly every one of them has hated any compiled language. Python was by far most popular. A problem ensuing from this is that we still have a lot of scientist-programmers and now they don’t know what causes segfaults, they have little to no concept of typing or how it relates to hardware, etc. They don’t know that Torch is actually C++ so are flummoxed when it fails since they don’t understand the difference between Torch and PyTorch.

I noticed there’s a very active thread here about Python in scientific programming which I didn’t read through, but I was amused that one of the first comments was that it’s because Python has certain very CS-oriented data structures like queues and trees. In my experience, it’s because it has a huge number of packages that do the numerical computations they want, and then they can plot the results. So things like the fpm (which I haven’t tried yet) and LFortran may ease some of these issues.

3 Likes

Spatial tree data structures like k-D, quadtrees, octrees, and so forth, are very useful for many fields, say computer vision or mesh- and grid-based (adaptive) PDE solvers.

On the topic of that Python thread. I had the pleasure of collaborating with some hydrologists which used the Fortran quadtree implementation I wrote to simulate mass transfer among dispersed particles: Parallelization of particle-mass-transfer algorithms on shared-memory, multi-core CPUs - ScienceDirect

I agree it would be great to have comparable packages for Fortran, and there are lots of use cases for these data structures. But I do user services at a pretty typical academic HPC center, though we do tend to be heavy on bioinformatics, and the vast majority of the Python users are students doing what might seem like fairly basic data science but on data too big to fit onto their laptops. Along with the deluge of PyTorch, of course.

I would just like to see a more “convenient” libraries for Fortran overall. I have written some modules to make Fortran look more like Python since TBH I get annoyed myself at the lack of say a “random” package (which is used a lot by many algorithms) so I wrote my own, but they haven’t really been thoroughly tested, since they were for my personal use. I will look into the Fortran standard library effort.

Yes, a lot of modern unstructured grid finite-volume CFD codes use k-D trees, oct-trees etc to find nearest neighbors etc. Also, newer “mesh-free”/particle based methods (SPH, RKPM etc.). Methods to reorder nodes and cells in FEM codes to reduce bandwidth etc also use things like priority queues. With the move to unstructured data structures (away from things that map neatly into a multi-dimensional array where you can just sweep contiguous data in I,J,K directions) these “CS” methods have become a standard part of modern CFD and FEM codes.

I was thinking further about this, and in my opinion, it is even more urgent that we be able to compete successfully with C++ than with Python in what is and always has been our niche, which is high-performance scientific/numerical/engineering type codes. The ones you are describing are perfect examples of this.

I used to teach a tutorial called “High Performance Python” even though I don’t really believe those words belong together. It’s hard to achieve. And it’s still the case that most “performance” codes are written in a compiled language even though many now have Python bindings so users can operate them. But another thing I have learned at this BoF and others is that C++ apparently has the ambition of becoming everything to everybody, so an already large and complex language is becoming ever more so. I haven’t done much of my own scientific programming for a long time, but I know that there are plenty of scientist-programmers who are mainly interested in the results and have little to no formal CS background. If they begin to have trouble understanding C++ that makes them run to Python, especially if their students already know it. Our goal should be to make it possible and acceptable for them to run to Fortran. Providing solid and easily accessible libraries of the necessary data structures is critical to this.

Education probably really needs to focus on the existence of modern features in Fortran. As we all know, too many think it’s still F77. But as I mentioned, I’ve done user support for a long time and I can tell you that many “amateur” programmers don’t know much of the advanced features of C++ either. A lot of their C++ is what I call “decorated C.” E.g. many still use srand/rand because they don’t know about or understand the new RNG generators. I have limited sudo powers and I had a reason to look at a student’s files because of some problem he was having, and he had files from the phyics “computing” course, all of which ended in .cpp and none of which contained a single line of C++. Just straight-up C. printf, no namespace, etc. This is what is getting passed down.

And of course at many institutions, management is a problem. Everything needs to be rewritten in C++ because it’s “better.” They don’t really know why, other than that new hires refuse to learn Fortran, they just know. The husband of a coworker of mine devoted a lot of time and effort at a previous employer, quite a few years ago, translating extremely well-tested and critical Fortran code to C++ for this reason. I do know that in some cases (not this one) the absence of allocatable arrays either in the standard or in widely-accessible compilers was a factor in getting scientists to move to C.

4 Likes