Unidata / netcdf-fortran

Official GitHub repository for netCDF-Fortran libraries, which depend on the netCDF C library. Install the netCDF C library first.
Other
244 stars 98 forks source link

Error: Symbol 'nc_noquantize' at (1) has no IMPLICIT type; did you mean 'nf_noquantize'? with netCDF 4.9.2 and netcdf-fortran-4.6.1 #427

Closed agahirpa closed 10 months ago

agahirpa commented 10 months ago

I am trying to compile netcdf-fortran-4.6.1 with netcdf-c 4.9.2 and I get the following error on ubuntu 22.02.

$ make check install
Making check in libsrc
make[1]: Entering directory '/home/agahirpa/WRF-Hydro/netcdf-fortran-4.6.1/libsrc'
make[1]: Nothing to be done for 'check'.
make[1]: Leaving directory '/home/agahirpa/WRF-Hydro/netcdf-fortran-4.6.1/libsrc'
Making check in fortran
make[1]: Entering directory '/home/agahirpa/WRF-Hydro/netcdf-fortran-4.6.1/fortran'
/bin/bash ../libtool  --tag=FC   --mode=compile gfortran -DPACKAGE_NAME=\"netCDF-Fortran\" -DPACKAGE_TARNAME=\"netcdf-fortran\" -DPACKAGE_VERSION=\"4.6.1\" -DPACKAGE_STRING=\"netCDF-Fortran\ 4.6.1\" -DPACKAGE_BUGREPORT=\"support-netcdf@unidata.ucar.edu\" -DPACKAGE_URL=\"\" -DPACKAGE=\"netcdf-fortran\" -DVERSION=\"4.6.1\" -DNF_RELAX_COORD_BOUND=1 -DENABLE_CDF5=1 -DNF_HAS_QUANTIZE=1 -DHAVE_F2008=1 -DHAVE_TS29113_SUPPORT=1 -DTEMP_LARGE=\".\" -DHAVE_STDIO_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_UNISTD_H=1 -DHAVE_SYS_TIME_H=1 -DSTDC_HEADERS=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DNF_INT1_T=byte -DNF_INT2_T=integer\*2 -DNF_INT8_T=integer\*8 -DNF_INT1_IS_C_SIGNED_CHAR=1 -DNF_INT2_IS_C_SHORT=1 -DNF_INT8_IS_C_LONG_LONG=1 -DNF_INT_IS_C_INT=1 -DNF_REAL_IS_C_FLOAT=1 -DNF_DOUBLEPRECISION_IS_C_DOUBLE=1 -DNCBYTE_T=byte -DNCSHORT_T=integer\*2 -DHAVE_LIBM=1 -DHAVE_NETCDF_H=1 -DHAVE_NC_DEF_OPAQUE=1 -DHAVE_NCCREATE=1 -DHAVE_NC_SET_LOG_LEVEL=1 -DHAVE_NC_DEF_VAR_SZIP=1 -DLOGGING=1 -DHAVE_SYS_PARAM_H=1 -DHAVE_LOCALE_H=1 -DHAVE_STDIO_H=1 -DHAVE_STDARG_H=1 -DHAVE_ERRNO_H=1 -DHAVE_CTYPE_H=1 -DHAVE_FCNTL_H=1 -DHAVE_MALLOC_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_STRINGS_H=1 -DHAVE_UNISTD_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_GETOPT_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_SYS_RESOURCE_H=1 -DHAVE_DIRENT_H=1 -DHAVE_SYS_WAIT_H=1 -DTIME_WITH_SYS_TIME=1 -DHAVE_VPRINTF=1 -DHAVE__BOOL=1 -DHAVE_STDBOOL_H=1 -DHAVE_ALLOCA_H=1 -DHAVE_ALLOCA=1 -DHAVE_SSIZE_T=1 -DHAVE_PTRDIFF_T=1 -DSIZEOF_SHORT=2 -DSIZEOF_INT=4 -DSIZEOF_LONG=8 -DSIZEOF_FLOAT=4 -DSIZEOF_DOUBLE=8 -DSIZEOF_OFF_T=8 -DSIZEOF_SIZE_T=8 -DSIZEOF_PTRDIFF_T=8 -I.   -I//home/agahirpa/local/include -I. -g -O2 -fallow-argument-mismatch -c -o module_netcdf_nf_data.lo module_netcdf_nf_data.F90
libtool: compile:  gfortran -DPACKAGE_NAME=\"netCDF-Fortran\" -DPACKAGE_TARNAME=\"netcdf-fortran\" -DPACKAGE_VERSION=\"4.6.1\" "-DPACKAGE_STRING=\"netCDF-Fortran 4.6.1\"" -DPACKAGE_BUGREPORT=\"support-netcdf@unidata.ucar.edu\" -DPACKAGE_URL=\"\" -DPACKAGE=\"netcdf-fortran\" -DVERSION=\"4.6.1\" -DNF_RELAX_COORD_BOUND=1 -DENABLE_CDF5=1 -DNF_HAS_QUANTIZE=1 -DHAVE_F2008=1 -DHAVE_TS29113_SUPPORT=1 -DTEMP_LARGE=\".\" -DHAVE_STDIO_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_UNISTD_H=1 -DHAVE_SYS_TIME_H=1 -DSTDC_HEADERS=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DNF_INT1_T=byte "-DNF_INT2_T=integer*2" "-DNF_INT8_T=integer*8" -DNF_INT1_IS_C_SIGNED_CHAR=1 -DNF_INT2_IS_C_SHORT=1 -DNF_INT8_IS_C_LONG_LONG=1 -DNF_INT_IS_C_INT=1 -DNF_REAL_IS_C_FLOAT=1 -DNF_DOUBLEPRECISION_IS_C_DOUBLE=1 -DNCBYTE_T=byte "-DNCSHORT_T=integer*2" -DHAVE_LIBM=1 -DHAVE_NETCDF_H=1 -DHAVE_NC_DEF_OPAQUE=1 -DHAVE_NCCREATE=1 -DHAVE_NC_SET_LOG_LEVEL=1 -DHAVE_NC_DEF_VAR_SZIP=1 -DLOGGING=1 -DHAVE_SYS_PARAM_H=1 -DHAVE_LOCALE_H=1 -DHAVE_STDIO_H=1 -DHAVE_STDARG_H=1 -DHAVE_ERRNO_H=1 -DHAVE_CTYPE_H=1 -DHAVE_FCNTL_H=1 -DHAVE_MALLOC_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_STRINGS_H=1 -DHAVE_UNISTD_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_GETOPT_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_SYS_RESOURCE_H=1 -DHAVE_DIRENT_H=1 -DHAVE_SYS_WAIT_H=1 -DTIME_WITH_SYS_TIME=1 -DHAVE_VPRINTF=1 -DHAVE__BOOL=1 -DHAVE_STDBOOL_H=1 -DHAVE_ALLOCA_H=1 -DHAVE_ALLOCA=1 -DHAVE_SSIZE_T=1 -DHAVE_PTRDIFF_T=1 -DSIZEOF_SHORT=2 -DSIZEOF_INT=4 -DSIZEOF_LONG=8 -DSIZEOF_FLOAT=4 -DSIZEOF_DOUBLE=8 -DSIZEOF_OFF_T=8 -DSIZEOF_SIZE_T=8 -DSIZEOF_PTRDIFF_T=8 -I. -I//home/agahirpa/local/include -I. -g -O2 -fallow-argument-mismatch -c module_netcdf_nf_data.F90  -fPIC -o .libs/module_netcdf_nf_data.o
module_netcdf_nf_data.F90:167:54:

  167 |  Integer, Parameter :: NF_NOQUANTIZE   = NC_NOQUANTIZE
      |                                                      1
