SUBROUTINE SUBSE1(X,N,D,DMIN,DMAX,Y,NY)
C
C     PURPOSE--THIS SUBROUTINE CARRIES OVER INTO Y ALL OBSERVATIONS
C              OF THE SINGLE PRECISION VECTOR X FOR WHICH THE
C              CORRESPONDING ELEMENTS IN THE
C              SINGLE PRECISION VECTOR D ARE INSIDE
C              THE CLOSED (INCLUSIVE) INTERVAL
C              DEFINED BY DMIN AND DMAX,
C              WHILE NOT CARRYING OVER ANY OBSERVATIONS OF X
C              CORRESPONDING TO ELEMENTS OF D
C              OUTSIDE OF THIS INTERVAL.
C              THE INPUT VECTOR X IS ITSELF UNALTERED;
C              THOSE ELEMENTS OF X TO BE RETAINED ARE
C              COPIED OVER INTO THE SINGLE PRECISION
C              OUTPUT VECTOR Y.
C              THUS ALL OBSERVATIONS OF X WHICH
C              CORRESPOND TO ELEMENTS IN D WHICH ARE SMALLER
C              THAN DMIN OR LARGER THAN DMAX ARE
C              NOT COPIED OVER INTO Y.
C              THE USE OF THIS SUBROUTINE
C              GIVES THE DATA ANALYST THE CAPABILITY TO
C              EASILY EXTRACT SUBSETS OF THE DATA 
C              PRIOR TO DATA ANALYSIS ON EACH SUBSET.
C     INPUT  ARGUMENTS--X      = THE SINGLE PRECISION VECTOR OF
C                                (UNSORTED OR SORTED) OBSERVATIONS.
C                     --N      = THE INTEGER NUMBER OF OBSERVATIONS
C                                IN THE VECTOR X. 
C                     --D      = THE SINGLE PRECISION VECTOR
C                                WHICH 'DEFINES' THE VARIOUS
C                                POSSIBLE SUBSETS OF X.
C                     --DMIN   = THE SINGLE PRECISION VALUE 
C                                WHICH DEFINES THE LOWER LIMIT
C                                (INCLUSIVELY) OF THE PARTICULAR
C                                SUBSET OF INTEREST TO BE RETAINED.
C                     --DMAX   = THE SINGLE PRECISION VALUE 
C                                WHICH DEFINES THE UPPER LIMIT
C                                (INCLUSIVELY) OF THE PARTICULAR
C                                SUBSET OF INTEREST TO BE RETAINED.
C     OUTPUT ARGUMENTS--Y      = THE SINGLE PRECISION VECTOR
C                                CONTAINING ONLY THOSE ELEMENTS
C                                OF X CORRESPONDING TO
C                                VALUES OF THE D VECTOR
C                                IN THE INTERVAL DMIN TO DMAX
C                                (INCLUSIVE).
C                     --NY     = THE INTEGER NUMBER OF RETAINED
C                                OBSERVATIONS COPIED INTO
C                                THE VECTOR Y.
C     OUTPUT--THE SINGLE PRECISION VECTOR Y
C             INTO WHICH HAVE BEEN COPIED
C             ONLY THOSE VALUES OF X WHICH
C             CORRESPOND TO VALUES
C             IN THE D VECTOR INSIDE
C             (INCLUSIVELY) THE INTERVAL OF
C             INTEREST, AND
C             THE INTEGER VALUE NY
C             WHICH GIVES THE NUMBER OF 
C             OBSERVATIONS COPIED INTO Y.
C             ALSO, 12 LINES OF SUMMARY INFORMATION
C             WILL BE GENERATED INDICATING
C             1) WHAT THE INTERVAL OF INTEREST WAS
C                IN THE D VECTOR;
C             2) HOW MANY OBSERVATIONS WERE DELETED;
C             3) WHAT THE SAMPLE SIZE OF X WAS (N);
C             4) WHAT THE SAMPLE SIZE OF Y WAS (NY);
C     PRINTING--YES.
C     RESTRICTIONS--THERE IS NO RESTRICTION ON THE MAXIMUM VALUE
C                   OF N FOR THIS SUBROUTINE.
C     OTHER DATAPAC   SUBROUTINES NEEDED--NONE.
C     FORTRAN LIBRARY SUBROUTINES NEEDED--NONE.
C     MODE OF INTERNAL OPERATIONS--SINGLE PRECISION.
C     LANGUAGE--ANSI FORTRAN. 
C     COMMENT--THE INPUT VECTOR X IS NOT ALTERED
C              BY APPLICATION OF THIS SUBROUTINE. 
C              THIS IS THE MAJOR DISTINCTION
C              BETWEEN THIS SUBROUTINE AND, SAY,
C              THE SUBSET SUBROUTINE.
C              IT IS THUS SEEN THAT THIS (SUBSE1) 
C              SUBROUTINE IS THE PREFERABLE OF THE 2
C              (SUBSET VERSUS SUBSE1)
C              FOR HANDLING THE PROBLEM OF
C              SEQUENTIALLY EXTRACTING EACH POSSIBLE
C              SUBSET OF X (FOR THE PURPOSE OF
C              ANALYZING EACH INDIVIDUAL SUBSET). 
C              INASMUCH AS THE ORIGINAL X VECTOR
C              REMAINS UNCHANGED, THE ANALYST
C              CAN ALWAYS OPERATE ON IT WITH
C              SUBSE1 IN SEQUENTIALLY EXTRACTING
C              SUBSETS OF INTEREST.
C     COMMENT--IN THE END, AFTER THIS SUBROUTINE HAS
C              MADE WHATEVER DELETIONS ARE APPROPRIATE,
C              THE OUTPUT VECTOR Y WILL BE 'PACKED';
C              THAT IS, NO 'HOLES' WILL EXIST IN THE
C              VECTOR Y--ALL OF THE RETAINED ELEMENTS
C              OF Y WILL BE PACKED INTO THE FIRST AVAILABLE 
C              LOCATIONS IN Y, WHILE THE REMAINDER
C              OF THE N LOCATIONS IN Y WILL BE ZERO-FILLED. 
C     COMMENT--ALTHOUGH THERE 
C              MAY BE A CORRESPONDANCE BETWEEN THE
C              ELEMENTS OF THE X AND D VECTORS
C              BEFORE APPLICATION OF
C              THIS SUBROUTINE, THERE WILL
C              BE NO CORRESPONDANCE BETWEEN
C              Y AND D (DUE TO THE PACKING OF
C              THE RETAINED ELEMENTS IN Y)
C              AFTER APPLICATION OF THIS SUBROUTINE.
C     REFERENCES--NONE.
C     WRITTEN BY--JAMES J. FILLIBEN
C                 STATISTICAL ENGINEERING LABORATORY (205.03)
C                 NATIONAL BUREAU OF STANDARDS
C                 WASHINGTON, D. C. 20234
C                 PHONE--301-921-2315
C     ORIGINAL VERSION--APRIL     1975. 
C     UPDATED         --NOVEMBER  1975. 
C
C---------------------------------------------------------------------
C
      DIMENSION X(1)
      DIMENSION Y(1)
      DIMENSION D(1)
