      PROGRAM SECSTR                                                    SECS0001
c ----------------------------------------------------------------------SECS0002
c                                                                       SECS0003
c  Windows NT / Win 95 code                                             SECS0004
c                                                                       SECS0005
c  Bernhard Rupp 1996 - minor modifications.                            SECS0006
c                                                                       SECS0007
c  1.  comment lines restricted to 72 columns                           SECS0008
c  2.  source code lines numbered                                       SECS0009
c  3.  to read file name of input file as parameter otherwise ask       SECS0010
c  4.  taken apart into subroutines                                     SECS0011
c                                                                       SECS0012
c       Changes are annotated by WINNT at the beginning of comment linesSECS0013
c                                                                       SECS0014
C-----------------------------------------------------------------------SECS0015
C                                                                       SECS0016
C SECSTR.F - Amended version of sstruc.f for use with structure-checkingSECS0017
c            suite of programs, PROCHECK                                SECS0018
C                                                                       SECS0019
C            Amendments by R A Laskowski, April 1992, identified by     SECS0020
C            CHECK v.m.n--> and CHECK v.m.n<-- comment lines, where m.n SECS0021
C            is the version number.                                     SECS0022
C                                                                       SECS0023
C v.2.0    - Rewrite to allow entry of any filename for the coordinates SECS0024
c            file rather than just the 4-letter Brookhaven code         SECS0025
C            Roman Laskowski (Jul/Aug 1992)                             SECS0026
c                                                                       SECS0027
C v.2.1    - Bug-fix so that input file is the .new file, rather than   SECS0028
c            the .pdb      file                                         SECS0029
C            Roman Laskowski ( 9 Dec 1992)                              SECS0030
c                                                                       SECS0031
C v.2.1.3  - Addition of asterisks to error prints so that can be       SECS0032
c            plucked out of the log files and displayed by the script   SECS0033
c            file.                                                      SECS0034
C            Roman Laskowski (26 Mar 1993)                              SECS0035
C            Bug-fix to prevent crashing in Subroutine Mktb in with     SECS0036
c            divide by zero (don't know why). Fix merely checks for     SECS0037
c            zero and skips the appropriate part of the code            SECS0038
C            Roman Laskowski (14 Apr 1993)                              SECS0039
c                                                                       SECS0040
C v.2.1.4  - Amendment to change name of residue information files from SECS0041
c            .res to .rin so as not to clash with the .rin files        SECS0042
c            produced by SHELX.                                         SECS0043
C            Amendment to FORMAT statements to change x to 1x throughoutSECS0044
c            as the IBM RS/6000 compiler objects to these.              SECS0045
C            Crude change to limit number of 'unknown amino acid' error SECS0046
C            messages displayed (particularly irritating for lots of    SECS0047
c            waters).                                                   SECS0048
C            Roman Laskowski (12 May 1993)                              SECS0049
C                                                                       SECS0050
C v.3.0   -  Tiny change so that VAX .COM routines don't show error if  SECS0051
c            no asterisks found in log file.                            SECS0052
C            Amendment so that Ooi numbers are written out to the .rin  SECS0053
c            file. Amendment so that Chi-3, 4, and 5 dihedrals are      SECS0054
c            written out to .rin file.                                  SECS0055
C            Roman Laskowski (14-26 Nov 1993)                           SECS0056
C                                                                       SECS0057
C v.3.0.1 -  Changed order of DATA statements in some routines so that  SECS0058
c            they follow the variable declarations (was causing problemsSECS0059
c            when      compiling with the f2c compiler).                SECS0060
C            Commented out unreferenced labels (producing compiler      SECS0061
c            warnings      when compiling on Convex).                   SECS0062
C            Roman Laskowski (29/30 Mar 1994)                           SECS0063
C                                                                       SECS0064
C v.3.1   -  Amendments for PROCHECK-NMR to deal with each MODEL in an  SECS0065
C            ensemble separately, writing each to a separate .rin file. SECS0066
C            Roman Laskowski (18/19 Apr 1994)                           SECS0067
C                                                                       SECS0068
C v.3.2   -  Calculation of main-chain and side-chain B-value st. devs. SECS0069
C            Roman Laskowski (30 Apr 1994)                              SECS0070
C            Minor amendments to various statements to make them        SECS0071
C            acceptable to f2c, and to deal with various uninitialised  SECS0072
C            variables. All tabs replaced by spaces. SAVE statements    SECS0073
C            for variables moved prior to declaration of those variablesSECS0074
C            in the routine. (Amendments supplied by Dave Love at       SECS0075
C            Daresbury).                                                SECS0076
C            David Love/Roman Laskowski (13 Oct 1994)                   SECS0077
C            Amendment for case where one one model in the PDB file and SECS0078
C            hence no MODEL and ENDMDL records                          SECS0079
C            Roman Laskowski (25 Oct 1994)                              SECS0080
C            Reinstatement of facility to process a list of PDB files inSECS0081
C            a single run. (For use with PROCOMP when comparing a set ofSECS0082
C            similar structures).                                       SECS0083
C            Roman Laskowski (7 Nov 1994)                               SECS0084
C                                                                       SECS0085
C v.3.3.1 -  Amendment to write .rin files for CA-only files.           SECS0086
C            Increased number of chain-breaks allowed, and checked for  SECS0087
C            overflow. (Can get a large number of apparent chain-breaks SECS0088
C            in structures where one chain is normal, and the other has SECS0089
C            C-alpha coordinates only).                                 SECS0090
C            Roman Laskowski (5 Jun 1995)                               SECS0091
C v.3.4   -  Bug-fix to run PROCHECK correctly on the 1st model only of SECS0092
C            multiple-model file.                                       SECS0093
C            Addition of model-number to output NMR .rin files.         SECS0094
C            Roman Laskowski (20 Mar 1996)                              SECS0095
C            Bug-fixes suggested by Dave Love.                          SECS0096
C            Roman Laskowski (26 Apr 1996)                              SECS0097
C                                                                       SECS0098
C                                                                       SECS0099
C Files:                                                                SECS0100
C                                                                       SECS0101
C  2 mplot.in       - List of NMR ensemble .rin files, for use by       SECS0102
c                     PROCHECK-NMR program mplot.f                      SECS0103
C  8 <filename>.rin - Output file holding all the residue-by-residue    SECS0104
C                     information required by program PPLOT.F           SECS0105
C 11 <filename>.new - Input .new file, being the cleaned-up version of  SECS0106
c                     the input PDB file.                               SECS0107
C                                                                       SECS0108
C-----------------------------------------------------------------------SECS0109
WINNT - needed for system call to getarg                                SECS0110
      integer(2)  n1,status                                             SECS0111
WINNT - end                                                             SECS0112
                                                                        SECS0113
CHECK v.1.0-->                                                          SECS0114
C      program sstruc                                                   SECS0115
CHECK v.1.0<--                                                          SECS0116
                                                                        SECS0117
c     copyright by David Keith Smith, 1989                              SECS0118
c***********************************************************************SECS0119
c     filename:      sstruc.f                                           SECS0120
c     last modified: 11th September 1991                                SECS0121
c***********************************************************************SECS0122
c     global variables                                                  SECS0123
c                                                                       SECS0124
      INCLUDE 'sstruc.par'                                              SECS0125
                                                                        SECS0126
      character aacod1*(abetsz), aacod3*(3*abetsz), atname*(4*mnchna-4),SECS0127
     &          ssbond(nstruc,maxres)*1, sssumm(maxres)*1,              SECS0128
     &          summpl(maxres)*1, seqbcd(maxres)*6,                     SECS0129
     &          autsum(maxres)*1, ssord*21, brksym(maxres)*1,           SECS0130
     &          headln*132, altcod(maxres)*1, aastd(maxres)*1,          SECS0131
     &          atpres(3,maxres)*1, thmprs(maxres)*1, hetcod*63,        SECS0132
     &          outsty*1, dsdef(maxres)*1, dudcod*105, modcod*(nmod*3), SECS0133
     &          stdmod*(nmod+1), nstdmd*(nmod+1), modpl*(nmod),         SECS0134
     &          batnam*(4*mnchna+4)                                     SECS0135
      integer   seqcod(maxres), seqlen, hbond(maxbnd,maxres),           SECS0136
     &          chnsz(maxchn), chnct, bridpt(2,maxres), hedlen,         SECS0137
     &          dspart(maxres), chnend(maxchn), oois(2,maxres)          SECS0138
      real      mcaaat(ncoord,mnchna,maxres), hbonde(maxbnd,maxres),    SECS0139
     &          scaaat(ncoord,sdchna,maxres), mcangs(nmnang,maxres),    SECS0140
     &          scangs(nsdang,maxres), cadsts(11,maxres),               SECS0141
     &          dsdsts(3,maxres)                                        SECS0142
      logical   atomin(mnchna,maxres), scatin(sdchna,maxres), caonly,   SECS0143
     &          readok, astruc                                          SECS0144
                                                                        SECS0145
CHECK v.3.0.1--> (Order of statements changed)                          SECS0146
c                                                                       SECS0147
c                                                                       SECS0148
c     local variables                                                   SECS0149
c                                                                       SECS0150
      integer   finish, opnera, opnerb, opnerc, fiend, ok, endnfi       SECS0151
      character indirn*1                                                SECS0152
      parameter (finish = 2, opnera = 1, opnerb = 3, fiend = 4, ok = 0, SECS0153
     &           opnerc = 5, endnfi = 6,                                SECS0154
     &           indirn='@')                                            SECS0155
      logical   finuse                                                  SECS0156
CHECK v.3.2-->                                                          SECS0157
C      integer   fistat, namlen, iocode, i, iostat,                     SECS0158
CHECK v.2.1-->                                                          SECS0159
C     +          corepl, corend, logpl, dirpl, nodepl, outlen           SECS0160
C     +          corepl, corend, outlen                                 SECS0161
CHECK v.2.1<--                                                          SECS0162
      integer   fistat, namlen, iocode, i, iostat                       SECS0163
CHECK v.3.2<--                                                          SECS0164
CHECK v.3.2-->                                                          SECS0165
C      character*(fnamln) finam, brknam, outnam, outdir                 SECS0166
      character*(fnamln) brknam, finam                                  SECS0167
CHECK v.3.2<--                                                          SECS0168
CHECK v.2.1-->                                                          SECS0169
C      integer   ifail, outln, lastsl, brklen                           SECS0170
CHECK v.3.2-->                                                          SECS0171
C      integer   outln                                                  SECS0172
CHECK v.3.2<--                                                          SECS0173
CHECK v.2.1<--                                                          SECS0174
                                                                        SECS0175
CHECK v.1.0-->                                                          SECS0176
      CHARACTER*4   BRCODE                                              SECS0177
      REAL          BVALUE(MAXRES)                                      SECS0178
CHECK v.1.0<--                                                          SECS0179
                                                                        SECS0180
CHECK v.2.0-->                                                          SECS0181
      CHARACTER*78  FILRES, PDBFIL                                      SECS0182
      INTEGER       IEND, ILEN, ISTART, NMCATM(MAXRES), NSCATM(MAXRES)  SECS0183
      LOGICAL       IERROR                                              SECS0184
      REAL          MCBVAL(MAXRES), SCBVAL(MAXRES)                      SECS0185
CHECK v.2.0<--                                                          SECS0186
CHECK v.3.0.1<--                                                        SECS0187
                                                                        SECS0188
CHECK v.3.1-->                                                          SECS0189
      CHARACTER*3   CMODEL                                              SECS0190
CHECK v.3.4-->                                                          SECS0191
C      INTEGER       IMODEL, NMODEL                                     SECS0192
      INTEGER       IMODEL, MODLNO, NMODEL                              SECS0193
CHECK v.3.4<--                                                          SECS0194
CHECK v.3.2-->                                                          SECS0195
C      LOGICAL       ENDFIL, FIRST, NMR                                 SECS0196
      LOGICAL       ENDFIL, ENSEMB, FIRST, NMR                          SECS0197
CHECK v.3.2<--                                                          SECS0198
CHECK v.3.1<--                                                          SECS0199
                                                                        SECS0200
CHECK v.3.2-->                                                          SECS0201
      REAL          MCBSTD(MAXRES), SCBSTD(MAXRES)                      SECS0202
CHECK v.3.2<--                                                          SECS0203
                                                                        SECS0204
      data aacod1(1:29)  /'ABCDEFGHIXKLMNXPQRSTXVWXYZX--'/              SECS0205
      data aacod3( 1:39) /'ALAASXCYSASPGLUPHEGLYHISILEXXXLYSLEUMET'/,   SECS0206
     &     aacod3(40:78) /'ASNXXXPROGLNARGSERTHRXXXVALTRPXXXTYRGLX'/,   SECS0207
     &     aacod3(79:87) /'UNKPCAINI'/                                  SECS0208
      data hetcod(1:39)  /'AIBPHLSECALMMPRFRDPYRLYMGLMPPHPGLOLETPH'/,   SECS0209
     &     hetcod(40:63) /'ABANLEB2VB2IB1FBNOB2AB2F'/                   SECS0210
      data modcod(1:39)  /'ACEANIBZOCBZCLTFORNH2PHORHATFATOS NHMYR'/,   SECS0211
     &     modcod(40:45) /'BOCMSU'/                                     SECS0212
      data dudcod( 1:39) /'  A  C  G  T  U1MA5MCOMC1MG2MGM2G7MGOMG'/,   SECS0213
     &     dudcod(40:78) /' YG  I +UH2U5MUPSU +C +AGALAGLGCUASGMAN'/    SECS0214
     &     dudcod(79:105) /'GLCCEGG4SAGSNAGGLSNGSNAMEXC'/               SECS0215
      data stdmod /'ABCDEFGHIJKLMNZY'/                                  SECS0216
      data nstdmd /'abcdefghijklmnzy'/                                  SECS0217
      data modpl  /'+0++++0++++0+++'/                                   SECS0218
      data ssord /'HEheBbGgIiJKLMNOPTtS '/                              SECS0219
      data atname /' N   CA  C   O  '/                                  SECS0220
      data batnam /' N   CA  B       O1  O2 '/                          SECS0221
      data atomin /allatm * .false./, mcaaat /allcrd * 0/               SECS0222
      data fistat/0/, finuse/.false./                                   SECS0223
CHECK v.3.2-->                                                          SECS0224
      data bvalue /maxres*0.0/                                          SECS0225
CHECK v.3.2<--                                                          SECS0226
                                                                        SECS0227
c                                                                       SECS0228
c     input file control loop                                           SECS0229
c                                                                       SECS0230
CHECK v.3.1-->                                                          SECS0231
CHECK v.3.4-->                                                          SECS0232
      IMODEL = 0                                                        SECS0233
CHECK v.3.4<--                                                          SECS0234
      NMODEL = 0                                                        SECS0235
CHECK v.3.1<--                                                          SECS0236
                                                                        SECS0237
CHECK v.1.0-->                                                          SECS0238
      WRITE(*,*)                                                        SECS0239
CHECK v.1.0<--                                                          SECS0240
                                                                        SECS0241
      write(*,*)'Secondary structure calculation program - ',           SECS0242
     &          'copyright by David Keith Smith, 1989'                  SECS0243
      write(*,*)                                                        SECS0244
                                                                        SECS0245
CHECK v.1.0-->                                                          SECS0246
      WRITE(*,*) 'Amended by R A Laskowski,  1992'                      SECS0247
WINNT - version notice                                                  SECS0248
      WRITE(*,*) 'Windows NT Version B.Rupp, 1996'                      SECS0249
      WRITE(*,*)                                                        SECS0250
WINNT - end                                                             SECS0251
CHECK v.2.0-->                                                          SECS0252
COUT---- Accept 4-letter Brookhaven code                                SECS0253
COUT      WRITE (*, 1010)                                               SECS0254
COUT 1010 FORMAT ('Enter 4-letter Brookhaven code of structure:')       SECS0255
COUT      READ (*,1020) BRCODE                                          SECS0256
COUT 1020 FORMAT(A)                                                     SECS0257
COUT      BRKNAM = 'p' // BRCODE // '.new'                              SECS0258
COUT      WRITE (*,1022) BRKNAM(1:NAMLEN+5)                             SECS0259
COUT 1022 FORMAT(//,                                                    SECS0260
COUT     -    'Processing file: ',A,/)                                  SECS0261
                                                                        SECS0262
COUT---- Form the names of the output files                             SECS0263
COUT      OUTNAM = 'p' // BRCODE // '.sst'                              SECS0264
COUT      OUTLEN = 9                                                    SECS0265
                                                                        SECS0266
COUT---- Open the file that will hold the dihedral angles               SECS0267
COUT      OPEN (UNIT=8,FILE='p'//BRCODE//'.res',STATUS='UNKNOWN',ERR=900SECS0268
COUTVAX                                                                 SECS0269
COUT     -    CARRIAGECONTROL='LIST'                                    SECS0270
COUTVAX                                                                 SECS0271
COUT     -    )                                                         SECS0272
CHECK v.1.0<--                                                          SECS0273
                                                                        SECS0274
                                                                        SECS0275
WINNT - accept file name from command line if provided else ask for it  SECS0276
CHECK v.2.0-->                                                          SECS0277
C---- Accept name of original .pdb file holding the structure           SECS0278
c      PRINT*, 'Enter filename containing coordinates of structure'     SECS0279
CHECK v.3.2-->                                                          SECS0280
c      PRINT*, '  (for file containing ensemble of NMR structures en',  SECS0281
c     -    'ter @filename;'                                             SECS0282
c      PRINT*, '   for set of separate PDB files to be processed, en',  SECS0283
c     -    'ter %filelist,'                                             SECS0284
c      PRINT*, '   where filelist contains a list of PDB files to be',  SECS0285
c     -    ' cleaned up)'                                               SECS0286
CHECK v.3.2<--                                                          SECS0287
c      READ(*,10) PDBFIL                                                SECS0288
c10    FORMAT(A)                                                        SECS0289
c                                                                       SECS0290
      n1 = 1                                                            SECS0291
      CALL GETARG(n1, pdbfil, status)                                   SECS0292
      if (status.lt.1) then                                             SECS0293
         PRINT*, 'Enter filename containing coordinates of structure'   SECS0294
CHECK v.3.2-->                                                          SECS0295
         PRINT*, '  (for file containing ensemble of NMR structures en',SECS0296
     &    'ter @filename;'                                              SECS0297
         PRINT*, '   for set of separate PDB files to be processed, en',SECS0298
     &    'ter %filelist,'                                              SECS0299
         PRINT*, '   where filelist contains a list of PDB files to be',SECS0300
     &    ' cleaned up)'                                                SECS0301
CHECK v.3.2<--                                                          SECS0302
         READ(*,10) PDBFIL                                              SECS0303
10       FORMAT(A)                                                      SECS0304
      else                                                              SECS0305
         write(*,*) 'File name parsed from command line : ',pdbfil      SECS0306
      end if                                                            SECS0307
WINNT - end                                                             SECS0308
                                                                        SECS0309
CHECK v.3.1-->                                                          SECS0310
C---- If the very first character of the file-name is an @, then the    SECS0311
C     PDB file is an NMR file containing several models of the structureSECS0312
CHECK v.3.2-->                                                          SECS0313
C      IF (PDBFIL(1:1).EQ.'@') THEN                                     SECS0314
C          NMR = .TRUE.                                                 SECS0315
C          PDBFIL = PDBFIL(2:)                                          SECS0316
C      ELSE                                                             SECS0317
C          NMR = .FALSE.                                                SECS0318
C      ENDIF                                                            SECS0319
C      FIRST = .TRUE.                                                   SECS0320
      IF (PDBFIL(1:1).EQ.'@') THEN                                      SECS0321
          NMR = .TRUE.                                                  SECS0322
          PDBFIL = PDBFIL(2:)                                           SECS0323
          FIRST = .TRUE.                                                SECS0324
          ENSEMB = .FALSE.                                              SECS0325
      ELSE IF (PDBFIL(1:1).EQ.'%') THEN                                 SECS0326
          ENSEMB = .TRUE.                                               SECS0327
          FIRST = .TRUE.                                                SECS0328
          NMR = .FALSE.                                                 SECS0329
      ELSE                                                              SECS0330
          ENSEMB = .FALSE.                                              SECS0331
          FIRST = .TRUE.                                                SECS0332
          NMR = .FALSE.                                                 SECS0333
      ENDIF                                                             SECS0334
CHECK v.3.2<--                                                          SECS0335
                                                                        SECS0336
C---- If this an NMR file, then open mplot.in file which will contain   SECS0337
C     the name of all the individual .new file output (one per model)   SECS0338
CHECK v.3.2-->                                                          SECS0339
C      IF (NMR) THEN                                                    SECS0340
      IF (ENSEMB .OR. NMR) THEN                                         SECS0341
CHECK v.3.2<--                                                          SECS0342
          OPEN(UNIT=MPLTFI, FILE='mplot.in', STATUS='UNKNOWN',          SECS0343
     &        FORM='FORMATTED', ACCESS='SEQUENTIAL',                    SECS0344
CVAX     -    CARRIAGECONTROL='LIST',RECL=132,                          SECS0345
     &    ERR=902)                                                      SECS0346
      ENDIF                                                             SECS0347
CHECK v.3.1<--                                                          SECS0348
                                                                        SECS0349
CHECK v.3.2-->                                                          SECS0350
C---- If processing a set of PDB files listed in the %filelist specifiedSECS0351
C     by the user, open the file-list                                   SECS0352
      fistat = ok                                                       SECS0353
      IF (ENSEMB) THEN                                                  SECS0354
          finam = PDBFIL                                                SECS0355
          finuse = .true.                                               SECS0356
          namlen = INDEX(finam,space)                                   SECS0357
          do 180 i = 1, namlen - 1                                      SECS0358
              finam(i:i) = finam(i+1:i+1)                               SECS0359
  180     continue                                                      SECS0360
          finam(namlen:namlen) = space                                  SECS0361
          open (namfi, file=finam, status='old',                        SECS0362
CVAX     -        READONLY,                                             SECS0363
     &        iostat=iocode)                                            SECS0364
          if (iocode .ne. 0) fistat = opnera                            SECS0365
          if (fistat.eq.opnera) GO TO 902                               SECS0366
      ENDIF                                                             SECS0367
CHECK v.3.2<--                                                          SECS0368
                                                                        SECS0369
CHECK v.3.2-->                                                          SECS0370
C---- If processing a list of structures, get the name of the next one  SECS0371
C     from the file list                                                SECS0372
 200  CONTINUE                                                          SECS0373
      IF (ENSEMB .AND. fistat .eq. ok) then                             SECS0374
          read (namfi, 10, iostat=iocode) brknam                        SECS0375
          if (iocode .lt. 0) then                                       SECS0376
             close (namfi)                                              SECS0377
             finuse = .false.                                           SECS0378
             fistat = endnfi                                            SECS0379
          else                                                          SECS0380
             namlen = index(brknam,space) - 1                           SECS0381
             write (*, 1030) brknam(1:namlen)                           SECS0382
 1030        format (' Working on Brookhaven file ',A,' . . . ')        SECS0383
          end if                                                        SECS0384
          PDBFIL = brknam                                               SECS0385
          NMR = .FALSE.                                                 SECS0386
      ENDIF                                                             SECS0387
CHECK v.3.2<--                                                          SECS0388
                                                                        SECS0389
C---- Peel off directory path and extension                             SECS0390
      CALL GETNAM(PDBFIL,ISTART,IEND,IERROR)                            SECS0391
      IF (IERROR) GO TO 999                                             SECS0392
                                                                        SECS0393
C---- Form names of other files that will be required in default dir    SECS0394
      ILEN = IEND - ISTART + 1                                          SECS0395
      BRCODE = ' '                                                      SECS0396
      BRKNAM = PDBFIL                                                   SECS0397
      NAMLEN = 78                                                       SECS0398
CHECK v.3.2-->                                                          SECS0399
C      OUTLEN = 78                                                      SECS0400
CHECK v.3.2<--                                                          SECS0401
CHECK v.2.1.4-->                                                        SECS0402
C      FILRES = PDBFIL(ISTART:IEND) // '.res'                           SECS0403
      FILRES = PDBFIL(ISTART:IEND) // '.rin'                            SECS0404
CHECK v.2.1.4<--                                                        SECS0405
CHECK v.2.1-->                                                          SECS0406
      BRKNAM = PDBFIL(ISTART:IEND) // '.new'                            SECS0407
CHECK v.2.1<--                                                          SECS0408
                                                                        SECS0409
                                                                        SECS0410
CHECK v.3.1-->                                                          SECS0411
CC---- Open the file that will hold the dihedral angles                 SECS0412
C      OPEN (UNIT=8,FILE=FILRES,STATUS='UNKNOWN',ERR=900                SECS0413
CCVAX     -    ,CARRIAGECONTROL='LIST'                                  SECS0414
C     -    )                                                            SECS0415
CHECK v.3.1<--                                                          SECS0416
                                                                        SECS0417
C---- Initialise B-values                                               SECS0418
      DO 20, I = 1, MAXRES                                              SECS0419
          MCBVAL(I) = 0.0                                               SECS0420
          SCBVAL(I) = 0.0                                               SECS0421
CHECK v.3.2-->                                                          SECS0422
          MCBSTD(I) = 0.0                                               SECS0423
          SCBSTD(I) = 0.0                                               SECS0424
CHECK v.3.2<--                                                          SECS0425
          NMCATM(I) = 0                                                 SECS0426
          NSCATM(I) = 0                                                 SECS0427
 20   CONTINUE                                                          SECS0428
CHECK v.2.0<--                                                          SECS0429
                                                                        SECS0430
c     write(*,*)'Do you require Standard or Full output (<S> or F)'     SECS0431
c     read(*,'(A1)')outsty                                              SECS0432
c     if (outsty .eq. 'F' .or. outsty .eq. 'f') then                    SECS0433
c        Outsty = 'F'                                                   SECS0434
c     else                                                              SECS0435
c        outsty = 'S'                                                   SECS0436
c     end if                                                            SECS0437
      Outsty = 'F'                                                      SECS0438
                                                                        SECS0439
CHECK v.1.0-->                                                          SECS0440
C      call getstr('Enter output directory',                            SECS0441
C     +            '/home/bsm/naylor/data/', outdir, outln, ifail)      SECS0442
C      if (ifail .ne. 0)  then                                          SECS0443
C         write(6,*) 'Error in GETSTR: Ifail = ', ifail                 SECS0444
C         stop                                                          SECS0445
C      end if                                                           SECS0446
C  100 continue                                                         SECS0447
CHECK v.1.0<--                                                          SECS0448
                                                                        SECS0449
CHECK v.3.2-->                                                          SECS0450
C      fistat = ok                                                      SECS0451
CHECK v.3.2<--                                                          SECS0452
c                                                                       SECS0453
c     get the next brk file or file of names from the user              SECS0454
c     finish is set when they've had enough                             SECS0455
c                                                                       SECS0456
                                                                        SECS0457
CHECK v.1.0-->                                                          SECS0458
C      write(*,*)'Enter the name of the next file to be processed.'     SECS0459
C      write(*,*)'  Just a file name for a Brookhaven format file'      SECS0460
C      write(*,'(a,a1,a,a)')'   ',Indirn,'file name for a file holding 'SECS0461
C     +                     'names of Brookhaven format files.'         SECS0462
C      write(*,*)'  If you''ve had enough a blank line let''s',         SECS0463
C     +          ' you escape!'                                         SECS0464
C      read(*,'(A)')finam                                               SECS0465
C      namlen = index(finam,space) - 1                                  SECS0466
C      if (namlen .le. 0) then                                          SECS0467
C         fistat = finish                                               SECS0468
C      else                                                             SECS0469
C         if (finam(1:1) .eq. indirn) then                              SECS0470
C            finuse = .true.                                            SECS0471
C            do 180 I = 1,namlen-1                                      SECS0472
C            finam(i:i) = finam(I+1:I+1)                                SECS0473
C  180       continue                                                   SECS0474
C            finam(namlen:namlen) = space                               SECS0475
C            open(unit=namfi,file=finam,status='old',iostat=iocode)     SECS0476
C            if (iocode .ne. 0) fistat = opnera                         SECS0477
C         end if                                                        SECS0478
C      end if                                                           SECS0479
CHECK v.1.0<--                                                          SECS0480
                                                                        SECS0481
c                                                                       SECS0482
c     get the brookhaven file name into the appropriate place           SECS0483
c     either from the file of names or the input name                   SECS0484
c                                                                       SECS0485
                                                                        SECS0486
CHECK v.1.0-->                                                          SECS0487
C  200 continue                                                         SECS0488
C      if (fistat .eq. ok) then                                         SECS0489
C         if (finuse) then                                              SECS0490
C            read(namfi,'(A)',iostat=iocode) brknam                     SECS0491
C            if (iocode .lt. 0) then                                    SECS0492
C               close(unit=namfi)                                       SECS0493
C               finuse = .false.                                        SECS0494
C               fistat = endnfi                                         SECS0495
C            else                                                       SECS0496
C               namlen = index(brknam,space) - 1                        SECS0497
C               write(*,*)brknam(1:namlen)                              SECS0498
C            end if                                                     SECS0499
C         else                                                          SECS0500
C            brknam = finam                                             SECS0501
C         end if                                                        SECS0502
C      end if                                                           SECS0503
CHECK v.1.0<--                                                          SECS0504
                                                                        SECS0505
c                                                                       SECS0506
c     open the brookhaven file if everything ok                         SECS0507
c                                                                       SECS0508
      If (fistat .eq. ok) then                                          SECS0509
CHECK v.1.0-->                                                          SECS0510
C         open (Unit=brkfi, file=brknam, status='old', iostat=iocode)   SECS0511
CHECK v.1.0<--                                                          SECS0512
         open (Unit=brkfi, file=brknam, status='old', iostat=iocode     SECS0513
CVAX     -         , READONLY                                           SECS0514
     &        )                                                         SECS0515
         if (iocode .ne. 0) fistat = opnerb                             SECS0516
      end if                                                            SECS0517
                                                                        SECS0518
CHECK v.1.0-->                                                          SECS0519
C      if (fistat .eq. ok) then                                         SECS0520
C         nodepl = index(brknam,'::')                                   SECS0521
C         if (nodepl .ne. 0) then                                       SECS0522
C            logpl = nodepl + 1 + index(brknam(nodepl+2:),':')          SECS0523
C         else                                                          SECS0524
C            logpl = index(brknam,':')                                  SECS0525
C         end if                                                        SECS0526
C         dirpl = index(brknam,']')                                     SECS0527
C         corepl = max(logpl,dirpl) + 1                                 SECS0528
C         corepl = lastsl(brknam) + 1                                   SECS0529
C         corend = corepl - 1 + index(brknam(corepl:),'.') - 1          SECS0530
C         if (corend .eq. corepl - 2) corend = namlen                   SECS0531
C         if (corend .lt. corepl) then                                  SECS0532
C            write (6,*) brknam(1:namlen)                               SECS0533
C            fistat = opnerc                                            SECS0534
C         end if                                                        SECS0535
C         brklen = corend - corepl + 1                                  SECS0536
C         outnam = outdir(1:outln)//brknam(corepl:corend)// '.sst'      SECS0537
C         outlen = outln + brklen + 4                                   SECS0538
C      end if                                                           SECS0539
CHECK v.1.0<--                                                          SECS0540
                                                                        SECS0541
CHECK v.3.1-->                                                          SECS0542
C---- If this is an NMR structure, then will loop back to here until    SECS0543
C     all models have been individually processed                       SECS0544
 100  CONTINUE                                                          SECS0545
                                                                        SECS0546
CHECK v.3.2-->                                                          SECS0547
C      IF (NMR) THEN                                                    SECS0548
      if (fistat.eq.ok) then                                            SECS0549
CHECK v.3.2<--                                                          SECS0550
                                                                        SECS0551
C----     Loop until first ATOM record encountered, or a MODEL record   SECS0552
C         is found (indicating an NMR structure) or end-of-file         SECS0553
c         encountered                                                   SECS0554
CHECK v.3.2-->                                                          SECS0555
C          CALL GETMOD(BRKFI,IMODEL,MXMODL,ENDFIL,IERROR)               SECS0556
CHECK v.3.4-->                                                          SECS0557
C          CALL GETMOD(BRKFI,IMODEL,MXMODL,ENDFIL,IERROR,NMR)           SECS0558
          CALL GETMOD(BRKFI,IMODEL,MXMODL,MODLNO,ENDFIL,IERROR,NMR)     SECS0559
CHECK v.3.4<--                                                          SECS0560
CHECK v.3.2<--                                                          SECS0561
                                                                        SECS0562
C----     Check whether end of file or data error encountered           SECS0563
          IF (ENDFIL) GO TO 500                                         SECS0564
          IF (IERROR) GO TO 999                                         SECS0565
                                                                        SECS0566
C----     Set up filename for .new output file for this model           SECS0567
CHECK v.3.2-->                                                          SECS0568
          IF (NMR) THEN                                                 SECS0569
CHECK v.3.2<--                                                          SECS0570
CHECK v.3.4-->                                                          SECS0571
C              WRITE(CMODEL,120) IMODEL                                 SECS0572
              WRITE(CMODEL,120) MODLNO                                  SECS0573
CHECK v.3.4<--                                                          SECS0574
 120          FORMAT(I3)                                                SECS0575
              IF (CMODEL(1:1).EQ.' ') CMODEL(1:1) = '0'                 SECS0576
              IF (CMODEL(2:2).EQ.' ') CMODEL(2:2) = '0'                 SECS0577
              FILRES = PDBFIL(ISTART:IEND) // '_' // CMODEL // '.rin'   SECS0578
              NMODEL = NMODEL + 1                                       SECS0579
          ENDIF                                                         SECS0580
CHECK v.3.2<--                                                          SECS0581
                                                                        SECS0582
CHECK v.3.2-->                                                          SECS0583
C----     Write this name out to the mplot.in file                      SECS0584
C          WRITE(MPLTFI,140) FILRES(1:ILEN + 8)                         SECS0585
C 140      FORMAT(A)                                                    SECS0586
C----     Write this name out to the mplot.in file                      SECS0587
          IF (ENSEMB .OR. NMR) THEN                                     SECS0588
              WRITE(MPLTFI,140) FILRES(1:ILEN + 8)                      SECS0589
 140          FORMAT(A)                                                 SECS0590
          ENDIF                                                         SECS0591
CHECK v.3.2<--                                                          SECS0592
                                                                        SECS0593
C----     Close previous .new file, if it exists                        SECS0594
          IF (.NOT.FIRST) CLOSE(8)                                      SECS0595
          FIRST = .FALSE.                                               SECS0596
CHECK v.3.2-->                                                          SECS0597
          IF (NMR) THEN                                                 SECS0598
CHECK v.3.2<--                                                          SECS0599
              PRINT*                                                    SECS0600
CHECK v.3.4-->                                                          SECS0601
C              PRINT*, '   Processing NMR model', IMODEL                SECS0602
              PRINT*, '   Processing NMR model', MODLNO                 SECS0603
CHECK v.3.4<--                                                          SECS0604
CHECK v.3.2-->                                                          SECS0605
          ENDIF                                                         SECS0606
CHECK v.3.2<--                                                          SECS0607
      ENDIF                                                             SECS0608
CHECK v.3.1<--                                                          SECS0609
                                                                        SECS0610
CHECK v.3.1-->                                                          SECS0611
C---- Open the file that will hold the dihedral angles                  SECS0612
      OPEN (UNIT=8,FILE=FILRES,STATUS='UNKNOWN',ERR=900                 SECS0613
CVAX     -    ,CARRIAGECONTROL='LIST'                                   SECS0614
     &    )                                                             SECS0615
CHECK v.3.1<--                                                          SECS0616
                                                                        SECS0617
c                                                                       SECS0618
c     if survived this far have a file to process otherwise             SECS0619
c     provide error messages                                            SECS0620
c                                                                       SECS0621
      if (fistat .eq. ok) then                                          SECS0622
c       **Process file                                                  SECS0623
         open(unit = errfi, status = 'SCRATCH')                         SECS0624
         readok = .true.                                                SECS0625
         caonly = .true.                                                SECS0626
         astruc = .false.                                               SECS0627
         call rdbrk(mcaaat, atname, atomin, aacod3, hetcod, seqcod,     SECS0628
     &              seqbcd, scaaat, scatin, altcod, aastd,  atpres,     SECS0629
     &              thmprs, caonly, astruc, headln, hedlen, readok,     SECS0630
     &              dudcod, modcod, stdmod, nstdmd, modpl,  seqlen,     SECS0631
                                                                        SECS0632
CHECK v.1.0-->                                                          SECS0633
C     +              batnam)                                            SECS0634
CHECK v.2.0-->                                                          SECS0635
C     +              batnam, BVALUE)                                    SECS0636
CHECK v.3.1-->                                                          SECS0637
C     +              batnam, BVALUE,MCBVAL,SCBVAL,NMCATM,NSCATM)        SECS0638
CHECK v.3.2-->                                                          SECS0639
C     +              batnam, BVALUE,MCBVAL,SCBVAL,NMCATM,NSCATM,NMR)    SECS0640
     &              batnam, BVALUE,MCBVAL,SCBVAL,NMCATM,NSCATM,NMR,     SECS0641
     &              MCBSTD,SCBSTD)                                      SECS0642
