NetCDF library seems broken


#1

With 2017.2r1 I can find those versions of NetCDF:

$ alces gridware search netcdf
main/libs/netcdf/4.3.0         main/libs/netcdf/4.6.0         main/libs/netcdffortran/4.2    main/libs/netcdffortran/4.4.4

Then I installed and loaded this one:

$ alces gridware install main/libs/netcdffortran/4.4.4 --variant 'default'
$ alces module load libs/netcdffortran/4.4.4

The configuration looks good:

$ nf-config --all

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

  --cc        -> /usr/bin/gcc
  --cflags    ->  -I/opt/gridware/depots/u/2feb09/el7/pkg/libs/netcdffortran/4.4.4/gcc-4.8.5+netcdf-4.6.0/include  -I/opt/gridware/depots/u/2feb09/el7/pkg/libs/netcdf/4.6.0/gcc-4.8.5+hdf5_serial-1.8.13/include

  --fc        -> /usr/bin/gfortran
  --fflags    -> -I/opt/gridware/depots/u/2feb09/el7/pkg/libs/netcdffortran/4.4.4/gcc-4.8.5+netcdf-4.6.0/include
  --flibs     -> -L/opt/gridware/depots/u/2feb09/el7/pkg/libs/netcdffortran/4.4.4/gcc-4.8.5+netcdf-4.6.0/lib -lnetcdff   -lnetcdf
  --has-f90   -> no
  --has-f03   -> yes

  --has-nc2   -> no
  --has-nc4   -> no

  --prefix    -> /opt/gridware/depots/u/2feb09/el7/pkg/libs/netcdffortran/4.4.4/gcc-4.8.5+netcdf-4.6.0
  --includedir-> /opt/gridware/depots/u/2feb09/el7/pkg/libs/netcdffortran/4.4.4/gcc-4.8.5+netcdf-4.6.0/include
  --version   -> netCDF-Fortran 4.4.4

However, the actual compilation fails

$ wget https://www.unidata.ucar.edu/software/netcdf/examples/programs/simple_xy_wr.f90
$ gfortran simple_xy_wr.f90 -o test_nc.exe -I/opt/gridware/depots/u/2feb09/el7/pkg/libs/netcdffortran/4.4.4/gcc-4.8.5+netcdf-4.6.0/include -L/opt/gridware/depots/u/2feb09/el7/pkg/libs/netcdffortran/4.4.4/gcc-4.8.5+netcdf-4.6.0/lib -lnetcdff
(error messages...)
/opt/gridware/depots/u/2feb09/el7/pkg/libs/netcdffortran/4.4.4/gcc-4.8.5+netcdf-4.6.0/lib/libnetcdff.so: undefined reference to `nc_put_vara_short'
/opt/gridware/depots/u/2feb09/el7/pkg/libs/netcdffortran/4.4.4/gcc-4.8.5+netcdf-4.6.0/lib/libnetcdff.so: undefined reference to `nc_get_vara_short'
/opt/gridware/depots/u/2feb09/el7/pkg/libs/netcdffortran/4.4.4/gcc-4.8.5+netcdf-4.6.0/lib/libnetcdff.so: undefined reference to `nc_get_att_float'
/opt/gridware/depots/u/2feb09/el7/pkg/libs/netcdffortran/4.4.4/gcc-4.8.5+netcdf-4.6.0/lib/libnetcdff.so: undefined reference to `nc_get_vara_schar'

Other versions (main/libs/netcdffortran/4.2) and variants (netcdf-mpi) also have the same problem. That test script simple_xy_wr.f90 can definitely work on EC2, say following the documentation of our group’s project. I can put our program in containers instead. But I also want to see if alcesflight’s native libraries can give me better performance.

Thanks in advance for the help!


#2

The error message “undefined reference to nc_put_vara_short” is because the NetCDF-Fortran library is trying to find the NetCDF-C library. So I “solved” this problem by also loading the NetCDF-C library:

$alces gridware install libs/netcdf/4.6.0
$alces module load libs/netcdf/4.6.0

And then add both C and Fortran libraries to the compile command:

gfortran simple_xy_wr.f90 -o test_nc.exe -I/opt/gridware/depots/u/2feb09/el7/pkg/libs/netcdffortran/4.4.4/gcc-4.8.5+netcdf-4.6.0/include -L/opt/gridware/depots/u/2feb09/el7/pkg/libs/netcdf/4.6.0/gcc-4.8.5+hdf5_serial-1.8.13/lib -L/opt/gridware/depots/u/2feb09/el7/pkg/libs/netcdffortran/4.4.4/gcc-4.8.5+netcdf-4.6.0/lib -lnetcdf -lnetcdff

However, although NetCDF-Fortran does depend on NetCDF-C at build time, when compiling users’ Fortran programs it shouldn’t be necessary to call the C-library again. There might be something wrong with the netcdf-fortran module in alces gridware.


#3

Hi @JiaweiZhuang,

Thanks for taking the time to let us know about this. I’ll pass the information on to our applications team, and we’ll look to see if there are alternative ways in which NetCDF-Fortran can be compiled such that it doesn’t have a dependency on NetCDF itself.

If you are aware of or determine a better method of compilation, please let us know!

Thanks,

Mark.