Converted md.c to C++
authorMark Abraham <mark.j.abraham@gmail.com>
Tue, 27 May 2014 13:14:53 +0000 (15:14 +0200)
committerMark Abraham <mark.j.abraham@gmail.com>
Mon, 2 Jun 2014 22:35:36 +0000 (00:35 +0200)
Removed unused variables, added missing headers, added missing
extern "C" specifiers. Removed assignments of unused values.

Made the code always call init_nlistheuristics(), in order to suppress
a clang-static-analyzer check that thinks (for example) MULTISIM(cr)
can change its value over MD loops. Calling that init function is
cheap, outside the MD loop, has no effect because those code paths are
always protected by a check for nstlist == -1, and probably those code
paths will go away shortly.

Change-Id: I8abb8ef28c121c7b5432bf38d958c0b2a55ed9da

src/gromacs/fileio/mdoutf.h
src/gromacs/fileio/trajectory_writing.h
src/programs/mdrun/md.cpp [moved from src/programs/mdrun/md.c with 99% similarity]
src/programs/mdrun/pme_loadbal.h
src/programs/mdrun/repl_ex.h

index 3372db38d9cf3c14912a74262192447b26ce58e7..645ecab6f09d966be56dec3062283410aee2a7ab 100644 (file)
 #include "filenm.h"
 #include "enxio.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct gmx_mtop_t;
 
 typedef struct gmx_mdoutf *gmx_mdoutf_t;
@@ -98,5 +102,8 @@ void mdoutf_write_to_trajectory_files(FILE *fplog, t_commrec *cr,
 #define MDOF_CPT          (1<<4)
 #define MDOF_IMD          (1<<5)
 
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* GMX_FILEIO_MDOUTF_H */
index 07cb6f4afeea2f1c6db113b61233b51d88b9a79c..a5250d2afdd68d5d2a5b1cb0335f612001b06a1a 100644 (file)
 #include "filenm.h"
 #include "mdoutf.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*! \brief Wrapper routine for writing trajectories during mdrun
  *
  * This routine does communication (e.g. collecting distributed coordinates)
@@ -79,4 +83,8 @@ do_md_trajectory_writing(FILE           *fplog,
                          );
 
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* GMX_FILEIO_TRAJECTORY_WRITING_H */
similarity index 99%
rename from src/programs/mdrun/md.c
rename to src/programs/mdrun/md.cpp
index bad0af3ab333fe6f6ca01af19d1f53ea1a5c0753..e3205842252f15641343591e8809f092efdf12f7 100644 (file)
@@ -82,6 +82,7 @@
 #include "nbnxn_cuda_data_mgmt.h"
 
 #include "gromacs/fileio/confio.h"
+#include "gromacs/fileio/mdoutf.h"
 #include "gromacs/fileio/trajectory_writing.h"
 #include "gromacs/fileio/trnio.h"
 #include "gromacs/fileio/trxio.h"
@@ -170,7 +171,7 @@ double do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[],
     rvec              mu_tot;
     t_vcm            *vcm;
     t_state          *bufstate = NULL;
-    matrix           *scale_tot, pcoupl_mu, M, ebox;
+    matrix            pcoupl_mu, M;
     gmx_nlheur_t      nlh;
     t_trxframe        rerun_fr;
     gmx_repl_ex_t     repl_ex = NULL;
@@ -189,10 +190,8 @@ double do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[],
     gmx_ekindata_t   *ekind, *ekind_save;
     gmx_shellfc_t     shellfc;
     int               count, nconverged = 0;
-    real              timestep   = 0;
-    double            tcount     = 0;
-    gmx_bool          bConverged = TRUE, bOK, bSumEkinhOld, bExchanged, bNeedRepartition;
-    gmx_bool          bAppend;
+    double            tcount                 = 0;
+    gmx_bool          bConverged             = TRUE, bOK, bSumEkinhOld, bExchanged, bNeedRepartition;
     gmx_bool          bResetCountersHalfMaxH = FALSE;
     gmx_bool          bVV, bIterativeCase, bFirstIterate, bTemp, bPres, bTrotter;
     gmx_bool          bUpdateDoLR;
@@ -207,7 +206,6 @@ double do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[],
     double            cycles;
     real              saved_conserved_quantity = 0;
     real              last_ekin                = 0;
-    int               iter_i;
     t_extmass         MassQ;
     int             **trotter_seq;
     char              sbuf[STEPSTRSIZE], sbuf2[STEPSTRSIZE];
@@ -231,7 +229,6 @@ double do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[],
 
     /* Check for special mdrun options */
     bRerunMD = (Flags & MD_RERUN);
-    bAppend  = (Flags & MD_APPENDFILES);
     if (Flags & MD_RESETCOUNTERSHALFWAY)
     {
         if (ir->nsteps > 0)
@@ -728,7 +725,6 @@ double do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[],
     bStateFromTPX    = !bStateFromCP;
     bInitStep        = bFirstStep && (bStateFromTPX || bVV);
     bStartingFromCpt = (Flags & MD_STARTFROMCPT) && bInitStep;
-    bLastStep        = FALSE;
     bSumEkinhOld     = FALSE;
     bExchanged       = FALSE;
     bNeedRepartition = FALSE;
@@ -738,10 +734,7 @@ double do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[],
     step     = ir->init_step;
     step_rel = 0;
 
-    if (ir->nstlist == -1)
-    {
-        init_nlistheuristics(&nlh, bGStatEveryStep, step);
-    }
+    init_nlistheuristics(&nlh, bGStatEveryStep, step);
 
     if (MULTISIM(cr) && (repl_ex_nst <= 0 ))
     {
index f2b9f0152b8b01879869bad34afb0ca717a387dd..eddb4d67eb9c035c01cf5aebbc461140fedf6a64 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2012,2013, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014, 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.
 #ifndef _pme_loadbal_h
 #define _pme_loadbal_h
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef struct pme_load_balancing *pme_load_balancing_t;
 
 /* Initialze the PP-PME load balacing data and infrastructure */
@@ -76,4 +80,8 @@ void pme_loadbal_done(pme_load_balancing_t pme_lb,
                       t_commrec *cr, FILE *fplog,
                       gmx_bool bNonBondedOnGPU);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _pme_loadbal_h */
index ec6c6ee23c7bffe641abce65e7dcc2824dcf3ded..b04f549ccccd40ca1cf3ca410560d19d0d854554 100644 (file)
 #include "typedefs.h"
 #include "types/commrec.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Abstract type for replica exchange */
 typedef struct gmx_repl_ex *gmx_repl_ex_t;
 
@@ -68,4 +72,8 @@ extern gmx_bool replica_exchange(FILE *fplog,
 extern void print_replica_exchange_statistics(FILE *fplog, gmx_repl_ex_t re);
 /* Should only be called on the master nodes */
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif  /* _repl_ex_h */