C
      IPR=6
C
C     CHECK THE INPUT ARGUMENTS FOR ERRORS
C
      IF(N.LT.1)GOTO50
      IF(N.EQ.1)GOTO55
      HOLD=X(1)
      DO60I=2,N
      IF(X(I).NE.HOLD)GOTO90
   60 CONTINUE
      WRITE(IPR, 9)HOLD
      GOTO90
   50 WRITE(IPR,15) 
      WRITE(IPR,47)N
      RETURN
   55 WRITE(IPR,18) 
   90 CONTINUE
    9 FORMAT(1H ,108H***** NON-FATAL DIAGNOSTIC--THE FIRST  INPUT ARGUME
     1NT (A VECTOR) TO THE SUBSE1 SUBROUTINE HAS ALL ELEMENTS = ,E15.8,6
     1H *****)
   15 FORMAT(1H , 91H***** FATAL ERROR--THE SECOND INPUT ARGUMENT TO THE
     1 SUBSE1 SUBROUTINE IS NON-POSITIVE *****)
   18 FORMAT(1H ,100H***** NON-FATAL DIAGNOSTIC--THE SECOND INPUT ARGUME
     1NT TO THE SUBSE1 SUBROUTINE HAS THE VALUE 1 *****)
   47 FORMAT(1H , 35H***** THE VALUE OF THE ARGUMENT IS ,I8   ,6H *****)
C
C-----START POINT-----------------------------------------------------
C
      POINTL=DMIN
      POINTU=DMAX
      IF(DMIN.GT.DMAX)POINTL=DMAX
      IF(DMIN.GT.DMAX)POINTU=DMIN
C
      K=0 
      DO100I=1,N
      IF(D(I).LT.POINTL.OR.D(I).GT.POINTU)GOTO100 
      K=K+1
      Y(K)=X(I)
  100 CONTINUE
      NY=K
      NDEL=N-NY
C
C     WRITE OUT A BRIEF SUMMARY
C
      WRITE(IPR,999)
      WRITE(IPR,101)
      WRITE(IPR,111)POINTL,POINTU
      WRITE(IPR,160)
      WRITE(IPR,161)
      WRITE(IPR,162)
      WRITE(IPR,163)
      WRITE(IPR,164)
      WRITE(IPR,165)
      WRITE(IPR,166)
      WRITE(IPR,185)N
      WRITE(IPR,190)NY
      WRITE(IPR,195)NDEL
  101 FORMAT(1H ,35HOUTPUT FROM THE SUBSE1 SUBROUTINE--)
  111 FORMAT(1H ,7X,26HD1 LIMITS (INCLUSIVE)--   ,E15.8,5H AND ,E15.8)
  160 FORMAT(1H ,7X,28HONLY THOSE OBSERVATIONS IN X)
  161 FORMAT(1H ,7X,27HWILL BE CARRIED OVER INTO Y)
  162 FORMAT(1H ,7X,40HFOR WHICH THE CORRESPONDING ELEMENTS OF ,
     1               2HD1)
  163 FORMAT(1H ,7X,37HARE SIMULTANEOUSLY WITHIN (INCLUSIVE))
  164 FORMAT(1H ,7X,21HEACH SPECIFIED LIMIT.)
  165 FORMAT(1H ,7X,40HNO OBSERVATIONS OUTSIDE OF THIS INTERVAL)
  166 FORMAT(1H ,7X,30HHAVE BEEN CARRIED OVER INTO Y.)
  185 FORMAT(1H ,7X,44HTHE INPUT  NUMBER OF OBSERVATIONS (IN X) IS ,I6)
  190 FORMAT(1H ,7X,44HTHE OUTPUT NUMBER OF OBSERVATIONS (IN Y) IS ,I6)
  195 FORMAT(1H ,7X,44HTHE NUMBER OF OBSERVATIONS DELETED       IS ,I6)
  999 FORMAT(1H )
C
      RETURN
      END