Intel MPI_SIZEOF 不适用于 Fortran 复杂类型

Fad*_*mic 3 fortran mpi intel-fortran

给出以下 Fortran 代码:

integer, parameter :: double = kind(1.0d0)

integer :: integerTest
real(double) :: doubleTest
complex(double) :: complexTest
integer :: testSize
integer :: ierr

integerTest = 0
doubleTest = real(0.d0, kind=double)
complexTest = cmplx(0.d0, 0.d0, kind=double)

call MPI_SIZEOF(integerTest, testSize, ierr)
! ...
call MPI_SIZEOF(doubleTest, testSize, ierr)
! ...
call MPI_SIZEOF(complexTest, testSize, ierr)
Run Code Online (Sandbox Code Playgroud)

使用 Intel MPI 编译时,出现错误:

error #6285: There is no matching specific subroutine for this generic subroutine call. [MPI_SIZEOF]
Run Code Online (Sandbox Code Playgroud)

在线上

 call MPI_SIZEOF(complexTest, testSize, ierr)
Run Code Online (Sandbox Code Playgroud)

使用 OpenMPI 编译和执行此代码不会出现任何问题。出现这个错误的原因是什么?看起来它正在寻找 类型的特定匹配complexTest,但是 的全部意义不就是MPI_SIZEOF与几乎任何类型通用吗?

Vla*_*r F 6

可能是 MPI 库中的错误,他们可能忘记将此特定功能添加到模块中。顺便说一句,“几乎任何类型”肯定是错误的,MPI_SIZEOF仅适用于内在类型。

作为解决方法,您可以使用

testSize = storage_size(complexTest) / character_storage_size
Run Code Online (Sandbox Code Playgroud)

(要不就/ 8

  • 确实如此,但上面的句子是“任何 Fortran 内在类型”。我冒昧地从英特尔 MPI 5.1 中反转了“mpi_sizeofs.mod”(希望英特尔不会起诉我),并且从特定子例程的名称来看,我猜测通用接受“INTEGER”、“REAL”的标量和一维数组对于“X”,`、`逻辑`、`字符`、`复杂`、`双精度`、`整数*1`、`整数*2`和`整数*8`。 (2认同)