      SUBROUTINE SAMPLE(IPTMIN,IPTMAX,NX,NY)

C     * NOV 07/07 - F.MAJAESS (REVISED TO USE "PCHIQU" INSTEAD 
C     *                        OF "PWRITX")
C     * MAR 11/2004 - M.BERKLEY (MODIFIED for NCAR V3.2)
C     * F. MAJAESS - MAY 28/01
C     *   INCREASE MCRA/MSRA VALUES FROM 50000 TO 300000.
C     * F. MAJAESS - 16 FEB 1994
C     *   - INCREASE MCRA/MSRA VALUES FROM 10000 TO 50000 TO
C     *     KEEP IT CONSISTENT WITH THE VALUES IN HAFTON.
C     * F.ZWIERS/S.WILSON - JUNE/1991
C     * PLOT A SHEET OF SAMPLE SHADING PATTERNS
C
C     *      IPTMIN,IPTMAX = RANGE OF SHADING PATTERNS TO PLOT
C     *      NX = NUMBER OF COLUMNS OF SAMPLE PATTERN CHIPS
C     *      NY = NUMBER OF ROWS OF SAMPLE PATTERN CHIPS
C                 (NOTE THAT NX*NY SHOULD BE >= IPTMAX-IPTMIN+1)
C
C     * NB: PATTERN CHARACTERISTICS ARE DESCRIBED BY THE ARRAYS FILPAT,
C     *     FILTYP, FILANG AND FILSPC.
C     *     !!! PERMANENT CHANGES MADE TO THESE ARRAYS MUST BE DUPLICATED
C     *         IN SUBROUTINE HAFTON!!!


C!!!      SAVE
      PARAMETER(MCRA=300000,MSRA=300000)

      INTEGER         NX, NY, ISIZ, IDSIZ
      REAL            DXF, DYF, DXU, DYU, CHRATIO, SIZ
      REAL            LMARGN, RMARGN, BMARGN, TMARGN, PMARGN

      COMMON /FILLPATTERNS/ FILPAT, FILTYP, FILANG, FILSPC
      INTEGER         FILPAT(0:420), FILTYP(0:420)
      REAL            FILANG(0:420), FILSPC(0:420)
      REAL            XCRA(4),YCRA(4),ISRA(MCRA),FSRA(MCRA)

      CHARACTER*83    TITLE

C     COMMON /INTPR/ZZZZZZ(2),TENSN,ZZZZZX(5),MLLINE,ZZZZZY
      COMMON /PUSER/MODE
      COMMON /FILLCO/ LAN, LSP, LPA, LCH, LDP(8, 8)

C     * DATA PERTAINING TO CHARACTER SIZES FOR PWRITX.
C     * NOTE:  THE FONT PWRITX USES IS DIGITIZED TO BE 32 PLOTTER 
C     * COORDINATE UNITS (PLU) HIGH - THIS INCLUDES SPACE ABOVE THE
C     * CHARACTER.  THE ACTUAL CHARACTER HEIGHT IS 21 PLU.  THEREFORE,
C     * THE ACTUAL HEGHT FOR A GIVEN CHARACTER SIZE CAN BE DETERMINED
C     * BY MULTIPLYING BY THE RATIO 32/21 = 1.52381
      DATA ISIZ /16/, CHRATIO /1.52381/, SIZ/16.0/

C     * SET THE LEFT, RIGHT, BOTTOM & TOP MARGINS FOR THE DISPLAY AREA.
      DATA LMARGN /0.0/, RMARGN /1.0/, BMARGN /0.05/, TMARGN /0.95/

      DATA MAXPAT/399/

CCCCCCCCCC

      CALL GSELNT(0)
  
C!!!
C     ISOLID=177777B
      ISOLID='177777'O
C     ISOLID=65535
C!!!
      CALL DASHDB(ISOLID)

      IPT = IPTMIN - 1
      NSRA = 200

C
C     * DETERMINE THE TRUE DIGITIZED CHARACTER SIZE
C
      IDSIZ = NINT(CHRATIO*FLOAT(ISIZ))

C
C     * DETERMINE HOW BIG OF AN AREA EACH PALETTE MUST BE DRAWN WITHIN
C     * IN FRACTIONAL AND PLOTTER COORDINATES.
C
      DXF = (RMARGN - LMARGN)/FLOAT(NX)
      DYF = (TMARGN - BMARGN)/FLOAT(NY)
      DXU = FLOAT(KFPX(DXF))
      DYU = FLOAT(KFPY(DYF))

C
C     * SET THE COORDINATES FOR THE BOX WITHIN THE PALETTE AREA
C     * AND THE POSITION OF THE TEXT LABEL UNDER IT.
C
      PMARGN = FLOAT(ISIZ)/2.0
      XL = PMARGN
      XH = DXU - PMARGN
      YL = PMARGN + IDSIZ
      YH = DYU - PMARGN

      XTXT = DXU/2.0
      YTXT = PMARGN + FLOAT(ISIZ)/2.0 


      DO 30 J=1, NY
         DO 20 I=1, NX

C
C           * SET THE PALETTE AREA
C
            CALL SET(LMARGN + (I - 1)*DXF, LMARGN + I*DXF,
     +               TMARGN - J*DYF, TMARGN - (J - 1)*DYF,
     +               0.0, DXU, 0.0, DYU, 1)

            XCRA(1) = XL
            XCRA(2) = XH
            XCRA(3) = XH
            XCRA(4) = XL
                        
            YCRA(1) = YL
            YCRA(2) = YL
            YCRA(3) = YH
            YCRA(4) = YH

C
C           * SET THE FOREGROUND COLOUR TO BLACK
            CALL GSCR(1, 1, 0.0, 0.0, 0.0)
            CALL GSLN(1)
            CALL GSPLCI(1)
C           * DRAW THE BOX
            CALL FRSTPT(XCRA(1),YCRA(1))
            DO 10 K=2,4
               CALL VECTOR(XCRA(K),YCRA(K))
   10       CONTINUE
            CALL VECTOR(XCRA(1),YCRA(1))
            CALL SFLUSH
C
C           * NOW FILL THE BOX
C
            IPT = IPT + 1

            IF (IPT.LE.IPTMAX)THEN

               CALL DFNCLR(IPT,FILPA)

               CALL SFSGFA(XCRA,YCRA,4,FSRA,NSRA,ISRA,NSRA,FILPA)

               WRITE(TITLE,'(I3)') IPT
               NC = INT(ALOG10(FLOAT(IPT))) + 1
C              CALL PWRITX(XTXT,YTXT,TITLE(4-NC:3),NC,ISIZ,0,0)
               CALL PCHIQU(XTXT,YTXT,TITLE(4-NC:3),SIZ,0.0,0.0)

            ENDIF
  20     CONTINUE
  30  CONTINUE
      CALL FRAME

      CALL SET(0.,1.,0.,1.,0.,1.,0.,1.,1)
      RETURN
      END
