D3DEnergetic / FIDASIM

A Neutral Beam and Fast-ion Diagnostic Modeling Suite
http://d3denergetic.github.io/FIDASIM/
Other
29 stars 19 forks source link

Compiling on macOS Catalina #210

Open lamorton opened 4 years ago

lamorton commented 4 years ago

I ran into the following when trying to compile the latest version:

Console output ``` make -B Building HDF5... tar -zxvf /Users/lmorton/Code/FIDASIM/deps/hdf5-1.8.16.tar.gz >> /dev/null 2>&1 cd /Users/lmorton/Code/FIDASIM/deps/hdf5-1.8.16; ./configure --prefix=/Users/lmorton/Code/FIDASIM/deps/hdf5 --enable-fortran >> /Users/lmorton/Code/FIDASIM/deps/hdf5_build.log 2>&1 cd /Users/lmorton/Code/FIDASIM/deps/hdf5-1.8.16; make >> /Users/lmorton/Code/FIDASIM/deps/hdf5_build.log 2>&1; make install >> /Users/lmorton/Code/FIDASIM/deps/hdf5_build.log 2>&1 cp /Users/lmorton/Code/FIDASIM/deps/hdf5-1.8.16/COPYING /Users/lmorton/Code/FIDASIM/deps/hdf5 cp /Users/lmorton/Code/FIDASIM/deps/hdf5-1.8.16/README.txt /Users/lmorton/Code/FIDASIM/deps/hdf5 rm -rf hdf5-1.8.16 HDF5 build complete gfortran -Ofast -g -fbacktrace -cpp -D_VERSION=\"v3.0.0-dev-25-gdc03fe45\" -fopenmp -D_OMP -c -I/Users/lmorton/Code/FIDASIM/deps/hdf5/include -I/Users/lmorton/Code/FIDASIM/src eigensystem.f90 gfortran -Ofast -g -fbacktrace -cpp -D_VERSION=\"v3.0.0-dev-25-gdc03fe45\" -fopenmp -D_OMP -c utilities.f90 gfortran -Ofast -g -fbacktrace -cpp -D_VERSION=\"v3.0.0-dev-25-gdc03fe45\" -fopenmp -D_OMP -c hdf5_utils.f90 -I/Users/lmorton/Code/FIDASIM/deps/hdf5/include -I/Users/lmorton/Code/FIDASIM/src gfortran -Ofast -g -fbacktrace -cpp -D_VERSION=\"v3.0.0-dev-25-gdc03fe45\" -fopenmp -D_OMP -c -I/Users/lmorton/Code/FIDASIM/deps/hdf5/include -I/Users/lmorton/Code/FIDASIM/src fidasim.f90 gfortran -Ofast -g -fbacktrace -cpp -D_VERSION=\"v3.0.0-dev-25-gdc03fe45\" -fopenmp -D_OMP -c -I/Users/lmorton/Code/FIDASIM/deps/hdf5/include -I/Users/lmorton/Code/FIDASIM/src eigensystem.f90 gfortran -Ofast -g -fbacktrace -cpp -D_VERSION=\"v3.0.0-dev-25-gdc03fe45\" -fopenmp -D_OMP -c utilities.f90 gfortran -Ofast -g -fbacktrace -cpp -D_VERSION=\"v3.0.0-dev-25-gdc03fe45\" -fopenmp -D_OMP -c hdf5_utils.f90 -I/Users/lmorton/Code/FIDASIM/deps/hdf5/include -I/Users/lmorton/Code/FIDASIM/src gfortran -Ofast -g -fbacktrace -cpp -D_VERSION=\"v3.0.0-dev-25-gdc03fe45\" -fopenmp -D_OMP fidasim.o eigensystem.o utilities.o hdf5_utils.o -o /Users/lmorton/Code/FIDASIM/fidasim -lm -L/usr/lib -L/Users/lmorton/Code/FIDASIM/deps/hdf5/lib -lhdf5_fortran -lhdf5hl_fortran -lhdf5_hl -lhdf5 -lz -ldl -Wl,-rpath,/Users/lmorton/Code/FIDASIM/deps/hdf5/lib -L/Users/lmorton/Code/FIDASIM/src gfortran -Ofast -g -fbacktrace -cpp -D_VERSION=\"v3.0.0-dev-25-gdc03fe45\" -fopenmp -D_OMP -c atomic_tables.f90 -I/Users/lmorton/Code/FIDASIM/deps/hdf5/include -I/Users/lmorton/Code/FIDASIM/src m2c -o /Users/lmorton/Code/FIDASIM/src/hdf5_utils.o /Users/lmorton/Code/FIDASIM/src/hdf5_utils.mod make[1]: m2c: No such file or directory make[1]: *** [/Users/lmorton/Code/FIDASIM/src/hdf5_utils.o] Error 1 make: *** [tables] Error 2 ```

