找回密码
 注册
查看: 2047|回复: 0

使用host_to_node还是PRF_CSEND_REAL的疑问

[复制链接]
发表于 2016-6-13 20:37:40 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
本帖最后由 blgy 于 2016-6-13 20:37 编辑

求助!
问题描述:
我的udf单机能运行,现将单机的修改为并行的。程序是别人写的,写的时候考虑了并行,估计没有在并行条件下测试。我在并行条件下编译后,出现警告,查找原因是出现在host_to_node的使用上。
程序中出现错误的语句。
  host_to_node_real(rsec,200);
  host_to_node_real(csec,200);
  host_to_node_real(twst,200);
  host_to_node_string(type,6000);

还有其他同样适用host_to_node的语句没有问题。程序中没有错误的语句
host_to_node_int(fzon,10);
host_to_node_int(nsec,10);
对比发现是变量的问题。

程序开始定义的变量如下:
real rsec[10][20];                                 /*Normalizes radius from GUI*/
real csec[10][20];                                 /*Chord at normalized sectional radius (GUI)*/
real twst[10][20];                 /*Twist*/
char type[10][20][30];             /*Profile type name */

int fzon[10];                      /*Rotor face zone ID*/
int nsec[10];                      /*Number of blade sections along span*/

因此是定义的变量数组维数的问题,host_to_node传递的变量数据是一维数组,而二维数组和三维数组不能传递。查看UDFmanual,发现是这样描述的:
High-level communication macros of the form node_to_host... and host_to_node... that are
described in Communicating Between the Host and Node Processes (p. 468) are typically used when
you want to send data from the host to all of the compute nodes, or from node-0 to the host. You
cannot, however, use these high-level macros when you need to pass data between compute nodes,
or pass data from all of the compute nodes to compute node-0. In these cases, you can use special
message passing macros described in this section.
Note that the higher-level communication macros expand to functions that perform a number of lowerlevel message passing operations which send sections of data as single arrays from one process to another process. These lower-level message passing macros can be easily identified in the macro name
by the characters SEND and RECV. Macros that are used to send data to processes have the prefix
PRF_CSEND, whereas macros that are used to receive data from processes have the prefix PRF_CRECV.
Data that is to be sent or received can belong to the following data types: character (CHAR), integer
(INT), REAL and logical (BOOLEAN). BOOLEAN variables are TRUE or FALSE. REAL variables are assigned
as float data types when running a single precision version of ANSYS Fluent and double when
running double precision. Message passing macros are defined in the prf.h header file and are listed
below.
/* message passing macros */
PRF_CSEND_CHAR(to, buffer, nelem, tag)
PRF_CRECV_CHAR (from, buffer, nelem, tag)
PRF_CSEND_INT(to, buffer, nelem, tag)
PRF_CRECV_INT(from, buffer, nelem, tag)
PRF_CSEND_REAL(to, buffer, nelem, tag)
PRF_CRECV_REAL(from, buffer, nelem, tag)
PRF_CSEND_BOOLEAN(to, buffer, nelem, tag)
PRF_CRECV_BOOLEAN(from, buffer, nelem, tag)
There are four arguments to the message-passing macros. For ‘send’ messages:
• to is the node ID of the process that data is being sent to.
• buffer is the name of an array of the appropriate type that will be sent.
• nelem is the number of elements in the array.
• tag is a user-defined message tag. The tag convention is to use myid when sending messages.

看意思是说得需要使用PRF_CSEND macros ,但是看帮助没有弄明白怎么使用,求助万能网友给点指点。

求助问题 如下:
1 二维数组real rsec[10][20],host_to_node_real(rsec,200)如何修改,使用PRF_CSEND还是PRF_CRECV。
2 三维数组char type[10][20][30],host_to_node_string(type,6000)如何修改,使用PRF_CSEND还是PRF_CRECV。

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表