|
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
做了一个并行例子。方盒子里充满流体,计算盒子底部受的压力(合力)——通过on_demand统计。
在消息传递方面(PRF_CSEND和PRF_CRECV)遇到问题。
我的想法是在对各个计算节点的合力作加和以后,通过0节点传递给HOST,然后用HOST存盘。但是,一旦选择以0节点输出(见源程序出问题的语句),机器就停住了。初步看来,好像是0节点没有输出,从而HOST一直处于等待状态。如果不加出问题语句,软件仅仅报警告信息。 哪位老大指点一下?谢谢!
************************************************
#include "udf.h"
#define rho 998.2
#define g 10.0
DEFINE_ON_DEMAND(on_demand)
{
FILE *fp;
real tot_force=0.0;
#if RP_NODE
real NV_VEC(A),NV_VEC(x);
Domain *domain=Get_Domain(1);
face_t f;
int bID=5; /*底面识别号*/
Thread *tfdan = Lookup_Thread(domain, bID);
begin_f_loop(f,tfdan)
if PRINCIPAL_FACE_P(f,tfdan) /*对每个节点统计合力*/
{
F_AREA(A,f,tfdan);
F_CENTROID(x,f,tfdan);
tot_force += F_P(f,tfdan)*A[1];
}
end_f_loop(f,tfdan)
Message0("to start...");
if(I_AM_NODE_ZERO_P) /*出问题的语句*/
{
Message("total force : %f before summary @ partition %d\n", tot_force, myid);
tot_force=PRF_GRSUM1(tot_force); /*对所有节点上的力进行求和*/
Message("begin sending data...\n");
PRF_CSEND_REAL(node_host, &tot_force, 1, myid); /*向HOST传送结果*/
}
#endif
#if RP_HOST
Message("\nbegin receiving data...\n"); /*如果源程序中含有问题的语句,计算界
面显示到此信息,计算停顿*/
PRF_CRECV_REAL(node_zero, &tot_force, 1, node_zero);
Message("\ntotal force: %f @ Partition %d\n", tot_force, myid);
if((fp=fopen("ForceSum.dat","a+"))==NULL)
{
printf("cannot open file\n");
return;
}
fprintf (fp,"%lf, %lf\n",CURRENT_TIME, tot_force);
fclose(fp);
#endif
} |
|