c***********************************************************************SECS879
      SUBROUTINE RDBRK( mcaaat, atname, atomin, aacod3, hetcod, seqcod, RDBR001
     &                  seqbcd, scaaat, scatin, altcod, aastd, atpres,  RDBR002
     &                  thmprs, caonly, astruc, headln, hedlen, readok, RDBR003
     &                  dudcod, modcod, stdmod, nstdmd, modpl, seqlen,  RDBR004
                                                                        RDBR005
CHECK v.1.0-->                                                          RDBR006
C     +                  batnam)                                        RDBR007
CHECK v.2.0-->                                                          RDBR008
C     +                  batnam, BVALUE)                                RDBR009
CHECK v.3.1-->                                                          RDBR010
C     +                  batnam, BVALUE,MCBVAL,SCBVAL,NMCATM,NSCATM)    RDBR011
CHECK v.3.2-->                                                          RDBR012
C     +                  batnam, BVALUE,MCBVAL,SCBVAL,NMCATM,NSCATM,NMR)RDBR013
     &                  batnam, BVALUE,MCBVAL,SCBVAL,NMCATM,NSCATM,NMR, RDBR014
     &                  MCBSTD,SCBSTD)                                  RDBR015
CHECK v.3.2<--                                                          RDBR016
CHECK v.3.1<--                                                          RDBR017
CHECK v.2.0<--                                                          RDBR018
CHECK v.1.0<--                                                          RDBR019
                                                                        RDBR020
      INCLUDE 'sstruc.par'                                              RDBR021
                                                                        RDBR022
      Integer seqlen, seqcod(maxres), hedlen                            RDBR023
      Character aacod3*(abetsz*3), atname*(mnchna*4-4),seqbcd(maxres)*6,RDBR024
     &          headln*132, altcod(maxres)*1, aastd(maxres)*1,          RDBR025
     &          atpres(3,maxres)*1, thmprs(maxres)*1, hetcod*63,        RDBR026
     &          modcod*(nmod*3), stdmod*(nmod+1), nstdmd*(nmod+1),      RDBR027
     &          modpl*(nmod), dudcod*105,batnam*(mnchna*4+4)            RDBR028
      Real mcaaat(ncoord,mnchna,maxres), scaaat(ncoord,sdchna,maxres)   RDBR029
      Logical Atomin(mnchna,maxres), scatin(sdchna,maxres), Caonly,     RDBR030
     &        astruc, readok                                            RDBR031
      Integer aaconv                                                    RDBR032
                                                                        RDBR033
CHECK v.1.0-->                                                          RDBR034
      REAL      BVALUE(MAXRES)                                          RDBR035
CHECK v.1.0<--                                                          RDBR036
                                                                        RDBR037
CHECK v.2.0-->                                                          RDBR038
      INTEGER   NMCATM(MAXRES), NSCATM(MAXRES)                          RDBR039
      REAL      MCBVAL(MAXRES), SCBVAL(MAXRES)                          RDBR040
CHECK v.2.0<--                                                          RDBR041
                                                                        RDBR042
CHECK v.3.1-->                                                          RDBR043
      LOGICAL   NMR                                                     RDBR044
CHECK v.3.1<--                                                          RDBR045
                                                                        RDBR046
CHECK v.3.2-->                                                          RDBR047
      REAL      MCBSTD(MAXRES), SCBSTD(MAXRES)                          RDBR048
CHECK v.3.2<--                                                          RDBR049
                                                                        RDBR050
c                                                                       RDBR051
c     local variables                                                   RDBR052
c                                                                       RDBR053
CHECK v.3.2-->                                                          RDBR054
      save scname, altnam, altpos, nscats, cbet                         RDBR055
