geodynamics / axisem

AxiSEM is a parallel spectral-element method to solve 3D wave propagation in a sphere with axisymmetric or spherically symmetric visco-elastic, acoustic, anisotropic structures.
67 stars 31 forks source link

CMake does not search for NetCDF correctly. #8

Open QuLogic opened 10 years ago

QuLogic commented 10 years ago

I have installed the packaged version of NetCDF for Fortran, but CMake does not correctly find it.

$ cmake .
...
-- Failed to find NetCDF interface for F90
-- Could NOT find NetCDF (missing:  NetCDF_has_interfaces) 
-- Configuring done
-- Generating done

Note that there are two sets of libraries, non-MPI:

$ rpm -q netcdf-fortran-devel
netcdf-fortran-devel-4.2-11.fc20.x86_64
$ rpm -ql netcdf-fortran-devel | grep netcdf.inc
/usr/include/netcdf.inc
$ rpm -ql netcdf-fortran-devel | grep netcdf.mod
/usr/lib64/gfortran/modules/netcdf.mod
$ rpm -ql netcdf-fortran-devel | grep netcdff
/usr/lib64/libnetcdff.so

and an MPI version,

$ rpm -q netcdf-fortran-openmpi-devel
netcdf-fortran-openmpi-devel-4.2-11.fc20.x86_64
$ rpm -ql netcdf-fortran-openmpi-devel | grep netcdf.inc
/usr/include/openmpi-x86_64/netcdf.inc
$ rpm -ql netcdf-fortran-openmpi-devel | grep netcdf.mod
/usr/include/openmpi-x86_64/netcdf.mod
$ rpm -ql netcdf-fortran-openmpi-devel | grep netcdff
/usr/lib64/openmpi/lib/libnetcdff.so

I don't think FindNetCDF.cmake correctly understands this split.

eheien commented 10 years ago

Do you also have the NetCDF C library (libnetcdf.so) installed? I believe the CMake module requires this as well, which may explain your problem. However it's probably not necessary for AxiSEM so if this is the problem we can remove the check for it.

martinvandriel commented 10 years ago

The solver should compile without netcdf, if netcdf is to be used, the macro "unc" needs to be defined (typically -Dunc as an option for the compiler). Additionally, there is an option in the inparam_advanced file, to switch netcdf on and of without recompiling.

eheien commented 10 years ago

The CMake build process has no problem if NetCDF isn’t installed - it uses the unc macro in the same manner as the original build. I believe Elliott was referring to the script not correctly finding his installation of NetCDF.

On Apr 22, 2014, at 2:31 PM, Martin van Driel notifications@github.com wrote:

The solver should compile without netcdf, if netcdf is to be used, the macro "unc" needs to be defined (typically -Dunc as an option for the compiler). Additionally, there is an option in the inparam_advanced file, to switch netcdf on and of without recompiling.

— Reply to this email directly or view it on GitHub.

QuLogic commented 10 years ago

I believe Elliott was referring to the script not correctly finding his installation of NetCDF.

Yes, that's correct. The build is fine without NetCDF, but I can't try with since CMake doesn't find NetCDF.

Do you also have the NetCDF C library (libnetcdf.so) installed?

You mean this, right?

$ rpm -ql netcdf-devel | grep libnetcdf
/usr/lib64/libnetcdf.so
eheien commented 10 years ago

Yes, that's correct. I'm not sure why CMake wouldn't find at least one of your NetCDF installations. Do you know if it works if you only have one installation active?

QuLogic commented 10 years ago

I can't remove the C devel package because the Fortran devel package depends on it.

eheien commented 10 years ago

Sorry, I meant in your original email you had two sets of libraries (MPI and non-MPI). If you disable one of those sets, does CMake find the other, or does it fail to find anything regardless of the setup?

QuLogic commented 10 years ago

Ah, yes, I see. I tried with only MPI devel and only non-MPI devel, but neither of these worked correctly.

eheien commented 10 years ago

When you run CMake, what is in CMakeCache.txt under NETCDF_INCLUDES, NETCDF_INCLUDES_F90, NETCDF_LIBRARIES, NETCDF_LIBRARIES_F90, and NETCDF_LIBRARIES_C? I'm just trying to understand the problem without being able to recreate it on my own machine. Thanks!

QuLogic commented 10 years ago

This is with only the MPI devel libraries installed:

NETCDF_INCLUDES:PATH=/usr/include
NETCDF_INCLUDES_F90:PATH=NETCDF_INCLUDES_F90-NOTFOUND
NETCDF_LIBRARIES:STRING=/usr/lib64/libnetcdf.so
NETCDF_LIBRARIES_C:FILEPATH=/usr/lib64/libnetcdf.so
NETCDF_LIBRARIES_F90:FILEPATH=NETCDF_LIBRARIES_F90-NOTFOUND
NETCDF_INCLUDES-ADVANCED:INTERNAL=1
NETCDF_INCLUDES_F90-ADVANCED:INTERNAL=1
NETCDF_LIBRARIES-ADVANCED:INTERNAL=1
NETCDF_LIBRARIES_C-ADVANCED:INTERNAL=1
NETCDF_LIBRARIES_F90-ADVANCED:INTERNAL=1

This is with both devel libraries installed:

NETCDF_INCLUDES:PATH=/usr/include
NETCDF_INCLUDES_F90:PATH=NETCDF_INCLUDES_F90-NOTFOUND
NETCDF_LIBRARIES:STRING=/usr/lib64/libnetcdf.so
NETCDF_LIBRARIES_C:FILEPATH=/usr/lib64/libnetcdf.so
NETCDF_LIBRARIES_F90:FILEPATH=/usr/lib64/libnetcdff.so
NETCDF_INCLUDES-ADVANCED:INTERNAL=1
NETCDF_INCLUDES_F90-ADVANCED:INTERNAL=1
NETCDF_LIBRARIES-ADVANCED:INTERNAL=1
NETCDF_LIBRARIES_C-ADVANCED:INTERNAL=1
NETCDF_LIBRARIES_F90-ADVANCED:INTERNAL=1

The problem is with the Fortran90 module. I see that it's treated as a header and hinted to be in ${NETCDF_INCLUDES}. Since that defaults to /usr/include, it doesn't work.