AGRIF doesn't compile with gcc15 due to conflicting types

Hi,

when compiling an AGRIF configuration (e.g. AGRIF_DEMO) using GCC 15 (which appears to be more restrict than previous versions) it fails with the following error message:

.../nemo/ext/AGRIF/LIB/UtilFortran.c:266:6: error: conflicting types for 'Write_Closing_Module'; have 'void(int)'
  266 | void Write_Closing_Module(int forend)
      |      ^~~~~~~~~~~~~~~~~~~~
In file included from .../nemo/ext/AGRIF/LIB/UtilFortran.c:38:
.../nemo/ext/AGRIF/LIB/decl.h:535:13: note: previous declaration of 'Write_Closing_Module' with type 'void(void)'
  535 | extern void Write_Closing_Module();
      |             ^~~~~~~~~~~~~~~~~~~~

This is in NEMO5; tested different branches including main.

A fix or guidance on how to fix this is appreciated.

Best regards
Franziska

Can you try this modification in ext/AGRIF/LIB/decl.h

-extern void Write_Closing_Module();
+extern void Write_Closing_Module(int forend);

Thanks a lot @smasson!
That was quick and it works!

I expected more conflicts of that kind to appear with all the similar definitions in decl.h but apparently this was the only one really running into a conflict.

Side note: some „type mismatches" occur down the road, which I turned from errors into warnings through compiler flags, so this seems to be OK, at least for compilation but should probably be fixed at some point.

I am happy to see that it works!
I personally still encounter compilation errors that appear to be macOS-specific :weary_face:

/Users/smasson/codes/nemo_main/mk/agrifpp.sh: line 73: 86018 Trace/BPT trap: 5       ${MYDIR}/conv ${MYDIR}/agrif_oce.in -rm -incdir ${MYDIR}/inc -comdirout ${MYDIR}/obj -convfile ${MYFILE}
fcm_internal compile failed (34048)
make: *** [/Users/smasson/codes/nemo_main/cfgs/AGRIF_DEMO/BLD_SCT_AGRIF/Makefile:608: dom_oce.f90] Error 1
make -s -f /Users/smasson/codes/nemo_main/cfgs/AGRIF_DEMO/BLD_SCT_AGRIF/Makefile -j 1 all failed (2) at /Users/smasson/codes/nemo_main/ext/FCM/bin/../lib/Fcm/Build.pm line 597.

Could you give us more details about the “type mismatches” you had?
Which versions compiler flags did you use?

To turn type mismatches into warnings, I use -fallow-argument-mismatch
Below I share my full list of compiler options, which I’ve been already using with gcc14 and older versions (that did not yet complain about the conflicting types).
Particularly zero-initialization and fcommon were mandatory (see my earlier ticket).

The type mismatches occur in ext/AGRIF/AGRIF_FILES/ modmpp.F90, modinterp.F90 and modupdate.F90 with

.../nemo/cfgs/AGRIF_DEMO/BLD/ppsrc/agrif/modmpp.f90:348:22:

  348 |         call MPI_SEND(sendtoproc(k),1,MPI_LOGICAL,k,etiquette,Agrif_mpi_comm,code)
      |                      1
