CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   Error at host: floating point exception (https://www.cfd-online.com/Forums/fluent/207296-error-host-floating-point-exception.html)

chi86 September 26, 2018 12:00

Error at host: floating point exception
 
Hi,
i have a problem when I run an UDF in paralell and write data to a file, here is the code:


Code:

DEFINE_EXECUTE_AT_END(execute_at_end)
{

#if !RP_HOST
    /* cell_t c; */
    face_t face;
    Thread *t;
    Domain *d;

    real position[ND_ND];
    real Avec[ND_ND];
    float x, y, z;
    float temp;
#else
    int i;
#endif

#if PARALLEL

    int size;  /* data passing variables */
    real *array;
    int pe;
#endif

#if !RP_NODE /* SERIAL or HOST */
       
        FILE *f_file;
        char filename[32];
        int i_curr_ts;

        snprintf(filename, sizeof(char) * 32, "ts_%d.txt", i_curr_ts);

        if ((f_file = fopen(filename, "w"))==NULL)
          Message("\n Warning: Unable to open %s for writing\n",filename);
        else
          Message("\nWriting Pressure to %s...\n",filename);

#endif


    i_curr_ts =i_curr_ts+1;


    if(time_ges>=30)
      {


#if RP_NODE /* This is now for parallel */

        d = Get_Domain(1);
        t = Lookup_Thread(d, 11);

        size=THREAD_N_ELEMENTS_INT(t);
        array = (real *)malloc(7 * size * sizeof(real)); /* 7 rows */

        begin_f_loop(face, t)
          {
            F_CENTROID(position, face, t);
        F_AREA(Avec, face, t);
            /* vol = C_VOLUME(c,t); */

            temp = F_T(face, t);

            x = position[0];
            y = position[1];
            z = position[2];

        array[face]= x;
        array[face+size]= y;
        array[face+size*2]= z;
        array[face+size*3]= temp;
        array[face+size*4]= Avec[0];
        array[face+size*5]= Avec[1];
        array[face+size*6]= Avec[2];

          }
        end_f_loop(face, t)

          pe = (I_AM_NODE_ZERO_P) ? node_host : node_zero;



        PRF_CSEND_INT(pe, &size, 1, myid);

        free(array);/* free array on nodes once data sent */

        if (I_AM_NODE_ZERO_P)
          compute_node_loop_not_zero (pe)
          {
            PRF_CRECV_INT(pe, &size, 1, pe);
        Message("aaaaaaaaaaaaaaaa %d\n",size);

          }
#endif /* RP_NODE */
       
       
      }
}

The problem is in the passing function of the variable size but I have no idea why it crashes. Any ideas?


All times are GMT -4. The time now is 10:42.