LiamBindle / geos-chem

Source code repository for the GEOS-Chem model of atmospheric chemistry and composition.
Other
0 stars 0 forks source link

CMake: unable to configure NetCDF-Fortran interface #2

Closed kilicomu closed 5 years ago

kilicomu commented 5 years ago

Hi Liam.

Using your instructions found here and information you provided in an email, I have attempted to configure the GEOS-Chem classic build using a clone of your feature/CMakeDemo branch (commit 695c). The configure process doesn't seem to be able to get past trying to find NetCDF libraries.

Some context:

On our HPC system, NetCDF-C and NetCDF-Fortran are installed in distinct locations, owing to the separation of the NetCDF-C and NetCDF-Fortran libraries a while back. Consequently, I have NetCDF-C installed at

/opt/apps/easybuild/software/data/netCDF/4.6.1-intel-2018b

and NetCDF-Fortran installed at

/opt/apps/easybuild/software/data/netCDF-Fortran/4.4.4-intel-2018b

For peace of mind, the contents of the relevant directories undeneath those library installation roots are:

[klcm500@login1 [viking] 4.6.1-intel-2018b]$ ls $(nc-config --prefix)/include
netcdf.h  netcdf_mem.h  netcdf_meta.h  netcdf_par.h

[klcm500@login1 [viking] 4.6.1-intel-2018b]$ ls $(nc-config --prefix)/lib64
cmake  libnetcdf.a  libnetcdf.settings  libnetcdf.so  libnetcdf.so.13  pkgconfig

[klcm500@login1 [viking] 4.6.1-intel-2018b]$ ls $(nf-config --prefix)/include
netcdf4_f03.mod  netcdf4_nc_interfaces.mod  netcdf4_nf_interfaces.mod  netcdf_f03.mod  netcdf_fortv2_c_interfaces.mod  netcdf.inc  netcdf.mod  netcdf_nc_data.mod  netcdf_nc_interfaces.mod  netcdf_nf_data.mod  netcdf_nf_interfaces.mod  typesizes.mod

[klcm500@login1 [viking] 4.6.1-intel-2018b]$ ls $(nf-config --prefix)/lib
libnetcdff.a  libnetcdff.la  libnetcdff.so  libnetcdff.so.6  libnetcdff.so.6.1.1  pkgconfig

The problem:

With my shell environment set up for building and running GEOS-Chem, when running

[klcm500@login1 [viking] build]$ cmake -DCMAKE_PREFIX_PATH="$(nc-config --prefix);$(nf-config --prefix)" ~/scratch/GEOS-Chem/code/intel/cmake

from within a build directory in my GEOS-Chem run directory, I face the following configuration error:

-- Failed to find NetCDF interface for F90
CMake Error at /opt/apps/easybuild/software/devel/CMake/3.12.1-GCCcore-7.3.0/share/cmake-3.12/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find NetCDF (missing: NETCDF_HAS_INTERFACES)
Call Stack (most recent call first):
  /opt/apps/easybuild/software/devel/CMake/3.12.1-GCCcore-7.3.0/share/cmake-3.12/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  CMakeScripts/FindNetCDF.cmake:121 (find_package_handle_standard_args)
  CMakeScripts/GC-ConfigureClassicBuild.cmake:20 (find_package)
  CMakeLists.txt:34 (include)

I have attached the CMakeCache.txt and CMakeOutput.log files from my build directory, and can provide any other information that you need. I apologise if I'm missing something obvious here!

CMakeCache.txt

CMakeOutput.log

LiamBindle commented 5 years ago

Hi Killian,

Thanks for trying this, and for the detailed issue. This is really helpful.

Everything you've done looks correct to me.

I looked through the FindNetCDF.cmake script I got from VTK, and it looks like they set NO_DEFAULT_PATHS by default, making their script to ignore CMAKE_PREFIX_PATH (reference here). It looks like their script mainly relies on additional variables like NETCDF_F90_INCLUDE_DIRS, for getting users to point to where things are installed, rather than using standard variables like CMAKE_PREFIX_PATH. My preference is to stick with standard CMake variables, and I think your idea for rewriting the FindNetCDF.cmake script and using nc-config and nf-config is a good one, so I'm going to do that for the next demo.

I'm going to have the second iteration of the Demo ready sometime in the next couple days (maybe Friday or Monday). If you want to try something in the meantime, you could try setting NETCDF_USE_DEFAULT_PATHS to true. It looks like this will turn off NO_DEFAULT_PATHS in the VTK FindNetCDF.cmake script causing CMAKE_PREFIX_PATH to be looked at. No need to try this, but if it's easy, it might get you past the FindNetCDF stage.

Anyways, thanks again! I'll follow up when the second version of the demo is ready. --Liam