【问题标题】:compilation error with MPI_type_create_resized in Fortran 90Fortran 90 中 MPI_type_create_resized 的编译错误
【发布时间】:2013-04-20 22:44:13
【问题描述】:

我需要在 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

【问题讨论】:

    标签: compiler-construction mpi intel fortran90


    【解决方案1】:

    这是编译器对参数类型的挑剔,这是一件好事;这里的下限和范围必须是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
    

    【讨论】:

    • 谢谢,乔纳森。这修复了来自英特尔 MPI 的警告消息。您知道如何修复来自 OpenMPI 的错误消息吗?非常感谢。
    • 同一个原因;以上对我来说适用于带有英特尔编译器的 openmpi v1.4.4 和 1.6.4 以及英特尔 mpi。
    • 更改后我仍然收到相同的错误。我用 openmpi v1.4.3 和 v1.6.0 进行了测试。报错提示没有匹配 MPI_type_create_resized 的子程序,很奇怪。
    • 乔纳森,我没有改变下界的常数。在我更改之后,它修复了错误。非常感谢。
    • 为了清楚起见,编译器无法匹配子例程的原因是它找不到具有适当类型参数的子例程版本。 OpenMPI 的 fortran 绑定在这方面比 IntelMPI 更麻烦,这通常是一件好事,即使有时会很烦人。
    猜你喜欢
    • 1970-01-01
    • 2014-02-24
    • 1970-01-01
    • 2015-08-07
    • 1970-01-01
    • 2020-01-09
    • 2014-08-28
    • 1970-01-01
    • 2020-03-19
    相关资源
    最近更新 更多