Merge branch 'release-4-6', adds the nbnxn functionality
[alexxy/gromacs.git] / src / gromacs / mdlib / md_support.c
index 4a0aff42b83f75bedcb401da680c3f04e1dc15ea..b3b7b6ab32b514eebdbff2e0767dfe041e22c566 100644 (file)
@@ -47,6 +47,8 @@
 #include "vcm.h"
 #include "nrnb.h"
 #include "macros.h"
+#include "md_logging.h"
+#include "md_support.h"
 
 /* Is the signal in one simulation independent of other simulations? */
 gmx_bool gs_simlocal[eglsNR] = { TRUE, FALSE, FALSE, TRUE };
@@ -498,14 +500,12 @@ void check_nst_param(FILE *fplog,t_commrec *cr,
                      const char *desc_nst,int nst,
                      const char *desc_p,int *p)
 {
-    char buf[STRLEN];
-
     if (*p > 0 && *p % nst != 0)
     {
         /* Round up to the next multiple of nst */
         *p = ((*p)/nst + 1)*nst;
-        sprintf(buf,"NOTE: %s changes %s to %d\n",desc_nst,desc_p,*p);
-        md_print_warning(cr,fplog,buf);
+        md_print_warn(cr,fplog,
+                      "NOTE: %s changes %s to %d\n",desc_nst,desc_p,*p);
     }
 }
 
@@ -588,35 +588,7 @@ void set_current_lambdas(gmx_large_int_t step, t_lambda *fepvals, gmx_bool bReru
     }
 }
 
-void reset_all_counters(FILE *fplog,t_commrec *cr,
-                        gmx_large_int_t step,
-                        gmx_large_int_t *step_rel,t_inputrec *ir,
-                        gmx_wallcycle_t wcycle,t_nrnb *nrnb,
-                        gmx_runtime_t *runtime)
-{
-    char buf[STRLEN],sbuf[STEPSTRSIZE];
-
-    /* Reset all the counters related to performance over the run */
-    sprintf(buf,"Step %s: resetting all time and cycle counters\n",
-            gmx_step_str(step,sbuf));
-    md_print_warning(cr,fplog,buf);
-
-    wallcycle_stop(wcycle,ewcRUN);
-    wallcycle_reset_all(wcycle);
-    if (DOMAINDECOMP(cr))
-    {
-        reset_dd_statistics_counters(cr->dd);
-    }
-    init_nrnb(nrnb);
-    ir->init_step += *step_rel;
-    ir->nsteps    -= *step_rel;
-    *step_rel = 0;
-    wallcycle_start(wcycle,ewcRUN);
-    runtime_start(runtime);
-    print_date_and_time(fplog,cr->nodeid,"Restarted time",runtime);
-}
-
-void min_zero(int *n,int i)
+static void min_zero(int *n,int i)
 {
     if (i > 0 && (*n == 0 || i < *n))
     {
@@ -624,7 +596,7 @@ void min_zero(int *n,int i)
     }
 }
 
-int lcd4(int i1,int i2,int i3,int i4)
+static int lcd4(int i1,int i2,int i3,int i4)
 {
     int nst;
 
@@ -652,8 +624,6 @@ int lcd4(int i1,int i2,int i3,int i4)
 int check_nstglobalcomm(FILE *fplog,t_commrec *cr,
                         int nstglobalcomm,t_inputrec *ir)
 {
-    char buf[STRLEN];
-
     if (!EI_DYNAMICS(ir->eI))
     {
         nstglobalcomm = 1;
@@ -689,8 +659,7 @@ int check_nstglobalcomm(FILE *fplog,t_commrec *cr,
             nstglobalcomm > ir->nstlist && nstglobalcomm % ir->nstlist != 0)
         {
             nstglobalcomm = (nstglobalcomm / ir->nstlist)*ir->nstlist;
-            sprintf(buf,"WARNING: nstglobalcomm is larger than nstlist, but not a multiple, setting it to %d\n",nstglobalcomm);
-            md_print_warning(cr,fplog,buf);
+            md_print_warn(cr,fplog,"WARNING: nstglobalcomm is larger than nstlist, but not a multiple, setting it to %d\n",nstglobalcomm);
         }
         if (ir->nstcalcenergy > 0)
         {
@@ -717,9 +686,8 @@ int check_nstglobalcomm(FILE *fplog,t_commrec *cr,
 
     if (ir->comm_mode != ecmNO && ir->nstcomm < nstglobalcomm)
     {
-        sprintf(buf,"WARNING: Changing nstcomm from %d to %d\n",
-                ir->nstcomm,nstglobalcomm);
-        md_print_warning(cr,fplog,buf);
+        md_print_warn(cr,fplog,"WARNING: Changing nstcomm from %d to %d\n",
+                      ir->nstcomm,nstglobalcomm);
         ir->nstcomm = nstglobalcomm;
     }
 
@@ -733,13 +701,13 @@ void check_ir_old_tpx_versions(t_commrec *cr,FILE *fplog,
     if (IR_TWINRANGE(*ir) && ir->nstlist > 1 &&
         ir->nstcalcenergy % ir->nstlist != 0)
     {
-        md_print_warning(cr,fplog,"Old tpr file with twin-range settings: modifying energy calculation and/or T/P-coupling frequencies");
+        md_print_warn(cr,fplog,"Old tpr file with twin-range settings: modifying energy calculation and/or T/P-coupling frequencies\n");
 
         if (gmx_mtop_ftype_count(mtop,F_CONSTR) +
             gmx_mtop_ftype_count(mtop,F_CONSTRNC) > 0 &&
             ir->eConstrAlg == econtSHAKE)
         {
-            md_print_warning(cr,fplog,"With twin-range cut-off's and SHAKE the virial and pressure are incorrect");
+            md_print_warn(cr,fplog,"With twin-range cut-off's and SHAKE the virial and pressure are incorrect\n");
             if (ir->epc != epcNO)
             {
                 gmx_fatal(FARGS,"Can not do pressure coupling with twin-range cut-off's and SHAKE");
@@ -804,15 +772,3 @@ void rerun_parallel_comm(t_commrec *cr,t_trxframe *fr,
         }
     }
 }
-
-void md_print_warning(const t_commrec *cr,FILE *fplog,const char *buf)
-{
-    if (MASTER(cr))
-    {
-        fprintf(stderr,"\n%s\n",buf);
-    }
-    if (fplog)
-    {
-        fprintf(fplog,"\n%s\n",buf);
-    }
-}