示例#1
0
void rewind_trj(t_trxstatus *status)
{
    initcount(status);

    gmx_fio_rewind(status->fio);
}
示例#2
0
ener_file_t open_enx(const char *fn,const char *mode)
{
    int        nre,i;
    gmx_enxnm_t *nms=NULL;
    int        file_version=-1;
    t_enxframe *fr;
    gmx_bool       bWrongPrecision,bOK=TRUE;
    struct ener_file *ef;

    snew(ef,1);

    if (mode[0]=='r') {
        ef->fio=gmx_fio_open(fn,mode);
        gmx_fio_checktype(ef->fio);
        gmx_fio_setprecision(ef->fio,FALSE);
        do_enxnms(ef,&nre,&nms);
        snew(fr,1);
        do_eheader(ef,&file_version,fr,nre,&bWrongPrecision,&bOK);
        if(!bOK)
        {
            gmx_file("Cannot read energy file header. Corrupt file?");
        }

        /* Now check whether this file is in single precision */
        if (!bWrongPrecision &&
            ((fr->e_size && (fr->nre == nre) && 
              (nre*4*(long int)sizeof(float) == fr->e_size)) ) )
        {
            fprintf(stderr,"Opened %s as single precision energy file\n",fn);
            free_enxnms(nre,nms);
        }
        else
        {
            gmx_fio_rewind(ef->fio);
            gmx_fio_checktype(ef->fio);
            gmx_fio_setprecision(ef->fio,TRUE);
            do_enxnms(ef,&nre,&nms);
            do_eheader(ef,&file_version,fr,nre,&bWrongPrecision,&bOK);
            if(!bOK)
            {
                gmx_file("Cannot write energy file header; maybe you are out of quota?");
            }

            if (((fr->e_size && (fr->nre == nre) && 
                            (nre*4*(long int)sizeof(double) == fr->e_size)) ))
                fprintf(stderr,"Opened %s as double precision energy file\n",
                        fn);
            else {
                if (empty_file(fn))
                    gmx_fatal(FARGS,"File %s is empty",fn);
                else
                    gmx_fatal(FARGS,"Energy file %s not recognized, maybe different CPU?",
                              fn);
            }
            free_enxnms(nre,nms);
        }
        free_enxframe(fr);
        sfree(fr);
        gmx_fio_rewind(ef->fio);
    }
    else 
        ef->fio = gmx_fio_open(fn,mode);

    ef->framenr=0;
    ef->frametime=0;
    return ef;
}
示例#3
0
文件: enxio.c 项目: Chadi-akel/cere
int open_enx(char *fn,char *mode)
{
  int        fp,nre,i;
  char       **nm=NULL;
  t_enxframe *fr;
  bool       bDum=TRUE;
  
  /* Energy files should always be opened as binary files,
   * but that is checked in gmx_fio_open.
   */

  if (mode[0]=='r') {
    fp=gmx_fio_open(fn,mode);
    gmx_fio_select(fp);
    gmx_fio_setprecision(fp,FALSE);
    do_enxnms(fp,&nre,&nm);
    snew(fr,1);
    do_eheader(fp,fr,&bDum);
    
    /* Now check whether this file is in single precision */
    if (((fr->e_size && (fr->nre == nre) && 
	  (nre*4*sizeof(float) == fr->e_size)) ||
	 (fr->d_size && 
	  (fr->ndisre*sizeof(float)*2+sizeof(int) == fr->d_size)))){
      fprintf(stderr,"Opened %s as single precision energy file\n",fn);
      for(i=0; (i<nre); i++)
	sfree(nm[i]);
      sfree(nm);
    }
    else {
      gmx_fio_rewind(fp);
      gmx_fio_select(fp);
      gmx_fio_setprecision(fp,TRUE);
      do_enxnms(fp,&nre,&nm);
      do_eheader(fp,fr,&bDum);
      if (((fr->e_size && (fr->nre == nre) && 
	    (nre*4*sizeof(double) == fr->e_size)) ||
	   (fr->d_size && 
	    (fr->ndisre*sizeof(double)*2+sizeof(int) == fr->d_size))))
	fprintf(stderr,"Opened %s as double precision energy file\n",fn);
      else {
	if (empty_file(fn))
	  fatal_error(0,"File %s is empty",fn);
	else
	  fatal_error(0,"Energy file %s not recognized, maybe different CPU?",
		      fn);
      }
      for(i=0; (i<nre); i++)
	  sfree(nm[i]);
      sfree(nm);
    }
    free_enxframe(fr);
    sfree(fr);
    gmx_fio_rewind(fp);
  }
  else 
    fp = gmx_fio_open(fn,mode);
    
  framenr=0;
    
  return fp;
}
示例#4
0
文件: enxio.c 项目: aar2163/GROMACS
int open_enx(const char *fn,const char *mode)
{
  int        fp,nre,i;
  gmx_enxnm_t *nms=NULL;
  int        file_version=-1;
  t_enxframe *fr;
  bool       bDum=TRUE;

  if (mode[0]=='r') {
    fp=gmx_fio_open(fn,mode);
    gmx_fio_select(fp);
    gmx_fio_setprecision(fp,FALSE);
    do_enxnms(fp,&nre,&nms);
    snew(fr,1);
    do_eheader(fp,&file_version,fr,TRUE,&bDum);
	if(!bDum)
	{
		gmx_file("Cannot read energy file header. Corrupt file?");
	}
	  
    /* Now check whether this file is in single precision */
    if (((fr->e_size && (fr->nre == nre) && 
	  (nre*4*sizeof(float) == fr->e_size)) ||
	 (fr->d_size && 
	  (fr->ndisre*sizeof(float)*2+sizeof(int) == fr->d_size)))){
      fprintf(stderr,"Opened %s as single precision energy file\n",fn);
      free_enxnms(nre,nms);
    }
    else {
      gmx_fio_rewind(fp);
      gmx_fio_select(fp);
      gmx_fio_setprecision(fp,TRUE);
      do_enxnms(fp,&nre,&nms);
      do_eheader(fp,&file_version,fr,TRUE,&bDum);
  	  if(!bDum)
	  {
		  gmx_file("Cannot write energy file header; maybe you are out of quota?");
	  }
		
      if (((fr->e_size && (fr->nre == nre) && 
	    (nre*4*sizeof(double) == fr->e_size)) ||
	   (fr->d_size && 
	    (fr->ndisre*sizeof(double)*2+sizeof(int) == fr->d_size))))
	fprintf(stderr,"Opened %s as double precision energy file\n",fn);
      else {
	if (empty_file(fn))
	  gmx_fatal(FARGS,"File %s is empty",fn);
	else
	  gmx_fatal(FARGS,"Energy file %s not recognized, maybe different CPU?",
		      fn);
      }
      free_enxnms(nre,nms);
    }
    free_enxframe(fr);
    sfree(fr);
    gmx_fio_rewind(fp);
  }
  else 
    fp = gmx_fio_open(fn,mode);
    
  framenr=0;
  frametime=0;

  return fp;
}