Error: Symbol 'nc_noquantize' at (1) has no IMPLICIT type; did you mean 'nf_noquantize'?
module_netcdf_nf_data.F90:168:67:

  168 |  Integer, Parameter :: NF_QUANTIZE_BITGROOM  = NC_QUANTIZE_BITGROOM
      |                                                                   1
Error: Symbol 'nc_quantize_bitgroom' at (1) has no IMPLICIT type; did you mean 'nf_quantize_bitgroom'?
make[1]: *** [Makefile:766: module_netcdf_nf_data.lo] Error 1
make[1]: Leaving directory '/home/agahirpa/WRF-Hydro/netcdf-fortran-4.6.1/fortran'
make: *** [Makefile:588: check-recursive] Error 1

I used the following: CPPFLAGS=-I//home/agahirpa/local/include LDFLAGS="-L/home/agahirpa/local/lib -Wl,-rpath,/home/agahirpa/local/lib -lnetcdf" ./configure --prefix=/home/agahirpa/local --disable-dependency-tracking

with the output from nc-config --all is below. The netcdf-c was compiled with:

$ ./configure --prefix=/home/agahirpa/local --disable-netcdf-4 --disable-dap
$ make check install
This netCDF 4.9.2 has been built with the following features:

  --cc            -> gcc
  --cflags        -> -I/home/agahirpa/local/include
  --libs          -> -L/home/agahirpa/local/lib -lnetcdf
  --static        -> -lm -lsz -lxml2 -lcurl
  --has-dap          -> no
  --has-dap2         -> no
  --has-dap4         -> no
  --has-nc2          -> yes
  --has-nc4          -> yes
  --has-hdf5         -> no
  --has-hdf4         -> no
  --has-logging      -> no
  --has-pnetcdf      -> no
  --has-szlib        -> yes
  --has-cdf5         -> yes
  --has-parallel4    -> no
  --has-parallel     -> no
  --has-nczarr       -> yes
  --has-zstd         -> no
  --has-benchmarks   -> no
  --has-multifilters -> yes
  --has-stdfilters   -> deflate bz2
  --has-quantize     -> yes

  --prefix           -> /home/agahirpa/local
  --includedir       -> /home/agahirpa/local/include
  --libdir           -> /home/agahirpa/local/lib
  --plugindir        ->
  --version          -> netCDF 4.9.2

