      SUBROUTINE S1 (NUMB,NCD,ITAG,MODE)
C     THIS SUBROUTINE RETRIEVES OR WRITES INFO ON DISK
C     RETURNS NUMB, THE LAST NON-ZERO ROW VALUE
      CHARACTER*60 U1(1),U2(1)
      DIMENSION FILE(2)
      COMMON/LIMITS/XMIN,XMAX,YMIN,YMAX
      COMMON/AR/BRAY (4,600),STRESS (200,4)
      COMMON/SIHI/IVECT(1800)
      DATA FILE(1),FILE(2)/5HSTRES,4HSSRC/
      U1(1)='(''SUBROUTINE S1 DISPLAYS ROW 1&2 OF STRESS'')'
      U2(1)='(''PUSH ANY BUTTON TO CONTINUE'')'
C     CLEAR DATA OUT OF STRESS ARRAY IF MODE=1(READ)
      IF (MODE.EQ.0) PAUSE 00001
      IF (MODE.LT.0) GO TO 44
      DO 22 I=1,200
      DO 22 J=1,4
   22 STRESS (I,J)=0.0
C     SEEK DISK RECORD
      CALL OPEN (1,FILE)
      CALL TEXT(2,18,0,0650,7,1,U1)
      I=0
   25 I=I+1
      READ (1,10)(STRESS(I,J),J=1,4)
   10 FORMAT(4F10.5)
      X=STRESS (I,1)
      Y=STRESS (I,2)
      IF (X.GT.0.) GO TO 25
      IF (Y.GT.0.) GO TO 25
      NUMB=I-1
      CALL CLOSE(1)
      L1=1
      NCD=NUMB
      CALL S3(L1,NUMB,NCD)
      CALL S9(NUMB,NCD)
C
C      ROUTINE S9(NUMB,NCD) SETS THE LIMITS TO CRT.
C
C.....ROUTINE S3(1) PLACES DATA IN STRESS INTO BRAY
C     THE SAME VALUES IN TOP AND BOTTOM TWO ROWS.
C
      ITAG=11
      CALL TEXT(2,19,0,0600,7,1,U2)
      IR=1
      CALL VECTOR(1,BRAY,1,NCD,IVECT,IR,LA,7,0,.FALSE.)
      CALL DISPLY(6,ITAG,IVECT,IR,LA)
      CALL S0(L)
      RETURN
   44 CONTINUE
      CALL OPEN(1,FILE)
      DO 45 I=1,NUMB
      STRESS (NUMB,1)=X
      STRESS (NUMB,2)=Y
      STRESS (NUMB,3)=SX
      WRITE (1,10)(STRESS (NUMB,J),J=1,4)
   45 CONTINUE
      CALL CLOSE(1)
      RETURN
      END
