      PROGRAM BPLOT                                                     BPLO0001
c ----------------------------------------------------------------------BPLO0002
c                                                                       BPLO0003
c  Windows NT / Win 95 code                                             BPLO0004
c                                                                       BPLO0005
c  Bernhard Rupp 1996 - minor modifications.                            BPLO0006
c                                                                       BPLO0007
c  1.  comment lines restricted to 72 columns                           BPLO0008
c  2.  source code lines numbered                                       BPLO0009
c  3.  to read file name of input file as parameter otherwise ask       BPLO0010
c  4.  taken apart into subroutines                                     BPLO0011
c                                                                       BPLO0012
c      Changes are annotated by WINNT at the beginning of comment lines BPLO0013
c                                                                       BPLO0014
C-----------------------------------------------------------------------BPLO0015
C                                                                       BPLO0016
C  BPLOT.FOR  -  Program to plot histograms of the main-chain bond      BPLO0017
C                length and bond angle data calculated by program       BPLO0018
C                anglen and stored in the appropriat.lan file           BPLO0019
C                                                                       BPLO0020
C     Written by Roman Laskowski, University College, London,           BPLO0021
C     November 1993.                                                    BPLO0022
C                                                                       BPLO0023
C     Original version was part of v.2.2 of the PROCHECK suite of       BPLO0024
C     programs.                                                         BPLO0025
C                                                                       BPLO0026
C     Amendments after v.3.0 will be labelled by CHECK v.m.n--> and     BPLO0027
C     CHECK v.m.n<-- where m.n is the version number corresponding to   BPLO0028
C     the change                                                        BPLO0029
C                                                                       BPLO0030
C  v.3.0   - Amendments to PostScript to routines to ensure that any    BPLO0031
C            lines output to the output PostScript file are not longer  BPLO0032
C            than 80 characters (as some laser printers can't cope with BPLO0033
C            long lines!)                                               BPLO0034
C            Small change to ensure that the final comment on the       BPLO0035
C            distorted geometry plots isn't sometimes lost when the     BPLO0036
C            pictures are close to the bottom of the page.              BPLO0037
C            Complete overhaul of parameter file, procheck.prm,         BPLO0038
C            including addition of colour options.                      BPLO0039
C            Addition of option to accept a single chain-ID to restrict BPLO0040
C            all the plots to just the residues of a single chain.      BPLO0041
C            Roman Laskowski (14 Nov-14 Dec 1993)                       BPLO0042
C  v.3.1   - Transfer of FINKEY, GETCOL and GETNAM routines to ps.f.    BPLO0043
C            Unit number for procheck.prm file changed to 10 for        BPLO0044
C            consistency.                                               BPLO0045
C            Addition of plot description to display of plot file name. BPLO0046
C            Roman Laskowski (8-19 Apr 1994)                            BPLO0047
C  v.3.2   - Addition of identifying plot handle to each plot filename. BPLO0048
C            Addition of descriptive plot title to header of PostScript BPLO0049
C            file.                                                      BPLO0050
C            Addition of .sum file holding a summary page.              BPLO0051
C            Addition of option to print plot filename on the plot      BPLO0052
C            itself. Chain ID made case-insensitive.                    BPLO0053
C            Where a bond length/angle spans two residues on the        BPLO0054
C            Distorted Geometry plot, change made to show both residue  BPLO0055
C            names.                                                     BPLO0056
C            Roman Laskowski (25 Apr-3 May 1994)                        BPLO0057
C            Addition of option allowing plots of same type to be       BPLO0058
C            combined in a single PostScript file.                      BPLO0059
C            Roman Laskowski (12 Oct 1994)                              BPLO0060
C            Minor amendments to various statements to make them        BPLO0061
C            acceptable to f2c, and to deal with various uninitialised  BPLO0062
C            variables.(Amendments supplied by Dave Love at Daresbury). BPLO0063
C            David Love/Roman Laskowski (18 Oct 1994)                   BPLO0064
C                                                                       BPLO0065
C  v.3.3.2 - Output of summary statistics in html format                BPLO0066
C            Roman Laskowski (21 Aug 1995)                              BPLO0067
C  v.3.4   - Amendments to PSPAGE calls to comply with additional       BPLO0068
C            parameter (used by other programs).                        BPLO0069
C            Roman Laskowski (25 Mar 1996)                              BPLO0070
C            Increase of number of colours that can be user-defined.    BPLO0071
C            Roman Laskowski (24 Apr 1996)                              BPLO0072
C                                                                       BPLO0073
C-----------------------------------------------------------------------BPLO0074
C                                                                       BPLO0075
C Compilation and linking (on unix)                                     BPLO0076
C -----------------------                                               BPLO0077
C                                                                       BPLO0078
C f77 -u -c bplot.f                                                     BPLO0079
C f77 -u -c ps.f                                                        BPLO0080
C f77 -o bplot bplot.o ps.o                                             BPLO0081
C                                                                       BPLO0082
C Compilation and linking (on VAX VMS)                                  BPLO0083
C -----------------------                                               BPLO0084
C                                                                       BPLO0085
C FORT BPLOT                                                            BPLO0086
C FORT PS                                                               BPLO0087
C LINK BPLOT, PS                                                        BPLO0088
C                                                                       BPLO0089
C-----------------------------------------------------------------------BPLO0090
C                                                                       BPLO0091
C     Files                                                             BPLO0092
C     -----                                                             BPLO0093
C                                                                       BPLO0094
C  2  <filename>.lan - File generated by program ANGLEN, holding all theBPLO0095
C                      mainchain bond lengths and bond angles           BPLO0096
C  3  <filename>.pln - File generated by program ANGLEN, holding the    BPLO0097
C                      transformed coordinates of all the planar groups BPLO0098
C  10 procheck.prm   - Input parameter file containing user-defined     BPLO0099
C                      options governing the plots produced.            BPLO0100
C  11 <filename>.dnn - Output PostScript files, numbered nn = 01, 02, ..BPLO0101
C                      with the last-used number being picked up from   BPLO0102
C                      the ps.number file                               BPLO0103
C  12  ps.number     - Input file holding last-used number for the      BPLO0104
C                      PostScript files                                 BPLO0105
C  14 <filename>.sum - Output summary page showing summarised results   BPLO0106
C                      from all the plots                               BPLO0107
C  15 <filename>.html- Output html file giving summary statistics in    BPLO0108
C                      html format                                      BPLO0109
C                                                                       BPLO0110
C-----------------------------------------------------------------------BPLO0111
C                                                                       BPLO0112
C     Subroutine calling tree                                           BPLO0113
C     -----------------------                                           BPLO0114
C                                                                       BPLO0115
C     MAIN    --> INITS                                                 BPLO0116
C             --> PARAMS   --> FINKEY                                   BPLO0117
C                          --> GETCOL                                   BPLO0118
C             --> GETPSN                                                BPLO0119
C                                                                       BPLO0120
C                 Get filename and resolution of structure              BPLO0121
C             --> GETCOD   --> GETNAM                                   BPLO0122
C             --> OPESUM                                                BPLO0123
C             --> OPEHTM                                                BPLO0124
C                                                                       BPLO0125
C                 Read through bond lengths/angles file to calculate    BPLO0126
C                 minimum, maximum and means values                     BPLO0127
C             --> GETLAN                                                BPLO0128
C                                                                       BPLO0129
C                 Plot the histograms for main-chain bond lengths, bond BPLO0130
C                 angles and planar groups                              BPLO0131
C             --> HPLOTS  --> HBOUND                                    BPLO0132
C                         --> HCOUNT                                    BPLO0133
C                         --> BARPLT  --> BAREND  --> PSENDP            BPLO0134
C                                                 --> PSCLOS            BPLO0135
C                                                 --> PSCTXT            BPLO0136
C                                                 --> PSRCTX            BPLO0137
C                                                 --> PSHADE            BPLO0138
C                                                 --> PSTRIA            BPLO0139
C                                                 --> PSTEXT            BPLO0140
C                                     --> BARHED  --> PSNAME            BPLO0141
C                                                 --> PSPAGE            BPLO0142
C                                                 --> PSOPEN            BPLO0143
C                                                 --> PSLWID            BPLO0144
C                                                 --> PSCTXT            BPLO0145
C                                     --> PSLWID                        BPLO0146
C                                     --> PSHADE                        BPLO0147
C                                     --> PSDASH                        BPLO0148
C                                     --> PSBBOX                        BPLO0149
C                                     --> AXES    --> PSLWID            BPLO0150
C                                                 --> PSLINE            BPLO0151
C                                                 --> PSCTXT            BPLO0152
C                                     --> BARTXT  --> PSCTXT            BPLO0153
C                                     --> BARLIN  --> PSLWID            BPLO0154
C                                                 --> PSDASH            BPLO0155
C                                                 --> PSLINE            BPLO0156
C                                     --> BARDRW  --> PSHADE            BPLO0157
C                                                 --> PSBBOX            BPLO0158
C                                                 --> PSTEXT            BPLO0159
C                                                 --> PSLINE            BPLO0160
C                                     --> BAROFF  --> PSHADE            BPLO0161
C                                                 --> PSTRIA            BPLO0162
C                                                                       BPLO0163
C                 Plot distorted geometry                               BPLO0164
C             --> DISTGM  --> DGPLOT  --> REAPLN                        BPLO0165
C                                     --> REALAN                        BPLO0166
C                                     --> DISEND  --> PSENDP            BPLO0167
C                                                 --> PSCLOS            BPLO0168
C                                     --> DISHED  --> PSNAME            BPLO0169
C                                                 --> PSPAGE            BPLO0170
C                                                 --> PSOPEN            BPLO0171
C                                                 --> PSLWID            BPLO0172
C                                                 --> PSCTXT            BPLO0173
C                                     --> DRWLIN  --> PSCTXT            BPLO0174
C                                                 --> PSLWID            BPLO0175
C                                                 --> PSLINE            BPLO0176
C                                                 --> PSHADE            BPLO0177
C                                                 --> PSBBOX            BPLO0178
C                                     --> DRWANG  --> PSCTXT            BPLO0179
C                                                 --> PSLWID            BPLO0180
C                                                 --> PSLINE            BPLO0181
C                                                 --> PSHADE            BPLO0182
C                                                 --> PSBBOX            BPLO0183
C                                     --> DRWPLN  --> PSCTXT            BPLO0184
C                                                 --> PSLWID            BPLO0185
C                                                 --> PSLINE            BPLO0186
C                                                 --> PSHADE            BPLO0187
C                                                 --> PSBBOX            BPLO0188
C                                                                       BPLO0189
C-----------------------------------------------------------------------BPLO0190
                                                                        BPLO0191
      INCLUDE 'bplot.inc'                                               BPLO0192
                                                                        BPLO0193