CHECK v.3.2<--                                                          SECS0643
CHECK v.3.1<--                                                          SECS0644
CHECK v.2.0<--                                                          SECS0645
CHECK v.1.0<--                                                          SECS0646
                                                                        SECS0647
CHECK v.3.3.1-->                                                        SECS0648
C         if (readok .and. .not. caonly) then                           SECS0649
         if (readok) then                                               SECS0650
CHECK v.3.3.1<--                                                        SECS0651
                                                                        SECS0652
CHECK v.1.0-->                                                          SECS0653
C            open(unit=outfi,file=outnam,status='unknown',iostat=iocode)SECS0654
CHECK v.1.0<--                                                          SECS0655
                                                                        SECS0656
CHECK v.3.2-->                                                          SECS0657
C            if (iocode .ne. 0) fistat = opnerc                         SECS0658
CHECK v.3.2<--                                                          SECS0659
c           ** look for breaks accross the peptide bonds                SECS0660
            call chnbrk(mcaaat, atomin, seqbcd, brksym, chnsz, chnct,   SECS0661
     &                  chnend, caonly, seqlen)                         SECS0662
c           ** determine the calpha distances i+2 to i+11               SECS0663
            if (outsty .eq. 'F')                                        SECS0664
CHECK v.3.2-->                                                          SECS0665
C     +         call mkcadt(mcaaat, atomin, cadsts, seqbcd, chnsz, chnctSECS0666
C     +                     seqlen)                                     SECS0667
     &         call mkcadt(mcaaat, atomin, cadsts, seqbcd,              SECS0668
     &                     seqlen)                                      SECS0669
