Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Fortan Compiler for Apple Silicon (M1, M2, M3)

Hello all,


are there any recommended Fortan Compiler for Apple Silicon (M1, M2, M3)?


Thank you.


Posted on Dec 20, 2023 1:25 PM

Reply
Question marked as Top-ranking reply

Posted on Jan 27, 2024 5:54 PM

GNU Fortran (GFortran) is excellent on Apple Silicon. Easily installed via Homebrew (brew.sh) at the command line. I do all of my Fortran development and testing on Apple Silicon, before moving to Linux AMD and Intel clusters. It follows all the same/usual standards, is kept updated with the current version, and the performance per core is brilliant.

14 replies
Sort By: 
Question marked as Top-ranking reply

Jan 27, 2024 5:54 PM in response to lowlevelmission

GNU Fortran (GFortran) is excellent on Apple Silicon. Easily installed via Homebrew (brew.sh) at the command line. I do all of my Fortran development and testing on Apple Silicon, before moving to Linux AMD and Intel clusters. It follows all the same/usual standards, is kept updated with the current version, and the performance per core is brilliant.

Reply

Feb 16, 2024 1:50 PM in response to lowlevelmission

I have been using the llvm compiler on a M2 MacBook Pro with some success. Results are different than the same scientific code on other platforms/compilers though. I have not been able to figure that out. I could not get NAG fortran to work very well. Another member of our group successfully compiled our code using NAG on an Intel-based mac but I could not do so on the ARM M2 chip

Reply

Dec 20, 2023 2:01 PM in response to lowlevelmission

There is a trial NAG Fortran compiler for Apple Silicon (ARM) Macs. It is not free, I don't use it, and you will need to talk with NAG about any limitations it may have on M1/2/3 Macs and associated library compatibility. It is my understanding that GNU is not targeting their Fortran development for Apple Silicon Macs.

Reply

Feb 4, 2024 6:11 AM in response to Jon_314

Thank you for the excellent information regarding GNU Fortran compiling platform. I'm a newbie at code writing and compiling and I apologize for asking this, but where do I get the GNU Fortran compiling binaries? I am using Apple M1 and M2 Silicon and am really in need of a Fortran compiler to compile the molecular dynamics software code, AMBER. Any information you can provide to help would be very thankfully received.

Reply

Feb 4, 2024 8:40 AM in response to bambamcubed

Your order of installation:


  1. You will need the homebrew (brew) package manager. See brew.sh and copy/paste the installation script line into the Terminal and press return.
    1. It will detect that it needs to install the Apple command-line tools for Xcode and do that. This is needed in order to build Apple Silicon binaries of the packages it installs
  2. On Apple Silicon Macs, homebrew will want to install into /opt/homebrew and binaries will be written into /opt/homebrew/bin.
    1. In your Bash or Zsh shell dot file, set export PATH="${PATH}:/opt/homebrew/bin"
    2. This will allow your SHELL to find the GNU bits after they are installed


There is no such thing as getting just the GNU fortran compiler. You must install the monster GNU C/C++ build and all of its libraries in order to get gfortran.


After you have installed homebrew, and while still in the Terminal, you want to do the following:


brew outdated
brew upgrade (if anything is shown as needing upgraded from the outdated command)
brew install gfortran
brew cleanup


The GNU Fortran documentation is online.

Reply

Feb 4, 2024 8:44 AM in response to VikingOSX

Your order of installation:


  1. You will need the homebrew (brew) package manager. See brew.sh and copy/paste the installation script line into the Terminal and press return.
    1. It will detect that it needs to install the Apple command-line tools for Xcode and do that. This is needed in order to build Apple Silicon binaries of the packages it installs. It does not install Xcode.
  2. On Apple Silicon Macs, homebrew will want to install into /opt/homebrew and binaries will be written into /opt/homebrew/bin.
    1. In your Bash or Zsh shell dot file, set export PATH="${PATH}:/opt/homebrew/bin"
    2. This will allow your SHELL to find the GNU bits after they are installed


There is no such thing as getting just the GNU fortran compiler. You must install the monster GNU C/C++ build and all of its libraries in order to get gfortran. Even on M1/M2 Macs, that will take awhile to build.


After you have installed homebrew, and while still in the Terminal, you want to do the following:


brew outdated
brew upgrade (if anything is shown as needing upgraded from the outdated command)
brew install gfortran
brew cleanup


The GNU Fortran documentation is online.

Reply

Dec 23, 2023 2:29 AM in response to VikingOSX

Thank you.


Then I can no longer use Apple Silicon Macs (M1, M2, M3) for scientific calculations / work.

So there are only two options for me, either I switch to another operating system, which I don't really want to do, but apparently have to, or I go back to using Apple FORTRAN on Apple II.

Reply

Dec 23, 2023 6:19 AM in response to lowlevelmission

And there is the work-in-progress Flang project (Fortran 2018) under the auspices of LLVM which in their own words, is "not ready for production usage", but is in active development. It is free and has an Apache license. It is written in contemporary C++ and takes Fortran code to an executable.


LLVM-Project: Flang


Having not written any production Fortran code in decades, I have not built/installed Flang myself.

Reply

Dec 24, 2023 6:24 PM in response to lowlevelmission

> And there is the work-in-progress Flang project (Fortran 2018)...


There is also a "Classic Flang" compiler based on an older version of pgfortran. It's eventually supposed to be replaced by the Fortran 2018 Flang, mentioned by VikingOSX.


I haven't used any of them, I'm just trying to be helpful :-)

Reply

Fortan Compiler for Apple Silicon (M1, M2, M3)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.