CHECK v.3.2<--                                                          RDBR056
                                                                        RDBR057
      integer   aapln                                                   RDBR058
      character allspc*16                                               RDBR059
      parameter (aapln = 13, allspc = '                ')               RDBR060
      real      acoord(ncoord), oldocc, occup, therm, oldthm            RDBR061
      logical   altset, xney                                            RDBR062
      integer   atcnt,attype, I, aacnt, wkpl,                           RDBR063
     &          clslen, cmplen, soulen, sctype, altpos(sideaa), respl,  RDBR064
     &          scatct, thmcnt, aacode, nscats(sideaa), hedend, sqrsct  RDBR065
      character aain(maxres)*3, atmnam*4, resnam*3, altloc*1,           RDBR066
     &          brkrec*80, oldchn*1, seqnum*6,                          RDBR067
     &          innum*6, keywd*(keylen), oldatm*4, setloc*1,            RDBR068
     &          class*40, compnd*50, source*50, brcode*4, cbet*4,       RDBR069
     &          scname(sideaa)*16, altnam(3)*16, contch*1, incode*4,    RDBR070
     &          wkstr*50, inseqr*150, setatm*4                          RDBR071
      integer   strlen, resfnd                                          RDBR072
      data scname(1)  /allspc/, scname(2) /allspc/                      RDBR073
      data scname(3)  /' SG             '/                              RDBR074
      data scname(4)  /' CG  OD1 OD2    '/                              RDBR075
      data scname(5)  /' CG  CD  OE1 OE2'/                              RDBR076
      data scname(6)  /' CG  CD1 CD2    '/, scname(7) /allspc/          RDBR077
      data scname(8)  /' CG  ND1 CD2    '/                              RDBR078
      data scname(9)  /' CG1 CD1        '/, scname(10) /allspc/         RDBR079
      data scname(11) /' CG  CD  CE  NZ '/                              RDBR080
      data scname(12) /' CG  CD1 CD2    '/                              RDBR081
      data scname(13) /' CG  SD  CE     '/                              RDBR082
      data scname(14) /' CG  OD1 ND2    '/, scname(15) /allspc/         RDBR083
      data scname(16) /' CG             '/                              RDBR084
      data scname(17) /' CG  CD  OE1 NE2'/                              RDBR085
      data scname(18) /' CG  CD  NE  CZ '/                              RDBR086
      data scname(19) /' OG             '/                              RDBR087
      data scname(20) /' OG1 CG2        '/, scname(21) /allspc/         RDBR088
      data scname(22) /' CG1 CG2        '/                              RDBR089
      data scname(23) /' CG  CD1 CD2    '/, scname(24) /allspc/         RDBR090
      data scname(25) /' CG  CD1 CD2    '/                              RDBR091
      data scname(26) /allspc/, scname(27) /allspc/                     RDBR092
      data scname(28) /' CG  CD  OE     '/                              RDBR093
      data scname(29) /' CG  CD  CE  NZ '/                              RDBR094
      data scname(30) /' CB1 CB2        '/                              RDBR095
      data scname(31) /' CG  CD1 CD2    '/                              RDBR096
      data scname(32) /'SEG  OD1 OD2    '/                              RDBR097
      data scname(33) /' CM             '/                              RDBR098
      data scname(34) /' SG             '/                              RDBR099
      data scname(35) /' CG  CD1 CD2    '/                              RDBR100
      data scname(36) /'                '/                              RDBR101
      data scname(37) /' CG  CD  CE  NZ '/                              RDBR102
      data scname(38) /' CM             '/                              RDBR103
      data scname(39) /' CG  CD1 CD2    '/                              RDBR104
      data scname(40) /'                '/                              RDBR105
      data scname(41) /' CG  CD1 CD2    '/                              RDBR106
      data scname(42) /' CG  CD1 CD2    '/                              RDBR107
      data scname(43) /' CG             '/                              RDBR108
      data scname(44) /' CG  CD  CE     '/                              RDBR109
      data scname(45) /' CG1 CG2        '/                              RDBR110
      data scname(46) /' CG1 CD1        '/                              RDBR111
      data scname(47) /' CG  CD1 CD2    '/                              RDBR112
      data scname(48) /' CG  CD  CE     '/                              RDBR113
      data scname(49) /allspc/, scname(50) /' CG  CD1 CD2    '/         RDBR114
      data altpos / 7*0, 1, 5*0, 2, 2*0, 3, 12*0, 13*0, 8*0/            RDBR115
      data altnam(1)  /' CG  AD1 AD2    '/                              RDBR116
      data altnam(2)  /' CG  AD1 AD2    '/                              RDBR117
      data altnam(3)  /' CG  CD  AE1 AE2'/                              RDBR118
      data nscats / 1, 4, 2, 4, 5, 7, 0, 6, 4, -1, 5, 4, 4, 4, -1,      RDBR119
     &              3, 5, 7, 2, 3, -1, 3, 10, -1, 8, 5, -1, 4, 12,      RDBR120
     &              2, 7, 4, 2, 2, 7, 8, 6, 1, 10, 3, 5, 9, 2,  4,      RDBR121
     &              3, 4, 7, 4, 1, 7/                                   RDBR122
      data cbet /' CB '/                                                RDBR123