WINNT - newfil is a parameter now                                       BPLO0194
      logical newfil                                                    BPLO0195
C---- Initialise variables                                              BPLO0196
      CALL INITS                                                        BPLO0197
      newfil=.false.                                                    BPLO0198
WINNT - newfil is false for BPLOT                                       BPLO0199
                                                                        BPLO0200
C---- Read in the program parameters                                    BPLO0201
      CALL PARAMS                                                       BPLO0202
      IF (IFAIL) GO TO 999                                              BPLO0203
                                                                        BPLO0204
C---- Read in the last-used plot-number for the PostScript files        BPLO0205
      CALL GETPSN(IPLOT)                                                BPLO0206
                                                                        BPLO0207
C---- Read in the code of the Brookhaven file and the structure's resoluBPLO0208
      CALL GETCOD                                                       BPLO0209
      IF (IFAIL) GO TO 999                                              BPLO0210
                                                                        BPLO0211
CHECK v.3.2-->                                                          BPLO0212
C---- Open the summary file                                             BPLO0213
WINNT - fork newfil over to OPESUM                                      BPLO0214
      CALL OPESUM(FILSUM,newfil,IFAIL)                                  BPLO0215
      IF (IFAIL) GO TO 999                                              BPLO0216
CHECK v.3.2<--                                                          BPLO0217
                                                                        BPLO0218
