      SUBROUTINE BARDRW(XL,YB,YT,SCALEX,IMAIN,WIDTH,MFREQ,NHIGHL,NWITHN)BARD001
C----------------------------------------------------------------------+BARD002
C                                                                       BARD003
C  SUBROUTINE BARDRW  -  Plot the histogram bars for this graph         BARD004
C                                                                       BARD005
C----------------------------------------------------------------------+BARD006
                                                                        BARD007
CHECK v.3.2-->                                                          BARD008
C      SUBROUTINE BARDRW(XL,YB,YT,SCALEX,IMAIN,WIDTH,MFREQ)             BARD009
CHECK v.3.2<--                                                          BARD010
                                                                        BARD011
      INCLUDE 'bplot.inc'                                               BARD012
                                                                        BARD013
CHECK v.3.2-->                                                          BARD014
C      INTEGER       COLOUR, IBAR, IFREQ, IMAIN, IPLANE, MFREQ          BARD015
      INTEGER       COLOUR, IBAR, IFREQ, IMAIN, IPLANE, MFREQ, NHIGHL,  BARD016
     &              NWITHN                                              BARD017
CHECK v.3.2<--                                                          BARD018
      LOGICAL       PLANE                                               BARD019
      REAL          CUTOFF, DX, DIST1, DIST2, SCALEX, SHADE, WIDTH, X1, BARD020
     &              X2, XCUT, XL, Y1, Y2, YB, YHT, YT                   BARD021
                                                                        BARD022
C---- Initialise plot positions                                         BARD023
      CALL PSLWID(0.1)                                                  BARD024
      IF (IMAIN.GT.NMAIN) THEN                                          BARD025
          PLANE = .TRUE.                                                BARD026
          IPLANE = IMAIN - NMAIN                                        BARD027
                                                                        BARD028
C----     Calculate cutoff defining whether bars are to be shaded black.BARD029
          IF (NPATOM(IPLANE).EQ.4) THEN                                 BARD030
              CUTOFF = LIMPLN(2)                                        BARD031
          ELSE                                                          BARD032
              CUTOFF = LIMPLN(1)                                        BARD033
          ENDIF                                                         BARD034
          XCUT = CUTOFF * SCALEX                                        BARD035
      ELSE                                                              BARD036
          PLANE = .FALSE.                                               BARD037
      ENDIF                                                             BARD038
      DX = WIDTH * SCALEX                                               BARD039
      X1 = XL                                                           BARD040
      Y1 = YB                                                           BARD041
      YHT = YT - YB                                                     BARD042
                                                                        BARD043
C---- Plot the bars on the graph                                        BARD044
      DO 300, IBAR = 1, NBARS(IMAIN)                                    BARD045
          X2 = X1 + DX                                                  BARD046
          IFREQ = BCOUNT(IBAR,IMAIN)                                    BARD047
          IF (IFREQ.GT.0) THEN                                          BARD048
                                                                        BARD049
C----         Determine whether bar is to be shaded or not              BARD050
              IF (PLANE) THEN                                           BARD051
                  IF ((X1 + X2) / 2.0 - XL.GE.XCUT) THEN                BARD052
                      COLOUR = COLPLT(PLTYPE,4)                         BARD053
                      SHADE = 0.0                                       BARD054
CHECK v.3.2-->                                                          BARD055
                      NHIGHL = NHIGHL + 1                               BARD056
CHECK v.3.2<--                                                          BARD057
                  ELSE                                                  BARD058
                      COLOUR = COLPLT(PLTYPE,3)                         BARD059
                      SHADE = 0.5                                       BARD060
CHECK v.3.2-->                                                          BARD061
                      NWITHN = NWITHN + 1                               BARD062
CHECK v.3.2<--                                                          BARD063
                  ENDIF                                                 BARD064
              ELSE                                                      BARD065
                  DIST1 = MCHMIN(IMAIN) + (X1 - XL) / SCALEX            BARD066
                  DIST1 = ABS(ENGMEA(IMAIN) - DIST1) / ENGSTD(IMAIN)    BARD067
                  DIST2 = MCHMIN(IMAIN) + (X2 - XL) / SCALEX            BARD068
                  DIST2 = ABS(ENGMEA(IMAIN) - DIST2) / ENGSTD(IMAIN)    BARD069
                  IF (DIST1.GT.LIMRES(PLTYPE)                           BARD070
     &                .AND. DIST2.GT.LIMRES(PLTYPE)) THEN               BARD071
                      COLOUR = COLPLT(PLTYPE,4)                         BARD072
                      SHADE = 0.0                                       BARD073
CHECK v.3.2-->                                                          BARD074
                      NHIGHL = NHIGHL + 1                               BARD075
CHECK v.3.2<--                                                          BARD076
                  ELSE                                                  BARD077
                      COLOUR = COLPLT(PLTYPE,3)                         BARD078
                      SHADE = 0.5                                       BARD079
CHECK v.3.2-->                                                          BARD080
                      NWITHN = NWITHN + 1                               BARD081
CHECK v.3.2<--                                                          BARD082
                  ENDIF                                                 BARD083
              ENDIF                                                     BARD084
              Y2 = Y1 + YHT * REAL(IFREQ) / REAL(MFREQ)                 BARD085
              IF (Y2.GT.YT) Y2 = YT                                     BARD086
              CALL PSHADE(SHADE,COLOUR,RGB,MXCOLR,INCOLR(PLTYPE))       BARD087
              CALL PSBBOX(X1,Y1,X2,Y1,X2,Y2,X1,Y2)                      BARD088
          ENDIF                                                         BARD089
          X1 = X2                                                       BARD090
 300  CONTINUE                                                          BARD091
                                                                        BARD092
      RETURN                                                            BARD093
      END                                                               BARD094
