C-----NOTE ! BEFORE LOADING PROGRAM BY $GLOAD, YOU MUST
C     ADDRESS PBA 7. FOR EXAMPLE $A PBA 7. ALSO DK1 -5
C     MAINLINE PROGRAM M1...LOADER NAME
C
C    LOAD AS FOLLOWS!
C
      CHARACTER*60T1(1),T2(1),T3(1),T4(1),T5(1),T6(1),T7(1)
      COMMON/LIMITS/XMIN,XMAX,YMIN,YMAX
      COMMON/AR/BRAY(4,600),STRESS(200,4)
      COMMON/SIHI/IVECT(1800)
      CALL CLEAR(.FALSE.)
      T1(1)='(''1-READ OR WRITE ON DISK. ROUTINE S1.'')'
      T2(1)='(''2-SELECT DATA BETEEN LIMMITS AND ZMIN, ZMAX.'')'
      T3(1)='(''3-NO SEPARATE ROUTINE, CALL 2.'')'
      T4(1)='(''4-SET SCREEN LIMITS WITH CROSS.'')'
      T5(1)='(''5-DRAW CONTOUR FREEHAND.'')'
      T6(1)='(''6-PLACE OUTLINE WITH PBA HANDLER.'')'
      T7(1)='(''7-SINGULAR CURVE FIT LEAST SQUARE TYPE.'')'
      ITAG=0
      MTAG=0
      XMAX=0
      YMAX=0.
      IER=0
      NUMB=0
      NPTS=0
  110 CONTINUE
C-----CALL THE MENU PROGRAM HERE----
      CALL TEXT(2,11,0,1000,7,1,T1)
      CALL TEXT(2,12,0,0950,7,1,T2)
      CALL TEXT(2,13,0,0900,7,1,T3)
      CALL TEXT(2,14,0,0850,7,1,T4)
      CALL TEXT(2,15,0,0800,7,1,T5)
      CALL TEXT(2,16,0,0750,7,1,T6)
      CALL TEXT(2,17,0,0700,7,1,T7)
      CALL S0 (L)
C   1 READ OR WRITE ON DISK MODIFY DATA DISPLAYED
C   2 SEARCH DATA IN WINDOW RETURN ONLY SPECIFIED DATA
C   4 SCALE UP DISPLAY ZOOM
C   5 DRAW CONTOUR FREEHAND
C   6 ITERATE CONTOUR BY CROSS TRAK
C   7 SMOOTH OUT CURVE BY CURVE FIT
C
      GO TO (10,20,30,40,50,60,70,80,90,100),L
C.....BRANCH OFF FOR VARIOUS SUBROUTINES
C
   10 CONTINUE
C-----CALL MENU1
C.....SET MODE = 1. MODE =-1 WRITES STRESS ON DISK FILE
      MODE=1
      CALL S1(NUMB,NCD,ITAG,MODE)
      A=XMAX
      B=XMIN
      C=YMAX
      D=YMIN
      WRITE(4,19)A,B,C,D,NUMB,NCD
   19 FORMAT(4F7.1,2I5)
      GO TO 110
C
   20 CONTINUE
      WRITE(4,1)
    1 FORMAT(4HZMIN)
      READ(4,2)ZMIN
    2 FORMAT(F10.5)
      WRITE(4,3)
    3 FORMAT(4HZMAX)
      READ(4,2)ZMAX
      CALL S2(A,B,C,D,ZMIN,ZMAX,NCD)
      GO TO 110
C
   30 CONTINUE
C-----NO SEPARATE ROUTINE, CALL SEARCH
      GO TO 20
C
   40 CONTINUE
      A=0.
      U=XMIN
      V=YMIN
      DO 41 M=1,2
      CALL S4(U,V)
      WRITE(4,2)U
      WRITE(4,2)V
      IF(U.GT.A)A=U
      IF(V.GT.A)A=V
      B=A
      IF(B.GT.U)B=U
      IF(B.GT.V)B=V
   41 CONTINUE
      ZMIN=-300.
      ZMAX=+300.
      C=A
      D=B
C
C------S2 NOW GETS ALL VALUES BETWEEN LIMITS
C     IN THE STRESS ARRAY AND STORES THEM IN BRAY.
C
      CALL S2(A,B,C,D,ZMIN,ZMAX,NCD)
      XMAX=A
      XMIN=B
      YMAX=A
      YMIN=B
      GO TO 110
C
   50 CONTINUE
      CALL S5(NCD,ITAG)
      GO TO 110
C
   60 CONTINUE
      CALL S6(NUMB,NCD,ITAG)
      GO TO 110
C
   70 CONTINUE
      IER=0
C......CHECK THE ORDER OF DATA POINTS
      DO 6 I=2,NCD
      J=I-1
      IF(BRAY(1,I).LT.BRAY(1,J))IER=1
      IF(IER.EQ.1)GO TO 7
    6 CONTINUE
    7 CONTINUE
      IER=0
      DO 8 I=2,NCD
      J=I-1
      IF(IER.EQ.1)GO TO 80
      IF(BRAY(1,I).GT.BRAY(1,J))IER=1
    8 CONTINUE
      CALL S8(NCD,IER,IOR,ITAG)
      GO TO 110
C
   80 CONTINUE
      WRITE(4,81)
   81 FORMAT(1X,15HX-NON SINGULAR.)
      DO 200 K=2,NCD
      DO 200 I=2,NCD
      J=I-1
      IF(BRAY(1,I).LT.BRAY(1,J))GO TO 200
      DO 202 M=1,2
      T=BRAY(I,M)
      BRAY(I,M)=BRAY(J,M)
      BRAY(J,M)=T
  202 CONTINUE
  200 CONTINUE
      GO TO 8
C-----BLOCK RETURN TO MAIN/L TO TEST S8,S7
C     EVEN IF X-SINGULAR.
C
C
   90 CONTINUE
  100 CONTINUE
C.....ROUTINE S10 IS NOT IN USE.
C     VECTOR AND DISPLY ARE CALLED DIRECT.
      GO TO 110
C
      END