CHECK v.3.3.2-->                                                        BPLO0219
C---- Open the html file                                                BPLO0220
WINNT - fork newfil over to OPEHTM                                      BPLO0221
      CALL OPEHTM(FILHTM,newfil,IFAIL)                                  BPLO0222
      IF (IFAIL) GO TO 999                                              BPLO0223
CHECK v.3.3.2<--                                                        BPLO0224
                                                                        BPLO0225
C---- Read through the bond lengths and bond angles file to find the meaBPLO0226
C     and maximum and minimum values                                    BPLO0227
      CALL GETLAN                                                       BPLO0228
      IF (IFAIL) GO TO 999                                              BPLO0229
                                                                        BPLO0230
C---- Perform the histogram plots                                       BPLO0231
      CALL HPLOTS                                                       BPLO0232
      IF (IFAIL) GO TO 999                                              BPLO0233
                                                                        BPLO0234
C---- Perform plots of distorted geometry                               BPLO0235
      IF (PLOTDG) CALL DISTGM                                           BPLO0236
      IF (IFAIL) GO TO 999                                              BPLO0237
                                                                        BPLO0238
 999  CONTINUE                                                          BPLO0239
      IF (IFAIL) THEN                                                   BPLO0240
         PRINT*, '*** Program terminated with error'                    BPLO0241
CHECK v.3.2-->                                                          BPLO0242
          WRITE(14,*)                                                   BPLO0243
          WRITE(14,*) '*** Program bplot terminated with error. See lo',BPLO0244
     &        'g file:  bplot.log'                                      BPLO0245
          WRITE(14,*)                                                   BPLO0246
CHECK v.3.2<--                                                          BPLO0247
      ELSE                                                              BPLO0248
         PRINT*, '* Program complete'                                   BPLO0249
      ENDIF                                                             BPLO0250
                                                                        BPLO0251
CHECK v.3.2-->                                                          BPLO0252
C---- Write closing line(s) to the summary file                         BPLO0253
      WRITE(14,1010)                                                    BPLO0254
 1010 FORMAT(' +------------------------------------------------------',BPLO0255
     &    '----------------------+',/,                                  BPLO0256
     &       '   + May be worth investigating further.  * Worth invest',BPLO0257
     &    'igating further.',/)                                         BPLO0258
                                                                        BPLO0259
C---- Display name of summary file                                      BPLO0260
      PRINT*, '*'                                                       BPLO0261
      PRINT*, '* Summary page: ', FILSUM(1:ILEN + 4)                    BPLO0262
      PRINT*, '*'                                                       BPLO0263
CHECK v.3.2<--                                                          BPLO0264
                                                                        BPLO0265
      END                                                               BPLO0266
