From: Alexey Shvetsov Date: Fri, 24 Jul 2015 17:16:56 +0000 (+0300) Subject: Merge branch 'master' into pygromacs X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=5a1c6c2d2947f53332b02ca7cbe01dced80b6376;hp=a9f409c8d07c336c774349af23b598c56fe09712;p=alexxy%2Fgromacs.git Merge branch 'master' into pygromacs --- diff --git a/src/contrib/anaf.c b/src/contrib/anaf.c deleted file mode 100644 index 044d987048..0000000000 --- a/src/contrib/anaf.c +++ /dev/null @@ -1,166 +0,0 @@ -/* - * - * 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 -#endif - -#include -#include -#include - -#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/trnio.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 #include #include +#include + +#include + #include "gromacs/correlationfunctions/expfit.h" #include "gromacs/correlationfunctions/integrate.h" #include "gromacs/correlationfunctions/manyautocorrelation.h" @@ -87,16 +90,12 @@ static void low_do_four_core(int nfour, int nframes, real c1[], real cfour[], int nCos) { int i = 0; - int fftcode; - real aver, *ans; - aver = 0.0; switch (nCos) { case enNorm: for (i = 0; (i < nframes); i++) { - aver += c1[i]; cfour[i] = c1[i]; } break; @@ -116,7 +115,7 @@ static void low_do_four_core(int nfour, int nframes, real c1[], real cfour[], gmx_fatal(FARGS, "nCos = %d, %s %d", nCos, __FILE__, __LINE__); } - fftcode = many_auto_correl(1, nframes, nfour, &cfour); + many_auto_correl(1, nframes, nfour, &cfour); } /*! \brief Routine to comput ACF without FFT. */ @@ -577,8 +576,8 @@ void low_do_autocorr(const char *fn, const output_env_t oenv, const char *title, } if (bFour) { - c0 = log((double)nframes)/log(2.0); - k = c0; + c0 = std::log(static_cast(nframes))/std::log(2.0); + k = static_cast(c0); if (k < c0) { k++; @@ -606,10 +605,9 @@ void low_do_autocorr(const char *fn, const output_env_t oenv, const char *title, * In this loop the actual correlation functions are computed, but without * normalizing them. */ - k = max(1, pow(10, (int)(log(nitem)/log(100)))); - for (i = 0; i < nitem; i++) + for (int i = 0; i < nitem; i++) { - if (bVerbose && ((i%k == 0 || i == nitem-1))) + if (bVerbose && (((i % 100) == 0) || (i == nitem-1))) { fprintf(stderr, "\rThingie %d", i+1); } @@ -660,10 +658,10 @@ void low_do_autocorr(const char *fn, const output_env_t oenv, const char *title, else { sum = print_and_integrate(fp, nout, dt, c1[0], NULL, 1); - if (bVerbose) - { - printf("Correlation time (integral over corrfn): %g (ps)\n", sum); - } + } + if (bVerbose) + { + printf("Correlation time (integral over corrfn): %g (ps)\n", sum); } } else diff --git a/src/gromacs/correlationfunctions/crosscorr.c b/src/gromacs/correlationfunctions/crosscorr.cpp similarity index 98% rename from src/gromacs/correlationfunctions/crosscorr.c rename to src/gromacs/correlationfunctions/crosscorr.cpp index 1911b5b41e..b588bd8f86 100644 --- a/src/gromacs/correlationfunctions/crosscorr.c +++ b/src/gromacs/correlationfunctions/crosscorr.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2014, by the GROMACS development team, led by + * Copyright (c) 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. diff --git a/src/gromacs/correlationfunctions/integrate.c b/src/gromacs/correlationfunctions/integrate.cpp similarity index 98% rename from src/gromacs/correlationfunctions/integrate.c rename to src/gromacs/correlationfunctions/integrate.cpp index dc0a7ae083..d58c5add9d 100644 --- a/src/gromacs/correlationfunctions/integrate.c +++ b/src/gromacs/correlationfunctions/integrate.cpp @@ -3,7 +3,7 @@ * * 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. diff --git a/src/gromacs/correlationfunctions/manyautocorrelation.c b/src/gromacs/correlationfunctions/manyautocorrelation.cpp similarity index 89% rename from src/gromacs/correlationfunctions/manyautocorrelation.c rename to src/gromacs/correlationfunctions/manyautocorrelation.cpp index c4fb7db465..8474c867a3 100644 --- a/src/gromacs/correlationfunctions/manyautocorrelation.c +++ b/src/gromacs/correlationfunctions/manyautocorrelation.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2014, by the GROMACS development team, led by + * Copyright (c) 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. @@ -43,10 +43,13 @@ #include "manyautocorrelation.h" -#include #include #include +#include + +#include + #include "gromacs/fft/fft.h" #include "gromacs/legacyheaders/macros.h" #include "gromacs/utility/gmxomp.h" @@ -57,7 +60,7 @@ int many_auto_correl(int nfunc, int ndata, int nfft, real **c) #pragma omp parallel { typedef real complex[2]; - int i, t, j, fftcode; + int i, j; gmx_fft_t fft1; complex *in, *out; int i0, i1; @@ -70,9 +73,9 @@ int many_auto_correl(int nfunc, int ndata, int nfft, real **c) // fprintf(stderr, "There are %d threads for correlation functions\n", nthreads); } i0 = thread_id*nfunc/nthreads; - i1 = min(nfunc, (thread_id+1)*nfunc/nthreads); + i1 = std::min(nfunc, (thread_id+1)*nfunc/nthreads); - fftcode = gmx_fft_init_1d(&fft1, nfft, GMX_FFT_FLAG_CONSERVATIVE); + gmx_fft_init_1d(&fft1, nfft, GMX_FFT_FLAG_CONSERVATIVE); /* Allocate temporary arrays */ snew(in, nfft); snew(out, nfft); @@ -88,7 +91,7 @@ int many_auto_correl(int nfunc, int ndata, int nfft, real **c) in[j][0] = in[j][1] = 0; } - fftcode = gmx_fft_1d(fft1, GMX_FFT_BACKWARD, (void *)in, (void *)out); + gmx_fft_1d(fft1, GMX_FFT_BACKWARD, (void *)in, (void *)out); for (j = 0; j < nfft; j++) { in[j][0] = (out[j][0]*out[j][0] + out[j][1]*out[j][1])/nfft; @@ -99,7 +102,7 @@ int many_auto_correl(int nfunc, int ndata, int nfft, real **c) in[j][0] = in[j][1] = 0; } - fftcode = gmx_fft_1d(fft1, GMX_FFT_FORWARD, (void *)in, (void *)out); + gmx_fft_1d(fft1, GMX_FFT_FORWARD, (void *)in, (void *)out); for (j = 0; (j < nfft); j++) { c[i][j] = out[j][0]/ndata; diff --git a/src/gromacs/correlationfunctions/polynomials.c b/src/gromacs/correlationfunctions/polynomials.cpp similarity index 97% rename from src/gromacs/correlationfunctions/polynomials.c rename to src/gromacs/correlationfunctions/polynomials.cpp index c5f499a17d..18765ab1ff 100644 --- a/src/gromacs/correlationfunctions/polynomials.c +++ b/src/gromacs/correlationfunctions/polynomials.cpp @@ -3,7 +3,7 @@ * * 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. diff --git a/src/gromacs/fileio/CMakeLists.txt b/src/gromacs/fileio/CMakeLists.txt index 0c638a78a8..c3a4552954 100644 --- a/src/gromacs/fileio/CMakeLists.txt +++ b/src/gromacs/fileio/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of the GROMACS molecular simulation package. # -# 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. @@ -53,7 +53,7 @@ gmx_install_headers( pdbio.h tpxio.h trajectory_writing.h - trnio.h + trrio.h trx.h trxio.h xdr_datatype.h diff --git a/src/gromacs/fileio/mdoutf.cpp b/src/gromacs/fileio/mdoutf.cpp index db89c8ea6a..2f6f68ac37 100644 --- a/src/gromacs/fileio/mdoutf.cpp +++ b/src/gromacs/fileio/mdoutf.cpp @@ -40,7 +40,7 @@ #include "gromacs/fileio/gmxfio.h" #include "gromacs/fileio/tngio.h" #include "gromacs/fileio/trajectory_writing.h" -#include "gromacs/fileio/trnio.h" +#include "gromacs/fileio/trrio.h" #include "gromacs/fileio/xtcio.h" #include "gromacs/fileio/xvgr.h" #include "gromacs/legacyheaders/checkpoint.h" @@ -125,7 +125,7 @@ gmx_mdoutf_t init_mdoutf(FILE *fplog, int nfile, const t_filenm fnm[], { 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); @@ -315,11 +315,11 @@ void mdoutf_write_to_trajectory_files(FILE *fplog, t_commrec *cr, { 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?"); @@ -405,7 +405,7 @@ void done_mdoutf(gmx_mdoutf_t of) } if (of->fp_trn) { - close_trn(of->fp_trn); + gmx_trr_close(of->fp_trn); } if (of->fp_dhdl != NULL) { diff --git a/src/gromacs/fileio/trnio.h b/src/gromacs/fileio/trnio.h deleted file mode 100644 index 3550790f91..0000000000 --- a/src/gromacs/fileio/trnio.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - * This file is part of the GROMACS molecular simulation package. - * - * Copyright (c) 1991-2000, University of Groningen, The Netherlands. - * Copyright (c) 2001-2004, The GROMACS development team. - * 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. - * - * GROMACS is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 - * of the License, or (at your option) any later version. - * - * GROMACS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with GROMACS; if not, see - * http://www.gnu.org/licenses, or write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * If you want to redistribute modifications to GROMACS, 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 http://www.gromacs.org. - * - * To help us fund GROMACS development, we humbly ask that you cite - * the research papers on the package. Check out http://www.gromacs.org. - */ - -#ifndef GMX_FILEIO_TRNIO_H -#define GMX_FILEIO_TRNIO_H - -#include "gromacs/math/vectypes.h" -#include "gromacs/utility/basedefinitions.h" -#include "gromacs/utility/real.h" - -/************************************************************** - * - * These routines handle trr (trajectory) I/O, they read and - * write trr files. The routines should be able to read single - * and double precision files without the user noting it. - * The files are backward compatible, therefore the header holds - * some unused variables. - * - * The routines in the corresponding c-file trnio.c - * are based on the lower level routines in gmxfio.c - * The integer file pointer returned from open_trn - * can also be used with the routines in gmxfio.h - * - **************************************************************/ - -#ifdef __cplusplus -extern "C" { -#endif - -struct t_fileio; - -typedef struct /* This struct describes the order and the */ - /* sizes of the structs in a trjfile, sizes are given in bytes. */ -{ - 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); -/* 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. - * 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); -/* Extern read a frame except the header (that should be pre-read, - * using routine read_trnheader, see above) from a trn 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 - * 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 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 - */ - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/src/gromacs/fileio/trnio.cpp b/src/gromacs/fileio/trrio.cpp similarity index 70% rename from src/gromacs/fileio/trnio.cpp rename to src/gromacs/fileio/trrio.cpp index b843db3317..f3e16b1f4d 100644 --- a/src/gromacs/fileio/trnio.cpp +++ b/src/gromacs/fileio/trrio.cpp @@ -36,7 +36,7 @@ */ #include "gmxpre.h" -#include "trnio.h" +#include "trrio.h" #include @@ -51,7 +51,7 @@ #define BUFSIZE 128 #define GROMACS_MAGIC 1993 -static int nFloatSize(t_trnheader *sh) +static int nFloatSize(gmx_trr_header_t *sh) { int nflsize = 0; @@ -73,7 +73,7 @@ static int nFloatSize(t_trnheader *sh) } 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)))) @@ -84,7 +84,8 @@ static int nFloatSize(t_trnheader *sh) 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; @@ -102,7 +103,7 @@ static gmx_bool do_trnheader(t_fileio *fio, gmx_bool bRead, t_trnheader *sh, gmx *bOK = *bOK && gmx_fio_do_string(fio, buf); if (bFirst) { - fprintf(stderr, "trn version: %s ", buf); + fprintf(stderr, "trr version: %s ", buf); } } else @@ -143,8 +144,9 @@ static gmx_bool do_trnheader(t_fileio *fio, gmx_bool bRead, t_trnheader *sh, gmx 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; @@ -178,11 +180,12 @@ static gmx_bool do_htrn(t_fileio *fio, t_trnheader *sh, 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) @@ -197,7 +200,7 @@ static gmx_bool do_trn(t_fileio *fio, gmx_bool bRead, int *step, real *t, real * sh->t = *t; sh->lambda = *lambda; } - if (!do_trnheader(fio, bRead, sh, &bOK)) + if (!do_trr_frame_header(fio, bRead, sh, &bOK)) { return FALSE; } @@ -209,22 +212,22 @@ static gmx_bool do_trn(t_fileio *fio, gmx_bool bRead, int *step, real *t, real * *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); @@ -237,72 +240,66 @@ static gmx_bool do_trn(t_fileio *fio, gmx_bool bRead, int *step, real *t, real * * ************************************************************/ -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); } diff --git a/src/gromacs/fileio/trrio.h b/src/gromacs/fileio/trrio.h new file mode 100644 index 0000000000..3f280576c0 --- /dev/null +++ b/src/gromacs/fileio/trrio.h @@ -0,0 +1,136 @@ +/* + * This file is part of the GROMACS molecular simulation package. + * + * Copyright (c) 1991-2000, University of Groningen, The Netherlands. + * Copyright (c) 2001-2004, The GROMACS development team. + * 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. + * + * GROMACS is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * GROMACS is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with GROMACS; if not, see + * http://www.gnu.org/licenses, or write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * If you want to redistribute modifications to GROMACS, 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 http://www.gromacs.org. + * + * To help us fund GROMACS development, we humbly ask that you cite + * the research papers on the package. Check out http://www.gromacs.org. + */ +#ifndef GMX_FILEIO_TRRIO_H +#define GMX_FILEIO_TRRIO_H + +#include "gromacs/math/vectypes.h" +#include "gromacs/utility/basedefinitions.h" +#include "gromacs/utility/real.h" + +/************************************************************** + * + * These routines handle trr (trajectory) I/O, they read and + * write trr files. The routines should be able to read single + * and double precision files without the user noting it. + * The files are backward compatible, therefore the header holds + * some unused variables. + * + * The routines in the corresponding c-file trrio.cpp + * are based on the lower level routines in gmxfio.cpp + * The file handle returned from gmx_trr_open() + * can also be used with the routines in gmxfio.h + * + **************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +struct t_fileio; + +/* 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 */ +} 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 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. + */ + +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 gmx_trr_read_frame_header(), see above) from a trr file. + * Return FALSE on error + */ + +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 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 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 + + +#endif diff --git a/src/gromacs/fileio/trxio.cpp b/src/gromacs/fileio/trxio.cpp index 116dc4c2a8..ab386090eb 100644 --- a/src/gromacs/fileio/trxio.cpp +++ b/src/gromacs/fileio/trxio.cpp @@ -53,7 +53,7 @@ #include "gromacs/fileio/tngio.h" #include "gromacs/fileio/tngio_for_tools.h" #include "gromacs/fileio/tpxio.h" -#include "gromacs/fileio/trnio.h" +#include "gromacs/fileio/trrio.h" #include "gromacs/fileio/trx.h" #include "gromacs/fileio/xdrf.h" #include "gromacs/fileio/xtcio.h" @@ -397,8 +397,8 @@ int write_trxframe_indexed(t_trxstatus *status, t_trxframe *fr, int nind, 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: @@ -549,8 +549,8 @@ int write_trxframe(t_trxstatus *status, t_trxframe *fr, gmx_conect gc) 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: @@ -636,12 +636,12 @@ t_trxstatus *open_trx(const char *outfile, const char *filemode) 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; @@ -677,7 +677,7 @@ static gmx_bool gmx_next_frame(t_trxstatus *status, t_trxframe *fr) } 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; } diff --git a/src/gromacs/gmxana/eigio.c b/src/gromacs/gmxana/eigio.c index 1561d5a446..97daf30f4b 100644 --- a/src/gromacs/gmxana/eigio.c +++ b/src/gromacs/gmxana/eigio.c @@ -38,7 +38,8 @@ #include "eigio.h" -#include "gromacs/fileio/trnio.h" +#include "gromacs/fileio/tpxio.h" +#include "gromacs/fileio/trrio.h" #include "gromacs/math/vec.h" #include "gromacs/utility/futil.h" #include "gromacs/utility/smalloc.h" @@ -49,7 +50,7 @@ void read_eigenvectors(const char *file, int *natoms, gmx_bool *bFit, 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; @@ -59,11 +60,11 @@ void read_eigenvectors(const char *file, int *natoms, gmx_bool *bFit, *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)) { @@ -84,8 +85,8 @@ void read_eigenvectors(const char *file, int *natoms, gmx_bool *bFit, 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 { @@ -114,9 +115,9 @@ void read_eigenvectors(const char *file, int *natoms, gmx_bool *bFit, 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; @@ -135,16 +136,17 @@ void read_eigenvectors(const char *file, int *natoms, gmx_bool *bFit, (*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; @@ -156,22 +158,22 @@ void write_eigenvectors(const char *trnname, int natoms, real mat[], 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++) { @@ -194,9 +196,9 @@ void write_eigenvectors(const char *trnname, int natoms, real mat[], } /* 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); } diff --git a/src/gromacs/gmxana/eigio.h b/src/gromacs/gmxana/eigio.h index b254923bb6..7b2638e16d 100644 --- a/src/gromacs/gmxana/eigio.h +++ b/src/gromacs/gmxana/eigio.h @@ -3,7 +3,7 @@ * * 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. @@ -56,11 +56,11 @@ extern void read_eigenvectors(const char *file, int *natoms, gmx_bool *bFit, /* 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. */ diff --git a/src/gromacs/gmxana/gmx_angle.c b/src/gromacs/gmxana/gmx_angle.c index 88304ed029..a12593a7b1 100644 --- a/src/gromacs/gmxana/gmx_angle.c +++ b/src/gromacs/gmxana/gmx_angle.c @@ -41,7 +41,7 @@ #include "gromacs/commandline/pargs.h" #include "gromacs/correlationfunctions/autocorr.h" -#include "gromacs/fileio/trnio.h" +#include "gromacs/fileio/trrio.h" #include "gromacs/fileio/xvgr.h" #include "gromacs/gmxana/gmx_ana.h" #include "gromacs/gmxana/gstat.h" @@ -56,11 +56,11 @@ #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}}; @@ -76,7 +76,7 @@ static void dump_dih_trn(int nframes, int nangles, real **dih, const char *fn, 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; @@ -93,9 +93,9 @@ static void dump_dih_trn(int nframes, int nangles, real **dih, const char *fn, } } } - 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); } @@ -209,7 +209,7 @@ int gmx_g_angle(int argc, char *argv[]) { if (mult != 4) { - gmx_fatal(FARGS, "Can not combine angles with trn dump"); + gmx_fatal(FARGS, "Can not combine angles with trr dump"); } else { @@ -309,7 +309,7 @@ int gmx_g_angle(int argc, char *argv[]) } 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) diff --git a/src/gromacs/gmxana/gmx_cluster.c b/src/gromacs/gmxana/gmx_cluster.c index 3a746b6eb3..011fe580e2 100644 --- a/src/gromacs/gmxana/gmx_cluster.c +++ b/src/gromacs/gmxana/gmx_cluster.c @@ -43,7 +43,6 @@ #include "gromacs/commandline/pargs.h" #include "gromacs/fileio/confio.h" #include "gromacs/fileio/matio.h" -#include "gromacs/fileio/trnio.h" #include "gromacs/fileio/trxio.h" #include "gromacs/fileio/xvgr.h" #include "gromacs/gmxana/cmat.h" diff --git a/src/gromacs/gmxana/gmx_covar.c b/src/gromacs/gmxana/gmx_covar.c index bad3518aba..779326f0b5 100644 --- a/src/gromacs/gmxana/gmx_covar.c +++ b/src/gromacs/gmxana/gmx_covar.c @@ -42,7 +42,6 @@ #include "gromacs/commandline/pargs.h" #include "gromacs/fileio/confio.h" #include "gromacs/fileio/matio.h" -#include "gromacs/fileio/trnio.h" #include "gromacs/fileio/trxio.h" #include "gromacs/fileio/xvgr.h" #include "gromacs/gmxana/eigio.h" diff --git a/src/gromacs/gmxana/gmx_sigeps.c b/src/gromacs/gmxana/gmx_sigeps.c index f426fe4e51..3866506b28 100644 --- a/src/gromacs/gmxana/gmx_sigeps.c +++ b/src/gromacs/gmxana/gmx_sigeps.c @@ -40,9 +40,6 @@ #include #include "gromacs/commandline/pargs.h" -#include "gromacs/fileio/confio.h" -#include "gromacs/fileio/pdbio.h" -#include "gromacs/fileio/trnio.h" #include "gromacs/fileio/xvgr.h" #include "gromacs/legacyheaders/macros.h" #include "gromacs/legacyheaders/names.h" diff --git a/src/gromacs/gmxana/gmx_trjcat.c b/src/gromacs/gmxana/gmx_trjcat.c index 6f8463f63e..d6c2335650 100644 --- a/src/gromacs/gmxana/gmx_trjcat.c +++ b/src/gromacs/gmxana/gmx_trjcat.c @@ -46,7 +46,6 @@ #include "gromacs/fileio/pdbio.h" #include "gromacs/fileio/tngio.h" #include "gromacs/fileio/tngio_for_tools.h" -#include "gromacs/fileio/trnio.h" #include "gromacs/fileio/trxio.h" #include "gromacs/fileio/xtcio.h" #include "gromacs/fileio/xvgr.h" diff --git a/src/gromacs/gmxana/gmx_trjconv.c b/src/gromacs/gmxana/gmx_trjconv.c index 9db84bee50..213eae951b 100644 --- a/src/gromacs/gmxana/gmx_trjconv.c +++ b/src/gromacs/gmxana/gmx_trjconv.c @@ -48,7 +48,7 @@ #include "gromacs/fileio/pdbio.h" #include "gromacs/fileio/tngio_for_tools.h" #include "gromacs/fileio/tpxio.h" -#include "gromacs/fileio/trnio.h" +#include "gromacs/fileio/trrio.h" #include "gromacs/fileio/trxio.h" #include "gromacs/fileio/xtcio.h" #include "gromacs/fileio/xvgr.h" @@ -463,7 +463,7 @@ static void mk_filenm(char *base, const char *ext, int ndigit, int file_nr, strcat(out_file, ext); } -void check_trn(const char *fn) +void check_trr(const char *fn) { if (fn2ftp(fn) != efTRR) { @@ -476,7 +476,7 @@ void do_trunc(const char *fn, real t0) 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; @@ -488,23 +488,23 @@ void do_trunc(const char *fn, real t0) } /* 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) @@ -525,7 +525,7 @@ void do_trunc(const char *fn, real 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); @@ -539,7 +539,7 @@ void do_trunc(const char *fn, real t0) else { fprintf(stderr, "Already at end of file (t=%g)...\n", t); - close_trn(in); + gmx_trr_close(in); } } } diff --git a/src/gromacs/gmxpreprocess/grompp.cpp b/src/gromacs/gmxpreprocess/grompp.cpp index 304e68c20b..8a6e43c666 100644 --- a/src/gromacs/gmxpreprocess/grompp.cpp +++ b/src/gromacs/gmxpreprocess/grompp.cpp @@ -52,7 +52,6 @@ #include "gromacs/fileio/confio.h" #include "gromacs/fileio/enxio.h" #include "gromacs/fileio/tpxio.h" -#include "gromacs/fileio/trnio.h" #include "gromacs/fileio/trxio.h" #include "gromacs/gmxpreprocess/add_par.h" #include "gromacs/gmxpreprocess/convparm.h" diff --git a/src/gromacs/gmxpreprocess/readrot.cpp b/src/gromacs/gmxpreprocess/readrot.cpp index 6968670a27..f663e95303 100644 --- a/src/gromacs/gmxpreprocess/readrot.cpp +++ b/src/gromacs/gmxpreprocess/readrot.cpp @@ -36,7 +36,7 @@ */ #include "gmxpre.h" -#include "gromacs/fileio/trnio.h" +#include "gromacs/fileio/trrio.h" #include "gromacs/gmxpreprocess/readir.h" #include "gromacs/legacyheaders/names.h" #include "gromacs/legacyheaders/txtdump.h" @@ -239,12 +239,12 @@ extern void set_reference_positions( 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: */ @@ -276,13 +276,13 @@ extern void set_reference_positions( 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); @@ -295,7 +295,7 @@ extern void set_reference_positions( 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); } } } diff --git a/src/gromacs/mdlib/expanded.c b/src/gromacs/mdlib/expanded.c index f1a1bce5e8..402662de4c 100644 --- a/src/gromacs/mdlib/expanded.c +++ b/src/gromacs/mdlib/expanded.c @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by + * Copyright (c) 2012,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. @@ -40,7 +40,6 @@ #include "gromacs/domdec/domdec.h" #include "gromacs/fileio/confio.h" #include "gromacs/fileio/gmxfio.h" -#include "gromacs/fileio/trnio.h" #include "gromacs/fileio/xtcio.h" #include "gromacs/legacyheaders/calcmu.h" #include "gromacs/legacyheaders/chargegroup.h" diff --git a/src/gromacs/mdlib/stat.cpp b/src/gromacs/mdlib/stat.cpp index 08ae193dff..fc906209eb 100644 --- a/src/gromacs/mdlib/stat.cpp +++ b/src/gromacs/mdlib/stat.cpp @@ -40,7 +40,6 @@ #include #include "gromacs/domdec/domdec.h" -#include "gromacs/fileio/trnio.h" #include "gromacs/fileio/xtcio.h" #include "gromacs/legacyheaders/checkpoint.h" #include "gromacs/legacyheaders/constr.h" diff --git a/src/gromacs/pulling/pull_rotation.cpp b/src/gromacs/pulling/pull_rotation.cpp index 187fef017f..a44e84a477 100644 --- a/src/gromacs/pulling/pull_rotation.cpp +++ b/src/gromacs/pulling/pull_rotation.cpp @@ -48,7 +48,6 @@ #include "gromacs/domdec/domdec.h" #include "gromacs/fileio/gmxfio.h" -#include "gromacs/fileio/trnio.h" #include "gromacs/fileio/xvgr.h" #include "gromacs/legacyheaders/copyrite.h" #include "gromacs/legacyheaders/gmx_ga2la.h" diff --git a/src/gromacs/tools/check.cpp b/src/gromacs/tools/check.cpp index cc19905b07..0c34c66cb1 100644 --- a/src/gromacs/tools/check.cpp +++ b/src/gromacs/tools/check.cpp @@ -45,7 +45,6 @@ #include "gromacs/fileio/enxio.h" #include "gromacs/fileio/gmxfio.h" #include "gromacs/fileio/tpxio.h" -#include "gromacs/fileio/trnio.h" #include "gromacs/fileio/trxio.h" #include "gromacs/fileio/xtcio.h" #include "gromacs/legacyheaders/macros.h" diff --git a/src/gromacs/tools/convert_tpr.cpp b/src/gromacs/tools/convert_tpr.cpp index 696f61c202..01c772c9c2 100644 --- a/src/gromacs/tools/convert_tpr.cpp +++ b/src/gromacs/tools/convert_tpr.cpp @@ -41,7 +41,7 @@ #include "gromacs/commandline/pargs.h" #include "gromacs/fileio/enxio.h" #include "gromacs/fileio/tpxio.h" -#include "gromacs/fileio/trnio.h" +#include "gromacs/fileio/trrio.h" #include "gromacs/gmxpreprocess/readir.h" #include "gromacs/legacyheaders/checkpoint.h" #include "gromacs/legacyheaders/macros.h" @@ -352,7 +352,7 @@ int gmx_convert_tpr(int argc, char *argv[]) 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; @@ -489,7 +489,7 @@ int gmx_convert_tpr(int argc, char *argv[]) "\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"); @@ -505,7 +505,7 @@ int gmx_convert_tpr(int argc, char *argv[]) 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) @@ -520,7 +520,7 @@ int gmx_convert_tpr(int argc, char *argv[]) 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; @@ -572,7 +572,7 @@ int gmx_convert_tpr(int argc, char *argv[]) free_enxframe(fr_ener); free_enxnms(nre, enm); } - close_trn(fp); + gmx_trr_close(fp); fprintf(stderr, "\n"); if (!bOK) diff --git a/src/gromacs/tools/dump.cpp b/src/gromacs/tools/dump.cpp index d9b20863d9..305abf88f6 100644 --- a/src/gromacs/tools/dump.cpp +++ b/src/gromacs/tools/dump.cpp @@ -50,7 +50,7 @@ #include "gromacs/fileio/tngio.h" #include "gromacs/fileio/tngio_for_tools.h" #include "gromacs/fileio/tpxio.h" -#include "gromacs/fileio/trnio.h" +#include "gromacs/fileio/trrio.h" #include "gromacs/fileio/xtcio.h" #include "gromacs/gmxpreprocess/gmxcpp.h" #include "gromacs/legacyheaders/checkpoint.h" @@ -203,57 +203,57 @@ static void list_top(const char *fn) } } -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); @@ -264,9 +264,9 @@ static void list_trn(const char *fn) 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) @@ -405,7 +405,7 @@ void list_trx(const char *fn) list_xtc(fn); break; case efTRR: - list_trn(fn); + list_trr(fn); break; case efTNG: list_tng(fn);