CHECK v.3.2-->                                                          RDBR124
C      save scname, altnam, altpos, nscats, cbet                        RDBR125
CHECK v.3.2<--                                                          RDBR126
                                                                        RDBR127
c                                                                       RDBR128
c     Routine to read the brookhaven data file and extract the sequence RDBR129
c     and the atom names and coordinates. Checking is also done for     RDBR130
c     residue compatibility between sequence and atom. C-alpha only     RDBR131
c     files are flagged. The sequence residues are expected together,   RDBR132
c     then the secondary structure records (sheets together), and then  RDBR133
c     the atom records which are expected in residue order.             RDBR134
c                                                                       RDBR135
      seqlen = 0                                                        RDBR136
      hedlen = 0                                                        RDBR137
      inseqr = space                                                    RDBR138
      sqrsct = 0                                                        RDBR139
      brcode = '    '                                                   RDBR140
      astruc = .false.                                                  RDBR141
  100 continue                                                          RDBR142
      read(brkfi,'(A)',end=3000) brkrec                                 RDBR143
      keywd = brkrec(1:keylen)                                          RDBR144
      if (keywd .eq. seqkey) go to 200                                  RDBR145
      if (keywd .eq. hedkey) go to 500                                  RDBR146
      if (keywd .eq. cmpkey) go to 600                                  RDBR147
      if (keywd .eq. soukey) go to 700                                  RDBR148
      if (keywd .eq. atmkey) go to 900                                  RDBR149
      if (keywd .eq. htakey) go to 900                                  RDBR150
CHECK v.3.1-->                                                          RDBR151
      IF (KEYWD .EQ. ENDMDL) GO TO 3000                                 RDBR152
CHECK v.3.1<--                                                          RDBR153
      if (keywd .eq. modkey) then                                       RDBR154
         readok = .false.                                               RDBR155
         seqlen = 0                                                     RDBR156
CHECK v.3.1-->                                                          RDBR157
         PRINT*, '*** ERROR: MODEL record encountered unexpectedly ',   RDBR158
     &       'in PDB file'                                              RDBR159
CHECK v.3.1<--                                                          RDBR160
         go to 3000                                                     RDBR161
      end if                                                            RDBR162
      if (keywd .eq. hlxkey .or. keywd .eq. shtkey .or.                 RDBR163
     &    keywd .eq. trnkey .or. keywd .eq. dsfkey) then                RDBR164
         if (.not. astruc) then                                         RDBR165
            open(unit = authfi, status = 'SCRATCH')                     RDBR166
            astruc = .true.                                             RDBR167
         end if                                                         RDBR168
         write(authfi,'(a)') brkrec                                     RDBR169
      end if                                                            RDBR170
      go to 100                                                         RDBR171
                                                                        RDBR172
  200 continue                                                          RDBR173
      read (brkrec,220) (aain(i),i = 1, aapln)                          RDBR174
CHECK v.3.2-->                                                          RDBR175
C  220 format(18x,13(x,a3))                                             RDBR176
  220 format(18x,13(1x,a3))                                             RDBR177
CHECK v.3.2<--                                                          RDBR178
      do 250, i = 1, aapln                                              RDBR179
      if (aain(i) .ne. '   ') then                                      RDBR180
         if (resfnd(inseqr,aain(i)) .eq. 0) then                        RDBR181
            sqrsct = sqrsct + 1                                         RDBR182
            inseqr((sqrsct-1)*3+1:sqrsct*3) = aain(i)                   RDBR183
         end if                                                         RDBR184
      end if                                                            RDBR185
  250 continue                                                          RDBR186
      go to 100                                                         RDBR187
