      SUBROUTINE INITS                                                  INIT001
                                                                        INIT002
      INCLUDE 'anglen.inc'                                              INIT003
                                                                        INIT004
      CHARACTER*1   A, AL                                               INIT005
      CHARACTER*13  BONLEN(NMAIN)                                       INIT006
CHECK v.2.2-->                                                          INIT007
C      INTEGER       ADJUST, I, IBAT, ILET, IMAIN, LEN, LEN1, LEN2, LEN3INIT008
      INTEGER       ADJUST, I, IATOM, IBAT, ILET, IMAIN, IPLANE, LEN,   INIT009
     &              LEN1, LEN2, LEN3                                    INIT010
CHECK v.2.2<--                                                          INIT011
                                                                        INIT012
C---- Initialise variables                                              INIT013
      A = 'A'                                                           INIT014
      ADJUST = ICHAR(A) - 1                                             INIT015
      IFAIL = .FALSE.                                                   INIT016
      NRESID = 0                                                        INIT017
      NXTPOS = 0                                                        INIT018
      PI = 4.0 *  ATAN(1.0)                                             INIT019
      RADDEG = 180.0 / PI                                               INIT020
                                                                        INIT021
C---- Set up pointers system for residue names                          INIT022
      DO 100, I = 1, MXTYPE                                             INIT023
          NXTLET(I) = 0                                                 INIT024
100   CONTINUE                                                          INIT025
      DO 200, I = 1, 26                                                 INIT026
          FSTLET(I) = 0                                                 INIT027
          LSTLET(I) = 0                                                 INIT028
200   CONTINUE                                                          INIT029
      DO 300, I = 1, MXTYPE                                             INIT030
          IF (RTYPE(I).EQ.'   ') GO TO 500                              INIT031
          ILET = ICHAR(RTYPE(I)(1:1)) - ADJUST                          INIT032
          IF (ILET.GT.26) ILET = 26                                     INIT033
          NXTPOS = NXTPOS + 1                                           INIT034
          IF (LSTLET(ILET).EQ.0) THEN                                   INIT035
              FSTLET(ILET) = NXTPOS                                     INIT036
              LSTLET(ILET) = NXTPOS                                     INIT037
          ELSE                                                          INIT038
              NXTLET(LSTLET(ILET)) = NXTPOS                             INIT039
              LSTLET(ILET) = NXTPOS                                     INIT040
          ENDIF                                                         INIT041
300   CONTINUE                                                          INIT042
                                                                        INIT043
C---- Initialise parameters defining each of the bond lengths and bond  INIT044
C     angles                                                            INIT045
 500  CONTINUE                                                          INIT046
                                                                        INIT047
C---- Loop through all the bond lengths and bond angles                 INIT048
      DO 1000, IMAIN = 1, NMAIN                                         INIT049
                                                                        INIT050
C----     Initialise valriables giving the relative residues from       INIT051
C         which the atoms defining each bond length/angle come (all     INIT052
C         zero means they come from the same residue).                  INIT053
          INAME(IMAIN) = 0                                              INIT054
          RELPOS(1,IMAIN) = 0                                           INIT055
          RELPOS(2,IMAIN) = 0                                           INIT056
          RELPOS(3,IMAIN) = 0                                           INIT057
                                                                        INIT058
C----     Set up array of integer values corresponding to the atom typesINIT059
C         in BONDAT                                                     INIT060
                                                                        INIT061
C----     Loop through the triplet of atoms defining this bond          INIT062
c         length/angle                                                  INIT063
          DO 700, I = 1, 3                                              INIT064
              BATNUM(I,IMAIN) = 0                                       INIT065
                                                                        INIT066
C----         Loop through all the main-chain atoms (as defined by the  INIT067
C             MATOM array).                                             INIT068
              DO 600, IBAT = 1, NMATOM                                  INIT069
                                                                        INIT070
C----             If this main-chain atom matches that in the BONDAT    INIT071
C                 array, store its position-number in the BATNUM aray   INIT072
                  IF (MATOM(IBAT).EQ.BONDAT(I,IMAIN)) THEN              INIT073
                      BATNUM(I,IMAIN) = IBAT                            INIT074
                  ENDIF                                                 INIT075
 600          CONTINUE                                                  INIT076
 700      CONTINUE                                                      INIT077
                                                                        INIT078
C----     Check whether dealing with a bond length or a bond angle (ie iINIT079
C         the third atom-name in the current triplet is not blank, it isINIT080
C         a bond angle)                                                 INIT081
          IF (BONDAT(3,IMAIN).NE.' ') THEN                              INIT082
              BANGLE(IMAIN) = .TRUE.                                    INIT083
              NBAT(IMAIN) = 3                                           INIT084
                                                                        INIT085
C----         Determine whether all atoms are in the same residue, or   INIT086
C             whether they span adjacent residues                       INIT087
                                                                        INIT088