According to this issue:

Gfortran creates a file namemod= for each module name. This confuses the gnu make, which thinks that .mod files are Modula2 source code files. You must override this built-in rule by adding the following line somewhere in your Makefile.

%.o : %.mod

So, I added that line as the 2nd command in src/makefile and the build went through.

I also had to manually install automake-1.14 (was at 1.16) because I had been getting the following error:

Console output ``` Building HDF5... tar -zxvf /Users/lmorton/Code/FIDASIM/deps/hdf5-1.8.16.tar.gz >> /dev/null 2>&1 cd /Users/lmorton/Code/FIDASIM/deps/hdf5-1.8.16; ./configure --prefix=/Users/lmorton/Code/FIDASIM/deps/hdf5 --enable-fortran >> /Users/lmorton/Code/FIDASIM/deps/hdf5_build.log 2>&1 cd /Users/lmorton/Code/FIDASIM/deps/hdf5-1.8.16; make >> /Users/lmorton/Code/FIDASIM/deps/hdf5_build.log 2>&1; make install >> /Users/lmorton/Code/FIDASIM/deps/hdf5_build.log 2>&1 make[1]: *** [hdf5] Error 2 make: *** [deps] Error 2 ``` Inside the log file, I found: ``` cd . && /bin/sh /Users/lmorton/Code/FIDASIM/deps/hdf5-1.8.16/bin/missing automake-1.14 --foreign Makefile /Users/lmorton/Code/FIDASIM/deps/hdf5-1.8.16/bin/missing: line 81: automake-1.14: command not found WARNING: 'automake-1.14' is missing on your system. You should only need it if you modified 'Makefile.am' or 'configure.ac' or m4 files included by 'configure.ac'. The 'automake' program is part of the GNU Automake package: ```

It might be worth adding some remarks about these in the 'Installation' section of the documentation, or maybe making the %.o : %.mod a conditional statement in the makefile for macOS systems.

lstagner commented 4 years ago

Thats interesting. Officially we don't support macOS but if you can get it to compile we can nominally support it. Where did you put the %.o : %.mod in the makefile?

lamorton commented 4 years ago

OK. Actually, it was the tables, not source --- I misremembered. So tables/makefile looks like this:

SHELL = /bin/bash

EX = $(TABLES_DIR)/generate_tables/$(EXEEXT)

%.o : %.mod

TBDEPS=$(SRC_DIR)/hdf5utils_.0 $SRC_DIR)/utilities.o
...
lamorton commented 3 years ago

I hit another snag. Apparently a Mac update changed my default gfortran compiler version from 6.3.0 to 8.2.0. This apparently caused the HDF5 library build to fail, because this warning:

cache.c:27086:23: warning: implicit declaration of function 'resize_configs_are_equal' is invalid in C99 [-Wimplicit-function-declaration]

became an error, and there were too many of them, so the compilation halted. So, it looks like there's some badness in the HDF5 library that makes it compiler-version-dependent. Might be worth updating the acceptable compiler version numbers.

lstagner commented 3 years ago

Ugh...hopefully this is just a mac thing. I've been avoiding updating the hdf5 version for a while now.

lamorton commented 3 years ago

OK, turns out the culprit was Xcode/clang, not gfortran (which makes sense b/c the error was specific to C). The update took me from clang 11.0.3 to 12.0.0; reverting that was what finally made the build work.