CHECK v.3.2<--                                                          SECS0670
c           ** create hydrogen atoms on the main chain nitrogens        SECS0671
CHECK v.3.2-->                                                          SECS0672
C            call creatH(mcaaat, atomin, chnsz, chnct, seqlen)          SECS0673
            call creatH(mcaaat, atomin, chnsz, chnct)                   SECS0674
CHECK v.3.2<--                                                          SECS0675
c           ** determine all hydrogen bonds                             SECS0676
            call mkhbnd(mcaaat, atomin, hbond, hbonde, seqcod, chnend,  SECS0677
     &                  seqlen)                                         SECS0678
c           ** calculate OOI numbers                                    SECS0679
            call ooi(atomin, mcaaat, seqbcd, oois, seqlen)              SECS0680
c           ** find main chain torsion angles                           SECS0681
                                                                        SECS0682
CHECK v.1.0-->                                                          SECS0683
C            call mkangl(mcaaat, mcangs, atomin, chnsz, chnct, caonly,  SECS0684
C     +                  seqlen)                                        SECS0685
            call mkangl(mcaaat, mcangs, atomin, chnsz, chnct, caonly,   SECS0686
     &                  seqlen, scaaat, scatin)                         SECS0687
CHECK v.1.0<--                                                          SECS0688
                                                                        SECS0689
