NCAR / musica

Multi-Scale Infrastructure for Chemistry Modeling
https://wiki.ucar.edu/display/MUSICA/MUSICA+Home
Apache License 2.0
3 stars 2 forks source link

TUV-x build error #155

Open lizziel opened 2 weeks ago

lizziel commented 2 weeks ago

Hi, I am running into a build error in TUV-x related to netcdf-fortran and wonder if you have seen this before. The error is an issue finding netcdf.mod.

f951: internal compiler error: in generate_finalization_wrapper, at fortran/class.c:2042
/n/home08/elundgren/code/ncar/code.musica/build/_deps/tuvx-src/src/util/io/netcdf.F90:84:9:

   84 |     use netcdf,                        only : nf90_create, nf90_open,         &
      |         1
Fatal Error: Cannot open module file ‘netcdf.mod’ for reading at (1): No such file or directory

I verified I have the netcdf fortran library by using nf-config, and that the path matches what is in CMakeCache.txt:

netcdff_INCLUDEDIR:INTERNAL=/n/sw/helmod-rocky8/apps/MPI/gcc/10.2.0-fasrc01/openmpi/4.1.0-fasrc01/netcdf-fortran/4.5.3-fasrc01/include

I also verified netcdf.mod is included in that path. I tried turning on a few non-default build options, but still get the same issue: cmake .. -DTUVX_ENABLE_NC_CONFIG=ON -DMUSICA_BUILD_FORTRAN_INTERFACE=ON

This is with CMake 3.25.2. Let me know if you have any insight!

K20shores commented 1 week ago

Hi @lizziel I think I have seen it before. I think sometimes the information provided in cmake about netcdf doesn't always set the include path for whatever reason. You could try setting -DCMAKE_Fortran_FLAGS="-I/n/sw/helmod-rocky8/apps/MPI/gcc/10.2.0-fasrc01/openmpi/4.1.0-fasrc01/netcdf-fortran/4.5.3-fasrc01/include"

K20shores commented 3 days ago

Hi @lizziel I was getting the same error as you on my local linux machine. For some reason, pkg-config doesn't give the proper include locations for netcdf.mod on my system.

(base) kyle@Blueberry:~/Documents/tuv-x (lapacke_debug)$ pkg-config --cflags --libs netcdf-fortran
-I/usr/include/hdf5/serial -lnetcdff
(base) kyle@Blueberry:~/Documents/tuv-x (lapacke_debug)$ pkg-config --cflags --libs netcdf
-I/usr/include/hdf5/serial -lnetcdf

Notice it's missing /usr/include, which is where netcdf.mod is for me

So, this may be a netcdf pkg-config issue on some systems (@WardF).

For me cmake -DCMAKE_Fortran_FLAGS="-I/usr/include" .. did indeed fix the issue with not finding netcdf.mod. Hopefully that will also fix it for you