Made g_tune_pme work correctly when ir->init_step > 0
authorCarsten Kutzner <ckutzne@gwdg.de>
Tue, 6 Nov 2012 13:03:25 +0000 (14:03 +0100)
committerCarsten Kutzner <ckutzne@gwdg.de>
Tue, 6 Nov 2012 13:03:25 +0000 (14:03 +0100)
For .tpr files with ir->init_step > 0, the benchmarks do not have the
correct number of steps. This fix sets init_step to zero for the benchmark .tpr
files but keeps the original init_step value for the launch .tpr file.
Benchmarking should now work correctly for .tpr files any init_step value,
regardless whether the .cpt file was provided to g_tune_pme or not.

Change-Id: I9d44647d4c71e1514709ee4d6477bd416f455f42

src/tools/gmx_tune_pme.c

index ab8ddaab9f8b819d902d62df4c9d631c2ac77700..7474694004ca7731e61156c1705704c93f7374b2 100644 (file)
@@ -99,6 +99,7 @@ typedef struct
 {
     int  nr_inputfiles;         /* The number of tpr and mdp input files */
     gmx_large_int_t orig_sim_steps;  /* Number of steps to be done in the real simulation */
+    gmx_large_int_t orig_init_step;  /* Init step for the real simulation */
     real *rcoulomb;             /* The coulomb radii [0...nr_inputfiles] */
     real *rvdw;                 /* The vdW radii */
     real *rlist;                /* Neighbourlist cutoff radius */
@@ -690,6 +691,7 @@ static void launch_simulation(
 
 static void modify_PMEsettings(
         gmx_large_int_t simsteps,  /* Set this value as number of time steps */
+        gmx_large_int_t init_step, /* Set this value as init_step */
         const char *fn_best_tpr,   /* tpr file with the best performance */
         const char *fn_sim_tpr)    /* name of tpr file to be launched */
 {
@@ -701,8 +703,9 @@ static void modify_PMEsettings(
     snew(ir,1);
     read_tpx_state(fn_best_tpr,ir,&state,NULL,&mtop);
         
-    /* Set nsteps to the right value */
+    /* Reset nsteps and init_step to the value of the input .tpr file */
     ir->nsteps = simsteps;
+    ir->init_step = init_step;
     
     /* Write the tpr file which will be launched */
     sprintf(buf, "Writing optimized simulation file %s with nsteps=%s.\n", fn_sim_tpr, gmx_large_int_pfmt);
@@ -988,7 +991,10 @@ static void make_benchmark_tprs(
     /* Reduce the number of steps for the benchmarks */
     info->orig_sim_steps = ir->nsteps;
     ir->nsteps           = benchsteps;
-    
+    /* We must not use init_step from the input tpr file for the benchmarks */
+    info->orig_init_step = ir->init_step;
+    ir->init_step        = 0;
+
     /* For PME-switch potentials, keep the radial distance of the buffer region */
     nlist_buffer   = ir->rlist - ir->rcoulomb;
 
@@ -2502,9 +2508,8 @@ int gmx_tune_pme(int argc,char *argv[])
     else
     {
         simulation_tpr = opt2fn("-so",NFILE,fnm);
-        modify_PMEsettings(bOverwrite? (new_sim_nsteps+cpt_steps) : 
-                           info->orig_sim_steps, tpr_names[best_tpr], 
-                           simulation_tpr);            
+        modify_PMEsettings(bOverwrite? (new_sim_nsteps+cpt_steps) : info->orig_sim_steps,
+                info->orig_init_step, tpr_names[best_tpr], simulation_tpr);
     }
 
     /* Now start the real simulation if the user requested it ... */