Merge branch 'master' into pygromacs
authorAlexey Shvetsov <alexxy@omrb.pnpi.spb.ru>
Fri, 24 Jul 2015 17:16:56 +0000 (20:16 +0300)
committerAlexey Shvetsov <alexxy@omrb.pnpi.spb.ru>
Fri, 24 Jul 2015 17:16:56 +0000 (20:16 +0300)
31 files changed:
src/contrib/anaf.c [deleted file]
src/contrib/mkice.c
src/contrib/test.c
src/gromacs/correlationfunctions/CMakeLists.txt
src/gromacs/correlationfunctions/autocorr.cpp [moved from src/gromacs/correlationfunctions/autocorr.c with 97% similarity]
src/gromacs/correlationfunctions/crosscorr.cpp [moved from src/gromacs/correlationfunctions/crosscorr.c with 98% similarity]
src/gromacs/correlationfunctions/integrate.cpp [moved from src/gromacs/correlationfunctions/integrate.c with 98% similarity]
src/gromacs/correlationfunctions/manyautocorrelation.cpp [moved from src/gromacs/correlationfunctions/manyautocorrelation.c with 89% similarity]
src/gromacs/correlationfunctions/polynomials.cpp [moved from src/gromacs/correlationfunctions/polynomials.c with 97% similarity]
src/gromacs/fileio/CMakeLists.txt
src/gromacs/fileio/mdoutf.cpp
src/gromacs/fileio/trnio.h [deleted file]
src/gromacs/fileio/trrio.cpp [moved from src/gromacs/fileio/trnio.cpp with 70% similarity]
src/gromacs/fileio/trrio.h [new file with mode: 0644]
src/gromacs/fileio/trxio.cpp
src/gromacs/gmxana/eigio.c
src/gromacs/gmxana/eigio.h
src/gromacs/gmxana/gmx_angle.c
src/gromacs/gmxana/gmx_cluster.c
src/gromacs/gmxana/gmx_covar.c
src/gromacs/gmxana/gmx_sigeps.c
src/gromacs/gmxana/gmx_trjcat.c
src/gromacs/gmxana/gmx_trjconv.c
src/gromacs/gmxpreprocess/grompp.cpp
src/gromacs/gmxpreprocess/readrot.cpp
src/gromacs/mdlib/expanded.c
src/gromacs/mdlib/stat.cpp
src/gromacs/pulling/pull_rotation.cpp
src/gromacs/tools/check.cpp
src/gromacs/tools/convert_tpr.cpp
src/gromacs/tools/dump.cpp

diff --git a/src/contrib/anaf.c b/src/contrib/anaf.c
deleted file mode 100644 (file)
index 044d987..0000000
+++ /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 <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/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<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;
-}
index a60b847cdd9b881be02bcde7221ec663c71cf627..389a20386b4994a70acc4ea2701264e57f9cbc7b 100644 (file)
@@ -50,7 +50,7 @@
 #include "gromacs/math/units.h"
 #include "names.h"
 #include "txtdump.h"
-#include "gromacs/fileio/trnio.h"
+#include "gromacs/fileio/trrio.h"
 #include "gromacs/topology/symtab.h"
 #include "gromacs/fileio/strdb.h"
 #include "gromacs/fileio/confio.h"
index 865f4b8b476812af1f80dfba784ccab4e7fcfcdc..888ae65950c9e26a8a7c97c44a6bbed5c561ea3b 100644 (file)
@@ -51,7 +51,6 @@
 #include "gromacs/math/units.h"
 #include "names.h"
 #include "txtdump.h"
-#include "gromacs/fileio/trnio.h"
 #include "gromacs/fileio/confio.h"
 
 real pot(real x,real qq,real c6,real c12)
index 6c6718af5d6b8c522d1604bc3c1624408645bda7..88d3bd88b34f1705d6599700052bdebb7f3ac058 100644 (file)
@@ -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.
@@ -32,7 +32,7 @@
 # To help us fund GROMACS development, we humbly ask that you cite
 # the research papers on the package. Check out http://www.gromacs.org.
 
