Issue building nccmp with GCC 10.1
I think I might have encountered an issue building nccmp with GCC 10.1 (and netCDF 4.7.4 if it matters). To wit, when I try and build:
mpicc -I.. -I/Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.12-Snap13/src//netcdf/include -I/Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.12-Snap13/src//netcdf/libsrc4 -D_THREAD_SAFE -pthread -D_THREAD_SAFE -pthread -o nccmp nccmp-log.o nccmp-nccmp.o nccmp-xmalloc.o nccmp-nccmp_buffer.o nccmp-nccmp_data.o nccmp-nccmp_darray.o nccmp-nccmp_darray_sort.o nccmp-nccmp_dim.o nccmp-nccmp_format.o nccmp-nccmp_group.o nccmp-nccmp_io.o nccmp-nccmp_metadata.o nccmp-nccmp_nc_type.o nccmp-nccmp_ncinfo.o nccmp-nccmp_nest.o nccmp-nccmp_odometer.o nccmp-nccmp_opt.o nccmp-nccmp_state.o nccmp-nccmp_stats.o nccmp-nccmp_stats_print.o nccmp-nccmp_strlist.o nccmp-nccmp_utils.o nccmp-nccmp_user_type.o nccmp-nccmp_var.o -lnetcdf -lm -lnetcdf -lm -L/Users/mathomp4/installed/MPI/gcc-gfortran-10.1.0/openmpi-4.0.3/Baselibs/6.0.12-Snap13/Darwin/lib -L/Users/mathomp4/installed/MPI/gcc-gfortran-10.1.0/openmpi-4.0.3/Baselibs/6.0.12-Snap13/Darwin/lib -lnetcdf -ljpeg -lmfhdf -ldf -ljpeg -lhdf5_hl -lhdf5 -lm -L/Users/mathomp4/installed/MPI/gcc-gfortran-10.1.0/openmpi-4.0.3/Baselibs/6.0.12-Snap13/Darwin/lib -lmfhdf -ldf -lsz -ljpeg -L/Users/mathomp4/installed/MPI/gcc-gfortran-10.1.0/openmpi-4.0.3/Baselibs/6.0.12-Snap13/Darwin/lib -lcurl -lz -lm -ldl -lm -L/Users/mathomp4/installed/MPI/gcc-gfortran-10.1.0/openmpi-4.0.3/Baselibs/6.0.12-Snap13/Darwin/lib -lcurl -lz -lm -lexpat -lmfhdf -ldf -lsz -ljpeg -ldl -lm
duplicate symbol '_mutex_print' in:
nccmp-nccmp_data.o
nccmp-nccmp_group.o
duplicate symbol '_mutex_print' in:
nccmp-nccmp_data.o
nccmp-nccmp_metadata.o
ld: 2 duplicate symbols for architecture x86_64
collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:393: nccmp] Error 1
make[3]: Leaving directory '/Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.12-Snap13/src/nccmp/src'
make[2]: *** [Makefile:379: install-recursive] Error 1
This does look similar to a bug I filed with netCDF-C where Dennis Heimbigner (amongst all the other issues I was having) found a real issue with GCC 10.1:
Second, the duplicate symbol error is actually correct. My surmise is that gcc 9 either recognizes that the two declarations are the same, or issues a warning -- but since I do not see it in the output you sent, it is probably the former. In any case, gcc 9 and gcc 10 are handling this different. I will issue a patch, but in the meantime, you can try the following:
FInd the following line in ncdump/ocprint,c (about line 59)
int ocdebug;
Change that line to this:
extern int ocdebug;
My guess is nccmp needs an extern
somewhere? (Or I guess netCDF uses EXTERNL
but whatever. I'm a Fortran coder.