Merge "grompp now retains the order of bonds converted to constraints" into release-4-6
authorDavid van der Spoel <davidvanderspoel@gmail.com>
Fri, 25 May 2012 14:26:50 +0000 (16:26 +0200)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Fri, 25 May 2012 14:26:50 +0000 (16:26 +0200)
23 files changed:
include/constr.h
include/gmxcpp.h
include/magic.h [deleted file]
include/main.h
include/network.h
include/types/constr.h
src/gmxlib/gmx_fatal.c
src/gmxlib/main.c
src/gmxlib/network.c
src/gmxlib/sighandler.c
src/gmxlib/statistics/gmx_statistics.c
src/gmxlib/statutil.c
src/gmxlib/trxio.c
src/gmxlib/typedefs.c
src/kernel/md.c
src/kernel/mdrun.c
src/kernel/readrot.c
src/mdlib/fft5d.c
src/tools/calcpot.c
src/tools/gmx_disre.c
src/tools/gmx_pme_error.c
src/tools/gmx_trjcat.c
src/tools/gmx_trjconv.c

index bc0419e42803004073a315d75913c51aed322be3..92d4cb520ca119f60d6606a7a7d01aabfdd66c39 100644 (file)
@@ -34,6 +34,8 @@
  * Gromacs Runs On Most of All Computer Systems
  */
 
+#ifndef _constr_h
+#define _constr_h
 #include "typedefs.h"
 
 #ifdef __cplusplus
@@ -253,3 +255,4 @@ gmx_bool constrain_lincs(FILE *log,gmx_bool bLog,gmx_bool bEner,
 #ifdef __cplusplus
 }
 #endif
+#endif
index 3ed2b48a6f012f43dcf87373088c001dc8b99c49..d260545a36edcda49be3b8a2abd152c0d607c547 100644 (file)
@@ -33,7 +33,8 @@
  * Gallium Rubidium Oxygen Manganese Argon Carbon Silicon
  */
 
-
+#ifndef _gmxcpp_h
+#define _gmxcpp_h
 typedef struct gmx_cpp *gmx_cpp_t; 
        
        /* The possible return codes for these functions */
@@ -82,3 +83,4 @@ int cpp_close_file(gmx_cpp_t *handlep);
    NOT THREAD SAFE 
    */
 char *cpp_error(gmx_cpp_t *handlep,int status);
+#endif
diff --git a/include/magic.h b/include/magic.h
deleted file mode 100644 (file)
index c493295..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 
- *                This source code is part of
- * 
- *                 G   R   O   M   A   C   S
- * 
- *          GROningen MAchine for Chemical Simulations
- * 
- *                        VERSION 3.2.0
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, 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:
- * Gromacs Runs On Most of All Computer Systems
- */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef GROMACS_MAGIC
-#define GROMACS_MAGIC 0xff0d
-#endif
-
-#ifdef __cplusplus
-}
-#endif
index ada90d2d05b830d240e1bb80a92286aabcc18126..5b10a1b6e42f79306874eb9d7665d06136750011 100644 (file)
 extern "C" {
 #endif
 
-gmx_bool gmx_parallel_env_initialized(void); 
-/* 1 when running in a parallel environment, so could also be 1 if
-   mdrun was started with: mpirun -np 1.
-  
-   Use this function only to check whether a parallel environment has
-   been initialized, for example when checking whether gmx_finalize()
-   needs to be called. Use PAR(cr) to check whether the simulation actually
-   has more than one node/thread. */
-
-
 void gmx_log_open(const char *fn,const t_commrec *cr,
                           gmx_bool bMasterOnly, unsigned long Flags, FILE**);
 /* Open the log file, if necessary (nprocs > 1) the logfile name is
@@ -85,7 +75,7 @@ t_commrec *init_par(int *argc,char ***argv_ptr);
  * (see network.h). The command line arguments are communicated so that they can be
  * parsed on each processor.
  * Arguments are the number of command line arguments, and a pointer to the
- * array of argument strings.
+ * array of argument strings. Both are allowed to be NULL.
  */
 
 t_commrec *init_par_threads(const t_commrec *cro);
@@ -95,9 +85,6 @@ t_commrec *init_par_threads(const t_commrec *cro);
    thread-local versions (a small memory leak results because we don't 
    deallocate the old shared version).  */
 
-t_commrec *init_cr_nopar(void);
-/* Returns t_commrec for non-parallel functionality */
-
 #ifdef __cplusplus
 }
 #endif
index 15db2187decd2c309975eb137f747fd946e67b45..daa5968921e444a7d67fade4e8af305b79319b8c 100644 (file)
@@ -118,8 +118,7 @@ void gmx_sumd_sim(int nr,double r[],const gmx_multisim_t *ms);
 void gmx_abort(int nodeid,int nnodes,int errorno);
 /* Abort the parallel run */
 
-void gmx_finalize(void);
-
+void gmx_finalize_par(void);
 /* Finish the parallel run in an ordered manner */
 
 #ifdef GMX_DOUBLE
index 9f5420ceb9c72d9118e7c5a14d6055f570606b31..7630a02629078012689e45b8c3acba656ff8cbed 100644 (file)
@@ -33,8 +33,8 @@
  * GRoups of Organic Molecules in ACtion for Science
  */
 
-#ifndef _constr_h
-#define _constr_h
+#ifndef _types_constr_h
+#define _types_constr_h
 
 #ifdef __cplusplus
 extern "C" {
index a743a515f8cdf266d414edc6110dcee3f68e814d..a636b9ec76a67f832de2d98693c0ebbeb1042023 100644 (file)
@@ -216,7 +216,6 @@ static void quit_gmx(const char *msg)
     }
 
 #ifndef GMX_THREAD_MPI
-    if (gmx_parallel_env_initialized())
     {
         int  nnodes;
         int  noderank;
@@ -225,20 +224,25 @@ static void quit_gmx(const char *msg)
         noderank = gmx_node_rank();
 
         if (nnodes > 1) 
+        {
             fprintf(stderr,"Error on node %d, will try to stop all the nodes\n",
                     noderank);
+        }
         gmx_abort(noderank,nnodes,-1);
     } 
-    else 
 #endif
+
+    if (debug)
     {
-        if (debug)
-            fflush(debug);
-        if (bDebugMode()) {
-            fprintf(stderr,"dump core (y/n):"); 
-            fflush(stderr);
-            if (toupper(getc(stdin))!='N') 
-                (void) abort(); 
+        fflush(debug);
+    }
+    if (bDebugMode())
+    {
+        fprintf(stderr,"dump core (y/n):"); 
+        fflush(stderr);
+        if (toupper(getc(stdin))!='N') 
+        {
+            (void) abort();
         }
     }
 
@@ -272,17 +276,21 @@ static void quit_gmx_noquit(const char *msg)
         perror(msg);
     }
 
