Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

develop fails to compile with gfortran10 due to missing -fallow-argument-mismatch compile flag #463

Closed
edwardhartnett opened this issue Apr 27, 2021 · 10 comments
Assignees
Labels

Comments

@edwardhartnett
Copy link
Collaborator

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?

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
@kgerheiser
Copy link
Contributor

Are you using GCC 10? It looks like the thing where you have to add fallow-argument-mismatch?

@kgerheiser
Copy link
Contributor

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

@edwardhartnett
Copy link
Collaborator Author

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?

@edwardhartnett edwardhartnett changed the title develop fails to compile? develop fails to compile with gfortran10 due to missing -fallow-argument-mismatch compile flag Apr 27, 2021
@kgerheiser
Copy link
Contributor

Instead of use mpi, we need to use use mpi_f08 for the correct interfaces.

@edwardhartnett
Copy link
Collaborator Author

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$ 

@kgerheiser
Copy link
Contributor

Hmm, I thought mpi_f08 might fix it because it has all the overloaded interfaces. Maybe not.

@kgerheiser
Copy link
Contributor

kgerheiser commented Apr 28, 2021

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.

@edwardhartnett
Copy link
Collaborator Author

Surely one can call two different overloads of the same function...

@kgerheiser
Copy link
Contributor

kgerheiser commented Apr 28, 2021

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.

@edwardhartnett
Copy link
Collaborator Author

I have opened a new issue to figure out how to compile without this flag. Now the flag is turned on for gfortran10,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants