*/
static int prepare_x_q(real *q[], rvec *x[], gmx_mtop_t *mtop, rvec x_orig[], t_commrec *cr)
{
- int i,anr_global;
+ int i;
int nq; /* number of charged particles */
+ gmx_mtop_atomloop_all_t aloop;
t_atom *atom;
snew(*q, mtop->natoms);
snew(*x, mtop->natoms);
nq=0;
- for (i=0; i<mtop->natoms; i++)
+
+ aloop = gmx_mtop_atomloop_all_init(mtop);
+
+ while (gmx_mtop_atomloop_all_next(aloop,&i,&atom))
{
- anr_global = i;
- gmx_mtop_atomnr_to_atom(mtop,anr_global,&atom);
if (is_charge(atom->q))
{
(*q)[nq] = atom->q;