[gmx-developers] maybe a bug in g_dipoles

Li Daobing nichloas at sohu.com
Fri Dec 12 02:48:35 CET 2003


Hello,

`make_ndx' produce a index file, the numbers in the file is `atom
index'.

when i use 'g_dipoles' with `-n' optiions, it treat the index number
in the index file as residue index, so we got an mistake result or
cause the program `Segmention fault' error.

detail:
in function do_dip:

      for(i=0; (i<gnx); i++) {
	int gi = grpindex ? grpindex[i] : i;
	mol_dip(mols->index[gi],mols->index[gi+1],mols->a,x,atom,dipole[i]);

the `gi' is already atom index(from ndx file), you use
`mols->index[gi]' may cause overflow or get an undefined number cause
mol_dip function raise overflow error in `kk = ma[k]' or `atom[kk]` line

in function mol_dip:
void mol_dip(int k0,int k1,atom_id ma[],rvec x[],t_atom atom[],rvec mu)
{
  int  k,kk,m;
  real q;
  
  clear_rvec(mu);
  for(k=k0; (k<k1); k++) {
    kk = ma[k];
    q  = e2d(atom[kk].q);
    for(m=0; (m<DIM); m++) 
      mu[m] += q*x[kk][m];
  }
}





-- 
Li Daobing




More information about the gromacs.org_gmx-developers mailing list