CHECK v.3.2-->                                                          RESU001
C      Subroutine result(hbonde, hbond,  aacod3, aacod1, seqcod, seqbcd,RESU002
C     +                  brksym, ssbond, bridpt, sssumm, summpl, autsum,RESU003
C     +                  mcangs, altcod, aastd,  atpres, thmprs, scangs,RESU004
C     +                  cadsts, brknam, headln, hedlen, outsty, dsdsts,RESU005
      Subroutine result(hbonde, aacod3, aacod1, seqcod, seqbcd,         RESU001
     &                  brksym, ssbond, sssumm, summpl, autsum,         RESU002
     &                  mcangs, scangs,                                 RESU003
     &                  outsty, dsdsts,                                 RESU004
CHECK v.3.2<--                                                          RESU005
                                                                        RESU006
CHECK v.1.0-->                                                          RESU007
C     +                  dsdef,  dspart, hetcod, oois,   seqlen)        RESU008
CHECK v.2.0-->                                                          RESU009
C     +                  dsdef,  dspart, hetcod, oois, seqlen, BVALUE)  RESU010
CHECK v.3.2-->                                                          RESU011
C     +                  dsdef,  dspart, hetcod, oois, seqlen, BVALUE,  RESU012
C     -                  MCBVAL,SCBVAL,NMCATM,NSCATM)                   RESU013
     &                  hetcod, oois, seqlen, BVALUE,                   RESU014
     &                  MCBVAL,SCBVAL,NMCATM,NSCATM,MCBSTD,SCBSTD)      RESU015
CHECK v.3.2<--                                                          RESU016
CHECK v.2.0<--                                                          RESU017
CHECK v.1.0<--                                                          RESU018
                                                                        RESU019
c                                                                       RESU020
c     Results are in 4 parts. The standard output set of details        RESU021
c     one line to an amino acid. The second set makes the full set      RESU022
c     again one line per amino acid. The third set is the structure     RESU023
c     patterns and summaries at 100 amino acids to the line             RESU024
c     with finally error and information messages                       RESU025
c                                                                       RESU026
      include 'sstruc.par'                                              RESU027
                                                                        RESU028
CHECK v.3.2-->                                                          RESU029
      save bpl, strpts, lefthd, rthd                                    RESU030
CHECK v.3.2<--                                                          RESU031
                                                                        RESU032
CHECK v.1.0-->                                                          RESU033
      REAL          BVALUE(MAXRES)                                      RESU034
CHECK v.1.0<--                                                          RESU035
                                                                        RESU036
CHECK v.2.0-->                                                          RESU037
      INTEGER       NMCATM(MAXRES), NSCATM(MAXRES)                      RESU038
      REAL          MCBVAL(MAXRES), SCBVAL(MAXRES)                      RESU039
CHECK v.2.0<--                                                          RESU040
                                                                        RESU041
CHECK v.3.2-->                                                          RESU042
      REAL          MCBSTD(MAXRES), SCBSTD(MAXRES)                      RESU043
CHECK v.3.2<--                                                          RESU044
                                                                        RESU045