c           ** find sidechain chi angles                                SECS0690
            if (outsty .eq. 'F')                                        SECS0691
     &         call mksang(mcaaat, atomin, scaaat, scangs, scatin,      SECS0692
     &                     seqcod, aacod3, hetcod, seqlen)              SECS0693
c           ** determine turns, bridges and sheets                      SECS0694
            call mktb(hbond, ssbond, mcangs, bridpt, chnend, seqlen)    SECS0695
c           ** determine bend residues                                  SECS0696
            call mkbend(mcangs, ssbond, seqlen)                         SECS0697
c           ** make Kabsch and Sander type 2ndry structure summary      SECS0698
            call mksumm(ssbond, sssumm, summpl, seqlen)                 SECS0699
c           ** make the authors atructure                               SECS0700
            call mkauth(seqbcd, autsum, ssord, astruc, seqlen)          SECS0701
c           ** find all disulphide bonds                                SECS0702
            if (outsty .eq. 'F')                                        SECS0703
     &         call disulf(seqbcd, dsdsts, scangs, scaaat, scatin,      SECS0704
     &                     atomin, mcaaat, seqcod, dsdef, dspart,       SECS0705
     &                     astruc, seqlen)                              SECS0706
c           ** produce the output file                                  SECS0707
CHECK v.3.2-->                                                          SECS0708
C            call result(hbonde, hbond,  aacod3, aacod1, seqcod, seqbcd,SECS0709
C     +                  brksym, ssbond, bridpt, sssumm, summpl, autsum,SECS0710
C     +                  mcangs, altcod, aastd,  atpres, thmprs, scangs,SECS0711
C     +                  cadsts, brknam, headln, hedlen, outsty, dsdsts,SECS0712
            call result(hbonde, aacod3, aacod1, seqcod, seqbcd,         SECS0713
     &                  brksym, ssbond, sssumm, summpl, autsum,         SECS0714
     &                  mcangs, scangs,                                 SECS0715
     &                  outsty, dsdsts,                                 SECS0716
CHECK v.3.2<--                                                          SECS0717
                                                                        SECS0718
CHECK v.1.0-->                                                          SECS0719
C     +                  dsdef,  dspart, hetcod, oois,   seqlen)        SECS0720
CHECK v.2.0-->                                                          SECS0721
C     +                  dsdef,  dspart, hetcod, oois,   seqlen, BVALUE)SECS0722
CHECK v.3.2-->                                                          SECS0723
C     +                  dsdef,  dspart, hetcod, oois,   seqlen, BVALUE,SECS0724
C     -                  MCBVAL,SCBVAL,NMCATM,NSCATM)                   SECS0725
     &                  hetcod, oois,   seqlen, BVALUE,                 SECS0726
     &                  MCBVAL,SCBVAL,NMCATM,NSCATM,MCBSTD,SCBSTD)      SECS0727
CHECK v.3.2<--                                                          SECS0728
CHECK v.2.0<--                                                          SECS0729
CHECK v.1.0<--                                                          SECS0730
                                                                        SECS0731
CHECK v.1.0-->                                                          SECS0732
C            close(unit=outfi)                                          SECS0733
CHECK v.1.0<--                                                          SECS0734
                                                                        SECS0735
         else                                                           SECS0736
c           close(unit=outfi)                                           SECS0737
            if (readok .and. caonly .and. outsty .eq. 'F') then         SECS0738
CHECK v.3.2-->                                                          SECS0739
C               outnam = outdir(1:outln)//brknam(corepl:corend) // '.scaSECS0740
               iostat = ok                                              SECS0741
CHECK v.3.2<--                                                          SECS0742
                                                                        SECS0743
CHECK v.1.0-->                                                          SECS0744
C               open(unit=outfi,file=outnam,status='unknown',           SECS0745
C     +              iostat=iocode)                                     SECS0746
CHECK v.1.0<--                                                          SECS0747
                                                                        SECS0748
               if (iostat .ne. ok) then                                 SECS0749
CHECK v.3.2-->                                                          SECS0750
C                  write(*,*)'Unable to open output file ',             SECS0751
C     +                      outnam(1:outlen)                           SECS0752
CHECK v.3.2<--                                                          SECS0753
                  close(unit=errfi)                                     SECS0754
               else                                                     SECS0755
                  call chnbrk(mcaaat, atomin, seqbcd, brksym, chnsz,    SECS0756
     &                        chnct,  chnend, caonly, seqlen)           SECS0757