-    if (!gmx_parallel_env_initialized())
+#ifdef GMX_THREAD_MPI
+    if (debug)
     {
-        if (debug)
-            fflush(debug);
-        if (bDebugMode()) {
-            fprintf(stderr,"dump core (y/n):"); 
-            fflush(stderr);
-            if (toupper(getc(stdin))!='N') 
-                (void) abort(); 
+        fflush(debug);
+    }
+    if (bDebugMode())
+    {
+        fprintf(stderr,"dump core (y/n):"); 
+        fflush(stderr);
+        if (toupper(getc(stdin))!='N') 
+        {
+            (void) abort(); 
         }
     }
+#endif
 
 #ifdef GMX_THREAD_MPI
     tMPI_Thread_mutex_unlock(&debug_mutex);
@@ -454,20 +462,17 @@ void gmx_fatal_collective(int f_errno,const char *file,int line,
     bFinalize = TRUE;
 
 #ifdef GMX_MPI
-    if (gmx_parallel_env_initialized())
+    /* Check if we are calling on all processes in MPI_COMM_WORLD */ 
+    if (cr != NULL)
     {
-        /* Check if we are calling on all processes in MPI_COMM_WORLD */ 
-        if (cr != NULL)
-        {
-            MPI_Comm_compare(cr->mpi_comm_mysim,MPI_COMM_WORLD,&result);
-        }
-        else
-        {
-            MPI_Comm_compare(dd->mpi_comm_all,MPI_COMM_WORLD,&result);
-        }
-        /* Any result except MPI_UNEQUAL allows us to call MPI_Finalize */
-        bFinalize = (result != MPI_UNEQUAL);
+        MPI_Comm_compare(cr->mpi_comm_mysim,MPI_COMM_WORLD,&result);
     }
+    else
+    {
+        MPI_Comm_compare(dd->mpi_comm_all,MPI_COMM_WORLD,&result);
+    }
+    /* Any result except MPI_UNEQUAL allows us to call MPI_Finalize */
+    bFinalize = (result != MPI_UNEQUAL);
 #endif
 
     if ((cr != NULL && MASTER(cr)  ) ||
@@ -501,28 +506,25 @@ void gmx_fatal_collective(int f_errno,const char *file,int line,
     }
 
 #ifdef GMX_MPI
-    if (gmx_parallel_env_initialized())
+    if (bFinalize)
     {
-        if (bFinalize)
-        {
-            /* Broadcast the fatal error number possibly modified
-             * on the master process, in case the user would like
-             * to use the return status on a non-master process.
-             * The master process in cr and dd always has global rank 0.
-             */
-            MPI_Bcast(&fatal_errno,sizeof(fatal_errno),MPI_BYTE,
-                      0,MPI_COMM_WORLD);
-
-            /* Finalize nicely instead of aborting */
-            MPI_Finalize();
-        }
-        else
-        {
-            /* Let all other processes wait till the master has printed
-             * the error message and issued MPI_Abort.
-             */
-            MPI_Barrier(MPI_COMM_WORLD);
-        }
+        /* Broadcast the fatal error number possibly modified
+         * on the master process, in case the user would like
+         * to use the return status on a non-master process.
+         * The master process in cr and dd always has global rank 0.
+         */
+        MPI_Bcast(&fatal_errno,sizeof(fatal_errno),MPI_BYTE,
+                  0,MPI_COMM_WORLD);
+
+        /* Finalize nicely instead of aborting */
+        MPI_Finalize();
+    }
+    else
+    {
+        /* Let all other processes wait till the master has printed
+         * the error message and issued MPI_Abort.
+         */
+        MPI_Barrier(MPI_COMM_WORLD);
     }
 #endif
 
index 52c8da84eba86c7abc4a5cf2f25c0b35da19e76f..8dda4d18b368ec6bdc1b65ef7f106d21046bfc36 100644 (file)
@@ -89,50 +89,6 @@ gmx_ctime_r(const time_t *clock,char *buf, int n);
 
 #define BUFSIZE        1024
 
-/* this is not strictly thread-safe, but it's only written to at the beginning
-   of the simulation, once by each thread with the same value. We assume
-   that writing to an int is atomic.*/
-static gmx_bool parallel_env_val;
-#ifdef GMX_THREAD_MPI
-tMPI_Thread_mutex_t parallel_env_mutex=TMPI_THREAD_MUTEX_INITIALIZER;
-#endif
-
-
-/* returns 1 when running in a parallel environment, so could also be 1 if
-   mdrun was started with: mpirun -np 1.
-     
-   Use this function only to check whether a parallel environment has   
-   been initialized, for example when checking whether gmx_finalize()   
-   needs to be called. Use PAR(cr) to check whether the simulation actually
-   has more than one node/thread.  */
-gmx_bool gmx_parallel_env_initialized(void)
-{
-    gmx_bool ret;
-#ifdef GMX_THREAD_MPI
-    tMPI_Thread_mutex_lock(&parallel_env_mutex);
-#endif
-    ret=parallel_env_val;
-#ifdef GMX_THREAD_MPI
-    tMPI_Thread_mutex_unlock(&parallel_env_mutex);
-#endif
-    return ret;
-}
-
-static void set_parallel_env(gmx_bool val)
-{
-#ifdef GMX_THREAD_MPI
-    tMPI_Thread_mutex_lock(&parallel_env_mutex);
-#endif
-    if (!parallel_env_val)
-    {
-        /* we only allow it to be set, not unset */
-        parallel_env_val=val;
-    }
-#ifdef GMX_THREAD_MPI
-    tMPI_Thread_mutex_unlock(&parallel_env_mutex);
-#endif
-}
-
 
 static void par_fn(char *base,int ftp,const t_commrec *cr,
                   gmx_bool bAppendSimId,gmx_bool bAppendNodeId,
@@ -527,39 +483,24 @@ t_commrec *init_par(int *argc,char ***argv_ptr)
 
     argv = *argv_ptr;
 
-#ifdef GMX_MPI
-#ifdef GMX_LIB_MPI
-    pe = TRUE;
-#ifdef GMX_CHECK_MPI_ENV
-    /* Do not use MPI calls when env.var. GMX_CHECK_MPI_ENV is not set */
-    if (getenv(GMX_CHECK_MPI_ENV) == NULL)
-        pe = FALSE;
-#endif /* GMX_CHECK_MPI_ENV */
-#endif /* GMX_LIB_MPI  */
-    set_parallel_env(pe);
-    if (pe) {
-        cr->sim_nodeid = gmx_setup(argc,argv,&cr->nnodes);
-    } else {
-        cr->nnodes     = 1;
-        cr->sim_nodeid = 0;
-    }
-#else /* GMX_MPI */
-    pe=FALSE;
-    set_parallel_env(pe);
-    cr->sim_nodeid   = 0;
-    cr->nnodes       = 1;
-#endif /* GMX_MPI */
+#if defined GMX_MPI && !defined GMX_THREAD_MPI
+    cr->sim_nodeid = gmx_setup(argc,argv,&cr->nnodes);
 
     if (!PAR(cr) && (cr->sim_nodeid != 0))
-        gmx_comm("(!PAR(cr) && (cr->sim_nodeid != 0))");
-
-    if (PAR(cr)) 
     {
-#ifdef GMX_MPI
-        cr->mpi_comm_mysim = MPI_COMM_WORLD;
-        cr->mpi_comm_mygroup = cr->mpi_comm_mysim;
-#endif /* GMX_MPI */
+        gmx_comm("(!PAR(cr) && (cr->sim_nodeid != 0))");
     }
+
+    cr->mpi_comm_mysim   = MPI_COMM_WORLD;
+    cr->mpi_comm_mygroup = cr->mpi_comm_mysim;
+#else
+    /* These should never be accessed */
+    cr->mpi_comm_mysim   = NULL;
+    cr->mpi_comm_mygroup = NULL;
+    cr->nnodes           = 1;
+    cr->sim_nodeid       = 0;
+#endif
+
     cr->nodeid = cr->sim_nodeid;
 
     cr->duty = (DUTY_PP | DUTY_PME);
@@ -567,7 +508,9 @@ t_commrec *init_par(int *argc,char ***argv_ptr)
     /* Communicate arguments if parallel */
 #ifndef GMX_THREAD_MPI
     if (PAR(cr))
+    {
         comm_args(cr,argc,argv_ptr);
+    }
 #endif /* GMX_THREAD_MPI */
 
 #ifdef GMX_MPI
@@ -603,8 +546,9 @@ t_commrec *init_par_threads(const t_commrec *cro)
     /* and we start setting our own thread-specific values for things */
     MPI_Initialized(&initialized);
     if (!initialized)
+    {
         gmx_comm("Initializing threads without comm");
-    set_parallel_env(TRUE);
+    }
     /* once threads will be used together with MPI, we'll
        fill the cr structure with distinct data here. This might even work: */
     cr->sim_nodeid = gmx_setup(0,NULL, &cr->nnodes);
@@ -619,20 +563,3 @@ t_commrec *init_par_threads(const t_commrec *cro)
     return NULL;
 #endif
 }
-
-
-t_commrec *init_cr_nopar(void)
-{
-    t_commrec *cr;
-
-    snew(cr,1);
-
-    cr->nnodes     = 1; 
-    /* cr->nthreads   = 1; */
-    cr->sim_nodeid = 0;
-    cr->nodeid     = 0;
-    /* cr->threadid   = 0; */
-    cr->duty       = (DUTY_PP | DUTY_PME);
-
-    return cr;
-}
index 91517dbf11fe903df91a50640648b6891688c874..08f573b766b896458fb6d47ba8b119b1018ecb2c 100644 (file)
@@ -738,18 +738,26 @@ void gmx_sumli_sim(int nr,gmx_large_int_t r[], const gmx_multisim_t *ms)
 }
 
 
-void gmx_finalize(void)
+void gmx_finalize_par(void)
 {
 #ifndef GMX_MPI
-  gmx_call("gmx_finalize");
+    /* Compiled without MPI, no MPI finalizing needed */
+    return;
 #else
-  int ret;
+    int initialized,finalized;
+    int ret;
 
-  /* just as a check; we don't want to finalize twice */
-  int finalized;
-  MPI_Finalized(&finalized);
-  if (finalized)
-      return;
+    MPI_Initialized(&initialized);
+    if (!initialized)
+    {
+        return;
+    }
+    /* just as a check; we don't want to finalize twice */
+    MPI_Finalized(&finalized);
+    if (finalized)
+    {
+       return;
+    }
 
   /* We sync the processes here to try to avoid problems
    * with buggy MPI implementations that could cause
index 7c9496a78c5e9b485d00467260fd222f5dfae203..95fe43525397ad3325c7e850dcf4cc3c5f958414 100644 (file)
@@ -102,6 +102,7 @@ static void gmx_signal(int signum)
 #ifdef HAVE_SIGACTION
     struct sigaction act;
     act.sa_handler = signal_handler;
+    sigemptyset(&act.sa_mask);
     act.sa_flags = SA_RESTART;
     sigaction(signum,&act,NULL);
 #else
index 7b50f924ae28a92aa4cb5ca9c2f94d808218457c..e57e4fe94296e10dbf6ccf68ec74f03bb222af3d 100644 (file)
 #include <math.h>
 #include "typedefs.h"
 #include "smalloc.h"
+#include "vec.h"
 #include "gmx_statistics.h"
 
-static double sqr(double x)
-{
-    return x*x;
-}
-
-static int gmx_nint(double x)
+static int gmx_dnint(double x)
 {
     return (int) (x+0.5);
 }
@@ -189,10 +185,10 @@ static int gmx_stats_compute(gmx_stats *stats,int weight)
         d2   = 0;
         for(i=0; (i<N); i++) 
         {
-            d2 += sqr(stats->x[i]-stats->y[i]);
+            d2 += dsqr(stats->x[i]-stats->y[i]);
             if ((stats->dy[i]) && (weight == elsqWEIGHT_Y))
             {
-                w = 1/sqr(stats->dy[i]);
+                w = 1/dsqr(stats->dy[i]);
             }
             else
             {
@@ -201,11 +197,11 @@ static int gmx_stats_compute(gmx_stats *stats,int weight)
             
             wtot  += w;
             
-            xx    += w*sqr(stats->x[i]);
-            xx_nw += sqr(stats->x[i]);
+            xx    += w*dsqr(stats->x[i]);
+            xx_nw += dsqr(stats->x[i]);
             
-            yy    += w*sqr(stats->y[i]);
-            yy_nw += sqr(stats->y[i]);
+            yy    += w*dsqr(stats->y[i]);
+            yy_nw += dsqr(stats->y[i]);
             
             yx    += w*stats->y[i]*stats->x[i];
             yx_nw += stats->y[i]*stats->x[i];
@@ -219,7 +215,7 @@ static int gmx_stats_compute(gmx_stats *stats,int weight)
       
         /* Compute average, sigma and error */
         stats->aver       = sy_nw/N;
-        stats->sigma_aver = sqrt(yy_nw/N - sqr(sy_nw/N));
+        stats->sigma_aver = sqrt(yy_nw/N - dsqr(sy_nw/N));
         stats->error      = stats->sigma_aver/sqrt(N);
 
         /* Compute RMSD between x and y */
@@ -231,10 +227,10 @@ static int gmx_stats_compute(gmx_stats *stats,int weight)
         yy_nw /= N;
         sx_nw /= N;
         sy_nw /= N;
-        ssxx = N*(xx_nw - sqr(sx_nw));
-        ssyy = N*(yy_nw - sqr(sy_nw));
+        ssxx = N*(xx_nw - dsqr(sx_nw));
+        ssyy = N*(yy_nw - dsqr(sy_nw));
         ssxy = N*(yx_nw - (sx_nw*sy_nw));
-        stats->Rdata = sqrt(sqr(ssxy)/(ssxx*ssyy)); 
+        stats->Rdata = sqrt(dsqr(ssxy)/(ssxx*ssyy));
         
         /* Compute straight line through datapoints, either with intercept
            zero (result in aa) or with intercept variable (results in a
@@ -262,8 +258,8 @@ static int gmx_stats_compute(gmx_stats *stats,int weight)
             {
                 dy = 1;
             }
-            chi2aa += sqr((stats->y[i]-(stats->aa*stats->x[i]))/dy);
-            chi2   += sqr((stats->y[i]-(stats->a*stats->x[i]+stats->b))/dy);
+            chi2aa += dsqr((stats->y[i]-(stats->aa*stats->x[i]))/dy);
+            chi2   += dsqr((stats->y[i]-(stats->a*stats->x[i]+stats->b))/dy);
         }
         if (N > 2) 
         {
@@ -542,7 +538,7 @@ int gmx_stats_make_histogram(gmx_stats_t gstats,real binwidth,int *nb,
     }
     else
     {
-        nbins = gmx_nint((delta)/binwidth + 0.5);
+        nbins = gmx_dnint((delta)/binwidth + 0.5);
     }
     snew(*x,nbins);
     snew(nindex,nbins);
@@ -683,10 +679,10 @@ static int low_lsq_y_ax_b(int n, real *xr, double *xd, real yr[],
       chi2 = 0;
       if (xd != NULL) {
       for(i=0; i<n; i++)
-      chi2 += sqr(yr[i] - ((*a)*xd[i] + (*b)));
+      chi2 += dsqr(yr[i] - ((*a)*xd[i] + (*b)));
       } else {
       for(i=0; i<n; i++)
-      chi2 += sqr(yr[i] - ((*a)*xr[i] + (*b)));
+      chi2 += dsqr(yr[i] - ((*a)*xr[i] + (*b)));
       }
   
       if (n > 2)
@@ -744,10 +740,10 @@ int lsq_y_ax_b_error(int n, real x[], real y[], real dy[],
       gmx_fatal(FARGS,"Zero or negative weigths in linear regression analysis");
     
       for (i=0; i<n; i++) {
-      s_2  = sqr(1.0/dy[i]);
-      sxx += s_2*sqr(x[i]);
+      s_2  = dsqr(1.0/dy[i]);
+      sxx += s_2*dsqr(x[i]);
       sxy += s_2*y[i]*x[i];
-      syy += s_2*sqr(y[i]);
+      syy += s_2*dsqr(y[i]);
       sx  += s_2*x[i];
       sy  += s_2*y[i];
       w   += s_2;
@@ -764,7 +760,7 @@ int lsq_y_ax_b_error(int n, real x[], real y[], real dy[],
   
       *chi2=0;
       for(i=0; i<n; i++)
-      *chi2+=sqr((y[i]-((*a)*x[i]+(*b)))/dy[i]);
+      *chi2+=dsqr((y[i]-((*a)*x[i]+(*b)))/dy[i]);
       *chi2 = *chi2/w;
   
       *da = sqrt(*chi2/((n-2)*dx2));
index 2b005fdf6670a4cfe346a50bfc83a23d2d579b9f..1912a8df7f7f550746a15ecf1f8eddc66b3ac605 100644 (file)
@@ -821,10 +821,10 @@ void parse_common_args(int *argc,char *argv[],unsigned long Flags,
             gmx_cmd(argv[1]);
         }
     } 
-    if (bExit) {
-        if (gmx_parallel_env_initialized())
-            /*gmx_abort(gmx_node_rank(),gmx_node_num(),0);*/
-            gmx_finalize();
+    if (bExit)
+    {
+        gmx_finalize_par();
+
         exit(0);
     }
 #undef FF
index 8dab18c9bea7b0f47f6f1ee19e82d0c3756fa389..f9d807c224921e218f248d21dc4bd23ece9f709c 100644 (file)
@@ -436,7 +436,7 @@ static gmx_bool gmx_next_frame(t_trxstatus *status,t_trxframe *fr)
   return bRet;    
 }
 
-static void choose_ff(FILE *fp)
+static void choose_file_format(FILE *fp)
 {
   int i,m,c;
   int rc;
@@ -585,7 +585,7 @@ static int xyz_first_x(t_trxstatus *status, FILE *fp, const output_env_t oenv,
   initcount(status);
 
   clear_mat(box);
-  choose_ff(fp);
+  choose_file_format(fp);
 
   for(m=0; (m<DIM); m++)
     box[m][m]=status->BOX[m];
index 96a6ccf32aa3557dc37c198b7d4e8c083a9f9164..897d2f82a78598ddeb3fe2ed14f7d7a51b6a207a 100644 (file)
@@ -421,7 +421,7 @@ void done_inputrec(t_inputrec *ir)
   }
 }
 
-static void init_ekinstate(ekinstate_t *eks)
+static void zero_ekinstate(ekinstate_t *eks)
 {
   eks->ekin_n         = 0;
   eks->ekinh          = NULL;
@@ -555,7 +555,7 @@ void init_state(t_state *state, int natoms, int ngtc, int nnhpres, int nhchainle
   state->sd_X = NULL;
   state->cg_p = NULL;
 
-  init_ekinstate(&state->ekinstate);
+  zero_ekinstate(&state->ekinstate);
 
   init_energyhistory(&state->enerhist);
 
index 8646444fe2807e9a7ec3b833e56308c702115884..a49e077d17574ad9bf51653929c1de84e52d8b92 100644 (file)
@@ -923,11 +923,10 @@ double do_md(FILE *fplog,t_commrec *cr,int nfile,const t_filenm fnm[],
         {
             if (update_forcefield(fplog,
                                   nfile,fnm,fr,
-                                  mdatoms->nr,state->x,state->box)) {
-                if (gmx_parallel_env_initialized())
-                {
-                    gmx_finalize();
-                }
+                                  mdatoms->nr,state->x,state->box))
+            {
+                gmx_finalize_par();
+
                 exit(0);
             }
         }
@@ -1614,10 +1613,8 @@ double do_md(FILE *fplog,t_commrec *cr,int nfile,const t_filenm fnm[],
                                  f,NULL,xcopy,
                                  &(top_global->mols),mdatoms->massT,pres))
             {
-                if (gmx_parallel_env_initialized())
-                {
-                    gmx_finalize();
-                }
+                gmx_finalize_par();
+
                 fprintf(stderr,"\n");
                 exit(0);
             }
index e0417e842d7362254c34d3cd54b7d5a1c43c77fe..5b0b78f2ef1f491ff7e97fc92024c0d4c5b5719a 100644 (file)
@@ -682,8 +682,7 @@ int main(int argc,char *argv[])
                 nstepout,resetstep,nmultisim,repl_ex_nst,repl_ex_seed,
                 pforce, cpt_period,max_hours,deviceOptions,Flags);
 
-  if (gmx_parallel_env_initialized())
-      gmx_finalize();
+  gmx_finalize_par();
 
   if (MULTIMASTER(cr)) {
       thanx(stderr);
index eb8644418e0db3c5b9b37101ac1b1fbf4dcabb53..bc5f2582991c528de354f67bce323b9a1651c3f6 100644 (file)
@@ -194,7 +194,7 @@ extern char **read_rotparams(int *ninp_p,t_inpfile **inp_p,t_rot *rot,
 
 
 /* Check whether the box is unchanged */
-static void check_box(matrix f_box, matrix box, char fn[], warninp_t wi)
+static void check_box_unchanged(matrix f_box, matrix box, char fn[], warninp_t wi)
 {
     int i,ii;
     gmx_bool bSame=TRUE;
@@ -265,7 +265,7 @@ extern void set_reference_positions(
              read_trn(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(f_box,box,reffile,wi);
+             check_box_unchanged(f_box,box,reffile,wi);
          }
          else
          {
index 7f99a6598b9de8e5febb59ffdd1f5eba80076774..1337c1119574ebc42b87e6f09da3e6d3b12e8276 100644 (file)
 #ifdef NOGMX
 #define GMX_PARALLEL_ENV_INITIALIZED 1
 #else 
-#include "main.h"
-#define GMX_PARALLEL_ENV_INITIALIZED gmx_parallel_env_initialized()
+#ifdef GMX_MPI
+#define GMX_PARALLEL_ENV_INITIALIZED 1
+#else
+#define GMX_PARALLEL_ENV_INITIALIZED 0
+#endif
 #endif
 
 #ifdef GMX_LIB_MPI
@@ -727,7 +730,7 @@ static void joinAxesTrans12(t_complex* lout,const t_complex* lin,int maxN,int ma
 }
 
 
-static void rotate(int x[]) {
+static void rotate_offsets(int x[]) {
     int t=x[0];
 /*    x[0]=x[2];
     x[2]=x[1];
@@ -789,15 +792,15 @@ static void compute_offsets(fft5d_plan plan, int xs[], int xl[], int xc[], int N
     /*input order is different for test program to match FFTW order 
       (important for complex to real)*/
     if (plan->flags&FFT5D_BACKWARD) {
-        rotate(xs);
-        rotate(xl);
-        rotate(xc);
-        rotate(NG);
+        rotate_offsets(xs);
+        rotate_offsets(xl);
+        rotate_offsets(xc);
+        rotate_offsets(NG);
         if (plan->flags&FFT5D_ORDER_YZ) {
-            rotate(xs);
-            rotate(xl);
-            rotate(xc);
-            rotate(NG);            
+            rotate_offsets(xs);
+            rotate_offsets(xl);
+            rotate_offsets(xc);
+            rotate_offsets(NG);
         }
     }
     if ((plan->flags&FFT5D_REALCOMPLEX) && ((!(plan->flags&FFT5D_BACKWARD) && s==0) || ((plan->flags&FFT5D_BACKWARD) && s==2))) {
index 15216cdcf8f16ca0649fbe6b72f58e9e1be33b71..623ad4c65f0aec3de25e9012b81ab6f7bad8cea9 100644 (file)
@@ -229,7 +229,7 @@ FILE *init_calcpot(const char *log,const char *tpx,const char *table,
   FILE     *fplog;
   
   /* Initiate */
-  *cr = init_cr_nopar();
+  *cr = init_par(NULL,NULL);
   gmx_log_open(log,*cr,FALSE,0,&fplog);
 
   init_nrnb(&nrnb);
index 132059f21bed0dde762df478734afacfa9518198..1a98aac553b0141614548870f518f4c738ec316e 100644 (file)
@@ -799,8 +799,7 @@ int gmx_disre(int argc,char *argv[])
   }
   thanx(stderr);
 
-  if (gmx_parallel_env_initialized())
-    gmx_finalize();
+  gmx_finalize_par();
 
   gmx_log_close(fplog);
   
index 42763cff53c2759b0b67c6ef695eff2e65a9d94f..66fb961f03a2562ae2626eb13894c9efd641c426 100644 (file)
@@ -1153,10 +1153,7 @@ int gmx_pme_error(int argc,char *argv[])
         fclose(fp);
     }
     
-    if (gmx_parallel_env_initialized())
-    {
-        gmx_finalize();
-    }
+    gmx_finalize_par();
     
     return 0;
 }
index de3c248a81a14c8433332a16985e5627c41f5052..cbac2309df0abb0534b328f1c72d5e0f1403b5ac 100644 (file)
@@ -57,7 +57,6 @@
 #include "do_fit.h"
 #include "rmpbc.h"
 #include "wgms.h"
-#include "magic.h"
 #include "pbc.h"
 #include "xvgr.h"
 #include "xdrf.h"
index de4f3ce88b650a1a1e11b09f1a4927e30e1bd93f..330a67766809387e604a768ad9b28968eb2e87a1 100644 (file)
@@ -59,7 +59,6 @@
 #include "do_fit.h"
 #include "rmpbc.h"
 #include "wgms.h"
-#include "magic.h"
 #include "pbc.h"
 #include "viewit.h"
 #include "xvgr.h"