changed reading hint
[gromacs/adressmacs.git] / src / kernel / pgutil.c
blob72131533da275440c124352658ae18c9d9cbd9ff
1 /*
2 * $Id$
3 *
4 * This source code is part of
5 *
6 * G R O M A C S
7 *
8 * GROningen MAchine for Chemical Simulations
9 *
10 * VERSION 2.0
12 * Copyright (c) 1991-1999
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
16 * Please refer to:
17 * GROMACS: A message-passing parallel molecular dynamics implementation
18 * H.J.C. Berendsen, D. van der Spoel and R. van Drunen
19 * Comp. Phys. Comm. 91, 43-56 (1995)
21 * Also check out our WWW page:
22 * http://md.chem.rug.nl/~gmx
23 * or e-mail to:
24 * gromacs@chem.rug.nl
26 * And Hey:
27 * GRowing Old MAkes el Chrono Sweat
29 static char *SRCID_pgutil_c = "$Id$";
31 #include "pgutil.h"
32 #include "string.h"
34 atom_id search_atom(char *type,int start,int natoms,t_atom at[],char **anm[])
36 int i,resnr=-1;
37 bool bPrevious;
39 bPrevious = (strchr(type,'-') != NULL);
41 if (!bPrevious) {
42 resnr = at[start].resnr;
43 if (strchr(type,'+') != NULL) {
44 /* The next residue */
45 type++;
46 while ((start<natoms) && (at[start].resnr == resnr))
47 start++;
48 if (start < natoms)
49 resnr = at[start].resnr;
51 for(i=start; (i<natoms) && (at[i].resnr == resnr); i++)
52 if (strcasecmp(type,*(anm[i]))==0)
53 return (atom_id) i;
55 else {
56 /* The previous residue */
57 type++;
58 if (start > 0)
59 resnr = at[start-1].resnr;
60 for(i=start-1; (i>=0) && (at[i].resnr == resnr); i--)
61 if (strcasecmp(type,*(anm[i]))==0)
62 return (atom_id) i;
64 return NO_ATID;
67 void set_at(t_atom *at,real m,real q,int type,int resnr)
69 at->m=m;
70 at->q=q;
71 at->type=type;
72 at->resnr=resnr;