c                                                                       RDBR188
c     set up header records                                             RDBR189
c                                                                       RDBR190
  500 continue                                                          RDBR191
      read(brkrec,520) contch, wkstr, incode                            RDBR192
  520 format(9x,a1,a40,12x,a4)                                          RDBR193
      if (contch .eq. space) then                                       RDBR194
         brcode = incode                                                RDBR195
         class = wkstr                                                  RDBR196
         clslen = strlen(class)                                         RDBR197
      end if                                                            RDBR198
      go to 100                                                         RDBR199
  600 continue                                                          RDBR200
      read(brkrec,620) contch, wkstr                                    RDBR201
  620 format(9x,a1,a50)                                                 RDBR202
      if (contch .eq. space) then                                       RDBR203
         compnd = wkstr                                                 RDBR204
         cmplen = strlen(compnd)                                        RDBR205
      end if                                                            RDBR206
      go to 100                                                         RDBR207
  700 continue                                                          RDBR208
      read(brkrec,720) contch, wkstr                                    RDBR209
  720 format(9x,a1,a50)                                                 RDBR210
      if (contch .eq. space) then                                       RDBR211
         source = wkstr                                                 RDBR212
         soulen = strlen(source)                                        RDBR213
      end if                                                            RDBR214
      go to 100                                                         RDBR215
c                                                                       RDBR216
c     set up header if any exists                                       RDBR217
c                                                                       RDBR218
  900 continue                                                          RDBR219
      headln(1:6) = brcode // '  '                                      RDBR220
      hedlen = 6                                                        RDBR221
      if (clslen .gt. 0) then                                           RDBR222
         headln(7:8+clslen) = class(1:clslen) // '  '                   RDBR223
         hedlen = hedlen + clslen + 2                                   RDBR224
      end if                                                            RDBR225
      if (cmplen .gt. 0) then                                           RDBR226
         hedend = hedlen + cmplen + 2                                   RDBR227
         if (hedend .gt. 132) hedend = 132                              RDBR228
         headln(hedlen+1:hedend) = compnd(1:cmplen) // '  '             RDBR229
         hedlen = hedend                                                RDBR230
      end if                                                            RDBR231
      if (soulen .gt. 0) then                                           RDBR232
         hedend = hedlen + soulen+ 2                                    RDBR233
         if (hedend .gt. 132) hedend = 132                              RDBR234
         headln(hedlen+1:hedend)  = source(1:soulen)                    RDBR235
         hedlen = hedend                                                RDBR236
      end if                                                            RDBR237
      if (hedlen .gt. 132) hedlen = 132                                 RDBR238
c                                                                       RDBR239
c     look for next atom records to process                             RDBR240
c                                                                       RDBR241
 1000 continue                                                          RDBR242
      if (brkrec(1:keylen) .ne. atmkey .and.                            RDBR243
     &   brkrec(1:keylen) .ne. htakey) then                             RDBR244
         read(brkfi,'(A)',end=3000) brkrec                              RDBR245
CHECK v.3.1-->                                                          RDBR246
         IF (BRKREC(1:KEYLEN) .EQ. ENDMDL) GO TO 3000                   RDBR247
CHECK v.3.1<--                                                          RDBR248
         go to 1000                                                     RDBR249
      end if                                                            RDBR250
