Earth Science Asked by Mike76 on July 26, 2021
Dear earth science community,
I am seeking a language to modernize a large Fortran project that works with geospatial NetCDF files.
The requirements for this language include:
Python
+numpy
isn’t really an option because of customized number-crunching with native performance.
Even if numpy
is implemented in C, the project includes custom algorithms that operate on matrices, and we do not want to write those in C.
I know that Python could be optimized by calling into C or Fortran, but I just don’t think that such optimization is going to happen with our team. Therefore, I am seeking a language that is "fast by default". Julia
seems to deliver much better on this "fast by default" promise, whereas Python is more like "fast if you have the right optimizations in place".
Matlab
is a non-starter because of its proprietary license.
C
is a non-starter because it does almost nothing to "modernize" a Fortran codebase.
Go
is probably not sufficiently well-established for scientific computing?
Julia
could be a promising option because it combines the ease of Python with native performance.
Kotlin
might be interesting because it combines the strength of the JVM with the possibility to compile to native code.
Swift
would be a great language, but I am not sure whether it is sufficiently mature for my targeted domain.
C++20
and Rust
are additional options that might be interesting, but I fear the complexity of those languages (remember that this is for earth scientists, not computer scientists).
Which options would you prefer for a gradual Fortran replacement with NetCDF files?
The modern language you are looking for is called modern Fortran 2018. Fortran 2008 and 2018 have everything a numerical computing project would need and so many features that many other languages mentioned here lack (including extremely pleasant array-syntax which has inspired all other languages such as MATLAB, Python, R, Julia, ..., even C++ numerical libraries). It is the only language that has native built-in parallelism and is the only language, along with C, for which the official MPI parallelism standard is released. It has also excellent vendor support for GPU parallel computing and as I heard in SC18, some vendors like NVIDIA/PGI have already started implementing the native parallelism features of Fortran via GPUs.
Modern Fortran is a high-level language comparable to MATLAB and Python, yet 100-500 times faster than both (https://modelingguru.nasa.gov/docs/DOC-2783). Using Coarray Fortran you can seamlessly parallelize your code with minimal effort to run it from your laptop to the largest supercomputers in the world. No other language has such capability at the moment. Fortran is also the only language that has all levels of parallelism, from instruction level to vectorized, concurrent, and coarray-distributed parallel computing. If such features are not considered "modern", perhaps "post-modern" would be a better description.
Fortran has been a reliable lasting language for almost 3 quarters of a century and has excellent highly-optimized compiler support (Intel, GNU, NAG, IBM, PGI/NVIDIA, ...). If you want to write code that lasts decades, then port your FORTRAN77 code to modern Fortran with minimal effort and save yourself time, energy, money, and computational power.
A good start with modern parallel object-oriented Fortran is "Modern Fortran Explained: Incorporating Fortran 2018" by Metcalf et al.
If you decide to port your code effortlessly to modern Fortran, you can also get help from the official Fortran language website https://fortran-lang.org/ and the community of programmers on Fortran discourse: https://fortran-lang.discourse.group/
Update Nov 17, 2020
Just yesterday NVIDIA released a news post on its GPU implementation of the concurrent features of Fortran 2008 / 2018. Users can now write code in pure modern Fortran and let the compiler automatically offload it to GPUs for thousands-way parallelism.
What is the relevance and importance of this achievement? The same Fortran code that a user writes can now be parallelized via GPUs, distributed CPUs, OpenMP threads, or auto-parallelization features of the Fortran compiler depending on the user's platform and compiler choice. All of that complexity is hidden from the user. No need for preprocessing and conditional compilations anymore. This further enhances the excellent existing portability of Fortran programs across platforms and architectures.
Correct answer by King on July 26, 2021
Right now, I think that Julia
makes the cut, because it provides a great tradeoff between "fast scripting" and "high-performance scientific computing".
But I am willing to hear other people's opinions, perhaps I have overlooked something.
Answered by Mike76 on July 26, 2021
As a former Fortran programmer I did a small online review several weeks ago into current trends for scientific programming.
To begin with, despite its age and its sometimes archaic style of programming, because of its huge legacy, Fortran isn't being directed to the trash can in a hurry. It's going to be used for a long time to come.
Like you, others have been looking for an alternative to start the move away from Fortran.
Though very popular, Python is very slow when executing programs. The speed of Fortran is another reason why it is still being used.
For astronomical and physics applications, I've seen a number of references state a preference for initially teaching students Fortran but when they get more experienced in their field exposing them to C++.
This comment from 2013, from a Physics forum encapsulates the general ideas I seen:
The older guys use fortran and c++. The younger people use python,java,and c++.
As with your answer, I think if Julia was more widely used it could have the potential to replace Fortran and possibly Python for scientific computing.
Answered by Fred on July 26, 2021
You could try Haskell, a modern functional language. It's straight forward to use but perhaps its lack of familiarity may a little intimidating for the uninitiated. It now comes with an extensive library.
Answered by Mozibur Ullah on July 26, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP