2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5 * Copyright (c) 2001-2004, The GROMACS development team.
6 * Copyright (c) 2013,2014, by the GROMACS development team, led by
7 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
8 * and including many others, as listed in the AUTHORS file in the
9 * top-level source directory and at http://www.gromacs.org.
11 * GROMACS is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public License
13 * as published by the Free Software Foundation; either version 2.1
14 * of the License, or (at your option) any later version.
16 * GROMACS is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with GROMACS; if not, see
23 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
24 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 * If you want to redistribute modifications to GROMACS, please
27 * consider that scientific software is very special. Version
28 * control is crucial - bugs must be traceable. We will be happy to
29 * consider code for inclusion in the official distribution, but
30 * derived work must not be called official GROMACS. Details are found
31 * in the README & COPYING files - if they are missing, get the
32 * official version at http://www.gromacs.org.
34 * To help us fund GROMACS development, we humbly ask that you cite
35 * the research papers on the package. Check out http://www.gromacs.org.
49 #ifdef GMX_USE_PLUGINS
60 #include "tngio_for_tools.h"
67 #include "checkpoint.h"
70 #include "gromacs/fileio/timecontrol.h"
72 /* defines for frame counter output */
77 /* Globals for gromos-87 input */
79 effXYZ, effXYZBox, effG87, effG87Box, effNR
93 char *persistent_line; /* Persistent line for reading g96 trajectories */
96 /* utility functions */
98 gmx_bool bRmod_fd(double a, double b, double c, gmx_bool bDouble)
103 tol = 2*(bDouble ? GMX_DOUBLE_EPS : GMX_FLOAT_EPS);
105 iq = (int)((a - b + tol*a)/c);
107 if (fabs(a - b - c*iq) <= tol*fabs(a))
119 int check_times2(real t, real t0, gmx_bool bDouble)
124 /* since t is float, we can not use double precision for bRmod */
129 if ((!bTimeSet(TBEGIN) || (t >= rTimeValue(TBEGIN))) &&
130 (!bTimeSet(TEND) || (t <= rTimeValue(TEND))))
132 if (bTimeSet(TDELTA) && !bRmod_fd(t, t0, rTimeValue(TDELTA), bDouble))
141 else if (bTimeSet(TEND) && (t >= rTimeValue(TEND)))
147 fprintf(debug, "t=%g, t0=%g, b=%g, e=%g, dt=%g: r=%d\n",
148 t, t0, rTimeValue(TBEGIN), rTimeValue(TEND), rTimeValue(TDELTA), r);
153 int check_times(real t)
155 return check_times2(t, t, FALSE);
158 static void initcount(t_trxstatus *status)
160 status->__frame = -1;
163 static void status_init(t_trxstatus *status)
166 status->xframe = NULL;
168 status->__frame = -1;
169 status->persistent_line = NULL;
174 int nframes_read(t_trxstatus *status)
176 return status->__frame;
179 static void printcount_(t_trxstatus *status, const output_env_t oenv,
180 const char *l, real t)
182 if ((status->__frame < 2*SKIP1 || status->__frame % SKIP1 == 0) &&
183 (status->__frame < 2*SKIP2 || status->__frame % SKIP2 == 0) &&
184 (status->__frame < 2*SKIP3 || status->__frame % SKIP3 == 0))
186 fprintf(stderr, "\r%-14s %6d time %8.3f ", l, status->__frame,
187 output_env_conv_time(oenv, t));
191 static void printcount(t_trxstatus *status, const output_env_t oenv, real t,
195 printcount_(status, oenv, bSkip ? "Skipping frame" : "Reading frame", t);
198 static void printlast(t_trxstatus *status, const output_env_t oenv, real t)
200 printcount_(status, oenv, "Last frame", t);
201 fprintf(stderr, "\n");
204 static void printincomp(t_trxstatus *status, t_trxframe *fr)
206 if (fr->not_ok & HEADER_NOT_OK)
208 fprintf(stderr, "WARNING: Incomplete header: nr %d time %g\n",
209 status->__frame+1, fr->time);
213 fprintf(stderr, "WARNING: Incomplete frame: nr %d time %g\n",
214 status->__frame+1, fr->time);
218 int prec2ndec(real prec)
222 gmx_fatal(FARGS, "DEATH HORROR prec (%g) <= 0 in prec2ndec", prec);
225 return (int)(log(prec)/log(10.0)+0.5);
228 real ndec2prec(int ndec)
230 return pow(10.0, ndec);
233 t_fileio *trx_get_fileio(t_trxstatus *status)
238 tng_trajectory_t trx_get_tng(t_trxstatus *status)
243 void clear_trxframe(t_trxframe *fr, gmx_bool bFirst)
250 fr->bFepState = FALSE;
281 void set_trxframe_ePBC(t_trxframe *fr, int ePBC)
283 fr->bPBC = (ePBC == -1);
287 int write_trxframe_indexed(t_trxstatus *status, t_trxframe *fr, int nind,
288 const atom_id *ind, gmx_conect gc)
291 rvec *xout = NULL, *vout = NULL, *fout = NULL;
308 else if (status->fio)
310 ftp = gmx_fio_getftp(status->fio);
314 gmx_incons("No input file available");
326 gmx_fatal(FARGS, "Need coordinates to write a %s trajectory",
340 for (i = 0; i < nind; i++)
342 copy_rvec(fr->v[ind[i]], vout[i]);
348 for (i = 0; i < nind; i++)
350 copy_rvec(fr->f[ind[i]], fout[i]);
359 for (i = 0; i < nind; i++)
361 copy_rvec(fr->x[ind[i]], xout[i]);
372 gmx_write_tng_from_trxframe(status->tng, fr, nind);
375 write_xtc(status->fio, nind, fr->step, fr->time, fr->box, xout, prec);
379 fwrite_trn(status->fio, nframes_read(status),
380 fr->time, fr->step, fr->box, nind, xout, vout, fout);
388 gmx_fatal(FARGS, "Can not write a %s file without atom names",
391 sprintf(title, "frame t= %.3f", fr->time);
394 write_hconf_indexed_p(gmx_fio_getfp(status->fio), title, fr->atoms, nind, ind,
396 fr->x, fr->bV ? fr->v : NULL, fr->box);
400 write_pdbfile_indexed(gmx_fio_getfp(status->fio), title, fr->atoms,
401 fr->x, -1, fr->box, ' ', fr->step, nind, ind, gc, TRUE);
405 write_g87(gmx_fio_getfp(status->fio), nind, xout, fr->box);
408 write_g96_conf(gmx_fio_getfp(status->fio), fr, nind, ind);
411 gmx_fatal(FARGS, "Sorry, write_trxframe_indexed can not write %s",
442 void trjtools_gmx_prepare_tng_writing(const char *filename,
448 const gmx_mtop_t *mtop,
449 const atom_id *index,
450 const char *index_group_name)
452 if (filemode != 'w' && filemode != 'a')
454 gmx_incons("Sorry, can only prepare for TNG output.");
465 gmx_prepare_tng_writing(filename,
474 else if (efTNG == fn2ftp(infile))
476 tng_trajectory_t tng_in;
477 gmx_tng_open(infile, 'r', &tng_in);
479 gmx_prepare_tng_writing(filename,
490 void write_tng_frame(t_trxstatus *status,
493 gmx_write_tng_from_trxframe(status->tng, frame, -1);
496 int write_trxframe(t_trxstatus *status, t_trxframe *fr, gmx_conect gc)
512 gmx_tng_set_compression_precision(status->tng, prec);
513 write_tng_frame(status, fr);
518 switch (gmx_fio_getftp(status->fio))
526 gmx_fatal(FARGS, "Need coordinates to write a %s trajectory",
527 ftp2ext(gmx_fio_getftp(status->fio)));
532 switch (gmx_fio_getftp(status->fio))
535 write_xtc(status->fio, fr->natoms, fr->step, fr->time, fr->box, fr->x, prec);
539 fwrite_trn(status->fio, fr->step, fr->time, fr->lambda, fr->box, fr->natoms,
540 fr->bX ? fr->x : NULL, fr->bV ? fr->v : NULL, fr->bF ? fr->f : NULL);
548 gmx_fatal(FARGS, "Can not write a %s file without atom names",
549 ftp2ext(gmx_fio_getftp(status->fio)));
551 sprintf(title, "frame t= %.3f", fr->time);
552 if (gmx_fio_getftp(status->fio) == efGRO)
554 write_hconf_p(gmx_fio_getfp(status->fio), title, fr->atoms,
555 prec2ndec(prec), fr->x, fr->bV ? fr->v : NULL, fr->box);
559 write_pdbfile(gmx_fio_getfp(status->fio), title,
560 fr->atoms, fr->x, fr->bPBC ? fr->ePBC : -1, fr->box,
561 ' ', fr->step, gc, TRUE);
565 write_g87(gmx_fio_getfp(status->fio), fr->natoms, fr->x, fr->box);
568 write_g96_conf(gmx_fio_getfp(status->fio), fr, -1, NULL);
571 gmx_fatal(FARGS, "Sorry, write_trxframe can not write %s",
572 ftp2ext(gmx_fio_getftp(status->fio)));
579 int write_trx(t_trxstatus *status, int nind, const atom_id *ind, t_atoms *atoms,
580 int step, real time, matrix box, rvec x[], rvec *v,
585 clear_trxframe(&fr, TRUE);
590 fr.bAtoms = atoms != NULL;
597 copy_mat(box, fr.box);
599 return write_trxframe_indexed(status, &fr, nind, ind, gc);
602 void close_trx(t_trxstatus *status)
604 gmx_tng_close(&status->tng);
607 gmx_fio_close(status->fio);
612 t_trxstatus *open_trx(const char *outfile, const char *filemode)
615 if (filemode[0] != 'w' && filemode[0] != 'a' && filemode[1] != '+')
617 gmx_fatal(FARGS, "Sorry, write_trx can only write");
623 stat->fio = gmx_fio_open(outfile, filemode);
627 static gmx_bool gmx_next_frame(t_trxstatus *status, t_trxframe *fr)
634 if (fread_trnheader(status->fio, &sh, &bOK))
636 fr->bDouble = sh.bDouble;
637 fr->natoms = sh.natoms;
643 fr->bFepState = TRUE;
644 fr->lambda = sh.lambda;
645 fr->bBox = sh.box_size > 0;
646 if (fr->flags & (TRX_READ_X | TRX_NEED_X))
650 snew(fr->x, sh.natoms);
652 fr->bX = sh.x_size > 0;
654 if (fr->flags & (TRX_READ_V | TRX_NEED_V))
658 snew(fr->v, sh.natoms);
660 fr->bV = sh.v_size > 0;
662 if (fr->flags & (TRX_READ_F | TRX_NEED_F))
666 snew(fr->f, sh.natoms);
668 fr->bF = sh.f_size > 0;
670 if (fread_htrn(status->fio, &sh, fr->box, fr->x, fr->v, fr->f))
676 fr->not_ok = DATA_NOT_OK;
682 fr->not_ok = HEADER_NOT_OK;
688 static void choose_file_format(FILE *fp)
696 printf(" Select File Format\n");
697 printf("---------------------------\n");
698 printf("1. XYZ File\n");
699 printf("2. XYZ File with Box\n");
700 printf("3. Gromos-87 Ascii Trajectory\n");
701 printf("4. Gromos-87 Ascii Trajectory with Box\n");
708 printf("\nChoice: ");
712 rc = scanf("%d", &i);
717 while ((i < 0) || (i >= effNR));
720 stat->eFF = (eFileFormat) i;
722 for (m = 0; (m < DIM); m++)
727 stat->bReadBox = (stat->eFF == effG87Box) || (stat->eFF == effXYZBox);
733 if (5 != fscanf(fp, "%d%lf%lf%lf%lf", &stat->NATOMS, &stat->BOX[XX], &stat->BOX[YY], &stat->BOX[ZZ], &stat->DT))
735 gmx_fatal(FARGS, "Error reading natoms/box in file");
740 printf("GROMOS! OH DEAR...\n\n");
741 printf("Number of atoms ? ");
743 if (1 != scanf("%d", &stat->NATOMS))
745 gmx_fatal(FARGS, "Error reading natoms in file");
748 printf("Time between timeframes ? ");
750 if (1 != scanf("%lf", &stat->DT))
752 gmx_fatal(FARGS, "Error reading dt from file");
755 if (stat->eFF == effG87)
757 printf("Box X Y Z ? ");
759 if (3 != scanf("%lf%lf%lf", &stat->BOX[XX], &stat->BOX[YY], &stat->BOX[ZZ]))
761 gmx_fatal(FARGS, "Error reading box in file");
774 printf("Hellow World\n");
778 static gmx_bool do_read_xyz(t_trxstatus *status, FILE *fp, int natoms,
779 rvec x[], matrix box)
784 for (i = 0; (i < natoms); i++)
786 for (m = 0; (m < DIM); m++)
788 if (fscanf(fp, "%lf", &x0) != 1)
792 fprintf(stderr, "error reading statusfile: x[%d][%d]\n", i, m);
800 if (status->bReadBox)
802 for (m = 0; (m < DIM); m++)
804 if (fscanf(fp, "%lf", &x0) != 1)
814 static gmx_bool xyz_next_x(t_trxstatus *status, FILE *fp, const output_env_t oenv,
815 real *t, int natoms, rvec x[], matrix box)
816 /* Reads until a new x can be found (return TRUE)
817 * or eof (return FALSE)
823 while (!bTimeSet(TBEGIN) || (*t < rTimeValue(TBEGIN)))
825 if (!do_read_xyz(status, fp, natoms, x, box))
829 printcount(status, oenv, *t, FALSE);
833 if (!bTimeSet(TEND) || (*t <= rTimeValue(TEND)))
835 if (!do_read_xyz(status, fp, natoms, x, box))
837 printlast(status, oenv, *t);
840 printcount(status, oenv, *t, FALSE);
845 printlast(status, oenv, pt);
849 static int xyz_first_x(t_trxstatus *status, FILE *fp, const output_env_t oenv,
850 real *t, rvec **x, matrix box)
851 /* Reads fp, mallocs x, and returns x and box
852 * Returns natoms when successful, FALSE otherwise
860 choose_file_format(fp);
862 for (m = 0; (m < DIM); m++)
864 box[m][m] = status->BOX[m];
867 snew(*x, status->NATOMS);
869 if (!xyz_next_x(status, fp, oenv, t, status->NATOMS, *x, box))
875 return status->NATOMS;
878 static gmx_bool pdb_next_x(t_trxstatus *status, FILE *fp, t_trxframe *fr)
882 int ePBC, model_nr, na;
883 char title[STRLEN], *time;
886 atoms.nr = fr->natoms;
888 atoms.pdbinfo = NULL;
889 /* the other pointers in atoms should not be accessed if these are NULL */
891 na = read_pdbfile(fp, title, &model_nr, &atoms, fr->x, &ePBC, boxpdb, TRUE, NULL);
892 set_trxframe_ePBC(fr, ePBC);
893 if (nframes_read(status) == 0)
895 fprintf(stderr, " '%s', %d atoms\n", title, fr->natoms);
900 fr->bBox = (boxpdb[XX][XX] != 0.0);
903 copy_mat(boxpdb, fr->box);
906 if (model_nr != NOTSET)
911 time = strstr(title, " t= ");
915 sscanf(time+4, "%lf", &dbl);
916 fr->time = (real)dbl;
921 /* this is a bit dirty, but it will work: if no time is read from
922 comment line in pdb file, set time to current frame number */
925 fr->time = (real)fr->step;
929 fr->time = (real)nframes_read(status);
938 if (na != fr->natoms)
940 gmx_fatal(FARGS, "Number of atoms in pdb frame %d is %d instead of %d",
941 nframes_read(status), na, fr->natoms);
947 static int pdb_first_x(t_trxstatus *status, FILE *fp, t_trxframe *fr)
951 fprintf(stderr, "Reading frames from pdb file");
953 get_pdb_coordnum(fp, &fr->natoms);
956 gmx_fatal(FARGS, "\nNo coordinates in pdb file\n");
959 snew(fr->x, fr->natoms);
960 pdb_next_x(status, fp, fr);
965 gmx_bool read_next_frame(const output_env_t oenv, t_trxstatus *status, t_trxframe *fr)
969 gmx_bool bOK, bRet, bMissingData = FALSE, bSkip = FALSE;
978 clear_trxframe(fr, FALSE);
984 /* Special treatment for TNG files */
989 ftp = gmx_fio_getftp(status->fio);
995 bRet = gmx_next_frame(status, fr);
998 /* Checkpoint files can not contain mulitple frames */
1001 read_g96_conf(gmx_fio_getfp(status->fio), NULL, fr,
1002 status->persistent_line);
1003 bRet = (fr->natoms > 0);
1006 bRet = xyz_next_x(status, gmx_fio_getfp(status->fio), oenv, &fr->time,
1007 fr->natoms, fr->x, fr->box);
1013 /* B. Hess 2005-4-20
1014 * Sometimes is off by one frame
1015 * and sometimes reports frame not present/file not seekable
1017 /* DvdS 2005-05-31: this has been fixed along with the increased
1018 * accuracy of the control over -b and -e options.
1020 if (bTimeSet(TBEGIN) && (fr->time < rTimeValue(TBEGIN)))
1022 if (xtc_seek_time(status->fio, rTimeValue(TBEGIN), fr->natoms, TRUE))
1024 gmx_fatal(FARGS, "Specified frame (time %f) doesn't exist or file corrupt/inconsistent.",
1025 rTimeValue(TBEGIN));
1029 bRet = read_next_xtc(status->fio, fr->natoms, &fr->step, &fr->time, fr->box,
1030 fr->x, &fr->prec, &bOK);
1031 fr->bPrec = (bRet && fr->prec > 0);
1038 /* Actually the header could also be not ok,
1039 but from bOK from read_next_xtc this can't be distinguished */
1040 fr->not_ok = DATA_NOT_OK;
1044 bRet = gmx_read_next_tng_frame(status->tng, fr, NULL, 0);
1047 bRet = pdb_next_x(status, gmx_fio_getfp(status->fio), fr);
1050 bRet = gro_next_x_or_v(gmx_fio_getfp(status->fio), fr);
1053 #ifdef GMX_USE_PLUGINS
1054 bRet = read_next_vmd_frame(fr);
1056 gmx_fatal(FARGS, "DEATH HORROR in read_next_frame ftp=%s,status=%s",
1057 ftp2ext(gmx_fio_getftp(status->fio)),
1058 gmx_fio_getname(status->fio));
1064 bMissingData = (((fr->flags & TRX_NEED_X) && !fr->bX) ||
1065 ((fr->flags & TRX_NEED_V) && !fr->bV) ||
1066 ((fr->flags & TRX_NEED_F) && !fr->bF));
1070 ct = check_times2(fr->time, fr->t0, fr->bDouble);
1071 if (ct == 0 || ((fr->flags & TRX_DONT_SKIP) && ct < 0))
1073 printcount(status, oenv, fr->time, FALSE);
1081 printcount(status, oenv, fr->time, TRUE);
1088 while (bRet && (bMissingData || bSkip));
1092 printlast(status, oenv, pt);
1095 printincomp(status, fr);
1102 int read_first_frame(const output_env_t oenv, t_trxstatus **status,
1103 const char *fn, t_trxframe *fr, int flags)
1106 gmx_bool bFirst, bOK;
1108 int ftp = fn2ftp(fn);
1109 gmx_int64_t *tng_ids;
1111 clear_trxframe(fr, TRUE);
1118 status_init( *status );
1119 (*status)->nxframe = 1;
1124 /* Special treatment for TNG files */
1125 gmx_tng_open(fn, 'r', &(*status)->tng);
1129 fio = (*status)->fio = gmx_fio_open(fn, "r");
1137 read_checkpoint_trxframe(fio, fr);
1141 /* Can not rewind a compressed file, so open it twice */
1142 if (!(*status)->persistent_line)
1144 /* allocate the persistent line */
1145 snew((*status)->persistent_line, STRLEN+1);
1147 read_g96_conf(gmx_fio_getfp(fio), fn, fr, (*status)->persistent_line);
1149 clear_trxframe(fr, FALSE);
1150 if (flags & (TRX_READ_X | TRX_NEED_X))
1152 snew(fr->x, fr->natoms);
1154 if (flags & (TRX_READ_V | TRX_NEED_V))
1156 snew(fr->v, fr->natoms);
1158 fio = (*status)->fio = gmx_fio_open(fn, "r");
1161 fr->natoms = xyz_first_x(*status, gmx_fio_getfp(fio), oenv, &fr->time,
1168 printcount(*status, oenv, fr->time, FALSE);
1173 if (read_first_xtc(fio, &fr->natoms, &fr->step, &fr->time, fr->box, &fr->x,
1174 &fr->prec, &bOK) == 0)
1177 fr->not_ok = DATA_NOT_OK;
1182 printincomp(*status, fr);
1186 fr->bPrec = (fr->prec > 0);
1191 printcount(*status, oenv, fr->time, FALSE);
1197 if (!gmx_read_next_tng_frame((*status)->tng, fr, NULL, 0))
1199 fr->not_ok = DATA_NOT_OK;
1201 printincomp(*status, fr);
1205 printcount(*status, oenv, fr->time, FALSE);
1210 pdb_first_x(*status, gmx_fio_getfp(fio), fr);
1213 printcount(*status, oenv, fr->time, FALSE);
1218 if (gro_first_x_or_v(gmx_fio_getfp(fio), fr))
1220 printcount(*status, oenv, fr->time, FALSE);
1225 #ifdef GMX_USE_PLUGINS
1226 fprintf(stderr, "The file format of %s is not a known trajectory format to GROMACS.\n"
1227 "Please make sure that the file is a trajectory!\n"
1228 "GROMACS will now assume it to be a trajectory and will try to open it using the VMD plug-ins.\n"
1229 "This will only work in case the VMD plugins are found and it is a trajectory format supported by VMD.\n", fn);
1230 gmx_fio_fp_close(fio); /*only close the file without removing FIO entry*/
1231 if (!read_first_vmd_frame(fn, fr))
1233 gmx_fatal(FARGS, "Not supported in read_first_frame: %s", fn);
1236 gmx_fatal(FARGS, "Not supported in read_first_frame: %s. Please make sure that the file is a trajectory.\n"
1237 "GROMACS is not compiled with plug-in support. Thus it cannot read non-GROMACS trajectory formats using the VMD plug-ins.\n"
1238 "Please compile with plug-in support if you want to read non-GROMACS trajectory formats.\n", fn);
1243 /* Return FALSE if we read a frame that's past the set ending time. */
1244 if (!bFirst && (!(fr->flags & TRX_DONT_SKIP) && check_times(fr->time) > 0))
1251 (!(fr->flags & TRX_DONT_SKIP) && check_times(fr->time) < 0))
1253 /* Read a frame when no frame was read or the first was skipped */
1254 if (!read_next_frame(oenv, *status, fr))
1261 return (fr->natoms > 0);
1264 /***** C O O R D I N A T E S T U F F *****/
1266 int read_first_x(const output_env_t oenv, t_trxstatus **status, const char *fn,
1267 real *t, rvec **x, matrix box)
1271 read_first_frame(oenv, status, fn, &fr, TRX_NEED_X);
1273 snew((*status)->xframe, 1);
1274 (*status)->nxframe = 1;
1275 (*(*status)->xframe) = fr;
1276 *t = (*status)->xframe->time;
1277 *x = (*status)->xframe->x;
1278 copy_mat((*status)->xframe->box, box);
1280 return (*status)->xframe->natoms;
1283 gmx_bool read_next_x(const output_env_t oenv, t_trxstatus *status, real *t,
1284 rvec x[], matrix box)
1288 status->xframe->x = x;
1289 /*xframe[status].x = x;*/
1290 bRet = read_next_frame(oenv, status, status->xframe);
1291 *t = status->xframe->time;
1292 copy_mat(status->xframe->box, box);
1297 void close_trj(t_trxstatus *status)
1299 gmx_tng_close(&status->tng);
1302 gmx_fio_close(status->fio);
1305 /* The memory in status->xframe is lost here,
1306 * but the read_first_x/read_next_x functions are deprecated anyhow.
1307 * read_first_frame/read_next_frame and close_trx should be used.
1312 void rewind_trj(t_trxstatus *status)
1316 gmx_fio_rewind(status->fio);
1319 /***** T O P O L O G Y S T U F F ******/
1321 t_topology *read_top(const char *fn, int *ePBC)
1327 epbc = read_tpx_top(fn, NULL, NULL, &natoms, NULL, NULL, NULL, top);