Beispiel #1
0
static int xtc_header(XDR *xd, int *magic, int *natoms, int64_t *step, real *time,
                      gmx_bool bRead, gmx_bool *bOK)
{
    int result;

    if (xdr_int(xd, magic) == 0)
    {
        return 0;
    }
    result = XTC_CHECK("natoms", xdr_int(xd, natoms)); /* number of atoms */
    if (result)
    {
        /* Note that XTC wasn't defined to be extensible, so we can't
         * fix the fact that we used xdr_int for the step number,
         * which is defined to be signed and 32 bit. */
        int intStep = *step;
        result = XTC_CHECK("step",   xdr_int(xd, &intStep)); /* frame number    */
        *step  = intStep;
    }
    if (result)
    {
        result = XTC_CHECK("time",   xdr_r2f(xd, time, bRead)); /* time */
    }
    *bOK = (result != 0);

    return result;
}
Beispiel #2
0
static int xtc_coord(XDR *xd, int *natoms, rvec *box, rvec *x, real *prec, gmx_bool bRead)
{
    int    i, j, result;
#if GMX_DOUBLE
    float *ftmp;
    float  fprec;
#endif

    /* box */
    result = 1;
    for (i = 0; ((i < DIM) && result); i++)
    {
        for (j = 0; ((j < DIM) && result); j++)
        {
            result = XTC_CHECK("box", xdr_r2f(xd, &(box[i][j]), bRead));
        }
    }

    if (!result)
    {
        return result;
    }

#if GMX_DOUBLE
    /* allocate temp. single-precision array */
    snew(ftmp, (*natoms)*DIM);

    /* Copy data to temp. array if writing */
    if (!bRead)
    {
        for (i = 0; (i < *natoms); i++)
        {
            ftmp[DIM*i+XX] = x[i][XX];
            ftmp[DIM*i+YY] = x[i][YY];
            ftmp[DIM*i+ZZ] = x[i][ZZ];
        }
        fprec = *prec;
    }
    result = XTC_CHECK("x", xdr3dfcoord(xd, ftmp, natoms, &fprec));

    /* Copy from temp. array if reading */
    if (bRead)
    {
        for (i = 0; (i < *natoms); i++)
        {
            x[i][XX] = ftmp[DIM*i+XX];
            x[i][YY] = ftmp[DIM*i+YY];
            x[i][ZZ] = ftmp[DIM*i+ZZ];
        }
        *prec = fprec;
    }
    sfree(ftmp);
#else
    result = XTC_CHECK("x", xdr3dfcoord(xd, x[0], natoms, prec));
#endif

    return result;
}
Beispiel #3
0
static int xtc_header(XDR *xd,int *magic,int *natoms,int *step,real *time,
		      bool bRead,bool *bOK)
{
  int result;

  if (xdr_int(xd,magic) == 0)
    return 0;
  result=XTC_CHECK("natoms", xdr_int(xd,natoms));  /* number of atoms */
  if (result)
    result=XTC_CHECK("step",   xdr_int(xd,step));    /* frame number    */
  if (result)
    result=XTC_CHECK("time",   xdr_r2f(xd,time,bRead));   /* time */
  *bOK=(result!=0);

  return result;
}