m.shafiee1374
Subscriber

So I changed my code like this:

DEFINE_ADJUST(name,dom) {
real c[3], Vx, d =1, d_new, d_min ;
real x[3] = {1,2,3} ; /*just an example*/
Thread *c_thread, *ct_min ;
cell_t cell, c_min ;

thread_loop_c(c_thread, dom)
{
    begin_c_loop_int(cell,c_thread)
   {
C_CENTROID(c,cell,c_thread) ;
         d_new = sqrt(pow(c[0]-x[0],2)+pow(c[1]-x[1],2)+pow(c[2]-x[2],2)) ;
         if (d_new < d )
         {
              d = d_new ;
              ct_min = c_thread ;
c_min = cell ;

         }       
    } end_c_loop_int(cell,c_thread)
}
d_min = PRF_GRLOW1(d) ;
if (d == d_min && I_AM_NODE_ZERO_P)           /*this is only true on the compute node with the closest cell*/
{
Vx = C_U(c_min,ct_min) ;

}
if (d == d_min && !I_AM_NODE_ZERO_P)
{
Vx = C_U(c_min,ct_min) ;
PRF_CSEND_REAL(node_zero, &Vx, 1, myid) ;
}
node_to_host_real_1(Vx) ; /*Send values from node zero to host*/
}


Now the problem is that there should be a PRF_CRECV command on node zero to recieve "Vx" from the sending compute node and then send it to host, but I have no idea which node will be sending the value of "Vx" and I can't loop over all the compute nodes since only one of them is sending the value of "Vx".
In other words the "from" arguement in "PRF_CRECV_REAL(from, &Vx, 1,tag)" is not known.