What's the best version of "Fortran" to use?

What version of “Fortran” should I use? 90? 95? Or higher?

2018 is well implemented, 2023 is coming on well but far from complete. Try LFortran, they are still in alpha but they always appreciate feedback

The question is rather: why would you want to use a version other than the latest one? The only good reason to me is the portability and availability in the compilers. F2023 is mostly not supported as of today, F2018 is fully supported only by the Intel compiler AFAIK (but gfortran supports most of it, and gfortran is available on many platforms). If want your code to be compiled by lot of different compilers, probably sticking to F2008 is a good trade-off

4 Likes

No reason to use Fortran 95 (ISO/CEI 1539-1:1997), 27 years old, except if you can’t update the compiler on an old machine…

If you use GFortran, just be conscious of what is already implemented:

It has now a rather good support of F2008, even if not yet 100% complete.

And your code will run on Intel Fortran, which now fully supports F2018.

Both are freely available, so most people should be able to compile your code. Except if they use a server they are not admin of.

2 Likes

I think this is correct, but of course it does not directly answer the question of which language version to use because there is no easy way to determine which important features might be missing from an available compiler.

To give an example, parameterized data types (PDT) were introduced in f2003, over two decades ago now. From the programmer’s perspective, they are a well designed feature that would be useful in many situations. There are alternatives to their use, using allocatable arrays, but there is nothing else in the language that really provides an exact replacement of the functionality. But PDTs have been and are only partially supported in most compilers. I think NAG and intel are right now the only compilers that claim full support. They are basically unusable in gfortran, although there is some partial support. So if a programmer is concerned about writing portable code, in particular code that works with a variety of compilers including gfortran, then he 1) cannot use PDTs, or 2) he is required to implement the feature in the open source to the gfortran compiler. If you cannot do 2), then you are stuck with 1).

On a smaller scale, there are often many quirks in specific compilers. It took a long time for ifort to implement the e0.n and es0.n format fields. Gfortran did those quickly (I think that was an f2008 feature). I wrote codes using those several years ago that generated bug reports from intel compiler users. Intel eventually caught up, but it was only a couple of years ago.

2 Likes

And I think the first question is what kind of programmer is @Takosan ? (hobbyist, student, Ph.D. student, engineer, researcher, etc.) And what kind of program he would like to write, for what purpose?

It really depends on the specific Fortran features that you need, which compilers support them, and which hardware you run on. Using the latest and greatest features right out of the box is not necessarily a good idea. I prefer to wait a couple of years until most issues and bugs have been ironed out.

Personally, I’m still coding per f2003, mostly using flang, sometimes gfortran for verification and whatnot.