CHECK v.3.2-->                                                          SECS0758
C                  call mkcadt(mcaaat, atomin, cadsts, seqbcd, chnsz,   SECS0759
C     +                        chnct,  seqlen)                          SECS0760
                  call mkcadt(mcaaat, atomin, cadsts, seqbcd,           SECS0761
     &                        seqlen)                                   SECS0762
CHECK v.3.2<--                                                          SECS0763
                  call ooi(atomin, mcaaat, seqbcd, oois, seqlen)        SECS0764
                                                                        SECS0765
CHECK v.1.0-->                                                          SECS0766
C                  call mkangl(mcaaat, mcangs, atomin, chnsz, chnct,    SECS0767
C     +                        caonly, seqlen)                          SECS0768
                  call mkangl(mcaaat, mcangs, atomin, chnsz, chnct,     SECS0769
     &                        caonly, seqlen, scaaat, scatin)           SECS0770
CHECK v.1.0<--                                                          SECS0771
                                                                        SECS0772
                  call mkauth(seqbcd, autsum, ssord, astruc, seqlen)    SECS0773
CHECK v.3.2-->                                                          SECS0774
C                  call carslt(aacod3, aacod1, seqcod, seqbcd, mcangs,  SECS0775
C     +                        cadsts, brksym, altcod, aastd,  brknam,  SECS0776
C     +                        headln, hedlen, autsum, hetcod, oois,    SECS0777
C     +                        seqlen)                                  SECS0778
                  call carslt(aacod3, aacod1, seqcod, hetcod, seqlen)   SECS0779
