From 3ce1746838d7d91a42f0b6f7428497f91ff3f2ab Mon Sep 17 00:00:00 2001 From: Berk Hess Date: Wed, 18 Aug 2010 11:44:00 +0200 Subject: [PATCH] added some comment to group grompp assignment options --- src/kernel/readir.c | 222 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 133 insertions(+), 89 deletions(-) diff --git a/src/kernel/readir.c b/src/kernel/readir.c index face473765..85703f58a7 100644 --- a/src/kernel/readir.c +++ b/src/kernel/readir.c @@ -87,7 +87,15 @@ static char QMmethod[STRLEN],QMbasis[STRLEN],QMcharge[STRLEN],QMmult[STRLEN], static char efield_x[STRLEN],efield_xt[STRLEN],efield_y[STRLEN], efield_yt[STRLEN],efield_z[STRLEN],efield_zt[STRLEN]; -enum { egrptpALL, egrptpALL_GENREST, egrptpPART, egrptpONE }; +enum { + egrptpALL, /* All particles have to be a member of a group. */ + egrptpALL_GENREST, /* A rest group with name is generated for particles * + * that are not part of any group. */ + egrptpPART, /* As egrptpALL_GENREST, but no name is generated * + * for the rest group. */ + egrptpONE /* Merge all selected groups into one group, * + * make a rest group for the remaining particles. */ +}; void init_ir(t_inputrec *ir, t_gromppopts *opts) @@ -1288,104 +1296,140 @@ static bool do_numbering(int natoms,gmx_groups_t *groups,int ng,char *ptrs[], int grptp,bool bVerbose, warninp_t wi) { - unsigned short *cbuf; - t_grps *grps=&(groups->grps[gtype]); - int i,j,gid,aj,ognr,ntot=0; - const char *title; - bool bRest; - char warn_buf[STRLEN]; - - if (debug) - fprintf(debug,"Starting numbering %d groups of type %d\n",ng,gtype); + unsigned short *cbuf; + t_grps *grps=&(groups->grps[gtype]); + int i,j,gid,aj,ognr,ntot=0; + const char *title; + bool bRest; + char warn_buf[STRLEN]; + + if (debug) + { + fprintf(debug,"Starting numbering %d groups of type %d\n",ng,gtype); + } - title = gtypes[gtype]; + title = gtypes[gtype]; - snew(cbuf,natoms); - for(i=0; (inm_ind,ng+1); /* +1 for possible rest group */ - for(i=0; (inr,gnames); - if ((grptp != egrptpONE) || (i == 0)) - grps->nm_ind[grps->nr++]=gid; - if (debug) - fprintf(debug,"Found gid %d for group %s\n",gid,ptrs[i]); + snew(grps->nm_ind,ng+1); /* +1 for possible rest group */ + for(i=0; (inr,gnames); + if ((grptp != egrptpONE) || (i == 0)) + { + grps->nm_ind[grps->nr++]=gid; + } + if (debug) + { + fprintf(debug,"Found gid %d for group %s\n",gid,ptrs[i]); + } - /* Now go over the atoms in the group */ - for(j=block->index[gid]; (jindex[gid+1]); j++) { - aj=block->a[j]; + /* Now go over the atoms in the group */ + for(j=block->index[gid]; (jindex[gid+1]); j++) + { + + aj=block->a[j]; - /* Range checking */ - if ((aj < 0) || (aj >= natoms)) - gmx_fatal(FARGS,"Invalid atom number %d in indexfile",aj); - - /* Lookup up the old group number */ - ognr = cbuf[aj]; - if (ognr != NOGID) - gmx_fatal(FARGS,"Atom %d in multiple %s groups (%d and %d)", - aj+1,title,ognr+1,i+1); - else { - /* Store the group number in buffer */ - if (grptp == egrptpONE) - cbuf[aj] = 0; - else - cbuf[aj] = i; - ntot++; - } - } - } - - /* Now check whether we have done all atoms */ - bRest = FALSE; - if (ntot != natoms) { - if (grptp == egrptpALL) { - gmx_fatal(FARGS,"%d atoms are not part of any of the %s groups", - natoms-ntot,title); - } else if (grptp == egrptpPART) { - sprintf(warn_buf,"%d atoms are not part of any of the %s groups", - natoms-ntot,title); - warning_note(wi,warn_buf); + /* Range checking */ + if ((aj < 0) || (aj >= natoms)) + { + gmx_fatal(FARGS,"Invalid atom number %d in indexfile",aj); + } + /* Lookup up the old group number */ + ognr = cbuf[aj]; + if (ognr != NOGID) + { + gmx_fatal(FARGS,"Atom %d in multiple %s groups (%d and %d)", + aj+1,title,ognr+1,i+1); + } + else + { + /* Store the group number in buffer */ + if (grptp == egrptpONE) + { + cbuf[aj] = 0; + } + else + { + cbuf[aj] = i; + } + ntot++; + } + } } - /* Assign all atoms currently unassigned to a rest group */ - for(j=0; (jnr; - bRest = TRUE; - } + + /* Now check whether we have done all atoms */ + bRest = FALSE; + if (ntot != natoms) + { + if (grptp == egrptpALL) + { + gmx_fatal(FARGS,"%d atoms are not part of any of the %s groups", + natoms-ntot,title); + } + else if (grptp == egrptpPART) + { + sprintf(warn_buf,"%d atoms are not part of any of the %s groups", + natoms-ntot,title); + warning_note(wi,warn_buf); + } + /* Assign all atoms currently unassigned to a rest group */ + for(j=0; (jnr; + bRest = TRUE; + } + } + if (grptp != egrptpPART) + { + if (bVerbose) + { + fprintf(stderr, + "Making dummy/rest group for %s containing %d elements\n", + title,natoms-ntot); + } + /* Add group name "rest" */ + grps->nm_ind[grps->nr] = restnm; + + /* Assign the rest name to all atoms not currently assigned to a group */ + for(j=0; (jnr; + } + } + grps->nr++; + } } - if (grptp != egrptpPART) { - if (bVerbose) - fprintf(stderr, - "Making dummy/rest group for %s containing %d elements\n", - title,natoms-ntot); - /* Add group name "rest" */ - grps->nm_ind[grps->nr] = restnm; - - /* Assign the rest name to all atoms not currently assigned to a group */ - for(j=0; (jnr; - } - grps->nr++; + + if (grps->nr == 1) + { + groups->ngrpnr[gtype] = 0; + groups->grpnr[gtype] = NULL; } - } - - if (grps->nr == 1) { - groups->ngrpnr[gtype] = 0; - groups->grpnr[gtype] = NULL; - } else { - groups->ngrpnr[gtype] = natoms; - snew(groups->grpnr[gtype],natoms); - for(j=0; (jgrpnr[gtype][j] = cbuf[j]; + else + { + groups->ngrpnr[gtype] = natoms; + snew(groups->grpnr[gtype],natoms); + for(j=0; (jgrpnr[gtype][j] = cbuf[j]; + } } - } - - sfree(cbuf); + + sfree(cbuf); - return (bRest && grptp == egrptpPART); + return (bRest && grptp == egrptpPART); } static void calc_nrdf(gmx_mtop_t *mtop,t_inputrec *ir,char **gnames) -- 2.11.4.GIT