Search code examples
macosterminalfortrangfortran

Cannot install fortran program on macOS via Terminal


When I run make in the Terminal I get the following error:

    gfortran: warning: couldn’t understand kern.osversion ‘15.6.0 
    gfortran  -O1  -I..    -DFLUSH  -c ../aocn2.f90

Any ideas on how to install fortran for macOS?


Solution

  • IMHO, the easiest way to install Fortran under macOS/OSX is via homebrew.

    First, go to App Store and install Apple's Xcode. You can get to App Store by typing space and starting to type App Store and then hit Enter/Return once it guesses correctly. Xcode looks like this:

    enter image description here

    Then start a Terminal, using space Terminal Enter/Return and do the rest in Terminal.

    Install the "Xcode command line tools":

    xcode-select --install
    

    Then install homebrew by going to homebrew website and copying and pasting the one-liner there.

    Then install GCC ("GNU Compiler Collection") which includes gfortran:

    brew install gcc
    

    You will need to set your PATH to include /usr/local/bin which is where homebrew installs programs:

    export PATH=/usr/local/bin:$PATH
    

    You can now run:

    gfortran someFile.for