CHECK v.3.2<--                                                          SECS0780
               end if                                                   SECS0781
            else                                                        SECS0782
               close(unit=errfi)                                        SECS0783
            end if                                                      SECS0784
            if (astruc) close(unit=authfi)                              SECS0785
CHECK v.2.1.3-->                                                        SECS0786
C            if (caonly .and. readok) write(*,*)'C-alpha only file'     SECS0787
C            if (.not. readok) write(*,*)'Error while reading file'     SECS0788
            if (caonly .and. readok) write(*,*)'**** C-alpha only file' SECS0789
            if (.not. readok) write(*,*)'**** Error while reading file' SECS0790
CHECK v.2.1.3<--                                                        SECS0791
         end if                                                         SECS0792
      else                                                              SECS0793
         if (fistat .eq. opnera) then                                   SECS0794
CHECK v.3.2-->                                                          SECS0795
C            write(*,*)'Unable to open the file of file names ',        SECS0796
C     +                 finam(1:namlen)                                 SECS0797
CHECK v.3.2<--                                                          SECS0798
            finuse = .false.                                            SECS0799
         else                                                           SECS0800
            if (fistat .eq. opnerb) then                                SECS0801
               write(*,*)'Unable to open the Brookhaven format file ',  SECS0802
     &                   brknam(1:namlen)                               SECS0803
            else                                                        SECS0804
               if (fistat .eq. opnerc) then                             SECS0805
