#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,
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;
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;
{
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);
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");
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)
{
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);
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)
{