+++ /dev/null
-/*
- *
- * This source code is part of
- *
- * G R O M A C S
- *
- * GROningen MAchine for Chemical Simulations
- *
- * VERSION 3.3.99_development_20071104
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2006, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * If you want to redistribute modifications, please consider that
- * scientific software is very special. Version control is crucial -
- * bugs must be traceable. We will be happy to consider code for
- * inclusion in the official distribution, but derived work must not
- * be called official GROMACS. Details are found in the README & COPYING
- * files - if they are missing, get the official version at www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
- *
- * For more info, check our website at http://www.gromacs.org
- *
- * And Hey:
- * Groningen Machine for Chemical Simulation
- */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
-
-#include "macros.h"
-#include "gromacs/utility/futil.h"
-#include "gromacs/commandline/pargs.h"
-#include "copyrite.h"
-#include "txtdump.h"
-#include "gromacs/utility/fatalerror.h"
-#include "gromacs/fileio/xtcio.h"
-#include "gromacs/fileio/enxio.h"
-#include "gromacs/utility/smalloc.h"
-#include "gromacs/fileio/gmxfio.h"
-#include "gromacs/fileio/tpxio.h"
-#include "gromacs/fileio/trrio.h"
-#include "txtdump.h"
-#include "gromacs/math/vec.h"
-
-static char *nm[5] = { "OW", "HW1", "HW2", "DW", "SW" };
-
-static void list_trn(char *fn)
-{
- static real mass[5] = { 15.9994, 1.008, 1.008, 0.0, 0.0 };
- int i,j=0,m,fpread,fpwrite,nframe;
- rvec *x,*v,*f,fmol[2],xcm[2],torque[j],dx;
- real mmm,len;
- matrix box;
- t_trnheader trn;
- gmx_bool bOK;
-
- printf("Going to open %s\n",fn);
- fpread = open_trn(fn,"r");
- fpwrite = open_tpx(NULL,"w");
-
- mmm=mass[0]+2*mass[1];
- for(i=0; (i<5); i++)
- mass[i] /= mmm;
-
- nframe = 0;
- while (fread_trnheader(fpread,&trn,&bOK)) {
- snew(x,trn.natoms);
- snew(v,trn.natoms);
- snew(f,trn.natoms);
- if (fread_htrn(fpread,&trn,
- trn.box_size ? box : NULL,
- trn.x_size ? x : NULL,
- trn.v_size ? v : NULL,
- trn.f_size ? f : NULL)) {
-
- if (trn.x_size && trn.f_size) {
- printf("There are %d atoms\n",trn.natoms);
- for(j=0; (j<2); j++) {
- clear_rvec(xcm[j]);
- clear_rvec(fmol[j]);
- clear_rvec(torque[j]);
- for(i=5*j; (i<5*j+5); i++) {
- rvec_inc(fmol[j],f[i]);
- for(m=0; (m<DIM); m++)
- xcm[j][m] += mass[i%5]*x[i][m];
- }
- for(i=5*j; (i<5*j+5); i++) {
- rvec_dec(x[i],xcm[j]);
- cprod(x[i],f[i],dx);
- rvec_inc(torque[j],dx);
- rvec_inc(x[i],xcm[j]);
- }
- }
- pr_rvecs(stdout,0,"FMOL ",fmol,2);
- pr_rvecs(stdout,0,"TORQUE",torque,2);
- printf("Distance matrix Water1-Water2\n%5s","");
- for(j=0; (j<5); j++)
- printf(" %10s",nm[j]);
- printf("\n");
- for(j=0; (j<5); j++) {
- printf("%5s",nm[j]);
- for(i=5; (i<10); i++) {
- rvec_sub(x[i],x[j],dx);
- len = sqrt(iprod(dx,dx));
- printf(" %10.7f",len);
- }
- printf("\n");
- }
- }
- }
- sfree(x);
- sfree(v);
- sfree(f);
- nframe++;
- }
- if (!bOK)
- fprintf(stderr,"\nWARNING: Incomplete frame header: nr %d, t=%g\n",
- nframe,trn.t);
- close_tpx(fpwrite);
- close_trn(fpread);
-}
-
-int main(int argc,char *argv[])
-{
- static char *desc[] = {
- "[TT]gmxdump[tt] reads a run input file ([REF].tpr[ref]),",
- "a trajectory ([REF].trr[ref]/[REF].xtc[ref]) or an energy",
- "file ([REF].edr[ref]) and prints that to standard",
- "output in a readable format. This program is essential for",
- "checking your run input file in case of problems.[PAR]"
- };
- t_filenm fnm[] = {
- { efTRN, "-f", NULL, ffOPTRD }
- };
-#define NFILE asize(fnm)
- char *fn;
-
- /* Command line options */
-
- CopyRight(stdout,argv[0]);
- parse_common_args(&argc,argv,0,NFILE,fnm,0,NULL,
- asize(desc),desc,0,NULL);
-
- if (ftp2bSet(efTRN,NFILE,fnm)) {
- fn = ftp2fn(efTRN,NFILE,fnm);
- printf("Going to open %s\n",fn);
- list_trn(fn);
- }
-
- gmx_thanx(stderr);
-
- return 0;
-}
{
case efTRR:
case efTRN:
- of->fp_trn = open_trn(filename, filemode);
+ of->fp_trn = gmx_trr_open(filename, filemode);
break;
case efTNG:
gmx_tng_open(filename, filemode[0], &of->tng);
{
if (of->fp_trn)
{
- fwrite_trn(of->fp_trn, step, t, state_local->lambda[efptFEP],
- state_local->box, top_global->natoms,
- (mdof_flags & MDOF_X) ? state_global->x : NULL,
- (mdof_flags & MDOF_V) ? global_v : NULL,
- (mdof_flags & MDOF_F) ? f_global : NULL);
+ gmx_trr_write_frame(of->fp_trn, step, t, state_local->lambda[efptFEP],
+ state_local->box, top_global->natoms,
+ (mdof_flags & MDOF_X) ? state_global->x : NULL,
+ (mdof_flags & MDOF_V) ? global_v : NULL,
+ (mdof_flags & MDOF_F) ? f_global : NULL);
if (gmx_fio_flush(of->fp_trn) != 0)
{
gmx_file("Cannot write trajectory; maybe you are out of disk space?");
}
if (of->fp_trn)
{
- close_trn(of->fp_trn);
+ gmx_trr_close(of->fp_trn);
}
if (of->fp_dhdl != NULL)
{
#define BUFSIZE 128
#define GROMACS_MAGIC 1993
-static int nFloatSize(t_trnheader *sh)
+static int nFloatSize(gmx_trr_header_t *sh)
{
int nflsize = 0;
}
else
{
- gmx_file("Can not determine precision of trn file");
+ gmx_file("Can not determine precision of trr file");
}
if (((nflsize != sizeof(float)) && (nflsize != sizeof(double))))
return nflsize;
}
-static gmx_bool do_trnheader(t_fileio *fio, gmx_bool bRead, t_trnheader *sh, gmx_bool *bOK)
+static gmx_bool
+do_trr_frame_header(t_fileio *fio, bool bRead, gmx_trr_header_t *sh, gmx_bool *bOK)
{
int magic = GROMACS_MAGIC;
static gmx_bool bFirst = TRUE;
*bOK = *bOK && gmx_fio_do_string(fio, buf);
if (bFirst)
{
- fprintf(stderr, "trn version: %s ", buf);
+ fprintf(stderr, "trr version: %s ", buf);
}
}
else
return *bOK;
}
-static gmx_bool do_htrn(t_fileio *fio, t_trnheader *sh,
- rvec *box, rvec *x, rvec *v, rvec *f)
+static gmx_bool
+do_trr_frame_data(t_fileio *fio, gmx_trr_header_t *sh,
+ rvec *box, rvec *x, rvec *v, rvec *f)
{
matrix pv;
gmx_bool bOK;
return bOK;
}
-static gmx_bool do_trn(t_fileio *fio, gmx_bool bRead, int *step, real *t, real *lambda,
- rvec *box, int *natoms, rvec *x, rvec *v, rvec *f)
+static gmx_bool
+do_trr_frame(t_fileio *fio, bool bRead, int *step, real *t, real *lambda,
+ rvec *box, int *natoms, rvec *x, rvec *v, rvec *f)
{
- t_trnheader *sh;
- gmx_bool bOK;
+ gmx_trr_header_t *sh;
+ gmx_bool bOK;
snew(sh, 1);
if (!bRead)
sh->t = *t;
sh->lambda = *lambda;
}
- if (!do_trnheader(fio, bRead, sh, &bOK))
+ if (!do_trr_frame_header(fio, bRead, sh, &bOK))
{
return FALSE;
}
*lambda = sh->lambda;
if (sh->ir_size)
{
- gmx_file("inputrec in trn file");
+ gmx_file("inputrec in trr file");
}
if (sh->e_size)
{
- gmx_file("energies in trn file");
+ gmx_file("energies in trr file");
}
if (sh->top_size)
{
- gmx_file("topology in trn file");
+ gmx_file("topology in trr file");
}
if (sh->sym_size)
{
- gmx_file("symbol table in trn file");
+ gmx_file("symbol table in trr file");
}
}
- bOK = do_htrn(fio, sh, box, x, v, f);
+ bOK = do_trr_frame_data(fio, sh, box, x, v, f);
sfree(sh);
*
************************************************************/
-void read_trnheader(const char *fn, t_trnheader *trn)
+void gmx_trr_read_single_header(const char *fn, gmx_trr_header_t *header)
{
- t_fileio *fio;
+ t_fileio *fio = gmx_trr_open(fn, "r");
gmx_bool bOK;
-
- fio = open_trn(fn, "r");
- if (!do_trnheader(fio, TRUE, trn, &bOK))
+ if (!do_trr_frame_header(fio, true, header, &bOK))
{
gmx_fatal(FARGS, "Empty file %s", fn);
}
- close_trn(fio);
+ gmx_trr_close(fio);
}
-gmx_bool fread_trnheader(t_fileio *fio, t_trnheader *trn, gmx_bool *bOK)
+gmx_bool gmx_trr_read_frame_header(t_fileio *fio, gmx_trr_header_t *header, gmx_bool *bOK)
{
- return do_trnheader(fio, TRUE, trn, bOK);
+ return do_trr_frame_header(fio, true, header, bOK);
}
-void write_trn(const char *fn, int step, real t, real lambda,
- rvec *box, int natoms, rvec *x, rvec *v, rvec *f)
+void gmx_trr_write_single_frame(const char *fn, int step, real t, real lambda,
+ rvec *box, int natoms, rvec *x, rvec *v, rvec *f)
{
- t_fileio *fio;
-
- fio = open_trn(fn, "w");
- do_trn(fio, FALSE, &step, &t, &lambda, box, &natoms, x, v, f);
- close_trn(fio);
+ t_fileio *fio = gmx_trr_open(fn, "w");
+ do_trr_frame(fio, false, &step, &t, &lambda, box, &natoms, x, v, f);
+ gmx_trr_close(fio);
}
-void read_trn(const char *fn, int *step, real *t, real *lambda,
- rvec *box, int *natoms, rvec *x, rvec *v, rvec *f)
+void gmx_trr_read_single_frame(const char *fn, int *step, real *t, real *lambda,
+ rvec *box, int *natoms, rvec *x, rvec *v, rvec *f)
{
- t_fileio *fio;
-
- fio = open_trn(fn, "r");
- (void) do_trn(fio, TRUE, step, t, lambda, box, natoms, x, v, f);
- close_trn(fio);
+ t_fileio *fio = gmx_trr_open(fn, "r");
+ do_trr_frame(fio, true, step, t, lambda, box, natoms, x, v, f);
+ gmx_trr_close(fio);
}
-void fwrite_trn(t_fileio *fio, int step, real t, real lambda,
- rvec *box, int natoms, rvec *x, rvec *v, rvec *f)
+void gmx_trr_write_frame(t_fileio *fio, int step, real t, real lambda,
+ rvec *box, int natoms, rvec *x, rvec *v, rvec *f)
{
- if (do_trn(fio, FALSE, &step, &t, &lambda, box, &natoms, x, v, f) == FALSE)
+ if (!do_trr_frame(fio, false, &step, &t, &lambda, box, &natoms, x, v, f))
{
gmx_file("Cannot write trajectory frame; maybe you are out of disk space?");
}
}
-gmx_bool fread_trn(t_fileio *fio, int *step, real *t, real *lambda,
- rvec *box, int *natoms, rvec *x, rvec *v, rvec *f)
+gmx_bool gmx_trr_read_frame(t_fileio *fio, int *step, real *t, real *lambda,
+ rvec *box, int *natoms, rvec *x, rvec *v, rvec *f)
{
- return do_trn(fio, TRUE, step, t, lambda, box, natoms, x, v, f);
+ return do_trr_frame(fio, true, step, t, lambda, box, natoms, x, v, f);
}
-gmx_bool fread_htrn(t_fileio *fio, t_trnheader *trn, rvec *box, rvec *x, rvec *v,
- rvec *f)
+gmx_bool gmx_trr_read_frame_data(t_fileio *fio, gmx_trr_header_t *header,
+ rvec *box, rvec *x, rvec *v, rvec *f)
{
- return do_htrn(fio, trn, box, x, v, f);
+ return do_trr_frame_data(fio, header, box, x, v, f);
}
-t_fileio *open_trn(const char *fn, const char *mode)
+t_fileio *gmx_trr_open(const char *fn, const char *mode)
{
return gmx_fio_open(fn, mode);
}
-void close_trn(t_fileio *fio)
+void gmx_trr_close(t_fileio *fio)
{
gmx_fio_close(fio);
}
*
* The routines in the corresponding c-file trrio.cpp
* are based on the lower level routines in gmxfio.cpp
- * The file handle returned from open_trn
+ * The file handle returned from gmx_trr_open()
* can also be used with the routines in gmxfio.h
*
**************************************************************/
struct t_fileio;
-typedef struct /* This struct describes the order and the */
- /* sizes of the structs in a trjfile, sizes are given in bytes. */
+/* This struct describes the order and the */
+/* sizes of the structs in a trr file, sizes are given in bytes. */
+typedef struct gmx_trr_header_t
{
- gmx_bool bDouble; /* Double precision? */
- int ir_size; /* Backward compatibility */
- int e_size; /* Backward compatibility */
- int box_size; /* Non zero if a box is present */
- int vir_size; /* Backward compatibility */
- int pres_size; /* Backward compatibility */
- int top_size; /* Backward compatibility */
- int sym_size; /* Backward compatibility */
- int x_size; /* Non zero if coordinates are present */
- int v_size; /* Non zero if velocities are present */
- int f_size; /* Non zero if forces are present */
-
- int natoms; /* The total number of atoms */
- int step; /* Current step number */
- int nre; /* Backward compatibility */
- real t; /* Current time */
- real lambda; /* Current value of lambda */
- int fep_state; /* Current value of alchemical state */
-} t_trnheader;
-
-struct t_fileio *open_trn(const char *fn, const char *mode);
-/* Open a trr / trr file */
-
-void close_trn(struct t_fileio *fio);
+ gmx_bool bDouble; /* Double precision? */
+ int ir_size; /* Backward compatibility */
+ int e_size; /* Backward compatibility */
+ int box_size; /* Non zero if a box is present */
+ int vir_size; /* Backward compatibility */
+ int pres_size; /* Backward compatibility */
+ int top_size; /* Backward compatibility */
+ int sym_size; /* Backward compatibility */
+ int x_size; /* Non zero if coordinates are present */
+ int v_size; /* Non zero if velocities are present */
+ int f_size; /* Non zero if forces are present */
+
+ int natoms; /* The total number of atoms */
+ int step; /* Current step number */
+ int nre; /* Backward compatibility */
+ real t; /* Current time */
+ real lambda; /* Current value of lambda */
+ int fep_state; /* Current value of alchemical state */
+} gmx_trr_header_t;
+
+struct t_fileio *gmx_trr_open(const char *fn, const char *mode);
+/* Open a trr file */
+
+void gmx_trr_close(struct t_fileio *fio);
/* Close it */
-gmx_bool fread_trnheader(struct t_fileio *fio, t_trnheader *trn, gmx_bool *bOK);
-/* Read the header of a trn file. Return FALSE if there is no frame.
+gmx_bool gmx_trr_read_frame_header(struct t_fileio *fio, gmx_trr_header_t *header, gmx_bool *bOK);
+/* Read the header of a trr file. Return FALSE if there is no frame.
* bOK will be FALSE when the header is incomplete.
*/
-void read_trnheader(const char *fn, t_trnheader *header);
-/* Read the header of a trn file from fn, and close the file afterwards.
- */
-
-void fwrite_trn(struct t_fileio *fio, int step, real t, real lambda,
- rvec *box, int natoms, rvec *x, rvec *v, rvec *f);
-/* Write a trn frame to file fp, box, x, v, f may be NULL */
-
-gmx_bool fread_htrn(struct t_fileio *fio, t_trnheader *sh,
- rvec *box, rvec *x, rvec *v, rvec *f);
+gmx_bool gmx_trr_read_frame_data(struct t_fileio *fio, gmx_trr_header_t *sh,
+ rvec *box, rvec *x, rvec *v, rvec *f);
/* Extern read a frame except the header (that should be pre-read,
- * using routine read_trnheader, see above) from a trn file.
+ * using routine gmx_trr_read_frame_header(), see above) from a trr file.
* Return FALSE on error
*/
-gmx_bool fread_trn(struct t_fileio *fio, int *step, real *t, real *lambda,
- rvec *box, int *natoms, rvec *x, rvec *v, rvec *f);
-/* Read a trn frame, including the header from fp. box, x, v, f may
+gmx_bool gmx_trr_read_frame(struct t_fileio *fio, int *step, real *t, real *lambda,
+ rvec *box, int *natoms, rvec *x, rvec *v, rvec *f);
+/* Read a trr frame, including the header from fp. box, x, v, f may
* be NULL, in which case the data will be skipped over.
* return FALSE on error
*/
-void write_trn(const char *fn, int step, real t, real lambda,
- rvec *box, int natoms, rvec *x, rvec *v, rvec *f);
-/* Write a single trn frame to file fn, which is closed afterwards */
+void gmx_trr_write_frame(struct t_fileio *fio, int step, real t, real lambda,
+ rvec *box, int natoms, rvec *x, rvec *v, rvec *f);
+/* Write a trr frame to file fp, box, x, v, f may be NULL */
-void read_trn(const char *fn, int *step, real *t, real *lambda,
- rvec *box, int *natoms, rvec *x, rvec *v, rvec *f);
-/* Read a single trn frame from file fn, which is closed afterwards
+void gmx_trr_read_single_header(const char *fn, gmx_trr_header_t *header);
+/* Read the header of a trr file from fn, and close the file afterwards.
*/
+void gmx_trr_read_single_frame(const char *fn, int *step, real *t, real *lambda,
+ rvec *box, int *natoms, rvec *x, rvec *v, rvec *f);
+/* Read a single trr frame from file fn, which is closed afterwards
+ */
+
+void gmx_trr_write_single_frame(const char *fn, int step, real t, real lambda,
+ rvec *box, int natoms, rvec *x, rvec *v, rvec *f);
+/* Write a single trr frame to file fn, which is closed afterwards */
+
#ifdef __cplusplus
}
#endif
write_xtc(status->fio, nind, fr->step, fr->time, fr->box, xout, prec);
break;
case efTRR:
- fwrite_trn(status->fio, nframes_read(status),
- fr->time, fr->step, fr->box, nind, xout, vout, fout);
+ gmx_trr_write_frame(status->fio, nframes_read(status),
+ fr->time, fr->step, fr->box, nind, xout, vout, fout);
break;
case efGRO:
case efPDB:
write_xtc(status->fio, fr->natoms, fr->step, fr->time, fr->box, fr->x, prec);
break;
case efTRR:
- fwrite_trn(status->fio, fr->step, fr->time, fr->lambda, fr->box, fr->natoms,
- fr->bX ? fr->x : NULL, fr->bV ? fr->v : NULL, fr->bF ? fr->f : NULL);
+ gmx_trr_write_frame(status->fio, fr->step, fr->time, fr->lambda, fr->box, fr->natoms,
+ fr->bX ? fr->x : NULL, fr->bV ? fr->v : NULL, fr->bF ? fr->f : NULL);
break;
case efGRO:
case efPDB:
static gmx_bool gmx_next_frame(t_trxstatus *status, t_trxframe *fr)
{
- t_trnheader sh;
- gmx_bool bOK, bRet;
+ gmx_trr_header_t sh;
+ gmx_bool bOK, bRet;
bRet = FALSE;
- if (fread_trnheader(status->fio, &sh, &bOK))
+ if (gmx_trr_read_frame_header(status->fio, &sh, &bOK))
{
fr->bDouble = sh.bDouble;
fr->natoms = sh.natoms;
}
fr->bF = sh.f_size > 0;
}
- if (fread_htrn(status->fio, &sh, fr->box, fr->x, fr->v, fr->f))
+ if (gmx_trr_read_frame_data(status->fio, &sh, fr->box, fr->x, fr->v, fr->f))
{
bRet = TRUE;
}
int *nvec, int **eignr,
rvec ***eigvec, real **eigval)
{
- t_trnheader head;
+ gmx_trr_header_t head;
int i, snew_size;
struct t_fileio *status;
rvec *x;
*bDMR = FALSE;
/* read (reference (t=-1) and) average (t=0) structure */
- status = open_trn(file, "r");
- fread_trnheader(status, &head, &bOK);
+ status = gmx_trr_open(file, "r");
+ gmx_trr_read_frame_header(status, &head, &bOK);
*natoms = head.natoms;
snew(*xav, *natoms);
- fread_htrn(status, &head, box, *xav, NULL, NULL);
+ gmx_trr_read_frame_data(status, &head, box, *xav, NULL, NULL);
if ((head.t >= -1.1) && (head.t <= -0.9))
{
sfree(*xref);
*xref = NULL;
}
- fread_trnheader(status, &head, &bOK);
- fread_htrn(status, &head, box, *xav, NULL, NULL);
+ gmx_trr_read_frame_header(status, &head, &bOK);
+ gmx_trr_read_frame_data(status, &head, box, *xav, NULL, NULL);
}
else
{
snew(*eigvec, snew_size);
*nvec = 0;
- while (fread_trnheader(status, &head, &bOK))
+ while (gmx_trr_read_frame_header(status, &head, &bOK))
{
- fread_htrn(status, &head, box, x, NULL, NULL);
+ gmx_trr_read_frame_data(status, &head, box, x, NULL, NULL);
if (*nvec >= snew_size)
{
snew_size += 10;
(*nvec)++;
}
sfree(x);
+ gmx_trr_close(status);
fprintf(stderr, "Read %d eigenvectors (for %d atoms)\n\n", *nvec, *natoms);
}
-void write_eigenvectors(const char *trnname, int natoms, real mat[],
+void write_eigenvectors(const char *trrname, int natoms, real mat[],
gmx_bool bReverse, int begin, int end,
int WriteXref, rvec *xref, gmx_bool bDMR,
rvec xav[], gmx_bool bDMA, real eigval[])
{
- struct t_fileio *trnout;
+ struct t_fileio *trrout;
int ndim, i, j, d, vec;
matrix zerobox;
rvec *x;
fprintf (stderr,
"\nWriting %saverage structure & eigenvectors %d--%d to %s\n",
(WriteXref == eWXR_YES) ? "reference, " : "",
- begin, end, trnname);
+ begin, end, trrname);
- trnout = open_trn(trnname, "w");
+ trrout = gmx_trr_open(trrname, "w");
if (WriteXref == eWXR_YES)
{
/* misuse lambda: 0/1 mass weighted fit no/yes */
- fwrite_trn(trnout, -1, -1, bDMR ? 1.0 : 0.0, zerobox, natoms, xref, NULL, NULL);
+ gmx_trr_write_frame(trrout, -1, -1, bDMR ? 1.0 : 0.0, zerobox, natoms, xref, NULL, NULL);
}
else if (WriteXref == eWXR_NOFIT)
{
/* misuse lambda: -1 no fit */
- fwrite_trn(trnout, -1, -1, -1.0, zerobox, natoms, x, NULL, NULL);
+ gmx_trr_write_frame(trrout, -1, -1, -1.0, zerobox, natoms, x, NULL, NULL);
}
/* misuse lambda: 0/1 mass weighted analysis no/yes */
- fwrite_trn(trnout, 0, 0, bDMA ? 1.0 : 0.0, zerobox, natoms, xav, NULL, NULL);
+ gmx_trr_write_frame(trrout, 0, 0, bDMA ? 1.0 : 0.0, zerobox, natoms, xav, NULL, NULL);
for (i = 0; i <= (end-begin); i++)
{
}
/* Store the eigenvalue in the time field */
- fwrite_trn(trnout, begin+i, eigval[vec], 0, zerobox, natoms, x, NULL, NULL);
+ gmx_trr_write_frame(trrout, begin+i, eigval[vec], 0, zerobox, natoms, x, NULL, NULL);
}
- close_trn(trnout);
+ gmx_trr_close(trrout);
sfree(x);
}
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
/* xav is the average/minimum structure is written (t=0). */
/* bDMA indicates mass weighted analysis/eigenvectors. */
-extern void write_eigenvectors(const char *trnname, int natoms, real mat[],
+extern void write_eigenvectors(const char *trrname, int natoms, real mat[],
gmx_bool bReverse, int begin, int end,
int WriteXref, rvec *xref, gmx_bool bDMR,
rvec xav[], gmx_bool bDMA, real *eigval);
-/* Write eigenvectors in mat to a TRN file. */
+/* Write eigenvectors in mat to a TRR file. */
/* The reference structure is written (t=-1) when WriteXref=eWXR_YES. */
/* When WriteXref==eWXR_NOFIT a zero frame is written (t=-1), */
/* with lambda=-1. */
#include "gromacs/utility/futil.h"
#include "gromacs/utility/smalloc.h"
-static void dump_dih_trn(int nframes, int nangles, real **dih, const char *fn,
+static void dump_dih_trr(int nframes, int nangles, real **dih, const char *fn,
real *time)
{
int i, j, k, l, m, na;
- struct t_fileio *trn;
+ struct t_fileio *fio;
rvec *x;
matrix box = {{2, 0, 0}, {0, 2, 0}, {0, 0, 2}};
printf("There are %d dihedrals. Will fill %d atom positions with cos/sin\n",
nangles, na);
snew(x, na);
- trn = open_trn(fn, "w");
+ fio = gmx_trr_open(fn, "w");
for (i = 0; (i < nframes); i++)
{
k = l = 0;
}
}
}
- fwrite_trn(trn, i, time[i], 0, box, na, x, NULL, NULL);
+ gmx_trr_write_frame(fio, i, time[i], 0, box, na, x, NULL, NULL);
}
- close_trn(trn);
+ gmx_trr_close(fio);
sfree(x);
}
{
if (mult != 4)
{
- gmx_fatal(FARGS, "Can not combine angles with trn dump");
+ gmx_fatal(FARGS, "Can not combine angles with trr dump");
}
else
{
}
if (opt2bSet("-or", NFILE, fnm))
{
- dump_dih_trn(nframes, nangles, dih, opt2fn("-or", NFILE, fnm), time);
+ dump_dih_trr(nframes, nangles, dih, opt2fn("-or", NFILE, fnm), time);
}
if (bFrac)
strcat(out_file, ext);
}
-void check_trn(const char *fn)
+void check_trr(const char *fn)
{
if (fn2ftp(fn) != efTRR)
{
t_fileio *in;
FILE *fp;
gmx_bool bStop, bOK;
- t_trnheader sh;
+ gmx_trr_header_t sh;
gmx_off_t fpos;
char yesno[256];
int j;
}
/* Check whether this is a .trr file */
- check_trn(fn);
+ check_trr(fn);
- in = open_trn(fn, "r");
+ in = gmx_trr_open(fn, "r");
fp = gmx_fio_getfp(in);
if (fp == NULL)
{
fprintf(stderr, "Sorry, can not trunc %s, truncation of this filetype is not supported\n", fn);
- close_trn(in);
+ gmx_trr_close(in);
}
else
{
j = 0;
fpos = gmx_fio_ftell(in);
bStop = FALSE;
- while (!bStop && fread_trnheader(in, &sh, &bOK))
+ while (!bStop && gmx_trr_read_frame_header(in, &sh, &bOK))
{
- fread_htrn(in, &sh, NULL, NULL, NULL, NULL);
+ gmx_trr_read_frame_data(in, &sh, NULL, NULL, NULL, NULL);
fpos = gmx_ftell(fp);
t = sh.t;
if (t >= t0)
if (strcmp(yesno, "YES") == 0)
{
fprintf(stderr, "Once again, I'm gonna DO this...\n");
- close_trn(in);
+ gmx_trr_close(in);
if (0 != gmx_truncate(fn, fpos))
{
gmx_fatal(FARGS, "Error truncating file %s", fn);
else
{
fprintf(stderr, "Already at end of file (t=%g)...\n", t);
- close_trn(in);
+ gmx_trr_close(in);
}
}
}
t_rot *rot, rvec *x, matrix box,
const char *fn, gmx_bool bSet, warninp_t wi)
{
- int g, i, ii;
- t_rotgrp *rotg;
- t_trnheader header; /* Header information of reference file */
- char base[STRLEN], extension[STRLEN], reffile[STRLEN];
- char *extpos;
- rvec f_box[3]; /* Box from reference file */
+ int g, i, ii;
+ t_rotgrp *rotg;
+ gmx_trr_header_t header; /* Header information of reference file */
+ char base[STRLEN], extension[STRLEN], reffile[STRLEN];
+ char *extpos;
+ rvec f_box[3]; /* Box from reference file */
/* Base name and extension of the reference file: */
if (gmx_fexist(reffile))
{
fprintf(stderr, " Reading them from %s.\n", reffile);
- read_trnheader(reffile, &header);
+ gmx_trr_read_single_header(reffile, &header);
if (rotg->nat != header.natoms)
{
gmx_fatal(FARGS, "Number of atoms in file %s (%d) does not match the number of atoms in rotation group (%d)!\n",
reffile, header.natoms, rotg->nat);
}
- read_trn(reffile, &header.step, &header.t, &header.lambda, f_box, &header.natoms, rotg->x_ref, NULL, NULL);
+ gmx_trr_read_single_frame(reffile, &header.step, &header.t, &header.lambda, f_box, &header.natoms, rotg->x_ref, NULL, NULL);
/* Check whether the box is unchanged and output a warning if not: */
check_box_unchanged(f_box, box, reffile, wi);
ii = rotg->ind[i];
copy_rvec(x[ii], rotg->x_ref[i]);
}
- write_trn(reffile, g, 0.0, 0.0, box, rotg->nat, rotg->x_ref, NULL, NULL);
+ gmx_trr_write_single_frame(reffile, g, 0.0, 0.0, box, rotg->nat, rotg->x_ref, NULL, NULL);
}
}
}
const char *top_fn, *frame_fn;
struct t_fileio *fp;
ener_file_t fp_ener = NULL;
- t_trnheader head;
+ gmx_trr_header_t head;
int i;
gmx_int64_t nsteps_req, run_step, frame;
double run_t, state_t;
"\nREADING COORDS, VELS AND BOX FROM TRAJECTORY %s...\n\n",
frame_fn);
- fp = open_trn(frame_fn, "r");
+ fp = gmx_trr_open(frame_fn, "r");
if (bScanEner)
{
fp_ener = open_enx(ftp2fn(efEDR, NFILE, fnm), "r");
frame = 0;
while (bFrame)
{
- bFrame = fread_trnheader(fp, &head, &bOK);
+ bFrame = gmx_trr_read_frame_header(fp, &head, &bOK);
if (bOK && frame == 0)
{
if (mtop.natoms != head.natoms)
bFrame = bFrame && bOK;
if (bFrame)
{
- bOK = fread_htrn(fp, &head, newbox, newx, newv, NULL);
+ bOK = gmx_trr_read_frame_data(fp, &head, newbox, newx, newv, NULL);
}
bFrame = bFrame && bOK;
bUse = FALSE;
free_enxframe(fr_ener);
free_enxnms(nre, enm);
}
- close_trn(fp);
+ gmx_trr_close(fp);
fprintf(stderr, "\n");
if (!bOK)
}
}
-static void list_trn(const char *fn)
+static void list_trr(const char *fn)
{
- t_fileio *fpread;
- int nframe, indent;
- char buf[256];
- rvec *x, *v, *f;
- matrix box;
- t_trnheader trn;
- gmx_bool bOK;
+ t_fileio *fpread;
+ int nframe, indent;
+ char buf[256];
+ rvec *x, *v, *f;
+ matrix box;
+ gmx_trr_header_t trrheader;
+ gmx_bool bOK;
- fpread = open_trn(fn, "r");
+ fpread = gmx_trr_open(fn, "r");
nframe = 0;
- while (fread_trnheader(fpread, &trn, &bOK))
+ while (gmx_trr_read_frame_header(fpread, &trrheader, &bOK))
{
- snew(x, trn.natoms);
- snew(v, trn.natoms);
- snew(f, trn.natoms);
- if (fread_htrn(fpread, &trn,
- trn.box_size ? box : NULL,
- trn.x_size ? x : NULL,
- trn.v_size ? v : NULL,
- trn.f_size ? f : NULL))
+ snew(x, trrheader.natoms);
+ snew(v, trrheader.natoms);
+ snew(f, trrheader.natoms);
+ if (gmx_trr_read_frame_data(fpread, &trrheader,
+ trrheader.box_size ? box : NULL,
+ trrheader.x_size ? x : NULL,
+ trrheader.v_size ? v : NULL,
+ trrheader.f_size ? f : NULL))
{
sprintf(buf, "%s frame %d", fn, nframe);
indent = 0;
indent = pr_title(stdout, indent, buf);
pr_indent(stdout, indent);
fprintf(stdout, "natoms=%10d step=%10d time=%12.7e lambda=%10g\n",
- trn.natoms, trn.step, trn.t, trn.lambda);
- if (trn.box_size)
+ trrheader.natoms, trrheader.step, trrheader.t, trrheader.lambda);
+ if (trrheader.box_size)
{
pr_rvecs(stdout, indent, "box", box, DIM);
}
- if (trn.x_size)
+ if (trrheader.x_size)
{
- pr_rvecs(stdout, indent, "x", x, trn.natoms);
+ pr_rvecs(stdout, indent, "x", x, trrheader.natoms);
}
- if (trn.v_size)
+ if (trrheader.v_size)
{
- pr_rvecs(stdout, indent, "v", v, trn.natoms);
+ pr_rvecs(stdout, indent, "v", v, trrheader.natoms);
}
- if (trn.f_size)
+ if (trrheader.f_size)
{
- pr_rvecs(stdout, indent, "f", f, trn.natoms);
+ pr_rvecs(stdout, indent, "f", f, trrheader.natoms);
}
}
else
{
fprintf(stderr, "\nWARNING: Incomplete frame: nr %d, t=%g\n",
- nframe, trn.t);
+ nframe, trrheader.t);
}
sfree(x);
if (!bOK)
{
fprintf(stderr, "\nWARNING: Incomplete frame header: nr %d, t=%g\n",
- nframe, trn.t);
+ nframe, trrheader.t);
}
- close_trn(fpread);
+ gmx_trr_close(fpread);
}
void list_xtc(const char *fn)
list_xtc(fn);
break;
case efTRR:
- list_trn(fn);
+ list_trr(fn);
break;
case efTNG:
list_tng(fn);