......
  683 |     call MPI_SEND( tab3D( imin(1):imax(1),  &
      |                   2   
Warning: Type mismatch between actual argument at (1) and actual argument at (2) (LOGICAL(4)/REAL(8)).
...nemo/cfgs/AGRIF_DEMO/BLD/ppsrc/agrif/modmpp.f90:361:22:

  361 |         call MPI_RECV(res,1,MPI_LOGICAL,k,etiquette,Agrif_mpi_comm,statut,code)
      |                      1
......
  523 |                 call MPI_RECV(temprecv%array1,datasize,Agrif_MPI_prec,k,etiquette, &
      |                              2
Warning: Type mismatch between actual argument at (1) and actual argument at (2) (LOGICAL(4)/REAL(8)).
.../nemo/cfgs/AGRIF_DEMO/BLD/ppsrc/agrif/modinterp.f90:732:27:

  711 |         call MPI_ALLGATHER(tab3,4*nbdim,MPI_INTEGER,tab4,4*nbdim,MPI_INTEGER,Agrif_mpi_comm,code)
      |                           2
......
  732 |         call MPI_ALLGATHER(memberin1,1,MPI_LOGICAL,memberinall,1,MPI_LOGICAL,Agrif_mpi_comm,code)
      |                           1
Warning: Type mismatch between actual argument at (1) and actual argument at (2) (LOGICAL(4)/INTEGER(4)).
.../nemo/cfgs/AGRIF_DEMO/BLD/ppsrc/agrif/modinterp.f90:732:51:

  711 |         call MPI_ALLGATHER(tab3,4*nbdim,MPI_INTEGER,tab4,4*nbdim,MPI_INTEGER,Agrif_mpi_comm,code)
      |                                                    2
......
  732 |         call MPI_ALLGATHER(memberin1,1,MPI_LOGICAL,memberinall,1,MPI_LOGICAL,Agrif_mpi_comm,code)
      |                                                   1
Warning: Type mismatch between actual argument at (1) and actual argument at (2) (LOGICAL(4)/INTEGER(4)).
.../nemo/cfgs/AGRIF_DEMO/BLD/ppsrc/agrif/modupdate.f90:677:27:

  665 |         call MPI_ALLGATHER(tab3,4*nbdim,MPI_INTEGER,tab4,4*nbdim,MPI_INTEGER,Agrif_mpi_comm,code)
      |                           2
......
  677 |         call MPI_ALLGATHER(memberin1,1,MPI_LOGICAL,memberinall,1,MPI_LOGICAL,Agrif_mpi_comm,code)
      |                           1
Warning: Type mismatch between actual argument at (1) and actual argument at (2) (LOGICAL(4)/INTEGER(4)).
.../nemo/cfgs/AGRIF_DEMO/BLD/ppsrc/agrif/modupdate.f90:677:51:

  665 |         call MPI_ALLGATHER(tab3,4*nbdim,MPI_INTEGER,tab4,4*nbdim,MPI_INTEGER,Agrif_mpi_comm,code)
      |                                                    2
......
  677 |         call MPI_ALLGATHER(memberin1,1,MPI_LOGICAL,memberinall,1,MPI_LOGICAL,Agrif_mpi_comm,code)
      |                                                   1
Warning: Type mismatch between actual argument at (1) and actual argument at (2) (LOGICAL(4)/INTEGER(4)).

arch.fcm

%NCDF_INC            -I%NCDF_HOME/include -I%HDF5_HOME/include
%NCDF_LIB            -L%HDF5_HOME/lib -L%NCDF_HOME/lib -L%NCDF_C_HOME/lib -lnetcdf -lnetcdff -lhdf5 -lz
%XIOS_INC            -I%XIOS_HOME/inc
%XIOS_LIB            -L%XIOS_HOME/lib -lxios -lstdc++


# key_nosignedzero required by NEMO5
%CPP                 cpp -P -Dkey_nosignedzero
%FC                  mpif90
%FCFLAGS             -O1 -fdefault-real-8 -ffree-line-length-none  -fallow-argument-mismatch  -finit-local-zero -finit-integer=0 -finit-real=zero -g -fbacktrace

%FFLAGS              %FCFLAGS
%LD                  mpif90
%FPPFLAGS            -P -traditional
%LDFLAGS             -Wl,--allow-multiple-definition 
%AR                  ar
%ARFLAGS             -r
%MK                  gmake
%USER_INC            %XIOS_INC %NCDF_INC
%USER_LIB            %XIOS_LIB %NCDF_LIB

%CC                  mpicc
%CFLAGS              -O0 -fcommon 

I’m using gcc 15.2.0, openmpi 5.0.10, netcdf-fortran 4.6.2