I don't know what I did wrong.

WardF commented 10 months ago

This should be working, so it is a little unusual that it's not. Can you attach the config.log file generated when you run configure on netCDF-Fortran 4.6.1? You may need to rename it to config.log.txt in order for GitHub to accept it as an upload.

agahirpa commented 10 months ago

This should be working, so it is a little unusual that it's not. Can you attach the config.log file generated when you run configure on netCDF-Fortran 4.6.1? You may need to rename it to config.log.txt in order for GitHub to accept it as an upload.

Thank you for looking into this. Attached is the config log file config.log.txt

jshn9515 commented 10 months ago

I have the same problem compiling netcdf-fortran-4.6.1 with netcdf-c 4.9.2 on CentOS 7.9.

WardF commented 10 months ago

Thank you; I'm still trying to sort out what is going on here, insofar as I've been unable to replicate the issue as of yet. From the config.log file you provided, @agahirpa, it looks like you're using Ubuntu 22.02 under WSL on a Windows host. Is this correct? @jshn9515 would you be able to provide your config.log file as well?

agahirpa commented 10 months ago

Thank you; I'm still trying to sort out what is going on here, insofar as I've been unable to replicate the issue as of yet. From the config.log file you provided, @agahirpa, it looks like you're using Ubuntu 22.02 under WSL on a Windows host. Is this correct? @jshn9515 would you be able to provide your config.log file as well?

@WardF that is correct: I am using Ubuntu 22.02 under WSL on a Window.

jshn9515 commented 10 months ago

Thank you for looking this. I think it is similar to #414. config.log.txt

After setting NF_NOQUANTIZE to 0 and NF_QUANTIZE_BITGROOM to 1, the issue was resolved. However, another error occurred:

netcdf.F90:47:2:

 #include "netcdf_externals.f90"
  1~~~~~~~~~~~~~~~~~~~~~
Fatal Error: netcdf_constants.f90: No such file or directory
compilation terminated.
make[1]: *** [Makefile:766: netcdf.lo] Error 1

The include statements are .f90 but the actual files are .F90.

jshn9515 commented 10 months ago

After completing the following steps, the compilation is successful, and all tests have passed:

  1. Change all occurrences of .f90 to .F90 in the include statements within netcdf.F90.
  2. Add #define USE_NETCDF4 before #ifdef USE_NETCDF4 in module_netcdf_nc_data.F90.
  3. Copy typeSizes.F90 and save as module_typesizes.F90.
WardF commented 10 months ago

Thanks @jshn9515 I am taking a look at making these changes, thanks!

agahirpa commented 10 months ago

Thanks a lot!

jshn9515 commented 8 months ago

Well... I finally find out the reason I receive these errors is that I had built the NetCDF-C library with the --disable-netcdf-4 option, which caused the NetCDF-Fortran library to be unable to find the USE_NETCDF4 symbol. Once I built NetCDF-C without this option, the original code was able to run without any need for modification.

Rdfing commented 8 months ago

Well... I finally find out the reason I receive these errors is that I had built the NetCDF-C library with the --disable-netcdf-4 option, which caused the NetCDF-Fortran library to be unable to find the USE_NETCDF4 symbol. Once I built NetCDF-C without this option, the original code was able to run without any need for modification.

By any chance you find a solution for this issue? I ran into the same problem. But in my case, even I build the NetCDF-C with netCDF-4, the make check in the NetCDF-F still complains

jshn9515 commented 8 months ago

I have no idea about that. Maybe you can open a new issue and describe that problem.

Rdfing commented 8 months ago

I have no idea about that. Maybe you can open a new issue and describe that problem.

Do you mind sharing your method for compiling the NetCDF 4.9.2 and NetCDF-fortran-4.6.1?

Thanks

jshn9515 commented 8 months ago

I built them on CentOS 7.9 with GCC 11.2.1. For NetCDF-C:

ZDIR=/usr/local
H5DIR=/usr/local
NCDIR=/usr/local
CPPFLAGS='-I${H5DIR}/include -I${ZDIR}/include'
LDFLAGS='-L${H5DIR}/lib -L${ZDIR}/lib'
./configure --prefix=${NCDIR}
make -j 4
make check
make install

And for NetCDF-Fortran:

NCDIR=/usr/local
NFDIR=/usr/local
CC=/usr/local/cc
FC=/usr/local/fortran
CPPFLAGS=-I${NCDIR}/include
LDFLAGS=-L${NCDIR}/lib
./configure --prefix=${NFDIR}
make -j 4
make check
make install

By the way, make sure all the dependencies have been installed correctly with all tests passed.