小编Mar*_*cel的帖子

MPI_Gather 在最基本的代码中给出了段错误

我正在开发一个更大的程序,在那里我与 MPI_Gather 斗争。

我写了一个最小的示例代码,见下文。

 program test
  use MPI
  integer :: ierr, rank, size
  double precision, allocatable, dimension(:) :: send, recv

  call MPI_Init(ierr)

  call MPI_Comm_size(MPI_COMM_WORLD, size, ierr)
  if (ierr /= 0) print *, 'Error in MPI_Comm_size'
  call MPI_Comm_rank(MPI_COMM_WORLD, rank, ierr)
  if (ierr /= 0) print *, 'Error in MPI_Comm_size'

  allocate(send(1), recv(size))

  send(1) = rank

  call MPI_Gather(send, 1, MPI_DOUBLE_PRECISION, &
                  recv, 1, MPI_DOUBLE_PRECISION, 0, MPI_COMM_WORLD)
  print *, recv
  call MPI_Finalize(ierr)
end program test
Run Code Online (Sandbox Code Playgroud)

当(有 2 个节点)我得到以下错误输出。

[jorvik:13887] *** Process received signal *** …
Run Code Online (Sandbox Code Playgroud)

fortran mpi

2
推荐指数
1
解决办法
649
查看次数

f2py - 函数参数的顺序混乱

我编写了一个小型 Fortran 函数,并使用 f2py 在 Python 中向它传递参数。不知怎的,参数的顺序在传输过程中被搞乱了,我不明白为什么。

Fortran 函数的相关部分(位于名为 calc_密度.f95 的文件中):

subroutine calc_density(position, nparticles, ncells, L, density)

implicit none

integer, intent(in) :: nparticles
integer, intent(in) :: ncells
double precision, intent(in) :: L
double precision, dimension(nparticles), intent(in) :: position
double precision, dimension(ncells), intent(out) :: density

double precision :: sumBuf, offSum
integer :: pLower, pUpper, pBuf, numBuf, last, idx
double precision, dimension(nparticles) :: sorted

 print *, 'Fortran ', 'position length ', size(position), &
  'density length ', size(density), 'nparticles ', nparticles, &
  'ncells …
Run Code Online (Sandbox Code Playgroud)

python fortran f2py

2
推荐指数
1
解决办法
1006
查看次数

标签 统计

fortran ×2

f2py ×1

mpi ×1

python ×1