gpt4 book ai didi

compiler-construction - Fortran 90 中 MPI_type_create_resized 的编译错误

转载 作者:行者123 更新时间:2023-12-04 05:00:05 24 4
gpt4 key购买 nike

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

最佳答案

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

关于compiler-construction - Fortran 90 中 MPI_type_create_resized 的编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16241852/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com