Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mf2005 not compiling on MacOS Monterey #97

Open
Olsthoorn opened this issue Nov 4, 2021 · 2 comments
Open

mf2005 not compiling on MacOS Monterey #97

Olsthoorn opened this issue Nov 4, 2021 · 2 comments

Comments

@Olsthoorn
Copy link

Olsthoorn commented Nov 4, 2021

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

@langevin-usgs
Copy link
Collaborator

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.

@jdhughes-usgs
Copy link
Collaborator

jdhughes-usgs commented Nov 29, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants