From: Carsten Kutzner Date: Fri, 5 Nov 2010 10:02:06 +0000 (+0100) Subject: Print warning when reference file is set but could not be found X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=97682b55807e66dc2d86203f62258e859e758a00;p=alexxy%2Fgromacs.git Print warning when reference file is set but could not be found --- diff --git a/src/kernel/grompp.c b/src/kernel/grompp.c index ee14674d5c..17772bc9a9 100644 --- a/src/kernel/grompp.c +++ b/src/kernel/grompp.c @@ -1529,7 +1529,11 @@ int main (int argc, char *argv[]) set_pull_init(ir,sys,state.x,state.box,oenv,opts->pull_start); if (ir->bRot) - set_reference_positions(ir->rot,sys,state.x,state.box,opt2fn("-ref",NFILE,fnm),wi); + { + set_reference_positions(ir->rot,sys,state.x,state.box, + opt2fn("-ref",NFILE,fnm),opt2bSet("-ref",NFILE,fnm), + wi); + } /* reset_multinr(sys); */ diff --git a/src/kernel/readir.h b/src/kernel/readir.h index a4730f9224..3f99910756 100644 --- a/src/kernel/readir.h +++ b/src/kernel/readir.h @@ -144,6 +144,6 @@ extern void make_rotation_groups(t_rot *rot,char **rotgnames, /* Process the rotation parameters after reading the index groups */ extern void set_reference_positions(t_rot *rot, gmx_mtop_t *mtop, rvec *x, matrix box, - const char *fn, warninp_t wi); + const char *fn, gmx_bool bSet, warninp_t wi); #endif /* _readir_h */ diff --git a/src/kernel/readrot.c b/src/kernel/readrot.c index f2873a8d99..dfde112688 100644 --- a/src/kernel/readrot.c +++ b/src/kernel/readrot.c @@ -42,6 +42,8 @@ #include "trnio.h" #include "txtdump.h" +static char *RotStr = {"Enforced rotation:"}; + static char s_vec[STRLEN]; @@ -113,8 +115,8 @@ extern char **read_rotparams(int *ninp_p,t_inpfile **inp_p,t_rot *rot, sprintf(warn_buf, "rot_vec%d = 0", g); warning_error(wi, warn_buf); } - fprintf(stderr, "Enforced rotation: Group %d (%s) normalized rot. vector: %f %f %f\n", - g, erotg_names[rotg->eType], vec[0], vec[1], vec[2]); + fprintf(stderr, "%s Group %d (%s) normalized rot. vector: %f %f %f\n", + RotStr, g, erotg_names[rotg->eType], vec[0], vec[1], vec[2]); for(m=0; mvec[m] = vec[m]; @@ -179,7 +181,7 @@ extern char **read_rotparams(int *ninp_p,t_inpfile **inp_p,t_rot *rot, /* Check whether the box is unchanged */ -static void check_box(matrix f_box, matrix box, char fn[],warninp_t wi) +static void check_box(matrix f_box, matrix box, char fn[], warninp_t wi) { int i,ii; gmx_bool bSame=TRUE; @@ -192,7 +194,8 @@ static void check_box(matrix f_box, matrix box, char fn[],warninp_t wi) bSame = FALSE; if (!bSame) { - sprintf(warn_buf, "Enforced rotation: Box size in reference file %s differs from actual box size!", fn); + sprintf(warn_buf, "%s Box size in reference file %s differs from actual box size!", + RotStr, fn); warning(wi, warn_buf); pr_rvecs(stderr,0,"Your box is:",box ,3); pr_rvecs(stderr,0,"Box in file:",f_box,3); @@ -201,8 +204,9 @@ static void check_box(matrix f_box, matrix box, char fn[],warninp_t wi) /* Extract the reference positions for the rotation group(s) */ -extern void set_reference_positions(t_rot *rot, gmx_mtop_t *mtop, rvec *x, matrix box, - const char *fn,warninp_t wi) +extern void set_reference_positions( + t_rot *rot, gmx_mtop_t *mtop, rvec *x, matrix box, + const char *fn, gmx_bool bSet, warninp_t wi) { int g,i,ii; t_rotgrp *rotg; @@ -218,16 +222,28 @@ extern void set_reference_positions(t_rot *rot, gmx_mtop_t *mtop, rvec *x, matri strcpy(extension,extpos+1); *extpos = '\0'; + for (g=0; gngrp; g++) { rotg = &rot->grp[g]; - fprintf(stderr, "Enforced rotation: group %d has %d reference positions.",g,rotg->nat); + fprintf(stderr, "%s group %d has %d reference positions.\n",RotStr,g,rotg->nat); snew(rotg->x_ref, rotg->nat); + /* Construct the name for the file containing the reference positions for this group: */ sprintf(reffile, "%s.%d.%s", base,g,extension); + + /* If the base filename for the reference position files was explicitly set by + * the user, we issue a fatal error if the group file can not be found */ + if (bSet && !gmx_fexist(reffile)) + { + gmx_fatal(FARGS, "%s The file containing the reference positions was not found.\n" + "Expected the file '%s' for group %d.\n", + RotStr, reffile, g); + } + if (gmx_fexist(reffile)) { - fprintf(stderr, " Reading them from %s.\n", reffile); + fprintf(stderr, " Reading them from %s.\n", reffile); read_trnheader(reffile, &header); if (rotg->nat != header.natoms) gmx_fatal(FARGS,"Number of atoms in file %s (%d) does not match the number of atoms in rotation group (%d)!\n", diff --git a/src/mdlib/pull_rotation.c b/src/mdlib/pull_rotation.c index 00dda8707e..536c3db3af 100644 --- a/src/mdlib/pull_rotation.c +++ b/src/mdlib/pull_rotation.c @@ -1210,6 +1210,9 @@ static void flex_fit_angle( /* Save the weight for this atom in this slab */ sd->weight[ind] = gaussian_weight(curr_x, rotg, n); + /* For mass weighting: */ + /* sd->weight[ind] *= erg->mc_sorted[l]; */ + /* Next atom in this slab */ ind++; }