CHECK v.3.2-->                                                          SECS0806
C                  write(*,*)'Unable to open output file ',             SECS0807
C     +                      outnam(1:outlen)                           SECS0808
CHECK v.3.2<--                                                          SECS0809
               end if                                                   SECS0810
            end if                                                      SECS0811
         end if                                                         SECS0812
      end if                                                            SECS0813
c                                                                       SECS0814
c     if they want more we'll cooperate                                 SECS0815
c                                                                       SECS0816
                                                                        SECS0817
CHECK v.1.0-->                                                          SECS0818
C      if (fistat .ne. finish) then                                     SECS0819
C         fistat = ok                                                   SECS0820
C         if (finuse) then                                              SECS0821
C            go to 200                                                  SECS0822
C         else                                                          SECS0823
C            go to 100                                                  SECS0824
C         end if                                                        SECS0825
C      end if                                                           SECS0826
CHECK v.1.0<--                                                          SECS0827
                                                                        SECS0828
CHECK v.3.1-->                                                          SECS0829
C---- If this is an NMR structure, then loop back for next model        SECS0830
CHECK v.3.2-->                                                          SECS0831
C      IF (NMR) GO TO 100                                               SECS0832
      IF (NMR .AND. fistat.eq.ok) GO TO 100                             SECS0833
CHECK v.3.2<--                                                          SECS0834
                                                                        SECS0835
C---- If this is an NMR structure, show how many models have been       SECS0836
c     processed                                                         SECS0837
 500  CONTINUE                                                          SECS0838
      IF (NMR) THEN                                                     SECS0839
          PRINT*                                                        SECS0840
          PRINT*, '* NMR ensemble comprises', NMODEL, ' model ',        SECS0841
     &        'structures'                                              SECS0842
      ENDIF                                                             SECS0843
CHECK v.3.1<--                                                          SECS0844
                                                                        SECS0845
CHECK v.3.2-->                                                          SECS0846
      if (fistat .ne. finish) then                                      SECS0847
         fistat = ok                                                    SECS0848
         if (finuse) then                                               SECS0849
            goto 200                                                    SECS0850
         end if                                                         SECS0851
      end if                                                            SECS0852
CHECK v.3.2<--                                                          SECS0853
                                                                        SECS0854
CHECK v.1.0-->                                                          SECS0855
      GO TO 999                                                         SECS0856
                                                                        SECS0857
C---- Fatal errors                                                      SECS0858
 900  CONTINUE                                                          SECS0859
CHECK v.2.1.4-->                                                        SECS0860
C      PRINT*, '**** ERROR. Unable to open .res file'                   SECS0861
      PRINT*, '**** ERROR. Unable to open .rin file'                    SECS0862
CHECK v.2.1.4<--                                                        SECS0863
      GO TO 999                                                         SECS0864
                                                                        SECS0865
CHECK v.3.1-->                                                          SECS0866
 902  CONTINUE                                                          SECS0867
      PRINT*, '*** ERROR opening mplot.in file. Program aborted'        SECS0868
      GO TO 999                                                         SECS0869
CHECK v.3.1<--                                                          SECS0870
                                                                        SECS0871
 999  CONTINUE                                                          SECS0872
CHECK v.1.0<--                                                          SECS0873
CHECK v.3.0-->                                                          SECS0874
      PRINT*, '* Program completed'                                     SECS0875
CHECK v.3.0<--                                                          SECS0876
                                                                        SECS0877
      END                                                               SECS0878
