我需要在 Fortran 90 代码中分散具有不连续块的 2D 数组。在调用 MPI_SCATTER 之前,代码需要调用 MPI_TYPE_CREATE_RESIZED 来更改新向量类型的边界和扩展。我使用的编译器是Intel XE 12.1。
使用英特尔 MPI 时,代码编译良好,但带有警告消息,我认为它不应该在那里:
mpiifort -c test.f90
test.f90(21): warning #6075: The data type of the actual argument does not match the definition. [EXTENT]
call MPI_TYPE_CREATE_RESIZED(oldtype, 1, extent, newtype, ierr)
-----------------------------------------^
使用 OpenMPI 时,编译终止并出现错误:
mpif90 -c test.f90
test.f90(21): error #6285: There is no matching specific subroutine for this generic subroutine call. [MPI_TYPE_CREATE_RESIZED]
call MPI_TYPE_CREATE_RESIZED(oldtype, 1, extent, newtype, ierr)
-----^
compilation aborted for test.f90 (code 1)
这是 OpenMPI 中的错误吗?有人知道如何修复它吗?谢谢。
下面贴出测试代码:
program test
!
USE MPI
implicit none
!
integer :: numprocs, ierr, status(MPI_STATUS_SIZE)
integer :: rows, cols
integer :: typesize, extent, oldtype, newtype
!=============================================================
!
call MPI_INIT( ierr )
call MPI_COMM_SIZE( MPI_COMM_WORLD, numprocs, ierr )
!
cols = 8
!
rows = cols
!
call MPI_TYPE_VECTOR(cols, rows/numprocs, rows, MPI_REAL8, oldtype, ierr)
call MPI_TYPE_SIZE(MPI_REAL8, typesize, ierr)
extent = rows/numprocs*typesize
call MPI_TYPE_CREATE_RESIZED(oldtype, 1, extent, newtype, ierr)
call MPI_TYPE_COMMIT(newtype, ierr)
!
call MPI_TYPE_FREE(oldtype, ierr)
call MPI_TYPE_FREE(newtype, ierr)
call MPI_FINALIZE(ierr)
stop
end
这是编译器对参数类型的挑剔,这是一件好事;这里的下界和范围必须是
MPI_ADDRESS_KIND
类型的整数。 所以这有效:
program test
!
USE MPI
implicit none
!
integer :: numprocs, ierr, status(MPI_STATUS_SIZE)
integer :: rows, cols, typesize
integer(kind=mpi_address_kind) :: lb, extent
integer :: oldtype, newtype
!=============================================================
!
call MPI_INIT( ierr )
call MPI_COMM_SIZE( MPI_COMM_WORLD, numprocs, ierr )
!
cols = 8
!
rows = cols
!
call MPI_TYPE_VECTOR(cols, rows/numprocs, rows, MPI_REAL8, oldtype, ierr)
call MPI_TYPE_SIZE(MPI_REAL8, typesize, ierr)
extent = rows/numprocs*typesize
lb = 1
call MPI_TYPE_CREATE_RESIZED(oldtype, lb, extent, newtype, ierr)
call MPI_TYPE_COMMIT(newtype, ierr)
!
call MPI_TYPE_FREE(oldtype, ierr)
call MPI_TYPE_FREE(newtype, ierr)
call MPI_FINALIZE(ierr)
stop
end