c                                                                       RDBR251
c     have first atom record for an aa                                  RDBR252
c     for each aa get the seqnum and resnam and check against the       RDBR253
c     read in sequence. If ok initialise to no atoms present and        RDBR254
c     get the coords                                                    RDBR255
c                                                                       RDBR256
      aacnt = 0                                                         RDBR257
      do 1234 i = 1, maxres                                             RDBR258
      aastd(i) = space                                                  RDBR259
 1234 continue                                                          RDBR260
      read(brkrec,1080)oldchn                                           RDBR261
 1080 format(21x,a1)                                                    RDBR262
                                                                        RDBR263
 1100 continue                                                          RDBR264
      keywd = brkrec(1:keylen)                                          RDBR265
      aacode = 0                                                        RDBR266
      altset = .false.                                                  RDBR267
      setatm = '    '                                                   RDBR268
      read(brkrec,1120) oldatm, setloc, resnam, seqnum, oldocc, oldthm  RDBR269
 1120 format(12x,a4,a1,a3,1x,a6,27x,2f6.2)                              RDBR270
      if (sqrsct .ne. 0 .and. resfnd(inseqr,resnam) .eq. 0) go to 1400  RDBR271
      if (resfnd(dudcod,resnam) .ne. 0) go to 1400                      RDBR272
      respl = resfnd(modcod,resnam)                                     RDBR273
      if (respl .ne. 0) then                                            RDBR274
         respl = (respl - 1) / 3 + 1                                    RDBR275
         if (Modpl(respl:respl) .eq. '+') then                          RDBR276
            aastd(aacnt+1) = stdmod(respl:respl)                        RDBR277
         else                                                           RDBR278
            if (aastd(aacnt) .eq. 'S') then                             RDBR279
               aastd(aacnt) = stdmod(respl:respl)                       RDBR280
            else                                                        RDBR281
               if (aastd(aacnt) .eq. 'O') then                          RDBR282
                  aastd(aacnt) = nstdmd(respl:respl)                    RDBR283
               else                                                     RDBR284
                  if (llt(aastd(aacnt),'a')) then                       RDBR285
                     aastd(aacnt) = stdmod(nmod+1:nmod+1)               RDBR286
                  else                                                  RDBR287
                     aastd(aacnt) = nstdmd(nmod+1:nmod+1)               RDBR288
                  end if                                                RDBR289
               end if                                                   RDBR290
            end if                                                      RDBR291
         end if                                                         RDBR292
         go to 1400                                                     RDBR293
      end if                                                            RDBR294
                                                                        RDBR295
      aacode = AAconv(resnam, aacod3, hetcod)                           RDBR296
                                                                        RDBR297
      if (aacode .le. 0) go to 1400                                     RDBR298
      aacnt = aacnt + 1                                                 RDBR299
      if (aastd(aacnt) .eq. space) then                                 RDBR300
         aastd(aacnt) = 'S'                                             RDBR301
         if (aacode .gt. stdaa) aastd(aacnt) = 'O'                      RDBR302
      else                                                              RDBR303
         if (aacode .gt. stdaa) then                                    RDBR304
            wkpl = index(stdmod,aastd(aacnt))                           RDBR305
            aastd(aacnt) = nstdmd(wkpl:wkpl)                            RDBR306
         end if                                                         RDBR307
      end if                                                            RDBR308
      seqcod(aacnt) = aacode                                            RDBR309
      seqbcd(aacnt) = seqnum                                            RDBR310
      atcnt = 0                                                         RDBR311
      scatct = 0                                                        RDBR312
      thmcnt = 0                                                        RDBR313
      thmprs(aacnt) = space                                             RDBR314
      do 1200 i = 1, mnchna                                             RDBR315
      atomin(i,aacnt) = .false.                                         RDBR316
 1200 continue                                                          RDBR317
      do 1220 i = 1, sdchna                                             RDBR318
      scatin(i,aacnt) = .false.                                         RDBR319
 1220 continue                                                          RDBR320
      do 1240 i = 1, 3                                                  RDBR321
      atpres(i,aacnt) = space                                           RDBR322
 1240 continue                                                          RDBR323