C----         If the 3rd atom is N, then first 2 atoms must come from   INIT089
C             previous residue, and that is the residue associated with INIT090
C             this angle                                                INIT091
              IF (BONDAT(3,IMAIN).EQ.'N  ') THEN                        INIT092
                  RELPOS(1,IMAIN) = -1                                  INIT093
                  RELPOS(2,IMAIN) = -1                                  INIT094
                  INAME(IMAIN) = -1                                     INIT095
                                                                        INIT096
C----         If 3rd atom is CA, then 1st atom must come from previous  INIT097
C             residue                                                   INIT098
              ELSE IF (BONDAT(3,IMAIN).EQ.'CA ') THEN                   INIT099
                  RELPOS(1,IMAIN) = -1                                  INIT100
                                                                        INIT101
C----         Otherwise, all 3 atoms come from the same residue         INIT102
              ELSE                                                      INIT103
                  RELPOS(1,IMAIN) = 0                                   INIT104
                  RELPOS(2,IMAIN) = 0                                   INIT105
              ENDIF                                                     INIT106
                                                                        INIT107
C----     If dealing with a bond length                                 INIT108
          ELSE                                                          INIT109
              BANGLE(IMAIN) = .FALSE.                                   INIT110
              NBAT(IMAIN) = 2                                           INIT111
                                                                        INIT112
C----         Determine whether the two atoms are in the same residue,  INIT113
C             or whether they span adjacent residues                    INIT114
                                                                        INIT115
C----         If the 2nd atom is N, then first atom must come from the  INIT116
C             previous residue                                          INIT117
              IF (BONDAT(2,IMAIN).EQ.'N  ') THEN                        INIT118
                  RELPOS(1,IMAIN) = -1                                  INIT119
              ENDIF                                                     INIT120
          ENDIF                                                         INIT121
                                                                        INIT122
C----     Form description of this bond length/angle from its component INIT123
C         atom names                                                    INIT124
          LEN1 = INDEX(BONDAT(1,IMAIN),' ') - 1                         INIT125
          LEN2 = INDEX(BONDAT(2,IMAIN),' ') - 1                         INIT126
          LEN3 = INDEX(BONDAT(3,IMAIN),' ') - 1                         INIT127
          IF (LEN1.LT.1) LEN1 = 3                                       INIT128
          IF (LEN2.LT.1) LEN2 = 3                                       INIT129
          IF (LEN3.LT.1) LEN3 = 3                                       INIT130
          BONLEN(IMAIN) = BONDAT(1,IMAIN)                               INIT131
          BONLEN(IMAIN)(LEN1 + 1:LEN1 + 1) = '-'                        INIT132
          BONLEN(IMAIN)(LEN1 + 2:) = BONDAT(2,IMAIN)                    INIT133
          LEN = LEN1 + LEN2 + 1                                         INIT134
          IF (BANGLE(IMAIN)) THEN                                       INIT135
              BONLEN(IMAIN)(LEN + 1: LEN + 1) = '-'                     INIT136
              BONLEN(IMAIN)(LEN +2:) = BONDAT(3,IMAIN)                  INIT137
              LEN = LEN + LEN3 + 1                                      INIT138
          ENDIF                                                         INIT139
                                                                        INIT140
 1000 CONTINUE                                                          INIT141
                                                                        INIT142
C---- Write out the Engh & Huber means and standard deviations for each INIT143
C     of the main-chain bond lengths and angles                         INIT144
      DO 1200, IMAIN = 1, NMAIN                                         INIT145
          IF (BANGLE(IMAIN)) THEN                                       INIT146
              AL = 'A'                                                  INIT147
          ELSE                                                          INIT148
              AL = 'L'                                                  INIT149
          ENDIF                                                         INIT150
          WRITE(2,1100) AL, BONLEN(IMAIN), ENGNAM(IMAIN),               INIT151
     &        EXDESC(EXCEPT(IMAIN)), ENGMEA(IMAIN), ENGSTD(IMAIN)       INIT152
 1100     FORMAT(A1,1X,A10,A17,4X,A16,2F8.3)                            INIT153
 1200 CONTINUE                                                          INIT154
                                                                        INIT155
CHECK v.2.2-->                                                          INIT156
C---- Count the number of planar atoms in each sidechain                INIT157
      DO 1280, IPLANE = 1, NPLANE                                       INIT158
          DO 1260, IATOM = 1, NPLATM                                    INIT159
              IF (ANAME(IATOM + 1,IPLANE).NE.'   ')                     INIT160
     &            NPATOM(IPLANE) = IATOM                                INIT161
 1260     CONTINUE                                                      INIT162
 1280 CONTINUE                                                          INIT163
                                                                        INIT164
C---- Write out the descriptions of the planar groups                   INIT165
      DO 1300, IPLANE = 1, NPLANE                                       INIT166
          WRITE(2,1290) 'P', NPATOM(IPLANE), 'Planar group     ',       INIT167
     &        ANAME(1,IPLANE)                                           INIT168
 1290     FORMAT(A1,1X,I4,6X,A17,4X,A3)                                 INIT169
 1300 CONTINUE                                                          INIT170
CHECK v.2.2<--                                                          INIT171
                                                                        INIT172
      RETURN                                                            INIT173
      END                                                               INIT174
