We have a large Fortran + MPI program with separate component modules that use either mpi or mpi_f08 to access MPI functionality. Even when everything is kept private, if another module tries to use both, we get the following compilation error:
mpif90 -c mpi_mix.F90 -o mpi_mix.o
NVFORTRAN-S-0166-mpi_fortran_weights_empty cannot be a common block and a subprogram (mpi_mix.F90)
NVFORTRAN-S-0166-mpi_fortran_unweighted cannot be a common block and a subprogram (mpi_mix.F90)
NVFORTRAN-S-0166-mpi_fortran_statuses_ignore cannot be a common block and a subprogram (mpi_mix.F90)
NVFORTRAN-S-0166-mpi_fortran_status_ignore cannot be a common block and a subprogram (mpi_mix.F90)
NVFORTRAN-S-0166-mpi_fortran_errcodes_ignore cannot be a common block and a subprogram (mpi_mix.F90)
NVFORTRAN-S-0166-mpi_fortran_argvs_null cannot be a common block and a subprogram (mpi_mix.F90)
NVFORTRAN-S-0166-mpi_fortran_argv_null cannot be a common block and a subprogram (mpi_mix.F90)
NVFORTRAN-S-0166-mpi_fortran_in_place cannot be a common block and a subprogram (mpi_mix.F90)
NVFORTRAN-S-0166-mpi_fortran_bottom cannot be a common block and a subprogram (mpi_mix.F90)
0 inform, 0 warnings, 9 severes, 0 fatal for mod1
The smallest single-file program that we found to reproduce the problem is the following:
! mpi_mpi.F90
module recent
use mpi_f08
implicit none
private
end module recent
module old
use mpi
implicit none
private
end module old
In our build system, modules recent and old are actually compiled separately, and any module that uses both of them produces the compilation error. Is that the expected behavior?
We have tried with AOCC, LLVM, Intel and GCC compilers, and they all seem fine with that code.
As additional information, we saw that the two different object files contain the same symbols:
$ nm recent.o
0000000000000000 T mod1_
0000000000000001 C mpi_fortran_argv_null_
0000000000000001 C mpi_fortran_argvs_null_
0000000000000004 C mpi_fortran_bottom_
0000000000000004 C mpi_fortran_errcodes_ignore_
0000000000000004 C mpi_fortran_in_place_
0000000000000018 C mpi_fortran_statuses_ignore_
0000000000000018 C mpi_fortran_status_ignore_
0000000000000004 C mpi_fortran_unweighted_
0000000000000004 C mpi_fortran_weights_empty_
$ nm old.o
0000000000000000 T mod1_
0000000000000001 C mpi_fortran_argv_null_
0000000000000001 C mpi_fortran_argvs_null_
0000000000000004 C mpi_fortran_bottom_
0000000000000004 C mpi_fortran_errcodes_ignore_
0000000000000004 C mpi_fortran_in_place_
0000000000000018 C mpi_fortran_statuses_ignore_
0000000000000018 C mpi_fortran_status_ignore_
0000000000000004 C mpi_fortran_unweighted_
0000000000000004 C mpi_fortran_weights_empty_
Any help is appreciated!