c                                                                       RDBR324
c     process coordinates find atom type and if main chain set in coordsRDBR325
c                                                                       RDBR326
 1300 continue                                                          RDBR327
      read(brkrec,1320)atmnam,altloc,(acoord(i),i=1,3), occup, therm    RDBR328
 1320 format(12x,a4,a1,13x,3f8.3,2f6.2)                                 RDBR329
      if (atmnam .eq. ' OXT' .or. atmnam .eq. ' NXT' .or.               RDBR330
     &    atmnam(2:2) .eq. 'H' .or. atmnam(2:2) .eq. 'D')               RDBR331
     &    go to 1400                                                    RDBR332
      if(aacode.lt.44) then                                             RDBR333
         attype = index(atname,atmnam)                                  RDBR334
      else                                                              RDBR335
         if (aacode.gt.44.and.aacode.le.50) then                        RDBR336
            attype = index(batnam,atmnam)                               RDBR337
         endif                                                          RDBR338
      endif                                                             RDBR339
      if (altloc .ne. space) then                                       RDBR340
         if (setatm .eq. '    ') then                                   RDBR341
            setatm = atmnam                                             RDBR342
            setloc = altloc                                             RDBR343
            oldocc = occup                                              RDBR344
            oldthm = therm                                              RDBR345
         end if                                                         RDBR346
         if (.not. altset) then                                         RDBR347
            if (setatm .eq. atmnam) then                                RDBR348
               if (occup .gt. oldocc) then                              RDBR349
                  setloc = altloc                                       RDBR350
                  oldocc = occup                                        RDBR351
                  if (xney(oldthm,0.0)) thmcnt = thmcnt - 1             RDBR352
                  oldthm = therm                                        RDBR353
                  if (attype .ne. 0) then                               RDBR354
                     atcnt = atcnt - 1                                  RDBR355
                  else                                                  RDBR356
                     scatct = scatct - 1                                RDBR357
                  end if                                                RDBR358
               end if                                                   RDBR359
            else                                                        RDBR360
               altset = .true.                                          RDBR361
            end if                                                      RDBR362
         end if                                                         RDBR363
      end if                                                            RDBR364
                                                                        RDBR365
      if (xney(therm,0.0).and. (altloc .eq. setloc .or.                 RDBR366
     &          altloc .eq. space)) thmcnt = thmcnt + 1                 RDBR367
      if (attype .ne. 0 .and. (altloc .eq. setloc .or.                  RDBR368
     &   altloc .eq. space)) then                                       RDBR369
         attype = attype / 4 + 1                                        RDBR370
         if (attype.le.4) then                                          RDBR371
                                                                        RDBR372
CHECK v.2.0-->                                                          RDBR373
            MCBVAL(AACNT) = MCBVAL(AACNT) + THERM                       RDBR374
            NMCATM(AACNT) = NMCATM(AACNT) + 1                           RDBR375
CHECK v.2.0<--                                                          RDBR376
CHECK v.3.2-->                                                          RDBR377
            MCBSTD(AACNT) = MCBSTD(AACNT) + THERM * THERM               RDBR378
CHECK v.3.2<--                                                          RDBR379
                                                                        RDBR380
            do 1350 i = 1, ncoord                                       RDBR381
            mcaaat(i,attype,aacnt) = acoord(i)                          RDBR382
 1350       continue                                                    RDBR383
            atomin(attype,aacnt) = .true.                               RDBR384
         endif                                                          RDBR385
         if (attype .ne. calph) caonly = .false.                        RDBR386
         atcnt = atcnt + 1                                              RDBR387
      end if                                                            RDBR388
      if (attype .eq. 0 .and. (altloc .eq. setloc .or.                  RDBR389
     &   altloc .eq. space)) then                                       RDBR390
                                                                        RDBR391
CHECK v.2.0-->                                                          RDBR392
         SCBVAL(AACNT) = SCBVAL(AACNT) + THERM                          RDBR393
         NSCATM(AACNT) = NSCATM(AACNT) + 1                              RDBR394
CHECK v.2.0<--                                                          RDBR395
CHECK v.3.2-->                                                          RDBR396
         SCBSTD(AACNT) = SCBSTD(AACNT) + THERM * THERM                  RDBR397
