I recently moved from the SGI, Sun workstation environment to a Mac. SGI and Sun came with Fortran compilers so I have maybe 100 small f77 codes I wrote over the years for post-processing and analysis of simulated data. I was hoping to get these codes running on my iMac with gfortran. Most of these are very simple codes but I can't get them to compile and execute. I tried starting with the basics and wrote the Hello World code from a gfortran help page. My code, fortran.f is:
program helloworld
print *, "hello world"
end program helloworld
When I tried compiling this according to the example I typed:
gfortran fortran.f
But I keep getting the error message:
FATAL:/opt/local/bin/../libexec/as/x86_64/as: I don't understand 'm' flag!
This is the same error message I get on my other codes. Can someone tell me what I'm doing wrong? I can't think of a simpler example but I can't seem to get it to work.
If your gfortran
was installed a long time ago and you have updated macOS since installing, it may need re-installing to get correctly aligned and linked with the latest macOS tools and libraries.
My advice would be to:
gfortran
,gfortran
.Hints for each of those steps follow:
Note that gfortran
is a part of GCC - the "GNU Compiler Collection".
If you installed gfortran
via homebrew, you can remove it with:
brew rm gcc
You can update Xcode by by going to AppStore and clicking Updates
at top-right.
The Xcode Command Line tools include make
and git
and command-line versions of the compilers. You can install/update the Xcode command line tools with:
xcode-select --install
You can install gfortran
with homebrew using:
brew install gcc
When you are finished, you should make sure that your PATH
includes /usr/local/bin
near the start and that there are no errors when you run:
brew doctor
which is a brilliant utility that checks your homebrew configuration is correct.