How to Install MPI Fortran Compiler - macos

I'm new to MPI and have a relatively straightforward question. I recently installed OpenMPI using the instructions here: https://wiki.helsinki.fi/display/HUGG/Open+MPI+install+on+Mac+OS+X. However, when I try to run the executable, I get the following error.
(base) timdesilva#MacBook-Pro-2021 ~ % gfortran --version
GNU Fortran (Homebrew GCC 11.2.0) 11.2.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
(base) timdesilva#MacBook-Pro-2021 ~ % echo $PATH
/Users/timdesilva/opt/anaconda3/bin:/Users/timdesilva/opt/anaconda3/condabin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin:/Library/Apple/usr/bin:/Applications/Stata/StataSE.app/Contents/MacOS
(base) timdesilva#MacBook-Pro-2021 ~ % which gfortran
/usr/local/bin/gfortran
(base) timdesilva#MacBook-Pro-2021 ~ % which mpifort
/Users/timdesilva/opt/anaconda3/bin/mpifort
(base) timdesilva#MacBook-Pro-2021 ~ % mpifort --version
/Users/timdesilva/opt/anaconda3/bin/mpifort: line 376: x86_64-apple-darwin13.4.0-gfortran: command not found
Sorry if this is a basic question, but any help would be much appreciated!

Related

gfortran cannot match MacOS Ventura version

The new MacOS Ventura seems to have broken gfortran MacOS version control. To reproduce my error you only have to do
gfortran --version
And the output is
gfortran: warning: could not understand version ‘13.00.00’
GNU Fortran (GCC) 11.3.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
This in itself is just a warning so it might not be a big deal but it breaks "./configure" scripts that require some MacOS versions, e.g. if you try to compile LoopTools you get the following error (in the log file)
arm64-apple-darwin20.0.0-gfortran: warning: could not understand version '13.00.00'
ld: -rpath can only be used when targeting Mac OS X 10.5 or later
collect2: error: ld returned 1 exit status
Since the version cannot be properly read it cannot be compared.
Is there some sort of work around this bug?
I had installed gfortran through conda but aparantly the version is from last year.
I solved it by removing it from conda (had to remove conda entirely due to linking issues) and installed it with brew : brew install gcc.

"c.lang (LLVM option parsing): Unknown command line argument" when running gfortran on Mac

I am trying to compile a "hello world" text file, but keep receiving an error in my mac terminal:
(base) name#Names-MacBook-Pro-3 File % gfortran -o test.exe try.f90
c.lang (LLVM option parsing): Unknown command line argument '-x86-pad-for-
align=false'. Try: 'clang (LLVM option parsing) --help'.
My fortran version:
GNU Fortran (Homebrew GCC 11.3.0_1) 11.3.0
text file (try.f90) that I wrote in VS:
program try
print*,'hello world!'
end program try
I tried with a space and without a space before print. The code I am using is from a youtuber who uses Atom text editor and the video is from 2020.
I am stuck. Please help.
I resolved my issue by updating Xcode. There was an incompatibility between gfortran and clang. To see available updates:
softwareupdate --list see the list of outdated software.
softwareupdate --install <name>
I faced the same issue and it seems the root cause was Xcode vs Command Line Tools were used. Probably some inconsistency (e.g. I might have upgraded the cli but not the gui).
Anyway, before
$ xcode-select --print-path
/Applications/Xcode.app/Contents/Developer/
I fixed this with
$ sudo xcode-select -switch /Library/Developer/CommandLineTools
and then gcc-12 or gfortran from homebrew worked as expected.
FWIW
$ clang --version
Apple clang version 13.0.0 (clang-1300.0.29.30)
Target: x86_64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ gcc-12 --version
gcc-12 (Homebrew GCC 12.2.0) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

gcc on OS X leads to dyld: Library not loaded: /opt/local/lib/libffi.6.dylib

$ gcc t0.c
dyld: Library not loaded: /opt/local/lib/libffi.6.dylib
Referenced from: /opt/local/libexec/llvm-9.0/lib/libLLVM.dylib
Reason: image not found
fatal error: /opt/local/bin/as: fatal error in /opt/local/bin/clang-mp-9.0
$ gcc --version
gcc (MacPorts gcc9 9.2.0_1) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Any help?
How it was fixed:
# update ports tree
$ sudo port selfupdate
# uninstall all ports
# note: in my case uninstalling all ports is much faster than
# auto-rebuilding ports which have/cause linking issues
$ sudo port -fp uninstall installed
# install needed ports
$ port install xxx yyy zzz
# test
$ gcc t0.c
<no errors as expected>
More info: https://guide.macports.org/#using.common-tasks.

gcc and gfortran is incompatiable

I am using MACOS Big Sur.
I installed the gcc 9 by
brew install gcc#9
But I found my gfortran is gfortran8.2. So I uninstall the gfortran and reinstall it by
brew install gfortran
But the version is
bash-3.2$ gfortran --version
GNU Fortran (Homebrew GCC 10.2.0_4) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty;
How I can install a gfortran9(link to gcc#9) by brew in Mac

Mac OS X: Installed and linked gcc 6.2 with Homebrew, but gcc --version still says 4.9.2

On OS X 10.11.6, I installed gcc 6.2.0 using homebrew. It lives over in usr/local/Cellar/gcc/6.2.0/bin. After getting it to link (it didn't do this automagically), I cd there and try the solution from this other thread to create an alias
ln -s gcc-6 gcc
then gcc --version gives me
cc (GCC) 4.9.2 20141029 (prerelease)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
All this is because trying to install things crashes because of -rdynamic flags, that I hope is fixed in a newer version.
You created the symlink with the proper target name (gcc) but forgot to set the PATH to your newly installed location (or set it after the system path).
What's confusing is that your system already has a version of gcc installed. You have to override the default path so your gcc command comes first.
edit your ~/.profile file and check PATH adjustment. Add a line in the end which contains:
export PATH=/usr/local/Cellar/gcc/6.2.0/bin:$PATH
Then open a new terminal and ensure that which gcc prints
/usr/local/Cellar/gcc/6.2.0/bin/gcc

Resources