Fortran MPI_Type_vector MPI_ERR_TYPE: invalid datatype


I am trying to run the following Fortran code with 19.4

program main
    use mpi_f08
    implicit none

    integer(kind = 4) :: n
    integer(kind = 4) , dimension(10000) :: a

    integer :: rank, size, to, from, tag, count, i, ierr
    TYPE(MPI_Datatype) :: iguard

    call MPI_INIT( ierr )
    call MPI_COMM_RANK( MPI_COMM_WORLD, rank, ierr )
    call MPI_COMM_SIZE( MPI_COMM_WORLD, size, ierr )
    print *, 'Process ', rank, ' of ', size, ' is alive'

    call MPI_Type_vector(3, 1, -2, MPI_DOUBLE_PRECISION, iguard)
    call MPI_TYPE_COMMIT(iguard, ierr)

    print *, 'Hello, World!'
    call MPI_FINALIZE(ierr)
end program main

but I get the following runtime error:

/opt/openmpi-4.0.1-pgi/bin/mpirun -np 2 ./openacctests_f
Process 0 of 2 is alive
Process 1 of 2 is alive
*** An error occurred in MPI_Type_vector
*** reported by process [899022849,0]
*** on communicator MPI_COMM_WORLD
*** MPI_ERR_TYPE: invalid datatype
*** MPI_ERRORS_ARE_FATAL (processes in this communicator will now abort,
*** and potentially your MPI job)
1 more process has sent help message help-mpi-errors.txt / mpi_errors_are_fatal
Set MCA parameter “orte_base_help_aggregate” to 0 to see all help / error messages

Is it because I use Fortran 2008?

Many thanks!

Hi elavram,

Is it because I use Fortran 2008?

Yes. We don’t support the MPI mpi_f08 module quite yet. Though, this work is underway and we hope to have it supported later this year or early next.