      Integer function respl(seqbcd, theres, lstpos, seqlen)            RESP001
c                                                                       RESP002
c     search through the residue identifiers to find the position       RESP003
c     of the relevant code. Codes will normally be in order so the      RESP004
c     search starts from the last position.                             RESP005
c                                                                       RESP006
      include 'sstruc.par'                                              RESP007
      character seqbcd(maxres)*6, theres*6                              RESP008
      integer   lstpos, seqlen                                          RESP009
                                                                        RESP010
      integer   nxres                                                   RESP011
                                                                        RESP012
      do 100, nxres = lstpos + 1, seqlen                                RESP013
      if (seqbcd(nxres) .eq. theres) go to 300                          RESP014
  100 continue                                                          RESP015
      do 200, nxres = 1, lstpos                                         RESP016
      if (seqbcd(nxres) .eq. theres) go to 300                          RESP017
  200 continue                                                          RESP018
      nxres = -1                                                        RESP019
  300 continue                                                          RESP020
      respl = nxres                                                     RESP021
      end                                                               RESP022
