Merge branch 'release-4-5-patches' into release-4-6
[alexxy/gromacs.git] / src / gmxlib / disre.c
index 1af415b295920d8e2d8ac1eb24a3d09139c60b32..1b2fddadae03c8fca879d16f523af75e92bb5d71 100644 (file)
@@ -1,37 +1,39 @@
-/* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*-
+/*
+ * This file is part of the GROMACS molecular simulation package.
  *
- * 
- *                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
+ * Copyright (c) 2012, by the GROMACS development team, led by
+ * David van der Spoel, Berk Hess, 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.
- * 
- * 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.
- * 
+ *
+ * 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 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 Mixture of Alchemy and Childrens' Stories
+ * the research papers on the package. Check out http://www.gromacs.org.
  */
 /* This file is completely threadsafe - keep it that way! */
 #ifdef HAVE_CONFIG_H
@@ -196,19 +198,19 @@ void init_disres(FILE *fplog,const gmx_mtop_t *mtop,
         if (MASTER(cr))
         {
             check_multi_int(fplog,cr->ms,dd->nsystems,
-                            "the number of systems per ensemble");
+                            "the number of systems per ensemble",
+                            FALSE);
         }
         gmx_bcast_sim(sizeof(int), &dd->nsystems, cr);
 
-        if (dd->nsystems <= 0 ||  cr->ms->nsim % dd->nsystems != 0)
+        /* We use to allow any value of nsystems which was a divisor
+         * of ms->nsim. But this required an extra communicator which
+         * was stored in t_fcdata. This pulled in mpi.h in nearly all C files.
+         */
+        if (!(cr->ms->nsim == 1 || cr->ms->nsim == dd->nsystems))
         {
-            gmx_fatal(FARGS,"The number of systems %d is not divisible by the number of systems per ensemble %d\n",cr->ms->nsim,dd->nsystems);
+            gmx_fatal(FARGS,"GMX_DISRE_ENSEMBLE_SIZE (%d) is not equal to 1 or the number of systems (option -multi) %d",dd->nsystems,cr->ms->nsim);
         }
-        /* Split the inter-master communicator into different ensembles */
-        MPI_Comm_split(cr->ms->mpi_comm_masters,
-                       cr->ms->sim/dd->nsystems,
-                       cr->ms->sim,
-                       &dd->mpi_comm_ensemble);
         if (fplog)
         {
             fprintf(fplog,"Our ensemble consists of systems:");
@@ -242,7 +244,8 @@ void init_disres(FILE *fplog,const gmx_mtop_t *mtop,
         if (cr && cr->ms && dd->nsystems > 1 && MASTER(cr))
         {
             check_multi_int(fplog,cr->ms,fcd->disres.nres,
-                            "the number of distance restraints");
+                            "the number of distance restraints",
+                            FALSE);
         }
         please_cite(fplog,"Tropp80a");
         please_cite(fplog,"Torda89a");
@@ -357,7 +360,7 @@ void calc_disres_R_6(const gmx_multisim_t *ms,
 #ifdef GMX_MPI
     if (dd->nsystems > 1)
     {
-        gmx_sum_comm(2*dd->nres,Rt_6,dd->mpi_comm_ensemble);
+        gmx_sum_sim(2*dd->nres,Rt_6,ms);
     }
 #endif
 }