Fortran Arrays in C++

I will admit that this was something that we did think about, because Fortran is a language that we both really appreciate, recommend first for any suitable project and generally really like. After some thinking, we thought that there were several reasons why this library wasn’t something that we should just keep for us internally

  1. There is already a substantial pool of people who want to move to C++ just because it is seen as more “modern” than Fortran. If you already feel that drive then there are a great many things that you can point to to justify your preference without this library - Kokkos, Sycl and the template system to name just a few. If people were already looking to start a project in C++ then the existing infrastructure is strong enough that they wouldn’t look at a problem and say “No, I’ll do it in Fortran”, and if they were looking to write it in Fortran, this library isn’t good enough for them to say “No, I’ll do it in C++”.

  2. Our library is not as good as Fortran. While the core “I just want to use arrays” is fairly elegant, there are a lot of rather ugly edges, particularly around elemental functions and component selection, that are forced on us by C++’s different idiom.

  3. If we can do it, so can other people. There is clearly a demand for scientific/technical tools in C++, see the above mentioned Kokkos and Sycl, and while we like to think that we are fairly good C++ programmers by academic standards, there are undoubtedly people better than us working on these other projects. We already know of two projects just at our home institution where people have chosen to work in C++ and have implemented the particular functions and array sizes that they want from Fortran in C++, so this is already going on. If there is a demand for this, it will be supplied sooner or later. If there is no demand then this library’s existence is not a matter for concern. In some senses, it is better that this is provided by people who actually like Fortran and want people to use it rather than people who prefer C++ and want people to move over

  4. I hope that one might wind up with a bit of a two way traffic here. One of the reasons why we are so explicit in the documentation that this library pretty much just implements what Fortran can do already is that we hope that it would encourage people to think more about how there is an entire language that is specifically designed to do this! I know students who have been made to learn C++ but don’t particularly like the language. If you show them that Fortran’s approach is better than C++’s, then they might want to move over for the other advantages. Another thing is that people who don’t use it still see Fortran as being FORTRAN77, and think that it is an old fashioned language. Seeing that to replicate its features in C++ needs 12,000 lines of heavily templated code might change some minds.

  5. This is just a random library by two people, which should mean that it isn’t really an option for actually serious work. We aren’t a national laboratory, and we aren’t even branding it with the name of the university that we work at (since they aren’t supporting the project), so while we want to make this available to the community because we think it will be useful, I fully expect it to become one of the many libraries that has no real effect on the world.

2 Likes