Merge branch release-5-1
authorMark Abraham <mark.j.abraham@gmail.com>
Fri, 24 Jul 2015 14:40:41 +0000 (16:40 +0200)
committerMark Abraham <mark.j.abraham@gmail.com>
Fri, 24 Jul 2015 14:40:41 +0000 (16:40 +0200)
Conflicts:
src/gromacs/commandline/shellcompletions.cpp
Removed line no longer appropriate, now that zsh completion
is supported. Master had changed the previous line, which
git flags as a merge conflict.

Change-Id: Id9d37615b2bd121b1206ca0e6e8eac62fcf38f01

1  2 
src/gromacs/commandline/shellcompletions.cpp
src/gromacs/gmxpreprocess/grompp.cpp
src/gromacs/options/filenameoptionmanager.cpp
src/gromacs/trajectoryanalysis/modules/sasa.cpp

index a0ef63e4c607e8917d6adb61ca97bb34d0ec1164,ce9f08a71779219b18ce4cb5a4786e91d9b17339..520ff469092dfc79a25b7095c878ff35b6aaed9f
@@@ -59,9 -59,9 +59,9 @@@
  #include "gromacs/options/optionsvisitor.h"
  #include "gromacs/utility/arrayref.h"
  #include "gromacs/utility/exceptions.h"
 -#include "gromacs/utility/file.h"
  #include "gromacs/utility/gmxassert.h"
  #include "gromacs/utility/stringutil.h"
 +#include "gromacs/utility/textwriter.h"
  
  namespace gmx
  {
@@@ -107,7 -107,7 +107,7 @@@ class OptionsListWriter : public Option
  class OptionCompletionWriter : public OptionsVisitor
  {
      public:
 -        explicit OptionCompletionWriter(File *out) : out_(*out) {}
 +        explicit OptionCompletionWriter(TextWriter *out) : out_(*out) {}
  
          virtual void visitSubSection(const Options &section)
          {
          void writeOptionCompletion(const OptionInfo  &option,
                                     const std::string &completion);
  
 -        File &out_;
 +        TextWriter &out_;
  };
  
  void OptionCompletionWriter::visitOption(const OptionInfo &option)
@@@ -196,8 -196,8 +196,8 @@@ class ShellCompletionWriter::Imp
              return formatString("_%s_%s_compl", binaryName_.c_str(), moduleName);
          }
  
 -        std::string             binaryName_;
 -        boost::scoped_ptr<File> file_;
 +        std::string                   binaryName_;
 +        boost::scoped_ptr<TextWriter> file_;
  };
  
  ShellCompletionWriter::ShellCompletionWriter(const std::string     &binaryName,
@@@ -210,22 -210,21 +210,21 @@@ ShellCompletionWriter::~ShellCompletion
  {
  }
  
 -File *ShellCompletionWriter::outputFile()
 +TextOutputStream &ShellCompletionWriter::outputStream()
  {
 -    return impl_->file_.get();
 +    return impl_->file_->stream();
  }
  
  void ShellCompletionWriter::startCompletions()
  {
 -    impl_->file_.reset(new File(impl_->binaryName_ + "-completion.bash", "w"));
 +    impl_->file_.reset(new TextWriter(impl_->binaryName_ + "-completion.bash"));
-     impl_->file_->writeLine("shopt -s extglob");
  }
  
  void ShellCompletionWriter::writeModuleCompletions(
          const char    *moduleName,
          const Options &options)
  {
 -    File &out = *impl_->file_;
 +    TextWriter &out = *impl_->file_;
      out.writeLine(formatString("%s() {", impl_->completionFunctionName(moduleName).c_str()));
      out.writeLine("local IFS=$'\\n'");
      out.writeLine("local c=${COMP_WORDS[COMP_CWORD]}");
index 8a6e43c666382223b157bbf261700cd739252faa,2f976b8d2eef1c8667d524a3ac287ca999f9aef2..d8a6737091a6bc1bbee23613862035b37f925ce3
  
  #include "grompp.h"
  
 -#include <assert.h>
  #include <errno.h>
  #include <limits.h>
 -#include <math.h>
  #include <string.h>
  
 +#include <cmath>
 +
 +#include <algorithm>
 +
  #include <sys/types.h>
  
  #include "gromacs/commandline/pargs.h"
  #include "gromacs/fileio/confio.h"
  #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/gmxpreprocess/add_par.h"
  #include "gromacs/gmxpreprocess/convparm.h"
@@@ -84,7 -84,6 +84,7 @@@
  #include "gromacs/utility/cstringutil.h"
  #include "gromacs/utility/fatalerror.h"
  #include "gromacs/utility/futil.h"
 +#include "gromacs/utility/gmxassert.h"
  #include "gromacs/utility/smalloc.h"
  #include "gromacs/utility/snprintf.h"
  
@@@ -189,7 -188,7 +189,7 @@@ static void check_cg_sizes(const char *
      maxsize = 0;
      for (cg = 0; cg < cgs->nr; cg++)
      {
 -        maxsize = max(maxsize, cgs->index[cg+1]-cgs->index[cg]);
 +        maxsize = std::max(maxsize, cgs->index[cg+1]-cgs->index[cg]);
      }
  
      if (maxsize > MAX_CHARGEGROUP_SIZE)
@@@ -291,7 -290,7 +291,7 @@@ static void check_bonds_timestep(gmx_mt
                  if (debug)
                  {
                      fprintf(debug, "fc %g m1 %g m2 %g period %g\n",
 -                            fc, m1, m2, sqrt(period2));
 +                            fc, m1, m2, std::sqrt(period2));
                  }
                  if (period2 < limit2)
                  {
                  *w_moltype->name,
                  w_a1+1, *w_moltype->atoms.atomname[w_a1],
                  w_a2+1, *w_moltype->atoms.atomname[w_a2],
 -                sqrt(w_period2), bWarn ? min_steps_warn : min_steps_note, dt,
 +                std::sqrt(w_period2), bWarn ? min_steps_warn : min_steps_note, dt,
                  bWater ?
                  "Maybe you asked for fexible water." :
                  "Maybe you forgot to change the constraints mdp option.");
@@@ -812,7 -811,7 +812,7 @@@ static void read_posres(gmx_mtop_t *mto
                          rvec com,
                          warninp_t wi)
  {
 -    gmx_bool        bFirst = TRUE, *hadAtom;
 +    gmx_bool       *hadAtom;
      rvec           *x, *v, *xp;
      dvec            sum;
      double          totmass;
      get_stx_coordnum(fn, &natoms);
      if (natoms != mtop->natoms)
      {
 -        sprintf(warn_buf, "The number of atoms in %s (%d) does not match the number of atoms in the topology (%d). Will assume that the first %d atoms in the topology and %s match.", fn, natoms, mtop->natoms, min(mtop->natoms, natoms), fn);
 +        sprintf(warn_buf, "The number of atoms in %s (%d) does not match the number of atoms in the topology (%d). Will assume that the first %d atoms in the topology and %s match.", fn, natoms, mtop->natoms, std::min(mtop->natoms, natoms), fn);
          warning(wi, warn_buf);
      }
      snew(x, natoms);
  
      if (rc_scaling != erscNO)
      {
 -        assert(npbcdim <= DIM);
 +        GMX_ASSERT(npbcdim <= DIM, "Only DIM dimensions can have PBC");
  
          for (mb = 0; mb < mtop->nmolblock; mb++)
          {
@@@ -995,6 -994,8 +995,6 @@@ static void gen_posres(gmx_mtop_t *mtop
                         rvec com, rvec comB,
                         warninp_t wi)
  {
 -    int i, j;
 -
      read_posres  (mtop, mi, FALSE, fnA, rc_scaling, ePBC, com, wi);
      /* It is safer to simply read the b-state posres rather than trying
       * to be smart and copy the positions.
@@@ -1091,7 -1092,7 +1091,7 @@@ interpolate1d( double     xmin
      int    ix;
      double a, b;
  
 -    ix = (x-xmin)/dx;
 +    ix = static_cast<int>((x-xmin)/dx);
  
      a = (xmin+(ix+1)*dx-x)/dx;
      b = (x-xmin-ix*dx)/dx;
@@@ -1181,7 -1182,7 +1181,7 @@@ setup_cmap (int              grid_spaci
  
  void init_cmap_grid(gmx_cmap_t *cmap_grid, int ngrid, int grid_spacing)
  {
 -    int i, k, nelem;
 +    int i, nelem;
  
      cmap_grid->ngrid        = ngrid;
      cmap_grid->grid_spacing = grid_spacing;
@@@ -1308,19 -1309,22 +1308,19 @@@ static real calc_temp(const gmx_mtop_t 
                        const t_inputrec *ir,
                        rvec             *v)
  {
 -    double                  sum_mv2;
      gmx_mtop_atomloop_all_t aloop;
      t_atom                 *atom;
      int                     a;
 -    int                     nrdf, g;
 -
 -    sum_mv2 = 0;
  
 +    double                  sum_mv2 = 0;
      aloop = gmx_mtop_atomloop_all_init(mtop);
      while (gmx_mtop_atomloop_all_next(aloop, &a, &atom))
      {
          sum_mv2 += atom->m*norm2(v[a]);
      }
  
 -    nrdf = 0;
 -    for (g = 0; g < ir->opts.ngtc; g++)
 +    double nrdf = 0;
 +    for (int g = 0; g < ir->opts.ngtc; g++)
      {
          nrdf += ir->opts.nrdf[g];
      }
@@@ -1345,7 -1349,7 +1345,7 @@@ static real get_max_reference_temp(cons
          }
          else
          {
 -            ref_t = max(ref_t, ir->opts.ref_t[i]);
 +            ref_t = std::max(ref_t, ir->opts.ref_t[i]);
          }
      }
  
@@@ -1367,6 -1371,7 +1367,6 @@@ static void set_verlet_buffer(const gmx
                                matrix            box,
                                warninp_t         wi)
  {
 -    int                    i;
      verletbuf_list_setup_t ls;
      real                   rlist_1x1;
      int                    n_nonlin_vsite;
      }
  
      printf("Calculated rlist for %dx%d atom pair-list as %.3f nm, buffer size %.3f nm\n",
 -           1, 1, rlist_1x1, rlist_1x1-max(ir->rvdw, ir->rcoulomb));
 +           1, 1, rlist_1x1, rlist_1x1-std::max(ir->rvdw, ir->rcoulomb));
  
      ir->rlistlong = ir->rlist;
      printf("Set rlist, assuming %dx%d atom pair-list, to %.3f nm, buffer size %.3f nm\n",
             ls.cluster_size_i, ls.cluster_size_j,
 -           ir->rlist, ir->rlist-max(ir->rvdw, ir->rcoulomb));
 +           ir->rlist, ir->rlist-std::max(ir->rvdw, ir->rcoulomb));
  
      printf("Note that mdrun will redetermine rlist based on the actual pair-list setup\n");
  
      if (sqr(ir->rlistlong) >= max_cutoff2(ir->ePBC, box))
      {
 -        gmx_fatal(FARGS, "The pair-list cut-off (%g nm) is longer than half the shortest box vector or longer than the smallest box diagonal element (%g nm). Increase the box size or decrease nstlist or increase verlet-buffer-tolerance.", ir->rlistlong, sqrt(max_cutoff2(ir->ePBC, box)));
 +        gmx_fatal(FARGS, "The pair-list cut-off (%g nm) is longer than half the shortest box vector or longer than the smallest box diagonal element (%g nm). Increase the box size or decrease nstlist or increase verlet-buffer-tolerance.", ir->rlistlong, std::sqrt(max_cutoff2(ir->ePBC, box)));
      }
  }
  
@@@ -1480,7 -1485,9 +1480,9 @@@ int gmx_grompp(int argc, char *argv[]
          "with [TT]-cpi[tt]. If you wish to change the ensemble or things",
          "like output frequency, then supplying the checkpoint file to",
          "[THISMODULE] with [TT]-t[tt] along with a new [REF].mdp[ref] file",
-         "with [TT]-f[tt] is the recommended procedure.[PAR]",
+         "with [TT]-f[tt] is the recommended procedure. Actually preserving",
+         "the ensemble (if possible) still requires passing the checkpoint",
+         "file to [gmx-mdrun] [TT]-cpi[tt].[PAR]",
  
          "By default, all bonded interactions which have constant energy due to",
          "virtual site constructions will be removed. If this constant energy is",
      t_molinfo         *mi, *intermolecular_interactions;
      gpp_atomtype_t     atype;
      t_inputrec        *ir;
 -    int                natoms, nvsite, comb, mt;
 +    int                nvsite, comb, mt;
      t_params          *plist;
      t_state           *state;
      matrix             box;
 -    real               max_spacing, fudgeQQ;
 +    real               fudgeQQ;
      double             reppow;
      char               fn[STRLEN], fnB[STRLEN];
      const char        *mdparin;
      int                ntype;
      gmx_bool           bNeedVel, bGenVel;
      gmx_bool           have_atomnumber;
 -    int                n12, n13, n14;
 -    t_params          *gb_plist = NULL;
 -    gmx_genborn_t     *born     = NULL;
      output_env_t       oenv;
      gmx_bool           bVerbose = FALSE;
      warninp_t          wi;
      char               warn_buf[STRLEN];
 -    unsigned int       useed;
 -    t_atoms            IMDatoms;   /* Atoms to be operated on interactively (IMD) */
  
      t_filenm           fnm[] = {
          { efMDP, NULL,  NULL,        ffREAD  },
      if (ir->ld_seed == -1)
      {
          ir->ld_seed = (gmx_int64_t)gmx_rng_make_seed();
 -        fprintf(stderr, "Setting the LD random seed to %"GMX_PRId64 "\n", ir->ld_seed);
 +        fprintf(stderr, "Setting the LD random seed to %" GMX_PRId64 "\n", ir->ld_seed);
      }
  
      if (ir->expandedvals->lmc_seed == -1)
      if (bRenum)
      {
          renum_atype(plist, sys, ir->wall_atomtype, atype, bVerbose);
 -        ntype = get_atomtype_ntypes(atype);
 +        get_atomtype_ntypes(atype);
      }
  
      if (ir->implicit_solvent != eisNO)
      }
      do_index(mdparin, ftp2fn_null(efNDX, NFILE, fnm),
               sys, bVerbose, ir,
 -             bGenVel ? state->v : NULL,
               wi);
  
      if (ir->cutoff_scheme == ecutsVERLET && ir->verletbuf_tol > 0 &&
              set_warning_line(wi, mdparin, -1);
              warning_error(wi, "Some of the Fourier grid sizes are set, but all of them need to be set.");
          }
 -        max_spacing = calc_grid(stdout, box, ir->fourier_spacing,
 -                                &(ir->nkx), &(ir->nky), &(ir->nkz));
 +        calc_grid(stdout, box, ir->fourier_spacing,
 +                  &(ir->nkx), &(ir->nky), &(ir->nkz));
      }
  
      /* MRS: eventually figure out better logic for initializing the fep
index 212c6a26a57be1b917a365ddcb2f60f8f118e6a7,e33443b8b1e54c4a1f65d8325cac3295f07fb5bf..1a627cd85c6d7f550f915cd71458928357855854
@@@ -81,7 -81,7 +81,7 @@@ const char *const c_compressedExtension
   */
  std::string findExistingExtension(const std::string                  &prefix,
                                    const FileNameOptionInfo           &option,
 -                                  const FileInputRedirectorInterface *redirector)
 +                                  const IFileInputRedirector         *redirector)
  {
      ConstArrayRef<int>                 types = option.fileTypes();
      ConstArrayRef<int>::const_iterator i;
@@@ -117,7 -117,7 +117,7 @@@ class FileNameOptionManager::Imp
          }
  
          //! Redirector for file existence checks.
 -        const FileInputRedirectorInterface *redirector_;
 +        const IFileInputRedirector         *redirector_;
          //! Global default file name, if set.
          std::string                         defaultFileName_;
          //! Whether input option processing has been disabled.
@@@ -138,7 -138,7 +138,7 @@@ FileNameOptionManager::~FileNameOptionM
  }
  
  void FileNameOptionManager::setInputRedirector(
 -        const FileInputRedirectorInterface *redirector)
 +        const IFileInputRedirector *redirector)
  {
      impl_->redirector_ = redirector;
  }
@@@ -268,15 -268,14 +268,14 @@@ std::string FileNameOptionManager::comp
  std::string FileNameOptionManager::completeDefaultFileName(
          const std::string &prefix, const FileNameOptionInfo &option)
  {
-     if (option.isDirectoryOption() || impl_->bInputCheckingDisabled_)
+     if (option.isDirectoryOption())
      {
          return std::string();
      }
      const bool        bInput = option.isInputFile() || option.isInputOutputFile();
      const std::string realPrefix
          = !impl_->defaultFileName_.empty() ? impl_->defaultFileName_ : prefix;
-     const bool        bAllowMissing = option.allowMissing();
-     if (bInput)
+     if (bInput && !impl_->bInputCheckingDisabled_)
      {
          const std::string completedName
              = findExistingExtension(realPrefix, option, impl_->redirector_);
          {
              return completedName;
          }
-         if (bAllowMissing)
+         if (option.allowMissing())
          {
              return realPrefix + option.defaultExtension();
          }
index 964910206941b4c7c53edf3f6c456aafd86455d5,cf243b44190d23983da444ea20e2e5edeaa7291d..edff30830f3311f17a373206b4b51f39ceddcca0
@@@ -445,7 -445,7 +445,7 @@@ Sasa::initOptions(Options *options, Tra
          "that are both too high."
      };
  
 -    options->setDescription(desc);
 +    settings->setHelpText(desc);
  
      options->addOption(FileNameOption("o").filetype(eftPlot).outputFile().required()
                             .store(&fnArea_).defaultBasename("area")
@@@ -655,7 -655,7 +655,7 @@@ Sasa::initAnalysis(const TrajectoryAnal
                  AnalysisDataPlotModulePointer plotm(
                          new AnalysisDataPlotModule(settings.plotSettings()));
                  plotm->setFileName(fnAtomArea_);
-                 plotm->setTitle("Area per residue over the trajectory");
+                 plotm->setTitle("Area per atom over the trajectory");
                  plotm->setXLabel("Atom");
                  plotm->setXFormat(8, 0);
                  plotm->setYLabel("Area (nm\\S2\\N)");
          }
          {
              AnalysisDataAverageModulePointer avem(new AnalysisDataAverageModule);
+             int prevResind = -1;
+             int row        = 0;
              for (int i = 0; i < surfaceSel_.posCount(); ++i)
              {
                  const int atomIndex     = surfaceSel_.position(i).atomIndices()[0];
                  const int residueIndex  = atoms.atom[atomIndex].resind;
-                 avem->setXAxisValue(i, atoms.resinfo[residueIndex].nr);
+                 if (residueIndex != prevResind)
+                 {
+                     avem->setXAxisValue(row, atoms.resinfo[residueIndex].nr);
+                     prevResind = residueIndex;
+                     ++row;
+                 }
              }
              residueArea_.addModule(avem);
              if (!fnResidueArea_.empty())
                  AnalysisDataPlotModulePointer plotm(
                          new AnalysisDataPlotModule(settings.plotSettings()));
                  plotm->setFileName(fnResidueArea_);
-                 plotm->setTitle("Area per atom over the trajectory");
+                 plotm->setTitle("Area per residue over the trajectory");
                  plotm->setXLabel("Residue");
                  plotm->setXFormat(8, 0);
                  plotm->setYLabel("Area (nm\\S2\\N)");