Fix hang with LJ-PME and empty domains
authorBerk Hess <hess@kth.se>
Mon, 4 Aug 2014 12:18:36 +0000 (14:18 +0200)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Tue, 5 Aug 2014 11:03:00 +0000 (13:03 +0200)
With LJ-PME and DD domains with 0 atoms and LJ-PME mdrun could hang.
Fixes #1571.

Change-Id: Ie205954c4f5e1a52df846a69972f735867eea15d

src/gromacs/legacyheaders/pme.h
src/gromacs/mdlib/domdec.c
src/gromacs/mdlib/pme_pp.c

index 5f985fe29bfba2e6aee5375cc4fa578b883f5bd6..da0b4a1c5dfdaa325f17293d320b7e66b22ca805 100644 (file)
@@ -152,6 +152,7 @@ gmx_pme_pp_t gmx_pme_pp_init(t_commrec *cr);
 /* Initialize the PME-only side of the PME <-> PP communication */
 
 void gmx_pme_send_parameters(t_commrec *cr,
+                             const interaction_const_t *ic,
                              gmx_bool bFreeEnergy_q, gmx_bool bFreeEnergy_lj,
                              real *chargeA, real *chargeB,
                              real *sqrt_c6A, real *sqrt_c6B,
index c995192a36de1f98b87e0e7e9163d701d1c8c294..ae2a4f8098b696a91f846ef2e483abcfbc01b82f 100644 (file)
@@ -9769,7 +9769,9 @@ void dd_partition_system(FILE                *fplog,
     if (!(cr->duty & DUTY_PME))
     {
         /* Send the charges and/or c6/sigmas to our PME only node */
-        gmx_pme_send_parameters(cr, mdatoms->nChargePerturbed, mdatoms->nTypePerturbed,
+        gmx_pme_send_parameters(cr,
+                                fr->ic,
+                                mdatoms->nChargePerturbed, mdatoms->nTypePerturbed,
                                 mdatoms->chargeA, mdatoms->chargeB,
                                 mdatoms->sqrt_c6A, mdatoms->sqrt_c6B,
                                 mdatoms->sigmaA, mdatoms->sigmaB,
index 1b3f9c65278db6ae0ffb5f3129031879a1c9a6c0..0aee97b824d4376cc52e0cc23e3f3d6cc44f174a 100644 (file)
@@ -190,9 +190,11 @@ static void gmx_pme_send_coeffs_coords(t_commrec *cr, int flags,
 
     if (debug)
     {
-        fprintf(debug, "PP rank %d sending to PME rank %d: %d%s%s\n",
+        fprintf(debug, "PP rank %d sending to PME rank %d: %d%s%s%s%s\n",
                 cr->sim_nodeid, dd->pme_nodeid, n,
                 flags & PP_PME_CHARGE ? " charges" : "",
+                flags & PP_PME_SQRTC6 ? " sqrtC6" : "",
+                flags & PP_PME_SIGMA  ? " sigma" : "",
                 flags & PP_PME_COORD  ? " coordinates" : "");
     }
 
@@ -295,6 +297,7 @@ static void gmx_pme_send_coeffs_coords(t_commrec *cr, int flags,
 }
 
 void gmx_pme_send_parameters(t_commrec *cr,
+                             const interaction_const_t *ic,
                              gmx_bool bFreeEnergy_q, gmx_bool bFreeEnergy_lj,
                              real *chargeA, real *chargeB,
                              real *sqrt_c6A, real *sqrt_c6B,
@@ -303,15 +306,14 @@ void gmx_pme_send_parameters(t_commrec *cr,
 {
     int flags;
 
-    /* We always send the charges, even with only LJ- and no Coulomb-PME */
-    flags = PP_PME_CHARGE;
-    if (sqrt_c6A != NULL)
+    flags = 0;
+    if (EEL_PME(ic->eeltype))
     {
-        flags |= PP_PME_SQRTC6;
+        flags |= PP_PME_CHARGE;
     }
-    if (sigmaA != NULL)
+    if (EVDW_PME(ic->vdwtype))
     {
-        flags |= PP_PME_SIGMA;
+        flags |= (PP_PME_SQRTC6 | PP_PME_SIGMA);
     }
     if (bFreeEnergy_q || bFreeEnergy_lj)
     {
@@ -561,9 +563,10 @@ int gmx_pme_recv_coeffs_coords(struct gmx_pme_pp          *pme_pp,
                         nat += pme_pp->nat[sender];
                         if (debug)
                         {
-                            fprintf(debug, "Received from PP rank %d: %d "
-                                    "charges\n",
-                                    pme_pp->node[sender], pme_pp->nat[sender]);
+                            fprintf(debug, "Received from PP rank %d: %d %s\n",
+                                    pme_pp->node[sender], pme_pp->nat[sender],
+                                    (q == eCommType_ChargeA ||
+                                     q == eCommType_ChargeB) ? "charges" : "params");
                         }
                     }
                 }