Instead of a segv, mdrun now gives an error msg if npme>np, fixes #795
[alexxy/gromacs.git] / src / mdlib / domdec_setup.c
index 8048e72710fdf8648c634e723457a7b35388574c..ed095f52e3fce587f59e44e22b3a2d530d936d43 100644 (file)
@@ -37,6 +37,11 @@ static int factorize(int n,int **fac,int **mfac)
 {
     int d,ndiv;
 
+    if (n <= 0)
+    {
+        gmx_fatal(FARGS, "Can only factorize positive integers.");
+    }
+
     /* Decompose n in factors */
     snew(*fac,n/2);
     snew(*mfac,n/2);
@@ -671,6 +676,12 @@ real dd_choose_grid(FILE *fplog,
                     gmx_fatal(FARGS,
                               "Can not have separate PME nodes with 2 or less nodes");
                 }
+                if (cr->npmenodes >= cr->nnodes)
+                {
+                    gmx_fatal(FARGS,
+                              "Can not have %d separate PME nodes with just %d total nodes",
+                              cr->npmenodes, cr->nnodes);
+                }
 
                 /* If the user purposely selected the number of PME nodes,
                  * only check for large primes in the PP node count.