CHECK v.3.2<--                                                          RDBR398
                                                                        RDBR399
         scatct = scatct + 1                                            RDBR400
         if (aacode .le. sideaa) then                                   RDBR401
            if (atmnam .eq. cbet) then                                  RDBR402
               sctype = 1                                               RDBR403
            else                                                        RDBR404
               sctype = index(scname(aacode),atmnam)                    RDBR405
               if (sctype .eq. 0 .and. altpos(aacode) .ne. 0)           RDBR406
     &            sctype = index(altnam(altpos(aacode)),atmnam)         RDBR407
               if (sctype .ne. 0) sctype = sctype / 4 + 2               RDBR408
            end if                                                      RDBR409
            if (sctype .ne. 0) then                                     RDBR410
               scatin(sctype,aacnt) = .true.                            RDBR411
                                                                        RDBR412
CHECK v.1.0-->                                                          RDBR413
               IF (ATMNAM(3:4).EQ.'G ' .OR. ATMNAM(3:4).EQ.'G1') THEN   RDBR414
                   BVALUE(AACNT) = THERM                                RDBR415
               ENDIF                                                    RDBR416
CHECK v.1.0<--                                                          RDBR417
                                                                        RDBR418
               do 1375 i = 1, ncoord                                    RDBR419
               scaaat(i,sctype,aacnt) = acoord(i)                       RDBR420
 1375          continue                                                 RDBR421
            end if                                                      RDBR422
         end if                                                         RDBR423
      end if                                                            RDBR424
c                                                                       RDBR425
c     search for the next atom record and treat as appropriate          RDBR426
c     process coords only if same aa                                    RDBR427
c     if new aa start aa process again after setting the count fields   RDBR428
c                                                                       RDBR429
 1400 continue                                                          RDBR430
      read(brkfi,'(a)',end=2000) brkrec                                 RDBR431
CHECK v.3.1-->                                                          RDBR432
      IF (BRKREC(1:KEYLEN) .EQ. ENDMDL) GO TO 2000                      RDBR433
CHECK v.3.1<--                                                          RDBR434
      If (brkrec(1:keylen) .ne. endkey) then                            RDBR435
         If (brkrec(1:keylen) .eq. atmkey .or.                          RDBR436
     &      brkrec(1:keylen) .eq. htakey) then                          RDBR437
            read(brkrec,'(21x,a6)') innum                               RDBR438
            if (innum.eq.seqnum.and.keywd.eq.brkrec(1:keylen)) then     RDBR439
               if (aacode .le. 0) go to 1400                            RDBR440
               go to 1300                                               RDBR441
            else                                                        RDBR442
               if (aacode .gt. 0)                                       RDBR443
     &            call cntset(atpres, thmprs, altcod, nscats, aacode,   RDBR444
     &                        aacnt, atcnt, scatct, thmcnt, setloc)     RDBR445
               If (aacnt .ge. maxres) then                              RDBR446
CHECK v.2.1.3-->                                                        RDBR447
C                  Write(errfi,*)'Too many amino acids',                RDBR448
C     +                          '  - input terminated'                 RDBR449
                  Write(errfi,*)'**** Too many amino acids',            RDBR450
     &                          '  - input terminated'                  RDBR451
CHECK v.2.1.3<--                                                        RDBR452
                  goto 2100                                             RDBR453
               else                                                     RDBR454
                  if (aacode .gt. 0) aastd(aacnt + 1) = space           RDBR455
                  go to 1100                                            RDBR456
               end if                                                   RDBR457
            end if                                                      RDBR458
         end if                                                         RDBR459
         go to 1400                                                     RDBR460
      end if                                                            RDBR461
 2000 continue                                                          RDBR462
      if (aacode .gt. 0)                                                RDBR463
     &   call cntset(atpres, thmprs, altcod, nscats, aacode,            RDBR464
     &               aacnt, atcnt, scatct, thmcnt, setloc)              RDBR465
 2100 continue                                                          RDBR466
      Seqlen = aacnt                                                    RDBR467
 3000 continue                                                          RDBR468
      if (seqlen .eq. 0) readok = .false.                               RDBR469
CHECK v.3.1-->                                                          RDBR470
C      close(unit=brkfi)                                                RDBR471
      IF (.NOT.NMR) THEN                                                RDBR472
          close(unit=brkfi)                                             RDBR473
      ENDIF                                                             RDBR474
CHECK v.3.1<--                                                          RDBR475
      END                                                               RDBR476
c***********************************************************************RDBR477
