2

我需要在 Fortran 90 代码中使用非连续块分散二维数组。在调用 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
4

1 回答 1

3

这是编译器对参数类型的挑剔,这是一件好事;这里的下界和范围必须是 kind 的整数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
于 2013-04-26T17:24:34.463 回答