Fortran 2008 中的 MPI 通信器类型

问题描述 投票:0回答:1

我一直在尝试构建一个应用程序,它似乎混合使用

mpi_f08
的文件和使用
mpi
的文件。问题是它无法编译某些 MPI 调用。我花了一段时间才发现真正的问题是通信器数据类型:

error #6285: There is no matching specific subroutine for this generic subroutine call. [MPI_BCAST]

这是摘录的部分:

module submod
  use mpi_f08
  implicit none

contains

  subroutine callmpi(pe, nproc, comm)
    integer :: pe,nproc
    integer :: comm
    integer :: ierr
    integer :: sbuf
    sbuf = 0
    call mpi_bcast( sbuf, 1, mpi_integer, 0, comm, ierr )
  end subroutine callmpi

end module submod

comm
数据类型从
integer
更改为
type(mpi_comm)
可以解决该问题。现在,应用程序很大,我想知道是否有一个编译器标志(英特尔)可以在不修改代码的情况下完成此操作。

fortran mpi intel-fortran
1个回答
0
投票

编译器标志并不神奇。

在 Fortran 2008 MPI 绑定中,如前所述,

MPI_Bcast
的接口与“旧版”Fortran 绑定不兼容。 (MPI 标准)
mpi_f08
模块不提供通用
MPI_Bcast
以及与此其他绑定匹配的特定过程。

Fortran 编译器不知道如何将整数映射到不同的类型,并且期望 Fortran 编译器能够处理特殊情况的 MPI 是极端的。

现在,您修改了

use mpi
(或
include 'mpi.f'
)代码以移至
use mpi_f08
,以便您可以进行进一步修改。要将代码库增量更新为 Fortran 2008 绑定,您可以使用如下技术:

  use mpi_f08, MPI_Bcast_unported => MPI_Bcast
  use mpi, only : MPI_Bcast

  call MPI_Init        ! F2008 binding, with optional ierror absent
  call MPI_Bcast(...)  ! Pre-F2008 binding call
© www.soinside.com 2019 - 2024. All rights reserved.