You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

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
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.

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

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.

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.

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.

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.

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.