Discussion:
[OMPI users] fortran problem when mixing "use mpi" and "use mpi_f08" with gfortran 5
Andrea Negri
2016-05-21 16:17:13 UTC
Permalink
Hi, in the last few days I ported my entire fortran mpi code to "use
mpif_08". You really did a great job with this interface. However,
since HDF5 still uses integers to handle communicators, I have a
module where I still use "use mpi", and with gfortran 5.3.0 and
openmpi-1.10.2 I got some errors.

I have been able to produce an extremely minimalistic example that
reproduces the same errors. If you try to compile with mpifort -c this
file

!==========================================
module test1_mod
! I use ONLY here just to show you that errors happen even with ONLY
use mpi, only: MPI_BARRIER, MPI_COMM_WORLD
implicit none
private
public :: test1
contains
subroutine test1(a)
implicit none
real, intent(inout) :: a
integer :: ierr
a=0
call mpi_barrier(MPI_COMM_WORLD, ierr)
endsubroutine test1
endmodule test1_mod



module prova2
use mpi_f08
implicit none
private
contains
subroutine prova3
use test
implicit none
real :: a

call test1(a)
endsubroutine prova3
endmodule prova2
!==========================================


and I obtain the errors:






use mpi_f08
1
prova.f90:2.4:

use mpi, only: MPI_BARRIER, MPI_COMM_WORLD
2
Error: Variable mpi_argv_null with binding label mpi_fortran_argv_null
at (1) uses the same global identifier as entity at (2)
prova.f90:19.4:

use mpi_f08
1
prova.f90:2.4:

use mpi, only: MPI_BARRIER, MPI_COMM_WORLD
2
Error: Variable mpi_argvs_null with binding label
mpi_fortran_argvs_null at (1) uses the same global identifier as
entity at (2)
prova.f90:19.4:

use mpi_f08
1
prova.f90:2.4:

use mpi, only: MPI_BARRIER, MPI_COMM_WORLD
2
Error: Variable mpi_bottom with binding label mpi_fortran_bottom at
(1) uses the same global identifier as entity at (2)
prova.f90:19.4:

use mpi_f08
1
prova.f90:2.4:

use mpi, only: MPI_BARRIER, MPI_COMM_WORLD
2
Error: Variable mpi_errcodes_ignore with binding label
mpi_fortran_errcodes_ignore at (1) uses the same global identifier as
entity at (2)
prova.f90:19.4:

use mpi_f08
1
prova.f90:2.4:

use mpi, only: MPI_BARRIER, MPI_COMM_WORLD
2
Error: Variable mpi_in_place with binding label mpi_fortran_in_place
at (1) uses the same global identifier as entity at (2)
prova.f90:19.4:

use mpi_f08
1
prova.f90:2.4:

use mpi, only: MPI_BARRIER, MPI_COMM_WORLD
2
Error: Variable mpi_status_ignore with binding label
mpi_fortran_status_ignore at (1) uses the same global identifier as
entity at (2)
prova.f90:19.4:

use mpi_f08
1
prova.f90:2.4:

use mpi, only: MPI_BARRIER, MPI_COMM_WORLD
2
Error: Variable mpi_statuses_ignore with binding label
mpi_fortran_statuses_ignore at (1) uses the same global identifier as
entity at (2)
prova.f90:19.4:

use mpi_f08
1
prova.f90:2.4:

use mpi, only: MPI_BARRIER, MPI_COMM_WORLD
2
Error: Variable mpi_unweighted with binding label
mpi_fortran_unweighted at (1) uses the same global identifier as
entity at (2)
prova.f90:19.4:

use mpi_f08
1
prova.f90:2.4:

use mpi, only: MPI_BARRIER, MPI_COMM_WORLD
2
Error: Variable mpi_weights_empty with binding label
mpi_fortran_weights_empty at (1) uses the same global identifier as
entity at (2)




I don't know if this is a compiler-related issue, since the PRIVATE
statement should mask everything...
Thanks in advance for the help.

Andrea
Jeff Squyres (jsquyres)
2016-05-25 03:46:49 UTC
Permalink
Post by Andrea Negri
Hi, in the last few days I ported my entire fortran mpi code to "use
mpif_08". You really did a great job with this interface. However,
since HDF5 still uses integers to handle communicators, I have a
module where I still use "use mpi", and with gfortran 5.3.0 and
openmpi-1.10.2 I got some errors.
FWIW, you can actually mix integer handles with mpi_f08 handles. The mpi_f08 handles are derived datatypes that contain exactly one member: an integer.

For example, if you call a subroutine with an integer MPI handle as a dummy parameter, and that subroutine has a Type(MPI_Comm)::comm variable, you can assign:

comm%mpi_val = integer_handle

And then use that Type(MPI_Comm) as an mpi_f08 handle.

The opposite is true, too -- you can extract the %mpi_val from an mpi_f08 handle and use it as an integer handle with "use mpi" or mpif.h interfaces.

Meaning: the %mpi_val value is exactly equivalent to the integer handles.
Post by Andrea Negri
I have been able to produce an extremely minimalistic example that
reproduces the same errors. If you try to compile with mpifort -c this
file
I think you had a typo -- it should be "use test1_mod", right?

I expanded your code a little to give it a program, and run it:

-----
!==========================================
module test1_mod
! I use ONLY here just to show you that errors happen even with ONLY
use mpi, only: MPI_BARRIER, MPI_COMM_WORLD
implicit none
private
public :: test1
contains
subroutine test1(a)
implicit none
real, intent(inout) :: a
integer :: ierr
a=0
print *, "Here I am"
call MPI_INIT(ierr)
call mpi_barrier(MPI_COMM_WORLD, ierr)
call MPI_FINALIZE(ierr)
print *, "Done with finalize"
endsubroutine test1
endmodule test1_mod



module prova2
use mpi_f08
implicit none
public :: prova3
contains
subroutine prova3
use test1_mod
implicit none
real :: a

call test1(a)
endsubroutine prova3
endmodule prova2
!==========================================

program doit
use prova2
implicit none

call prova3()
end program doit
-----

I then compiled it with the Intel compiler and ran it:

-----
$ mpifort mix-usempi-usempif08-2.f90 -I. && mpirun -np 2 ./a.out
Here I am
Here I am
Done with finalize
Done with finalize
-----

Now that does not mean that there isn't a bug in OMPI -- I'm just saying that it works with the Intel compiler.

I tried the following:

- Open MPI dev master with icc: works
- Open MPI dev master with gcc 5.2.0: works
- Open MPI v1.10.x head with icc: works
- Open MPI v1.10.x head with gcc 5.2.0: same errors you got
- Open MPI v2.x head with gcc 5.2.0: works

We have clearly changed something since v1.10.x, but I don't know offhand exactly what would have caused this difference.

Is there a chance you can use the Intel compiler? Or the Open MPI v2.0.0 rc?
--
Jeff Squyres
***@cisco.com
For corporate legal information go to: http://www.cisco.com/web/about/doing_business/legal/cri/
Loading...