Failed to Build CRTM using ecbuild

I was trying to build CRTM from this GitHub - JCSDA/crtm-bundle: Bundle containing all the repositories that are needed to compile CRTM v2.4.0. in a Linux workstation 20.04. Upon trying what is suggested in the README file, i.e. sh ./kickstart_pyCRTM.sh, I was shown this error.

– [crtm] (2.4.0) [8bf1007]
– Found OpenMP_Fortran: -fopenmp (found version “4.5”)
– Found OpenMP: True (found version “4.5”) found components: Fortran
CMake Error at /usr/share/cmake-3.16/Modules/FindPackgeHandleStandardArgs.cmake:146 (message):
Could NOT find NetCDF (missing: NetCDF_INCLUDE_DIRS NetCDF_LIBRARIES Fortran)
Call Stack (most recent call first):
/usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
/usr/share/ecbuild/cmake/FindNetCDF.cmake:168 (find_package_handle_standard_args)
crtm/CMakeLists.txt: 21 (find_package)

I edited the shell script and added these flags in the ecbuild line:
ecbuild -DNetCDF_INCLUDE_DIRS=/home/user/Documents/netcdf/ -DNetCDF_LIBRARIES=/home/user/Documents/netcdf/lib/ …/

But now I was shown this error:

– [crtm] (2.4.0) [8bf1007]
– Found OpenMP_Fortran: -fopenmp (found version “4.5”)
– Found OpenMP: True (found version “4.5”) found components: Fortran
CMake Error at /usr/share/cmake-3.16/Modules/FindPackgeHandleStandardArgs.cmake:146 (message):
Could NOT find NetCDF (missing: Fortran) (found version “4.7.2”)
Call Stack (most recent call first):
/usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
/usr/share/ecbuild/cmake/FindNetCDF.cmake:168 (find_package_handle_standard_args)
crtm/CMakeLists.txt: 21 (find_package)

However, the gfortran installed in my system is 9.4.0 (the 4.7.2 seems to be the version for my NetCDF). So I don’t know what version was found nor how to correct this error. I don’t even know if this is an error for CRTM or for CMake.

If there is any more information required, I can gladly provide them. Thank you!

Hello @cce_space , welcome to the forum!

This looks like ecbuild not being able to find the Fortran API of NetCDF:

This could have multiple reasons. Can you first check that the NetCDF Fortran API is available on your system and then that you are able to link it in an application?

@cce_space welcome!

Could NOT find NetCDF (missing: Fortran) (found version “4.7.2”)

Follow up on this error and the comment above, could you please also share the file names in your netCDF library folder? i.e.: /home/user/Documents/netcdf/lib/

Thank you for the replies.

For checking the NetCDF Fortran API available on the system, I ran nf-config --all, and this showed.

This netCDF-Fortran 4.5.2 has been built with the following features: 

  --cc        -> gcc
  --cflags    ->  -I/home/user/Documents/netcdf/include -I/home/user/Documents/include -I/home/user/Documents/netcdf/include -I/home/user/Documents/grib2/include

  --fc        -> gfortran
  --fflags    -> -I/home/user/Documents/netcdf/include
  --flibs     -> -L/home/user/Documents/netcdf/lib -lnetcdff -L/home/user/Documents/lib -L/home/user/Documents/netcdf/lib -L/home/user/Documents/grib2/lib -lnetcdf -ldl -lm -lnetcdf -lhdf5_hl -lhdf5 -lz
  --has-f90   -> 
  --has-f03   -> yes

  --has-nc2   -> yes
  --has-nc4   -> yes

  --prefix    -> /home/user/Documents/netcdf
  --includedir-> /home/user/Documents/netcdf/include
  --version   -> netCDF-Fortran 4.5.2

For linking the NetCDF Fortran to an application, I just copied a sample NetCDF-Fortran code from here: NetCDF | Programming in Modern Fortran, and then compiled them using

gfortran -I/home/user/Documents/netcdf/include/ -L/home/user/Documents/netcdf/lib/ -o example example.f90 -lnetcdff

It gave the expected results.

Data to be written to NetCDF file:
----------------------------------------------------------------
   0   1   2   3   4   5   6   7   8   9  10  11
   6   7   8   9  10  11  12  13  14  15  16  17
  12  13  14  15  16  17  18  19  20  21  22  23
  18  19  20  21  22  23  24  25  26  27  28  29
  24  25  26  27  28  29  30  31  32  33  34  35
  30  31  32  33  34  35  36  37  38  39  40  41
----------------------------------------------------------------

Data read from NetCDF file:
----------------------------------------------------------------
   0   1   2   3   4   5   6   7   8   9  10  11
   6   7   8   9  10  11  12  13  14  15  16  17
  12  13  14  15  16  17  18  19  20  21  22  23
  18  19  20  21  22  23  24  25  26  27  28  29
  24  25  26  27  28  29  30  31  32  33  34  35
  30  31  32  33  34  35  36  37  38  39  40  41
----------------------------------------------------------------

Here are the contents of the /netcdf/lib/ folder,

libnetcdf.a    libnetcdff.so        libnetcdf.la        libnetcdf.so.15
libnetcdff.a   libnetcdff.so.7      libnetcdf.settings  libnetcdf.so.15.2.0
libnetcdff.la  libnetcdff.so.7.0.0  libnetcdf.so        pkgconfig

And the contents of pkgconfig

netcdf-fortran.pc  netcdf.pc
2 Likes

Thank you for the information.
Could you please check which version of ecbuild are you using? Thanks.

The ecbuild is 3.1.0, while the cmake is 3.16.3.

@cce_space can you try upgrading to:

ecbuild version 3.3.2
cmake version 3.26.3

Sometimes that fixes that sort of problem.

Good day, I apologise for the late reply, I was away on the weekend.

I upgraded my ecbuild to 3.3.2 and cmake to 3.26.3, unfortunately the problem still persists.

CMake Error at /snap/cmake/1288/share/cmake-3.26/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find NetCDF (missing: NetCDF_INCLUDE_DIRS NetCDF_LIBRARIES
  Fortran)
Call Stack (most recent call first):
  /snap/cmake/1288/share/cmake-3.26/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  /home/essmsd/Documents/ecbuild/share/ecbuild/cmake/FindNetCDF.cmake:168 (find_package_handle_standard_args)
  crtm/CMakeLists.txt:21 (find_package)

Did you already try to build the crtm on its own (i.e. not the bundle)?