1      logical function argos_prep_imp(latm,matm,natm,lbnd,mbnd,nbnd,
2     + limp,mimp,nimp)
3c
4c $Id$
5c
6      implicit none
7#include "argos_prep_common.fh"
8c
9      integer matm,natm,mbnd,nbnd,mimp,nimp
10      integer latm(6,matm),lbnd(2,mbnd),limp(4,mimp)
11c
12      integer i,j,k,l,ltemp,na
13      integer ia(10),nia(10)
14c
15      nimp=0
16c
17c     loop over all atoms
18c
19      do 1 i=1,natm
20      if(latm(2,i).gt.0) then
21c
22c     count the number of bonds to this atom
23c
24      na=0
25      do 2 j=1,nbnd
26      if(lbnd(1,j).eq.i) then
27      na=na+1
28      ia(na)=lbnd(2,j)
29      endif
30      if(lbnd(2,j).eq.i) then
31      na=na+1
32      ia(na)=lbnd(1,j)
33      endif
34    2 continue
35c
36      nia(1)=0
37      nia(2)=0
38      nia(3)=0
39      do 54 k=1,nbnd
40      if(lbnd(1,k).eq.ia(1)) nia(1)=nia(1)+1
41      if(lbnd(2,k).eq.ia(1)) nia(1)=nia(1)+1
42      if(lbnd(1,k).eq.ia(2)) nia(2)=nia(2)+1
43      if(lbnd(2,k).eq.ia(2)) nia(2)=nia(2)+1
44      if(lbnd(1,k).eq.ia(3)) nia(3)=nia(3)+1
45      if(lbnd(2,k).eq.ia(3)) nia(3)=nia(3)+1
46   54 continue
47      do 55 k=1,2
48      do 56 l=2,3
49      if(nia(k).lt.nia(l)) then
50      ltemp=nia(k)
51      nia(k)=nia(l)
52      nia(l)=ltemp
53      ltemp=ia(k)
54      ia(k)=ia(l)
55      ia(l)=ltemp
56      endif
57   56 continue
58   55 continue
59c
60c     planar
61c
62      if(latm(2,i).eq.1.and.na.eq.3) then
63      nimp=nimp+1
64      limp(1,nimp)=i
65      limp(2,nimp)=ia(1)
66      limp(3,nimp)=ia(2)
67      limp(4,nimp)=ia(3)
68      endif
69c
70c     chiral
71c
72      if((latm(2,i).eq.2.or.latm(2,i).eq.3).and.na.eq.3) then
73      nimp=nimp+1
74      limp(1,nimp)=i
75      limp(2,nimp)=ia(1)
76      limp(3,nimp)=ia(2)
77      limp(4,nimp)=ia(3)
78      endif
79c
80c     aromatic ring
81c
82      if(latm(2,i).ge.4.and.na.eq.3.and.
83     + ((ffield(1:5).eq.'amber'.and.latm(2,i).le.6).or.
84     + (ffield(1:5).eq.'charm'))) then
85      nimp=nimp+1
86      limp(1,nimp)=i
87      limp(2,nimp)=ia(1)
88      limp(3,nimp)=ia(2)
89      limp(4,nimp)=ia(3)
90      endif
91c
92      endif
93    1 continue
94c
95      argos_prep_imp=.true.
96c
97      return
98      end
99