      SUBROUTINE S2 (A,B,C,D, ZMIN,ZMAX,NCD)
      INTEGER FIRST,END
C     THIS ROUTINE SELECTS DATA INSIDE WINDOW OF X Y COORD AND
C     BETWEEN LIMITS ZMIN ZMAX
C     THE ROUTINE RETURNS THE INFORMATION INTO ARRAY BRAY.
C
C     NCD IS THE MAXIMUM ROW VALUE OF BRAY CORRESPONDING
C     TO END VALUE IN VECTOR
C
      COMMON/LIMITS/XMIN,XMAX,YMIN,YMAX
      COMMON/AR/BRAY (4,600),STRESS(200,4)
      COMMON/SIHI/IVECT(1800)
      K=0
      NCD=0
      WRITE(4,28)NCD,ZMIN,ZMAX
   28 FORMAT(1X,4H NCD,I5,4HZMIN,F8.1,4HZMAX,F8.1)
      DO 30 I=1,200
      X=STRESS (I,1)
      Y=STRESS (I,2)
      SX=STRESS (I,3)
      IF (X.GE.A) GO TO 30
      IF (X.LE.B) GO TO 30
      IF (Y.GE.C) GO TO 30
      IF (Y.LE.D) GO TO 30
      IF (SX.GT.ZMAX) GO TO 30
      IF (SX.LT.ZMIN) GO TO 30
      K=K+1
      BRAY(1,K)=X
      BRAY(2,K)=Y
   30 CONTINUE
C
C.....ROUTINE S3(1) LOADS UPPRR AND LOWER
C     ROWS OF BRAY ARRAY FROM STRESS.
C
      NCD=K
      NUMB=K
      L1=2
      CALL S3(L1,NUMB,NCD)
      CALL S9(NUMB,NCD)
      ITAG=2
      FIRST=1
      CALL VECTOR(1,BRAY,1,NCD,IVECT,FIRST,LAST,7,0,.FALSE.)
      CALL DISPLY(6,ITAG,IVECT,FIRST,LAST)
      WRITE(4,28)NCD,ZMIN,ZMAX
      RETURN
      END
