pymake icon indicating copy to clipboard operation
pymake copied to clipboard

mf2005 not compiling on MacOS Monterey

Open Olsthoorn opened this issue 3 years ago • 2 comments

The new MacOS Monterey broke well running old USGS programs now leaving incomplete output files upon normal termination. This proved to be due to not flushing the file buffers upon ending the program. This is also the case when recompiled with the newest gfortran for MacOS Monterey, hence the problem would lay in the dynamic system libraries that come with the OS. This is solved by adding CALL FLUSH() just before the last END statement in the main program. Next to this, Apple also broke compiling with Pymake. This is due to 1) the stdio.h and stdlib.h no longer on normal /usr/local/bin or so. It is solved by adding an INCLUDEDIR directive pointing to the right folder. Second, Apple removed the standard libraries like libc.a, libc.so from the file system. They are not win the "dynamic link cache". This turns out to be solved by adding --sysroot compiler directive.

I add the adapted makefiles for both mf2005 and seawat that show the correct arguments. Notice that seawat has more issues, due to the new fortran compiler being more seviere than previous ones, which are also described in the makefile. makefile_mac_monterey_swt.txt makefile_mf2005_MacMontery.txt Compling_issue_analysis.txt

Olsthoorn avatar Nov 04 '21 23:11 Olsthoorn

Hi Theo, thanks for all your work on this. We are just in the process of switching to Big Sur, and so we won't have to deal with this on our end for a little while. But it's good to know about these problems. The FLUSH issue sounds like a compiler error, so hopefully that will get fixed, but adding a final flush in our finalize routines shouldn't be difficult to do if necessary.

Your compiling issue analysis will be very helpful for us moving forward. It looks like you will have saved us many days of work. Thank you.

langevin-usgs avatar Nov 05 '21 12:11 langevin-usgs

I just updated to Monterey and have not had the same problems. I was able to compile and run SEAWAT and MODFLOW-2005. I installed gcc-11 and gfortran-11 using Homebrew. Previously I used macports to install gfortran but I could not install gcc-10 or earlier so I switched to Homebrew. Before installing gcc-11 I installed the latest version of Xcode and after it was installed I ran

xcodebuild -license

and

xcode-select --install

I noticed after installing gcc-11 with Homebrew that when I ran gcc --version it was using clang so I setup an alias in my .zhrc file for the zsh shell (which is now the default shell).

alias gcc='gcc-11'
alias cc='gcc-11'
alias g++='g++-11'
alias c++='c++-11'

and added the Homebrew installation location to my path

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

After doing all of this I was able to compile SEAWAT and MODFLOW using make_swtv4.py and make_mf2005.py in the pymake examples directory. I tested that the compiled executables using t001_test.py and t002_test.py in the autotest directory.

I am not sure if the clang vs. gcc is the source of the problems since I was also able to compile and run SEAWAT with gfortran and clang using

python t002_test.py -fc gfortran -cc clang

I am not sure if any of this will help.

jdhughes-usgs avatar Nov 29 '21 19:11 jdhughes-usgs