MPI在Fortran 90中使用指针发送派生数据类型 [英] MPI send derived data type with pointer in Fortran 90

查看:142
本文介绍了MPI在Fortran 90中使用指针发送派生数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将用户定义的数据类型发送为:

I would like to send a user defined data type as:

TYPE CELL
    INTEGER :: NUM
    TYPE(CELL), POINTER :: NEXT => NULL()
END TYPE CELL

TYPE CELLLIST
    INTEGER :: NBCELL
    TYPE(CELL), POINTER :: BEGIN => NULL()
END TYPE CELLLIST

,由MPI发送的变量定义为:

and the variable to be sent by MPI is defined as:

TYPE(CELLLIST) :: _CELLLIST

在此变量中,_CELLIST%NBCELL表示列表的长度,而CELL类型的指针指向列表的开头.

In this variable, _CELLIST%NBCELL denotes the length of the list, and a pointer of type CELL points to the head of the list.

我想使用MPI_send和MPI_recv通过MPI传输单元格列表.该怎么做?

I'd like to use MPI_send and MPI_recv to transfer the cell list via MPI. How to do that?

推荐答案

将指针从一个MPI进程发送到另一个MPI进程是毫无意义的.

Sending pointers from one MPI process to another is pointless.

问题在于,它们(指针)是特定于进程的.可以将指针视为存储目标内存地址的指针,这是一个合理的类比.该内存地址不是可移植的,没有一个进程的地址空间中的地址与另一进程的地址空间中的地址相同的概念.

The problem is that they, pointers, are process-specific. It's a reasonable analogy to think of a pointer as storing the memory address of its target. That memory address isn't portable, there is no concept of an address in one process's address space being the same as an address in another process's address space.

您将必须解开_CELLLIST中的指针链,通过CELLS发送,然后在目标进程上重建指针链.

You will have to unravel the chain of pointers in your _CELLLIST, send across the CELLS, then rebuild the pointer chain on the target process(es).

我想您可以将CELLS打包到一个数组中以进行传输.或者,您可能一次发送一个CELL,但前提是接收过程将按照接收包含CELL的消息的顺序重建动态数据结构.

I suppose that you might pack the CELLS into an array for transfer. Or you might send one CELL at a time on the understanding that the receiving process(es) will rebuild the dynamic data structure in the order in which it receives the messages containing the CELLs.

这篇关于MPI在Fortran 90中使用指针发送派生数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