CHECK v.3.2-->                                                          RESU046
C      integer   hbond(maxbnd,maxres), seqcod(maxres), seqlen,          RESU047
C     +          bridpt(2,maxres), hedlen, dspart(maxres), oois(2,maxresRESU048
      integer   seqcod(maxres), seqlen,                                 RESU049
     &          oois(2,maxres)                                          RESU050
CHECK v.3.2<--                                                          RESU051
      real      hbonde(maxbnd,maxres), mcangs(nmnang,maxres),           RESU052
CHECK v.3.2-->                                                          RESU053
C     +          scangs(nsdang,maxres), cadsts(11,maxres),              RESU054
     &          scangs(nsdang,maxres),                                  RESU055
CHECK v.3.2<--                                                          RESU056
     &          dsdsts(3,maxres)                                        RESU057
      character aacod3*(abetsz*3), ssbond(nstruc,maxres)*1,             RESU058
CHECK v.3.2-->                                                          RESU059
C     +          sssumm(maxres)*1, brknam*(fnamln), summpl(maxres),     RESU060
C     +          seqbcd(maxres)*6, aacod1*(abetsz), autsum(maxres)*1,   RESU061
C     +          brksym(maxres)*1, headln*132, altcod(maxres)*1,        RESU062
C     +          aastd(maxres)*1, atpres(3,maxres), thmprs(maxres),     RESU063
C     +          outsty*1, dsdef(maxres)*1, hetcod*63                   RESU064
     &          sssumm(maxres)*1, summpl(maxres),                       RESU065
     &          seqbcd(maxres)*6, aacod1*(abetsz), autsum(maxres)*1,    RESU066
     &          brksym(maxres)*1,                                       RESU067
     &          outsty*1, hetcod*63                                     RESU068
CHECK v.3.2<--                                                          RESU069
                                                                        RESU070
      integer   nxres, i, bpl(maxbnd), staa, nxstr, nxang, nxst, nxrow, RESU071
CHECK v.2.1-->                                                          RESU072
C     +          aathln, strpts(9), j, hednum                           RESU073
     &          aathln, strpts(9), hednum                               RESU074
CHECK v.2.1<--                                                          RESU075
      character aa3*3, aa1*1, lefthd(13)*9, rthd(13)*9,                 RESU076
     &          wkln1*(aaonln), wkln2*122, sumln(3)*(aaonln)            RESU077
      data bpl /3,1,4,2/                                                RESU078
      data strpts/chisgn, bend, turn, pih, thrtnh, bridg2, bridg1,      RESU079
     &            sheet1, alphah/                                       RESU080
      data lefthd /'chirality', '    bends', '    turns', '  5-turns',  RESU081
     &             '  3-turns', ' bridge-2', ' bridge-1', '   sheets',  RESU082
     &             '  4-turns', '   author', 'Kabs/Sand', '  summary',  RESU083
     &             ' sequence'/                                         RESU084
      data rthd   /'chirality', 'bends    ', 'turns    ', '5-turns  ',  RESU085
     &             '3-turns  ', 'bridge-2 ', 'bridge-1 ', 'sheets   ',  RESU086
     &             '4-turns  ', 'author   ', 'Kabs/Sand', 'summary  ',  RESU087
     &             'sequence '/                                         RESU088
CHECK v.3.2-->                                                          RESU089
C      save bpl, strpts, lefthd, rthd                                   RESU090
CHECK v.3.2<--                                                          RESU091
                                                                        RESU092
      hednum = 1                                                        RESU093
CHECK v.3.2-->                                                          RESU094
C      call hedset(brknam, headln, hedlen, hednum, seqlen)              RESU095
CHECK v.3.2<--                                                          RESU096
      do 500, nxres = 1, seqlen                                         RESU097
      if (seqcod(nxres) .le. abetsz) then                               RESU098
         staa = (seqcod(nxres) - 1) * 3 + 1                             RESU099
         aa3 = aacod3(staa:staa+2)                                      RESU100
         aa1 = aacod1(seqcod(nxres):seqcod(nxres))                      RESU101
      else                                                              RESU102
         staa = (seqcod(nxres) - abetsz - 1) * 3 + 1                    RESU103
         aa3 = hetcod(staa:staa+2)                                      RESU104
         aa1 = '-'                                                      RESU105
      end if                                                            RESU106
                                                                        RESU107
CHECK v.1.0-->                                                          RESU108
C      write(outfi,300) nxres, brksym(nxres), seqbcd(nxres),            RESU109
C     +     altcod(nxres), aa3, aa1, autsum(nxres), sssumm(nxres),      RESU110
C     +     summpl(nxres), (ssbond(nxstr,nxres), nxstr = alphah, sheet1)RESU111
C     +     (ssbond(nxstr,nxres), nxstr = bridg1, chisgn),              RESU112
C     +     (bridpt(nxstr,nxres), nxstr = 1, 2),                        RESU113
C     +     (mcangs(nxang,nxres), nxang = 1, nmnang),                   RESU114
C     +     (hbond(bpl(i),nxres), hbonde(bpl(i),nxres), i=1,4),         RESU115
C     +     oois(ooi1,nxres), oois(ooi2,nxres)                          RESU116
C  300 format(1x,i4,a1,a6,x,a1,x,a3,x,a1,3(x,a1),x,9a1,2(x,i4),         RESU117
C     +       4(x,f6.1),2(x,f5.1),4(x,i4,x,f4.1),2(x,i2))               RESU118
                                                                        RESU119
C---- Write out to output .rin file                                     RESU120
CHECK v.2.0-->                                                          RESU121
C      WRITE(8,300) NXRES, AA3, BRKSYM(NXRES), SEQBCD(NXRES),           RESU122
C     -    SUMMPL(NXRES), (MCANGS(NXANG,NXRES), NXANG = 1, 3),          RESU123
C     -    (SCANGS(I,NXRES), I = 1, 3), HBONDE(BPL(1),NXRES),           RESU124
C     -    DSDSTS(3,NXRES), MCANGS(IMPLD,NXRES), BVALUE(NXRES)          RESU125
C 300  FORMAT(I4,A3,A1,A6,A1,10F7.2)                                    RESU126
                                                                        RESU127
C---- Calculate the mean and standard deviation for the main-chain      RESU128
C     and side-chain B-values                                           RESU129
      IF (NMCATM(NXRES).NE.0) THEN                                      RESU130
          MCBVAL(NXRES) = MCBVAL(NXRES) / NMCATM(NXRES)                 RESU131
CHECK v.3.2-->                                                          RESU132
          MCBSTD(NXRES) = MCBSTD(NXRES) / NMCATM(NXRES)                 RESU133
     &        - MCBVAL(NXRES) * MCBVAL(NXRES)                           RESU134
          IF (NMCATM(NXRES).GT.1 .AND. MCBSTD(NXRES).GT.0.0) THEN       RESU135
              MCBSTD(NXRES) = SQRT(MCBSTD(NXRES))                       RESU136
          ELSE                                                          RESU137
              MCBSTD(NXRES) = 0.0                                       RESU138
          ENDIF                                                         RESU139
CHECK v.3.2<--                                                          RESU140
      ELSE                                                              RESU141
          MCBVAL(NXRES) = 0.0                                           RESU142
CHECK v.3.2-->                                                          RESU143
          MCBSTD(NXRES) = 0.0                                           RESU144
CHECK v.3.2<--                                                          RESU145
      ENDIF                                                             RESU146
      IF (NSCATM(NXRES).NE.0) THEN                                      RESU147
          SCBVAL(NXRES) = SCBVAL(NXRES) / NSCATM(NXRES)                 RESU148
CHECK v.3.2-->                                                          RESU149
          SCBSTD(NXRES) = SCBSTD(NXRES) / NSCATM(NXRES)                 RESU150
     &        - SCBVAL(NXRES) * SCBVAL(NXRES)                           RESU151
          IF (NSCATM(NXRES).GT.1 .AND. SCBSTD(NXRES).GT.0.0) THEN       RESU152
              SCBSTD(NXRES) = SQRT(SCBSTD(NXRES))                       RESU153
          ELSE                                                          RESU154
              SCBSTD(NXRES) = 0.0                                       RESU155
          ENDIF                                                         RESU156
CHECK v.3.2<--                                                          RESU157
      ELSE                                                              RESU158
          SCBVAL(NXRES) = 0.0                                           RESU159
CHECK v.3.2-->                                                          RESU160
          SCBSTD(NXRES) = 0.0                                           RESU161
CHECK v.3.2<--                                                          RESU162
      ENDIF                                                             RESU163
                                                                        RESU164
C---- Write out to output .rin file                                     RESU165
      WRITE(8,300) NXRES, AA3, BRKSYM(NXRES), SEQBCD(NXRES),            RESU166
     &    SUMMPL(NXRES), (MCANGS(NXANG,NXRES), NXANG = 1, 3),           RESU167
CHECK v.3.0-->                                                          RESU168
C     -    (SCANGS(I,NXRES), I = 1, 3), HBONDE(BPL(1),NXRES),           RESU169
C     -    DSDSTS(3,NXRES), MCANGS(IMPLD,NXRES), BVALUE(NXRES),         RESU170
C     -    MCBVAL(NXRES), SCBVAL(NXRES)                                 RESU171
C 300  FORMAT(I4,A3,A1,A6,A1,10F7.2,2F7.3)                              RESU172
     &    (SCANGS(I,NXRES), I = 1, 4), HBONDE(BPL(1),NXRES),            RESU173
     &    DSDSTS(3,NXRES), MCANGS(IMPLD,NXRES), BVALUE(NXRES),          RESU174
     &    MCBVAL(NXRES), SCBVAL(NXRES), OOIS(OOI1,NXRES),               RESU175
CHECK v.3.2-->                                                          RESU176
C     -    OOIS(OOI2,NXRES)                                             RESU177
C 300  FORMAT(I4,A3,A1,A6,A1,11F7.2,2F7.3,2(1X,I2))                     RESU178
     &    OOIS(OOI2,NXRES), MCBSTD(NXRES), SCBSTD(NXRES)                RESU179
 300  FORMAT(I4,A3,A1,A6,A1,11F7.2,2F7.3,2(1X,I2),2F7.3)                RESU180
CHECK v.3.2<--                                                          RESU181
CHECK v.3.0<--                                                          RESU182
CHECK v.2.0<--                                                          RESU183
CHECK v.1.0<--                                                          RESU184
                                                                        RESU185
  500 continue                                                          RESU186
                                                                        RESU187
CHECK v.1.0-->                                                          RESU188
C      write(outfi,*)char(12)                                           RESU189
CHECK v.1.0<--                                                          RESU190
                                                                        RESU191
      if (outsty .eq. 'F') then                                         RESU192
         hednum = 2                                                     RESU193
CHECK v.3.2-->                                                          RESU194
C         call hedset(brknam, headln, hedlen, hednum, seqlen)           RESU195
CHECK v.3.2<--                                                          RESU196
         do 1000, nxres = 1, seqlen                                     RESU197
         if (seqcod(nxres) .le. abetsz) then                            RESU198
            staa = (seqcod(nxres) - 1) * 3 + 1                          RESU199
            aa3 = aacod3(staa:staa+2)                                   RESU200
            aa1 = aacod1(seqcod(nxres):seqcod(nxres))                   RESU201
         else                                                           RESU202
            staa = (seqcod(nxres) - abetsz - 1) * 3 + 1                 RESU203
            aa3 = hetcod(staa:staa+2)                                   RESU204
            aa1 = '-'                                                   RESU205
         end if                                                         RESU206
CHECK v.3.0.1-->                                                        RESU207
C  800    continue                                                      RESU208
CHECK v.3.0.1<--                                                        RESU209
                                                                        RESU210
CHECK v.1.0-->                                                          RESU211
C         write(outfi,900)nxres, brksym(nxres), seqbcd(nxres), aa3, aa1,RESU212
C     +      aastd(nxres), (atpres(i,nxres),i=1,3),                     RESU213
C     +      thmprs(nxres), (scangs(i,nxres),i=1,4), dspart(nxres),     RESU214
C     +      dsdef(nxres), (dsdsts(i,nxres),i=1,3),                     RESU215
C     +      (cadsts(i,nxres),i=1,11)                                   RESU216
C  900    format(x,i4,a1,a6,x,a3,x,a1,5(x,a1),4(x,f6.1),x,i4,x,a1,      RESU217
C     +          3(x,f4.1),11(x,f4.1))                                  RESU218
CHECK v.1.0<--                                                          RESU219
                                                                        RESU220
 1000    continue                                                       RESU221
                                                                        RESU222
CHECK v.1.0-->                                                          RESU223
C         write(outfi,*) char(12)                                       RESU224
CHECK v.1.0<--                                                          RESU225
                                                                        RESU226
      end if                                                            RESU227
                                                                        RESU228
CHECK v.1.0-->                                                          RESU229
C      write(outfi,1001) brknam                                         RESU230
C 1001 format(x,a)                                                      RESU231
C      write(outfi,1001) headln(1:hedlen)                               RESU232
CHECK v.1.0<--                                                          RESU233
                                                                        RESU234
      do 2000, nxst = 1, seqlen, aaonln                                 RESU235
                                                                        RESU236
CHECK v.1.0-->                                                          RESU237
C      write(outfi,*)                                                   RESU238
CHECK v.1.0<--                                                          RESU239
                                                                        RESU240
      aathln = aaonln                                                   RESU241
      if (nxst + aathln - 1 .gt. seqlen) aathln = seqlen - nxst + 1     RESU242
      do 1100, nxstr = 1,aathln                                         RESU243
      sumln(1)(nxstr:nxstr) = autsum(nxst+nxstr-1)                      RESU244
      sumln(2)(nxstr:nxstr) = sssumm(nxst+nxstr-1)                      RESU245
 1100 continue                                                          RESU246
      do 1300, nxrow = 1, 2                                             RESU247
      wkln2 = lefthd(9+nxrow) // '  ' // sumln(nxrow)(1:aathln) //      RESU248
     &        '  ' // rthd(9+nxrow)                                     RESU249
                                                                        RESU250
CHECK v.1.0-->                                                          RESU251
C      write(outfi,1200)wkln2(1:aathln+22)                              RESU252
CHECK v.1.0<--                                                          RESU253
                                                                        RESU254
CHECK v.3.0.1-->                                                        RESU255
C 1200 format(x,A)                                                      RESU256
CHECK v.3.0.1<--                                                        RESU257
 1300 continue                                                          RESU258
      do 1500, nxrow = 1, 9                                             RESU259
      do 1400, nxstr = 1, aathln                                        RESU260
      wkln1(nxstr:nxstr) = ssbond(strpts(nxrow),nxst+nxstr-1)           RESU261
 1400 continue                                                          RESU262
      wkln2 = lefthd(nxrow) // '  ' // wkln1(1:aathln) // '  '          RESU263
     &        // rthd(nxrow)                                            RESU264
                                                                        RESU265
CHECK v.1.0-->                                                          RESU266
C      write(outfi,1200)wkln2(1:aathln+22)                              RESU267
CHECK v.1.0<--                                                          RESU268
                                                                        RESU269
 1500 continue                                                          RESU270
      do 1600, nxstr = 1,aathln                                         RESU271
      sumln(3)(nxstr:nxstr) = summpl(nxst+nxstr-1)                      RESU272
      if (seqcod(nxst+nxstr-1) .le. abetsz) then                        RESU273
         wkln1(nxstr:nxstr) =                                           RESU274
     &   aacod1(seqcod(nxst+nxstr-1):seqcod(nxst+nxstr-1))              RESU275
      else                                                              RESU276
         wkln1(nxstr:nxstr) = '-'                                       RESU277
      end if                                                            RESU278
 1600 continue                                                          RESU279
      wkln2 = lefthd(12) // '  ' // sumln(3)(1:aathln) // '  '          RESU280
     &        // rthd(12)                                               RESU281
                                                                        RESU282
CHECK v.1.0-->                                                          RESU283
C      write(outfi,1200) wkln2(1:aathln+22)                             RESU284
CHECK v.1.0<--                                                          RESU285
                                                                        RESU286
      wkln2 = lefthd(13) // '  ' // wkln1(1:aathln) // '  ' //rthd(13)  RESU287
                                                                        RESU288
CHECK v.1.0-->                                                          RESU289
C      write(outfi,1200) wkln2(1:aathln+22)                             RESU290
CHECK v.1.0<--                                                          RESU291
                                                                        RESU292
                                                                        RESU293
CHECK v.1.0-->                                                          RESU294
C      write(outfi,1700) (nxst-1+j*10,j=1,aathln/10)                    RESU295
CHECK v.1.0<--                                                          RESU296
                                                                        RESU297
CHECK v.3.0.1-->                                                        RESU298
C 1700 format(12x,10(i10))                                              RESU299
CHECK v.3.0.1<--                                                        RESU300
 2000 continue                                                          RESU301
                                                                        RESU302
      call msgprt                                                       RESU303
                                                                        RESU304
CHECK v.1.0-->                                                          RESU305
C      write(outfi,*) char(12)                                          RESU306
CHECK v.1.0<--                                                          RESU307
                                                                        RESU308
      end                                                               RESU309
