Unidata / netcdf-fortran

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

double include in parallel tests #182

Open edhartnett opened 5 years ago

edhartnett commented 5 years ago

From Chris H. at NOAA:

I’m seeing another failure, this time a compile problem, for netcdf-fortran 4.4.5. This only happens when it’s built with parallel support from HDF5 and with OpenMPI. What is happening is that builds during “make check” of:

nf_test/f90tst_parallel.F90 nf_test/f90tst_parallel2.F90 nf_test/f90tst_parallel3.F90

die with a bunch of messages about "Ambiguous generic interface MPI_SIZEOF”. Here is one such example, but there are a bunch:

libtool: link: mpif90 -fPIC -I../fortran -g -Wl,-rpath -Wl,/scratch4/BMC/gsd-hpcs/Christopher.W.Harrop/bass-develop/opt/netcdf/4.7.0/intel/17.0.5.239/openmpi/4.0.1/lib -o .libs/tst_io tst_io.o -L/scratch4/BMC/gsd-hpcs/Christopher.W.Harrop/bass-develop/opt/netcdf/4.7.0/intel/17.0.5.239/openmpi/4.0.1/lib ../fort ran/.libs/libnetcdff.so -lz -lcurl -lm /scratch4/BMC/gsd-hpcs/Christopher.W.Harrop/bass-develop/opt/netcdf/4.7.0/intel/17.0.5.239/openmpi/4.0.1/lib/libnetcdf.so -Wl,-rpath -Wl,/scratch4/BMC/gsd-hpcs/Christopher.W.Harrop/bass-develop/opt/netcdf/4.7.0/intel/17.0.5.239/openmpi/4.0.1/lib mpif90 -fPIC -DHAVE_CONFIG_H -I. -I.. -I../libsrc -I../fortran -I../fortran -DpgiFortran -I/scratch4/BMC/gsd-hpcs/Christopher.W.Harrop/bass-develop/opt/netcdf/4.7.0/intel/17.0.5.239/openmpi/4.0.1/include -I../fortran -g -c -o f90tst_parallel.o f90tst_parallel.F90 /scratch4/BMC/gsd-hpcs/Christopher.W.Harrop/bass-develop/opt/openmpi/4.0.1/intel/17.0.5.239/include/mpif-sizeof.h(17): error #5286: Ambiguous generic interface MPI_SIZEOF: previously declared specific procedure MPI_SIZEOF_CHARACTER_SCALAR is not distinguishable from this declaration. [MPI_SIZEOF_CHARACTER_SCALA R] SUBROUTINE MPI_Sizeof_character_scalar(x, size, ierror) -----------------^

I have figured out that there are two very simple ways to fix this, but I’m not familiar wth the NetCDF development process to know if the team would consider this a bug. The problem is that in these programs mpif.h is being included twice. Once in the main program, and once in the test subroutine. The problem goes away if those includes are changed to “use mpi” or if the include is removed from the contained subroutine.

For example, my commenting out the include fixes the issue:

contains ! This subroutine handles errors by printing an error message and
! exiting with a non-zero status.
subroutine handle_err(errcode) use netcdf implicit none integer, intent(in) :: errcode

if(errcode /= nf90_noerr) then
   print *, 'Error: ', trim(nf90_strerror(errcode))
   stop 2
endif

end subroutine handle_err

subroutine parallel_io(mode_flag) use typeSizes use netcdf implicit none ! include 'mpif.h'

What is your take on this? Genuine bug (why are they using an “include" instead of a “use" for a f90 test, and why is it included twice in the same scope)?

I didn’t have issues with any other MPI implementation or any other compiler. So, not sure what to think about that.

ghost commented 5 years ago

I got the same error. I simply comment out the second `include' and it worked.

edhartnett commented 5 years ago

Genuine bug. I will fix.

edhartnett commented 5 years ago

OK, the problem is, without the second 'include' then my build fails like this:

mpifort -DPACKAGE_NAME=\"netCDF-Fortran\" -DPACKAGE_TARNAME=\"netcdf-fortran\" -DPACKAGE_VERSION=\"4.5.0-development\" -DPACKAGE_STRING=\"netCDF-Fortran\ 4.5.0-development\" -DPACKAGE_BUGREPORT=\"support-netcdf@unidata.ucar.edu\" -DPACKAGE_URL=\"\" -DPACKAGE=\"netcdf-fortran\" -DVERSION=\"4.5.0-development\" -DNF_RELAX_COORD_BOUND=1 -DENABLE_CDF5=1 -DNF_HAS_PARALLEL4=1 -DHAVE_F2008=1 -DHAVE_TS29113_SUPPORT=1 -DTEMP_LARGE=\".\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTT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 -DSIZEOF_PTRDIFF_T=8 -I.  -I../fortran -I/usr/local/netcdf-c-4.7.0-development_mpich-3.2/include  -g -O2 -c -o f03tst_parallel.o f03tst_parallel.F
f03tst_parallel.F:73:39:

       call MPI_Comm_rank(MPI_COMM_WORLD, my_rank, ierr)
                                       1
Error: Symbol ‘mpi_comm_world’ at (1) has no IMPLICIT type
f03tst_parallel.F:84:24:

      $     MPI_INFO_NULL, ncid)
                        1
Error: Symbol ‘mpi_info_null’ at (1) has no IMPLICIT type
Makefile:985: recipe for target 'f03tst_parallel.o' failed
make[2]: *** [f03tst_parallel.o] Error 1
make[2]: Leaving directory '/home/ed/tmp/netcdf-fortran/nf_test4'
Makefile:1441: recipe for target 'check-am' failed
make[1]: *** [check-am] Error 2
make[1]: Leaving directory '/home/ed/tmp/netcdf-fortran/nf_test4'
Makefile:1444: recipe for target 'check' failed
make: *** [check] Error 2

So now I don't know what to do...

ghost commented 5 years ago

Just for your reference, I use ifort wrapped by openmpi (mpifort) to compile the program, then the second `include' is extraneous. It might be a compiler dependent issue.