********> bugfix.62 Author: Bill Ross Date: 1/20/96 Programs: Carnal Severity: Moderate Problem: The EXH2O option of COORD does not work (selecting N closest waters to solute or group of atoms). Use of group option causes core dump, output waters have completely wrong atoms. Cause: Clearly was never used. Fix: Make the following change to coord.c: ----------------------------------------------------------------------- *** OLD coord.c --- NEW coord.c *************** *** 325,331 **** inerr("COORD BOX: input set has no box",""); crdptr->idunion.crd.box = srcboxmax; } else if (!strcmp(tok, "EXH2O")) { ! /* * forbid mixed ATOM EXH2O INH2O */ --- 325,332 ---- inerr("COORD BOX: input set has no box",""); crdptr->idunion.crd.box = srcboxmax; } else if (!strcmp(tok, "EXH2O")) { ! int totwat; ! /* * forbid mixed ATOM EXH2O INH2O */ *************** *** 367,377 **** /* * allocate array for per-water min distances */ ! crdptr->idunion.crd.watarray = (watstruct *) ! get(((crdptr->idunion.crd.set->max - ! crdptr->idunion.crd.natoms) / 3) ! * sizeof(watstruct) ); /* * see if group id for restricted solute --- 368,377 ---- /* * allocate array for per-water min distances */ ! totwat = (crdptr->idunion.crd.set->max - ! crdptr->idunion.crd.natoms) / 3; crdptr->idunion.crd.watarray = (watstruct *) ! get( totwat * sizeof(watstruct) ); /* * see if group id for restricted solute *************** *** 715,721 **** } } } ! if (--i%10) fprintf(file, "\n"); if (idptr->idunion.crd.box) { #ifdef DBG --- 715,724 ---- } } } ! /* ! * if last line not full, end it ! */ ! if ( i % 10 ) fprintf(file, "\n"); if (idptr->idunion.crd.box) { #ifdef DBG *************** *** 834,840 **** min = d; } idptr->idunion.crd.watarray[k].dist = min; ! idptr->idunion.crd.watarray[k].atnumx = i; } } else { int ngrp = idptr->idunion.crd.watgrp->idunion.group.natoms; --- 837,843 ---- min = d; } idptr->idunion.crd.watarray[k].dist = min; ! idptr->idunion.crd.watarray[k].atnumx = i * 3; } } else { int ngrp = idptr->idunion.crd.watgrp->idunion.group.natoms; *************** *** 849,861 **** xyzwat = &idptr->idunion.crd.set->crd[i*3]; min = 9.9e9; for (j=0; jidunion.crd.set->crd[grp[j]], box); if (d < min) min = d; } idptr->idunion.crd.watarray[k].dist = min; ! idptr->idunion.crd.watarray[k].atnumx = i; } } --- 852,864 ---- xyzwat = &idptr->idunion.crd.set->crd[i*3]; min = 9.9e9; for (j=0; jidunion.crd.set->crd[grp[j]], box); if (d < min) min = d; } idptr->idunion.crd.watarray[k].dist = min; ! idptr->idunion.crd.watarray[k].atnumx = i * 3; } } ----------------------------------------------------------------------- Make the following changes to geom.c: ----------------------------------------------------------------------- *** OLD geom.c --- NEW geom.c *************** *** 79,100 **** boxdistancesq( p1, p2, box) _REAL p1[3], p2[3], box[3]; { ! _REAL x, y, z; #ifdef DBG printf("boxdistsq / p1: %f %f %f p2: %f %f %f box: %f %f %f\n", p1[0], p1[1], p1[2], p2[0], p2[1], box[0], box[1], box[2]); #endif ! x = p1[0] - p2[0]; ! x = x - (fabs(x) + box[0] / 2.0) * ((x < 0) ? -1 : 1); x = x * x; ! y = (p1[1] - p2[1]); ! y = y - (fabs(y) + box[1] / 2.0) * ((y < 0) ? -1 : 1); y = y * y; ! z = ( p1[2] - p2[2]); ! z = z - (fabs(z) + box[2] / 2.0) * ((z < 0) ? -1 : 1); z = z * z; return (x + y + z); --- 80,104 ---- boxdistancesq( p1, p2, box) _REAL p1[3], p2[3], box[3]; { ! _REAL x, y, z, t; #ifdef DBG printf("boxdistsq / p1: %f %f %f p2: %f %f %f box: %f %f %f\n", p1[0], p1[1], p1[2], p2[0], p2[1], box[0], box[1], box[2]); #endif ! x = fabs(p1[0] - p2[0]); ! if (x > (t = box[0] - x)) ! x = t; x = x * x; ! y = fabs(p1[1] - p2[1]); ! if (y > (t = box[1] - y)) ! y = t; y = y * y; ! z = fabs(p1[2] - p2[2]); ! if (z > (t = box[2] - z)) ! z = t; z = z * z; return (x + y + z); *************** *** 109,133 **** boxdistance( p1, p2, box) _REAL p1[3], p2[3], box[3]; { ! double x, y, z; #ifdef DBG printf("boxdist / p1: %f %f %f p2: %f %f %f box: %f %f %f\n", p1[0], p1[1], p1[2], p2[0], p2[1], box[0], box[1], box[2]); #endif ! x = (double) (p1[0] - p2[0]); ! x = x - (fabs(x) + (double) box[0] / 2.0) * ((x < 0) ? -1 : 1); x = x * x; ! y = (double) (p1[1] - p2[1]); ! y = y - (fabs(y) + (double) box[1] / 2.0) * ((y < 0) ? -1 : 1); y = y * y; ! z = (double) ( p1[2] - p2[2]); ! z = z - (fabs(z) + (double) box[2] / 2.0) * ((z < 0) ? -1 : 1); z = z * z; ! return ((_REAL)sqrt (x + y + z)); } --- 113,138 ---- boxdistance( p1, p2, box) _REAL p1[3], p2[3], box[3]; { ! double x, y, z, t; #ifdef DBG printf("boxdist / p1: %f %f %f p2: %f %f %f box: %f %f %f\n", p1[0], p1[1], p1[2], p2[0], p2[1], box[0], box[1], box[2]); #endif ! x = fabs(p1[0] - p2[0]); ! if (x > (t = box[0] - x)) ! x = t; x = x * x; ! y = fabs(p1[1] - p2[1]); ! if (y > (t = box[1] - y)) ! y = t; y = y * y; ! z = fabs(p1[2] - p2[2]); ! if (z > (t = box[2] - z)) ! z = t; z = z * z; ! return ( (_REAL)sqrt(x + y + z)); } ----------------------------------------------------------------------- Temporary workarounds: None --