Fortran for Apple Silicon

Apple will develop a Fortran compiler for the new Apple Silicon platform?
  • I am a computational physicist and neuroscientist and I need Intel Fortran to do my work. Without this, I have to switch to Linux.

Add a Comment

Accepted Reply

Your best bet is probably flang which is part of the LLVM project. Not really production ready yet, but should be usable when the arm64 Macs are released.

Replies

Your best bet is probably flang which is part of the LLVM project. Not really production ready yet, but should be usable when the arm64 Macs are released.
There are currently no options:
  • no commercial compiler

  • LLVM's Fortran front-end is not functional: cannot compile very simple code, array assignments, and basic libraries like LAPACK

  • GCC does not currently target arm-darwin

This impacts a lot of scientific code, and in particular Python libraries that rely on Fortran, such as Scipy, scikit-learn, and many others.
I have used flang successfully on Apple Silicon, but flang/f18 itself doesn't come with a Fortran runtime (it uses pgf90 by default) and as of now, there is no compatible Fortran runtime to generate executables. Anyone able to troubleshoot this yet?
I use iMac and MacBook Pro for scientific computing with Intel Fortran, sometimes gfortran. If it will not possible to use a fortran compiler in the new Macs I will have to abandon Apple.
  • Second this, at least for development purposes.

Add a Comment
Keep an eye here for developments https://github.com/Homebrew/brew/issues/7857
You'll want to follow the gcc support, which is just starting with gmp getting support for Apple Silicon. I can't imagine Apple Silicon not having a compatible fortran compiler, considering you can use gfortran with other AArch64 targets.
Apple makes Swift and had no control over gfortran. You'll have to re-direct your requests to GNU and ask them to port gfortran to Apple Silicon.
Any update on this? All my native C applications compile for Apple Silicon. However, many scientists leverage my tools using R and their pipelines depend on Fortran for specific functions. Good support for R and Fortran is really important for many scientists.

Any update on this? All my native C applications compile for Apple Silicon. However, many scientists leverage my tools using R and their pipelines depend on Fortran for specific functions. Good support for R and Fortran is really important for many scientists.

I have 100% confidence that Apple's level of support for Fortan will not change with the switch to Apple Silicon.


Not by Apple, but a Fortran compiler tuned for Apple Silicon is out now from NAG.


I have not heard anything from Apple but the NAG Fortran Compiler is available. Search for "nag fortran apple".
Apple hasn’t develop any publicly-available Fortran compiler to date, and there is no indication that would change.

Furthermore lack of gcc (the GNU Compiler Collection) support for Apple Silicon seems to be holding back Fortran as well, since many open source Fortran project seems to depend on that.

In any case, you could run gcc (and thus Fortran) under Rosetta 2. Many CPU-oriented Benchmarks has shown that the M1 already runs Intel apps faster than most portable Macs that came before it. Search the web for “How to Run Legacy Command Line Apps on Apple Silicon“ to set up a Terminal profile that runs Intel apps by default so that you can continue using Fortran in “Intel mode” until native support finally arrive.

Thanks to the work of fxcoudert and Iain Sandoe there is now an experimental release of gfortran. It worked well in my limited testing.  https://github.com/fxcoudert/gfortran-for-macOS/releases
I haven't tried it (don't have the hardware), but hpc.sourceforge.net apparently has GCC/gfortran binaries for M1.
If anyone has successfully implemented 'the work of fxcoudert and Iain Sandoe there is now an experimental release of gfortran', can they briefly explain the steps to follow.
Even though everything is mentioned I am having hard time to follow and get the expected results.

Few of the errors I am getting while installing packages in R are,
  1. make: gfortran: No such file or directory - this is solved by installing the experimental gfortran release

  2. ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0' - can not find anything related to this.

Thank you very much for your help.
This is an old question but I found that now there is a experimental fortran compiler for M1. Look on GitHub for: "gfortran 11-experimental-2 for ARM Big Sur (macOS 11)". I was able to compile my parallel code with this compiler and also a lot of other stuff. As for experimental version is is pretty stable.