Closed edwardhartnett closed 3 years ago
Are you using GCC 10? It looks like the thing where you have to add fallow-argument-mismatch
?
Global cycle and a few of the other utilities have
if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 10)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch")
endif()
But not chgres_cube
Ah ha! That's it of course.
I will add the flag to our CMake build.
And how are we going to resolve this so we don't need the flag?
Instead of use mpi
, we need to use use mpi_f08
for the correct interfaces.
When I change it to use mpi_f08 (which is recommended) it fails like this:
[ 51%] Building Fortran object sorc/chgres_cube.fd/CMakeFiles/chgres_cube_lib.dir/model_grid.F90.o
cd /home/ed/UFS_UTILS/b/sorc/chgres_cube.fd && /usr/bin/gfortran -I/usr/local/NCEPLIBS-nemsio-2.5.1/include -I/usr/local/NCEPLIBS-sfcio-1.4.0/include -I/usr/local/NCEPLIBS-sigio-2.3.0/include -I/usr/local/NCEPLIBS-bacio-2.4.1/include_4 -I/usr/local/NCEPLIBS-sp-2.3.3/include_d -I/usr/local/w3nco-2.4.0/include_d -I/home/ed/esmf/mod -I/home/ed/esmf/include -I/usr/local/netcdf-fortran-4.5.3_netcdf-c-4.7.4/include -I/usr/include -I/usr/local/NCEPLIBS-wgrib2-2.9.0/include -I/usr/local/include -g -fbacktrace -ffree-line-length-0 -fdefault-real-8 -fconvert=big-endian -O3 -Jmod -c /home/ed/UFS_UTILS/sorc/chgres_cube.fd/model_grid.F90 -o CMakeFiles/chgres_cube_lib.dir/model_grid.F90.o
/home/ed/UFS_UTILS/sorc/chgres_cube.fd/model_grid.F90:1061:22:
855 | call MPI_BCAST(temp_num,10,MPI_CHAR,0,MPI_COMM_WORLD,error)
| 2
......
1061 | call MPI_BCAST(dx,1,MPI_REAL8,0,MPI_COMM_WORLD,error)
| 1
Error: Type mismatch between actual argument at (1) and actual argument at (2) (REAL(8)/CHARACTER(*)).
make[2]: *** [sorc/chgres_cube.fd/CMakeFiles/chgres_cube_lib.dir/build.make:119: sorc/chgres_cube.fd/CMakeFiles/chgres_cube_lib.dir/model_grid.F90.o] Error 1
make[2]: Leaving directory '/home/ed/UFS_UTILS/b'
make[1]: *** [CMakeFiles/Makefile2:1913: sorc/chgres_cube.fd/CMakeFiles/chgres_cube_lib.dir/all] Error 2
make[1]: Leaving directory '/home/ed/UFS_UTILS/b'
make: *** [Makefile:158: all] Error 2
(base) ed@mikado:~/UFS_UTILS/b$
Hmm, I thought mpi_f08
might fix it because it has all the overloaded interfaces. Maybe not.
Could be MPI variant specific. What's happening is that there's an implicit interface and it picks up MPI_BCAST
in the first call taking a character(*)
and infers the interface from that, and then later on MPI_BCAST
is called with a real(8)
, but they don't match, and there's two non-overloaded interfaces taking different kinds of arguments.
Surely one can call two different overloads of the same function...
That's what confuses me. Using use mpi
or use mpi_f08
(but not mpi.h
) should provide explicit overloaded interfaces to MPI_BCAST
, but it seems like MPI_BCAST
is being picked up as an implicit external
function (without an interface).
And because the routine has no interface the compiler will infer that the function takes whatever you pass to it, but when it sees it called in two different contexts it throws the error.
I have opened a new issue to figure out how to compile without this flag. Now the flag is turned on for gfortran10,
For some reason the develop branch is not compiling for me today.
What am I doing wrong? Do I need a more recent version of one of my libraries?