-file(GLOB GMXCORRFUNC_SOURCES *.c *.cpp)
+file(GLOB GMXCORRFUNC_SOURCES *.cpp)
 file(GLOB LMFIT_SOURCES ${CMAKE_SOURCE_DIR}/src/external/lmfit/*.c)
 
 set(LIBGROMACS_SOURCES ${LIBGROMACS_SOURCES} ${GMXCORRFUNC_SOURCES}  ${LMFIT_SOURCES} PARENT_SCOPE)
similarity index 97%
rename from src/gromacs/correlationfunctions/autocorr.c
rename to src/gromacs/correlationfunctions/autocorr.cpp
index 72966978ce38d0a90f5fef87c4e35d1f6ffbcf61..7cdf48d57796f5b184fa53249d04a480e270e6ea 100644 (file)
 
 #include "autocorr.h"
 
-#include <math.h>
 #include <stdio.h>
 #include <string.h>
 
+#include <cmath>
+
+#include <algorithm>
+
 #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<double>(nframes))/std::log(2.0);
+        k  = static_cast<int>(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
similarity index 98%
rename from src/gromacs/correlationfunctions/crosscorr.c
rename to src/gromacs/correlationfunctions/crosscorr.cpp
index 1911b5b41e176ab0e7e6f67db618efc1e6227c9a..b588bd8f86ad5cec0dd657293f236a1bf8ed0f2f 100644 (file)
@@ -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.
similarity index 98%
rename from src/gromacs/correlationfunctions/integrate.c
rename to src/gromacs/correlationfunctions/integrate.cpp
index dc0a7ae0834ee8f834576fe8459b2e447c19b076..d58c5add9d8ba5d2f6d322242450493fedce526d 100644 (file)
@@ -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.
similarity index 89%
rename from src/gromacs/correlationfunctions/manyautocorrelation.c
rename to src/gromacs/correlationfunctions/manyautocorrelation.cpp
index c4fb7db465c5716f7d5a32ac7e21759cea165f85..8474c867a35ace234da337d420bee75d393805c8 100644 (file)
@@ -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.
 
 #include "manyautocorrelation.h"
 
-#include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
 
+#include <cmath>
+
+#include <algorithm>
+
 #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;
similarity index 97%
rename from src/gromacs/correlationfunctions/polynomials.c
rename to src/gromacs/correlationfunctions/polynomials.cpp
index c5f499a17daf50f92fbd1b2a13d3db484427c02c..18765ab1ff7f8c37c3daee3c9a685cf892314b09 100644 (file)
@@ -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.
index 0c638a78a8b7e026bb47f96b48ff3bca28d3bd9b..c3a4552954d9a0b4f4e0e1c6d425c4bbf9569cc3 100644 (file)
@@ -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
index db89c8ea6a45f38b1c99db5d8f85edbb07c9cf56..2f6f68ac37e7dfd6bbbc28080f82ab8acf18ed2c 100644 (file)
@@ -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 (file)
index 3550790..0000000
+++ /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
similarity index 70%
rename from src/gromacs/fileio/trnio.cpp
rename to src/gromacs/fileio/trrio.cpp
index b843db33176c6e9942a900468a688a16b40f2240..f3e16b1f4d966d55ea90bf38d8b3a13a31cbd8b5 100644 (file)
@@ -36,7 +36,7 @@
  */
 #include "gmxpre.h"
 
-#include "trnio.h"
+#include "trrio.h"
 
 #include <cstring>
 
@@ -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 (file)
index 0000000..3f28057
--- /dev/null
@@ -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
index 116dc4c2a89a50633f9688ead9a19b15997d8d04..ab386090ebfc962c432e8afc8c1cee6af7bfe95c 100644 (file)
@@ -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;
         }
index 1561d5a4468974757b6cfe2788e78f076b931f32..97daf30f4b90b70743e2d7d94ba6cf727e88368a 100644 (file)
@@ -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);
 }
index b254923bb6812bc59b2cd037e8660d63166449bf..7b2638e16d3f99d7b6e3f4b1466128d57c6ba610 100644 (file)
@@ -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.                                                    */
index 88304ed029ab441202a6c11e67934f7e0000ba37..a12593a7b19b40b9b79eeca02d5c795342e6580a 100644 (file)
@@ -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"
 #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)
index 3a746b6eb330681bc4e570e07acf6a2c72b12530..011fe580e29347bb9092f6b99c17b051ca5e0bcb 100644 (file)
@@ -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"
index bad3518ababad410abcb8c924d8ff9d719c8dfcd..779326f0b5a91ab8473a45f602a691da66ba2b33 100644 (file)
@@ -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"
index f426fe4e5135a2e6d29f6320744ba205b2900907..3866506b280c0e65b57091e7a9bada03eb1c743d 100644 (file)
@@ -40,9 +40,6 @@
 #include <stdio.h>
 
 #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"
index 6f8463f63e58755937499a4b84245e3cdb939473..d6c2335650c06fa4d2aeee205abe5af5fc829234 100644 (file)
@@ -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"
index 9db84bee50493dd295a364001c5e80fbb7aaec1e..213eae951b78a56321bea554305c0c56c84f3303 100644 (file)
@@ -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);
         }
     }
 }
index 304e68c20b450385650962f701dcd93262957fd9..8a6e43c666382223b157bbf261700cd739252faa 100644 (file)
@@ -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"
index 6968670a27e557690725cb15c82ea7a3c20837f7..f663e953037c5ebb2fd3af115dfd852a2ad5e840 100644 (file)
@@ -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);
         }
     }
 }
index f1a1bce5e8f7ddb1938771ae27f55a58514473ed..402662de4c31989a0eb6c13f3a657c3fe60cd7cd 100644 (file)
@@ -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"
index 08ae193dff8597e59a38d4a67692e55326eb7d27..fc906209eb9d83335513753baa4f3768621c1346 100644 (file)
@@ -40,7 +40,6 @@
 #include <string.h>
 
 #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"
index 187fef017fe8490b57f09ff2f290630e7fff1b8c..a44e84a47775c7458ea11f481ce12081fdce3b13 100644 (file)
@@ -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"
index cc19905b072b0d06a8d053070335c61e36d3908d..0c34c66cb142f9d418ecef8106a38e07a2d86ab7 100644 (file)
@@ -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"
index 696f61c20289b3a56dcf575a392e33062d06cbbd..01c772c9c2bfb1ccd16eb3f09648ada47b725587 100644 (file)
@@ -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)
index d9b20863d961305c046d3dc13fb2d1adca760c2c..305abf88f6153b6b70d647118f87190700cd105f 100644 (file)
@@ -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);