Sort all includes in src/gromacs
[alexxy/gromacs.git] / src / gromacs / mdlib / pme_pp.c
index b375abcef0608beb82b648c13ee94f31e009bb70..f00d242ae766acdc1b170c774f329b0046818485 100644 (file)
  * the research papers on the package. Check out http://www.gromacs.org.
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "gmxpre.h"
 
+#include "config.h"
 
+#include <math.h>
 #include <stdio.h>
 #include <string.h>
-#include <math.h>
-#include "typedefs.h"
-#include "smalloc.h"
-#include "gmx_fatal.h"
-#include "vec.h"
-#include "pme.h"
-#include "network.h"
-#include "domdec.h"
-#include "sighandler.h"
 
+#include "gromacs/legacyheaders/domdec.h"
+#include "gromacs/legacyheaders/network.h"
+#include "gromacs/legacyheaders/pme.h"
+#include "gromacs/legacyheaders/sighandler.h"
+#include "gromacs/legacyheaders/typedefs.h"
+#include "gromacs/legacyheaders/types/commrec.h"
+#include "gromacs/math/vec.h"
+#include "gromacs/utility/fatalerror.h"
 #include "gromacs/utility/gmxmpi.h"
+#include "gromacs/utility/smalloc.h"
 
 enum {
     eCommType_ChargeA, eCommType_ChargeB, eCommType_SQRTC6A, eCommType_SQRTC6B,
@@ -160,7 +160,7 @@ gmx_pme_pp_t gmx_pme_pp_init(t_commrec gmx_unused *cr)
 /* This should be faster with a real non-blocking MPI implementation */
 /* #define GMX_PME_DELAYED_WAIT */
 
-static void gmx_pme_send_params_coords_wait(gmx_domdec_t gmx_unused *dd)
+static void gmx_pme_send_coeffs_coords_wait(gmx_domdec_t gmx_unused *dd)
 {
 #ifdef GMX_MPI
     if (dd->nreq_pme)
@@ -171,7 +171,7 @@ static void gmx_pme_send_params_coords_wait(gmx_domdec_t gmx_unused *dd)
 #endif
 }
 
-static void gmx_pme_send_params_coords(t_commrec *cr, int flags,
+static void gmx_pme_send_coeffs_coords(t_commrec *cr, int flags,
                                        real gmx_unused *chargeA, real gmx_unused *chargeB,
                                        real gmx_unused *c6A, real gmx_unused *c6B,
                                        real gmx_unused *sigmaA, real gmx_unused *sigmaB,
@@ -189,15 +189,17 @@ static void gmx_pme_send_params_coords(t_commrec *cr, int flags,
 
     if (debug)
     {
-        fprintf(debug, "PP node %d sending to PME node %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" : "");
     }
 
 #ifdef GMX_PME_DELAYED_WAIT
     /* When can not use cnb until pending communication has finished */
-    gmx_pme_send_params_coords_wait(dd);
+    gmx_pme_send_coeffs_coords_wait(dd);
 #endif
 
     if (dd->pme_receive_vir_ener)
@@ -288,12 +290,13 @@ static void gmx_pme_send_params_coords(t_commrec *cr, int flags,
     /* We can skip this wait as we are sure x and q will not be modified
      * before the next call to gmx_pme_send_x_q or gmx_pme_receive_f.
      */
-    gmx_pme_send_params_coords_wait(dd);
+    gmx_pme_send_coeffs_coords_wait(dd);
 #endif
 #endif
 }
 
 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,
@@ -302,15 +305,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)
     {
@@ -319,7 +321,7 @@ void gmx_pme_send_parameters(t_commrec *cr,
         flags |= (flags << 1);
     }
 
-    gmx_pme_send_params_coords(cr, flags,
+    gmx_pme_send_coeffs_coords(cr, flags,
                                chargeA, chargeB,
                                sqrt_c6A, sqrt_c6B, sigmaA, sigmaB,
                                NULL, NULL, 0, 0, maxshift_x, maxshift_y, -1);
@@ -346,7 +348,7 @@ void gmx_pme_send_coordinates(t_commrec *cr, matrix box, rvec *x,
     {
         flags |= PP_PME_ENER_VIR;
     }
-    gmx_pme_send_params_coords(cr, flags, NULL, NULL, NULL, NULL, NULL, NULL,
+    gmx_pme_send_coeffs_coords(cr, flags, NULL, NULL, NULL, NULL, NULL, NULL,
                                box, x, lambda_q, lambda_lj, 0, 0, step);
 }
 
@@ -356,7 +358,7 @@ void gmx_pme_send_finish(t_commrec *cr)
 
     flags = PP_PME_FINISH;
 
-    gmx_pme_send_params_coords(cr, flags, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, -1);
+    gmx_pme_send_coeffs_coords(cr, flags, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, -1);
 }
 
 void gmx_pme_send_switchgrid(t_commrec gmx_unused *cr,
@@ -400,7 +402,7 @@ void gmx_pme_send_resetcounters(t_commrec gmx_unused *cr, gmx_int64_t gmx_unused
 #endif
 }
 
-int gmx_pme_recv_params_coords(struct gmx_pme_pp          *pme_pp,
+int gmx_pme_recv_coeffs_coords(struct gmx_pme_pp          *pme_pp,
                                int                        *natoms,
                                real                      **chargeA,
                                real                      **chargeB,
@@ -443,7 +445,7 @@ int gmx_pme_recv_params_coords(struct gmx_pme_pp          *pme_pp,
 
         if (debug)
         {
-            fprintf(debug, "PME only node receiving:%s%s%s%s%s\n",
+            fprintf(debug, "PME only rank receiving:%s%s%s%s%s\n",
                     (cnb.flags & PP_PME_CHARGE)        ? " charges" : "",
                     (cnb.flags & PP_PME_COORD )        ? " coordinates" : "",
                     (cnb.flags & PP_PME_FINISH)        ? " finish" : "",
@@ -560,9 +562,10 @@ int gmx_pme_recv_params_coords(struct gmx_pme_pp          *pme_pp,
                         nat += pme_pp->nat[sender];
                         if (debug)
                         {
-                            fprintf(debug, "Received from PP node %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");
                         }
                     }
                 }
@@ -575,7 +578,7 @@ int gmx_pme_recv_params_coords(struct gmx_pme_pp          *pme_pp,
         {
             if (!(pme_pp->flags_charge & (PP_PME_CHARGE | PP_PME_SQRTC6)))
             {
-                gmx_incons("PME-only node received coordinates before charges and/or C6-values"
+                gmx_incons("PME-only rank received coordinates before charges and/or C6-values"
                            );
             }
 
@@ -593,13 +596,13 @@ int gmx_pme_recv_params_coords(struct gmx_pme_pp          *pme_pp,
 
             if (*bFreeEnergy_q && !(pme_pp->flags_charge & PP_PME_CHARGEB))
             {
-                gmx_incons("PME-only node received free energy request, but "
+                gmx_incons("PME-only rank received free energy request, but "
                            "did not receive B-state charges");
             }
 
             if (*bFreeEnergy_lj && !(pme_pp->flags_charge & PP_PME_SQRTC6B))
             {
-                gmx_incons("PME-only node received free energy request, but "
+                gmx_incons("PME-only rank received free energy request, but "
                            "did not receive B-state C6-values");
             }
 
@@ -616,7 +619,7 @@ int gmx_pme_recv_params_coords(struct gmx_pme_pp          *pme_pp,
                     nat += pme_pp->nat[sender];
                     if (debug)
                     {
-                        fprintf(debug, "Received from PP node %d: %d "
+                        fprintf(debug, "Received from PP rank %d: %d "
                                 "coordinates\n",
                                 pme_pp->node[sender], pme_pp->nat[sender]);
                     }
@@ -659,7 +662,7 @@ static void receive_virial_energy(t_commrec *cr,
         if (debug)
         {
             fprintf(debug,
-                    "PP node %d receiving from PME node %d: virial and energy\n",
+                    "PP rank %d receiving from PME rank %d: virial and energy\n",
                     cr->sim_nodeid, cr->dd->pme_nodeid);
         }
 #ifdef GMX_MPI
@@ -700,7 +703,7 @@ void gmx_pme_receive_f(t_commrec *cr,
 
 #ifdef GMX_PME_DELAYED_WAIT
     /* Wait for the x request to finish */
-    gmx_pme_send_params_coords_wait(cr->dd);
+    gmx_pme_send_coeffs_coords_wait(cr->dd);
 #endif
 
     natoms = cr->dd->nat_home;
@@ -770,7 +773,7 @@ void gmx_pme_send_force_vir_ener(struct gmx_pme_pp *pme_pp,
 
     if (debug)
     {
-        fprintf(debug, "PME node sending to PP node %d: virial and energy\n",
+        fprintf(debug, "PME rank sending to PP rank %d: virial and energy\n",
                 pme_pp->node_peer);
     }
 #ifdef GMX_MPI