      Integer function AAconv(aacode, aacod3, hetcod)                   AACO001
c                                                                       AACO002
c     find the numerical position of an amino acid code                 AACO003
c                                                                       AACO004
      include 'sstruc.par'                                              AACO005
CHECK v.3.2-->                                                          AACO006
      save lastcd                                                       AACO007
CHECK v.3.2<--                                                          AACO008
      character aacode*3, aacod3*(3*abetsz), hetcod*63                  AACO009
CHECK v.3.0.1--> (Order of statements changed)                          AACO010
      integer   resfnd                                                  AACO011
      integer   aaval                                                   AACO012
CHECK v.3.0.1<--                                                        AACO013
CHECK v.2.1.4-->                                                        AACO014
      character lastcd*3                                                AACO015
      data lastcd / '   ' /                                             AACO016
                                                                        AACO017
CHECK v.3.2-->                                                          AACO018
C      save lastcd                                                      AACO019
CHECK v.3.2<--                                                          AACO020
CHECK v.2.1.4<--                                                        AACO021
                                                                        AACO022
      aaval = resfnd(aacod3,aacode)                                     AACO023
      if (aaval .eq. 0) then                                            AACO024
         aaval = resfnd(hetcod,aacode)                                  AACO025
         if (aaval .eq. 0) then                                         AACO026
            aaval = unkcod                                              AACO027
CHECK v.2.1.4-->                                                        AACO028
C            write(errfi,530) aacode, ' unknown amino acid code'        AACO029
            if (aacode.ne.lastcd) then                                  AACO030
                write(errfi,530) aacode, ' unknown amino acid code'     AACO031
                lastcd = aacode                                         AACO032
            endif                                                       AACO033
CHECK v.2.1.4<--                                                        AACO034
  530       format(a3,a)                                                AACO035
         else                                                           AACO036
            aaval = abetsz + aaval / 3 + 1                              AACO037
         end if                                                         AACO038
      else                                                              AACO039
         aaval = aaval / 3 + 1                                          AACO040
      end if                                                            AACO041
      AAconv = aaval                                                    AACO042
      END                                                               AACO043
