From ab62d0bd91421e8d25d3c24fdfd8a64c0d4af2eb Mon Sep 17 00:00:00 2001 From: David van der Spoel Date: Fri, 22 Jan 2010 10:50:35 +0100 Subject: [PATCH] Fixed atomprop such that it (again) only reads the file that you really need. --- src/gmxlib/atomprop.c | 52 ++++++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/src/gmxlib/atomprop.c b/src/gmxlib/atomprop.c index 7690478339..4c3c227bc1 100644 --- a/src/gmxlib/atomprop.c +++ b/src/gmxlib/atomprop.c @@ -62,6 +62,7 @@ typedef struct { } aprop_t; typedef struct gmx_atomprop { + bool bWarned; aprop_t prop[epropNR]; t_aa_names *aan; } gmx_atomprop; @@ -219,13 +220,22 @@ static void set_prop(gmx_atomprop_t aps,int eprop) double def[epropNR] = { 12.011, 0.14, 0.0, 2.2, -1 }; aprop_t *ap; + if ((!aps->bWarned) && (eprop == epropMass) || (eprop == epropVDW)) { + printf("WARNING: masses and atomic (Van der Waals) radii will be determined\n"); + printf(" based on residue and atom names. These numbers can deviate\n"); + printf(" from the correct mass and radius of the atom type.\n"); + aps->bWarned = TRUE; + } + ap = &ap2->prop[eprop]; - ap->db = strdup(fns[eprop]); - ap->def = def[eprop]; - read_prop(aps,eprop,fac[eprop]); - - if (debug) - fprintf(debug,"Entries in %s: %d\n",ap->db,ap->nprop); + if (!ap->bSet) { + ap->db = strdup(fns[eprop]); + ap->def = def[eprop]; + read_prop(aps,eprop,fac[eprop]); + + if (debug) + fprintf(debug,"Entries in %s: %d\n",ap->db,ap->nprop); + } } gmx_atomprop_t gmx_atomprop_init(void) @@ -236,14 +246,7 @@ gmx_atomprop_t gmx_atomprop_init(void) snew(aps,1); aps->aan = get_aa_names(); - - printf("WARNING: masses and atomic (Van der Waals) radii will be determined\n"); - printf(" based on residue and atom names. These numbers can deviate\n"); - printf(" from the correct mass and radius of the atom type.\n"); - - - for(p=0; pbWarned = FALSE; return (gmx_atomprop_t)aps; } @@ -252,16 +255,18 @@ static void destroy_prop(aprop_t *ap) { int i; - sfree(ap->db); - - for(i=0; inprop; i++) { - sfree(ap->atomnm[i]); - sfree(ap->resnm[i]); + if (ap->bSet) { + sfree(ap->db); + + for(i=0; inprop; i++) { + sfree(ap->atomnm[i]); + sfree(ap->resnm[i]); + } + sfree(ap->atomnm); + sfree(ap->resnm); + sfree(ap->bAvail); + sfree(ap->value); } - sfree(ap->atomnm); - sfree(ap->resnm); - sfree(ap->bAvail); - sfree(ap->value); } void gmx_atomprop_destroy(gmx_atomprop_t aps) @@ -294,6 +299,7 @@ bool gmx_atomprop_query(gmx_atomprop_t aps, char atomname[MAXQ],resname[MAXQ]; bool bExact; + set_prop(aps,eprop); if ((strlen(atomnm) > MAXQ-1) || (strlen(resnm) > MAXQ-1)) { if (debug) fprintf(debug,"WARNING: will only compare first %d characters\n", -- 2.11.4.GIT