Install gfortran on macOS
Homebrew note
On macOS the simplest path for beginners is Homebrew, a package manager for command line tools.
MacPorts is a known alternative with the same goal. This lesson uses Homebrew because its gcc package always bundles a matching gfortran.
Install gcc
Gfortran ships with gcc on Homebrew, so one package gives you both the C and the Fortran compilers.
brew install gcc
The download takes a few minutes on a first install. No extra flags are needed for this course.
Verify with gfortran --version
Open a fresh terminal window and ask the compiler for its version number.
gfortran --version
GNU Fortran 14.2.0
If the version line prints, the install is done and you can move to the first program lesson.
PATH notes
Homebrew may also install version suffixed binaries such as gfortran-14 beside the plain gfortran name.
If the plain name is not found, try the suffixed name, then open a fresh terminal so the new PATH value loads.
gfortran-14 --version
GNU Fortran 14.2.0
Use the name that answers on your machine for the rest of the course. Both names run the same compiler.
The code on this page was not run: it needs macOS with Homebrew.
Article author: Arthur Isaev