Merge "Fixing trjconv -sub" into release-4-5-patches
authorDavid van der Spoel <davidvanderspoel@gmail.com>
Mon, 14 Jan 2013 19:16:59 +0000 (20:16 +0100)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Mon, 14 Jan 2013 19:16:59 +0000 (20:16 +0100)
include/disre.h
src/gmxlib/disre.c
src/gmxlib/mtop_util.c
src/gmxlib/sfactor.c
src/kernel/gmxdump.c
src/kernel/runner.c
src/tools/gmx_disre.c
src/tools/gmx_membed.c
src/tools/gmx_rmsf.c

index 9648f68e653b3fbfcee2171b48ec5962ce33754d..646c7d1830b8bce42b83f9582aafbf33e6a96908 100644 (file)
@@ -45,12 +45,14 @@ extern "C" {
 #endif
 
 void init_disres(FILE *fplog,const gmx_mtop_t *mtop,
-                       t_inputrec *ir,const t_commrec *cr,gmx_bool bPartDecomp,
-                       t_fcdata *fcd,t_state *state);
+                 t_inputrec *ir,const t_commrec *cr,gmx_bool bPartDecomp,
+                 t_fcdata *fcd,t_state *state, gmx_bool bIsREMD);
 /* Initiate *fcd data, must be called once, nbonds is the number 
  * of iatoms in the ilist of the idef struct.
  * When time averaging is used, the history is initialized in state,
  * unless it was read before from a checkpoint file.
+ * The implementation of distance restraints with -multi
+ * must differ according to whether REMD is active.
  */
 
 void calc_disres_R_6(const gmx_multisim_t *ms,
index 0551026fd55c2fd655bb69debc89bf226120626c..1af415b295920d8e2d8ac1eb24a3d09139c60b32 100644 (file)
@@ -55,7 +55,7 @@
 
 void init_disres(FILE *fplog,const gmx_mtop_t *mtop,
                  t_inputrec *ir,const t_commrec *cr,gmx_bool bPartDecomp,
-                 t_fcdata *fcd,t_state *state)
+                 t_fcdata *fcd,t_state *state, gmx_bool bIsREMD)
 {
     int          fa,nmol,i,npair,np;
     t_iparams    *ip;
@@ -181,7 +181,7 @@ void init_disres(FILE *fplog,const gmx_mtop_t *mtop,
     dd->Rtav_6 = &(dd->Rt_6[dd->nres]);
 
     ptr = getenv("GMX_DISRE_ENSEMBLE_SIZE");
-    if (cr && cr->ms != NULL && ptr != NULL)
+    if (cr && cr->ms != NULL && ptr != NULL && !bIsREMD)
     {
 #ifdef GMX_MPI
         dd->nsystems = 0;
@@ -190,8 +190,16 @@ void init_disres(FILE *fplog,const gmx_mtop_t *mtop,
         {
             fprintf(fplog,"Found GMX_DISRE_ENSEMBLE_SIZE set to %d systems per ensemble\n",dd->nsystems);
         }
-        check_multi_int(fplog,cr->ms,dd->nsystems,
-                        "the number of systems per ensemble");
+        /* This check is only valid on MASTER(cr), so probably
+         * ensemble-averaged distance restraints are broken on more
+         * than one processor per simulation system. */
+        if (MASTER(cr))
+        {
+            check_multi_int(fplog,cr->ms,dd->nsystems,
+                            "the number of systems per ensemble");
+        }
+        gmx_bcast_sim(sizeof(int), &dd->nsystems, cr);
+
         if (dd->nsystems <= 0 ||  cr->ms->nsim % dd->nsystems != 0)
         {
             gmx_fatal(FARGS,"The number of systems %d is not divisible by the number of systems per ensemble %d\n",cr->ms->nsim,dd->nsystems);
@@ -225,7 +233,13 @@ void init_disres(FILE *fplog,const gmx_mtop_t *mtop,
         if (fplog) {
             fprintf(fplog,"There are %d distance restraints involving %d atom pairs\n",dd->nres,dd->npair);
         }
-        if (cr && cr->ms)
+        /* Have to avoid g_disre de-referencing cr blindly, mdrun not
+         * doing consistency checks for ensemble-averaged distance
+         * restraints when that's not happening, and only doing those
+         * checks from appropriate processes (since check_multi_int is
+         * too broken to check whether the communication will
+         * succeed...) */
+        if (cr && cr->ms && dd->nsystems > 1 && MASTER(cr))
         {
             check_multi_int(fplog,cr->ms,fcd->disres.nres,
                             "the number of distance restraints");
index adc441209eb725cb9cee92580beeaaa0f8825b72..e29c3ed18201c16fcc046c644722ea10735365b4 100644 (file)
@@ -841,6 +841,8 @@ static void gen_local_top(const gmx_mtop_t *mtop,const t_inputrec *ir,
         }
         if (idef->il[F_POSRES].nr > nposre_old)
         {
+            /* Executing this line line stops gmxdump -sys working
+             * correctly. I'm not aware there's an elegant fix. */
             set_posres_params(idef,molb,nposre_old/2,natoms);
         }
 
index 9023807f7ff7f1fb13d50edbe89e441fe3123d6f..0cd6a79799a59803be85cdbf8055446a3dd92d78 100644 (file)
@@ -131,7 +131,6 @@ extern t_complex *** rc_tensor_allocation(int x, int y, int z)
   t_complex ***t;
   int i,j;
 
-  snew(t,x);
   t = (t_complex ***)calloc(x,sizeof(t_complex**));
   if(!t) exit(fprintf(stderr,"\nallocation error"));
   t[0] = (t_complex **)calloc(x*y,sizeof(t_complex*));
index 4e99088d8415146d18e2c0c5396eea21c3565533..c7a1918029a1a34fa52ae358ec0705ce8b962938 100644 (file)
@@ -469,6 +469,9 @@ int main(int argc,char *argv[])
     "Note that currently setting [TT]GMXLIB[tt] is the only way to customize",
     "directories used for searching include files.",
   };
+  const char *bugs[] = {
+    "Position restraint output from -sys -s is broken"
+  };
   t_filenm fnm[] = {
     { efTPX, "-s", NULL, ffOPTRD },
     { efTRX, "-f", NULL, ffOPTRD },
@@ -493,7 +496,7 @@ int main(int argc,char *argv[])
   
   CopyRight(stderr,argv[0]);
   parse_common_args(&argc,argv,0,NFILE,fnm,asize(pa),pa,
-                   asize(desc),desc,0,NULL,&oenv);
+                    asize(desc),desc,asize(bugs),bugs,&oenv);
 
 
   if (ftp2bSet(efTPX,NFILE,fnm))
index 23e3a7620227ac6d3dbc94bcd20706d1e49e072f..8b1d8fce7d366cef3ab987110403a96f407e4b5e 100644 (file)
@@ -483,7 +483,7 @@ int mdrunner(int nthreads_requested, FILE *fplog,t_commrec *cr,int nfile,
     snew(fcd,1);
 
     /* This needs to be called before read_checkpoint to extend the state */
-    init_disres(fplog,mtop,inputrec,cr,Flags & MD_PARTDEC,fcd,state);
+    init_disres(fplog,mtop,inputrec,cr,Flags & MD_PARTDEC,fcd,state, repl_ex_nst > 0);
 
     if (gmx_mtop_ftype_count(mtop,F_ORIRES) > 0)
     {
index 888e64293bca5fbf3bc811aadabe5503d5f1599f..0b4f0bdddcd070b20515dc645d881ac02c6ad303 100644 (file)
@@ -683,7 +683,7 @@ int gmx_disre(int argc,char *argv[])
     isize=0;
 
   ir.dr_tau=0.0;
-  init_disres(fplog,&mtop,&ir,NULL,FALSE,&fcd,NULL);
+  init_disres(fplog,&mtop,&ir,NULL,FALSE,&fcd,NULL,FALSE);
 
   natoms=read_first_x(oenv,&status,ftp2fn(efTRX,NFILE,fnm),&t,&x,box);
   snew(f,5*natoms);
index e3d4c671ff9bc2557e7c33c71250bba0e2ac80d9..db2854f40eafdf52a1e43fcf153ea448d0b5712a 100644 (file)
@@ -3040,7 +3040,7 @@ int mdrunner_membed(FILE *fplog,t_commrec *cr,int nfile,const t_filenm fnm[],
     snew(fcd,1);
 
     /* This needs to be called before read_checkpoint to extend the state */
-    init_disres(fplog,mtop,inputrec,cr,Flags & MD_PARTDEC,fcd,state);
+    init_disres(fplog,mtop,inputrec,cr,Flags & MD_PARTDEC,fcd,state,FALSE);
 
     if (gmx_mtop_ftype_count(mtop,F_ORIRES) > 0)
     {
index 89f8f7dff6cd36e7ba5728da1bfd476c8856924f..8f7317b8d01b1b19648d45365173fa479d47230e 100644 (file)
@@ -423,7 +423,7 @@ int gmx_rmsf(int argc,char *argv[])
                                 *(top.atoms.atomname[index[i]]));
        
        fprintf(fp,"%5d  %10.5f  %10.5f\n",
-               bRes ? top.atoms.resinfo[top.atoms.atom[index[i]].resind].nr : i+1,rmsf[i]*bfac,
+               bRes ? top.atoms.resinfo[top.atoms.atom[index[i]].resind].nr : index[i]+1,rmsf[i]*bfac,
                pdb_bfac);
       }
     }
@@ -434,7 +434,7 @@ int gmx_rmsf(int argc,char *argv[])
       if (!bRes || i+1==isize ||
          top.atoms.atom[index[i]].resind!=top.atoms.atom[index[i+1]].resind)
        fprintf(fp,"%5d %8.4f\n",
-               bRes ? top.atoms.resinfo[top.atoms.atom[index[i]].resind].nr : i+1,sqrt(rmsf[i]));
+               bRes ? top.atoms.resinfo[top.atoms.atom[index[i]].resind].nr : index[i]+1,sqrt(rmsf[i]));
     ffclose(fp);
   }
   
@@ -452,7 +452,7 @@ int gmx_rmsf(int argc,char *argv[])
       if (!bRes || i+1==isize ||
          top.atoms.atom[index[i]].resind!=top.atoms.atom[index[i+1]].resind)
        fprintf(fp,"%5d %8.4f\n",
-               bRes ? top.atoms.resinfo[top.atoms.atom[index[i]].resind].nr : i+1,sqrt(rmsf[i]));
+               bRes ? top.atoms.resinfo[top.atoms.atom[index[i]].resind].nr : index[i]+1,sqrt(rmsf[i]));
     ffclose(fp);
   }