C           SUBROUTINE INSTG
      SUBROUTINE INSTG
C     INTERSTAGE OUTPUT
C      NUMBER OF SECTORS IS THREE OR LESS,HUB AND CASING VALUES ARE
C         CALCULATED AND PRINTED
C     NUMBER OF SECTORS IS MORE THAN THREE,ONLY SECTOR PITCHLINE
C         VALUES ARE PRINTED
C
      REAL MFSTOP
      LOGICAL PREVER
      COMMON /SNTCP/G,AJ,PRPC,ICASE,PREVER,MFSTOP,JUMP,LOPIN,ISCASE,
     1KN,GAMF,IP,SCRIT,PTRN,ISECT,KSTG,WTOL,RHOTOL,PRTOL,TRLOOP,LSTG,
     2LBRC,IBRC,ICHOKE,ISORR,CHOKE,PT0PS1(6,8),PTRS2(6,8),TRDIAG,SC,RC,
     3DELPR,PASS,IPC,LOPC,ISS
C
      COMMON/GEBE/DRBARR,DRBARS,E1,E2,E3,E4,E5,E6,HBRRH,HBRSH,IAFE
     1,IALF,IBT2,ICPR,ICPS,ISR2,ISTR,ISTS,L,R1,R3,R4,R5,
     2TALF,WGT0(8),WT(7),HBARS,HBARR,I
C
      COMMON /SINIT/H1(6,8),H2(6,8),DP0(6,8),DP1(6,8),DP1A(6,8),DP2(6,8)
     1,DP2A(6,8),CSALF1(6,8),ALF1(6,8),CSBET2(6,8),BET2(6,8),RADSD(6,8),
     2RADRD(6,8),ANN1(6,8),ANN2(6,8),ANN2A(6,8),ANN1A(6,8),U1A(6,8),
     3U2(6,8),ANN0(6,8),PT0(6,8),TT0(6,8),ALPHA0(6,8),PTP(6,8)
C
      COMMON /SINPUT/
     1PTPS,PTIN,TTIN,WAIR,FAIR,DELC,DELL,DELA,AACS,VCTD,STG,SECT,EXPN,
     2EXPP,EXPRE,RG,RPM,PAF,SLI,STGCH,ENDJOB,XNAME(20),TITLE(20),
     3PCNH(6),GAM(6,8),DR(6,8),DT(6,8),RWG(6,8),ALPHAS(6,8),ALPHA1(6,8),
     4ETARS(6,8),ETAS(6,8),CFS(6,8),ANDO(6,8),BETA1(6,8),BETA2(6,8),ETAR
     5R(6,8),ETAR(6,8),CFR(6,8),TFR(6,8),ANDOR(6,8),OMEGAS(6,8),AS0(6,8)
     6,ASMP0(6,8),ACMN0(6,8),A1(6,8),A2(6,8),A3(6,8),A4(6,8),A5(6,8),A6(
     76,8),OMEGAR(6,8),BSIA(6,8),BSMPIA(6,8),BCMNIA(6,8),B1(6,8),B2(6,8)
     8,B3(6,8),B4(6,8),B5(6,8),B6(6,8),SESTHI(8),RERTHI(8)
     9,fairx(5,8),wairx(5,8),rg1(8),rg1a(8),rg2(8),rg2a(8)
C
      REAL M0
      COMMON /SSTA01/CP0(8),w0(6),               PS0(6,8),V0(6,8),TS0(6,
     18),VU0(6,8),VZ0(6,8),RHOS0(6,8),PS1(6,8),WGT1(8),TA1(8),WG1(6,8),
     2            DPDR1(6,8),SI(6,8),  CP1(8),PHI1(6,8),TS1(6,8),V1(6,8)
     3,RHOS1(6,8),ALF1E(6,8),VU1(6,8),VZ1(6,8),M0(6,8)
C
      REAL MR1A
      COMMON /SSTA1A/VU1A(6,8),WG1A(6,8),WGT1A(8),VZ1A(6,8),  CP1A(8),
     1PS1A(6,8),RU1A(6,8),R1A(6,8),BET1A(6,8),RI(6,8),TTR1A(6,8),PTR1A(6
     2,8),MR1A(6,8)
C
      COMMON /SSTA2/V2(6,8),TTR2(6,8),PTR2(6,8),WG2(6,8),WGT2(8),TA2(8),
     1           PS2(6,8),PHI2(6,8)
C
      REAL MR2,M2     ,MF2
      COMMON /SFLOW2/TS2(6,8),CP2(8),R2(6,8),RHOS2(6,8),BET2E(6,8),RU2(6
     1,8),VU2(6,8),DPDR2(6,8),VZ2(6,8),MR2(6,8),MF2(6,8),M2(6,8)
C
      REAL M2A,MF2A
      COMMON /SSTA2A/WG2A(6,8),WGT2A(8),VU2A(6,8),VZ2A(6,8),PS2A(6,8),
     1ALF2A(6,8),TT2A(6,8),PT2A(6,8),TTBAR(8),PTBAR(8),STT0(8),SPT0(8),
     2M2A(6,8),MF2A(6,8),CP2A(8),V2A(6,8),TS2A(6,8),TAS(8),PAS(8),GAMS(8
     3),CPO(8),DELHVD(6,8)
C
      COMMON /SOVRAL/DELHT(6,8),DELHTI(6,8),DELHSI(6,8),DEHATI(6,8),
     1ETATT(6,8),ETATS(6,8),ETATAT(6,8),delhtu(6,8)
C
      COMMON /C1FIT1/ STDP0(7),STTT0(7),STPT0(7),STALF(7)
     1,STSI(7),STV0(7),STVU0(7),STVZ0(7),STTS0(7),
     2STPS0(7),STDEN0(7),STM0(7),STDP1(7),STTT1(7),
     3STALFE(7),STDELA(7),STV1(7),STVU1(7),STVZ1(7),
     4STTS1(7),STPS1(7),STDEN1(7),STM1(7),ZWIINC(7),
     5CPS(7),STDP1A(7),STTTR1(7),STPTR1(7),STBET1(7),
     6STRI(7),STR1A(7),STRU1A(7),STMR1A(7),STU1A(7),
     7STDP2(7),STBET2(7),SDBETA(7),SR2(7),SRU2(7),
     8SMR2(7),SU2(7),RX(7),STDELH(7),STPSI(7),
     9SETATT(7),SETATS(7),SETAAT(7),RZWINC(7),CPR(7),
     1STDP2A(7),STPT2(7),STTT2(7),STV2(7),STVU2(7),
     2STALF2(7),STMF2(7),STVZ2(7),STTS2(7),STPS2(7),
     3STDEN2(7),STM2(7),LJ,JJ,K
      COMMON /C2FIT1/  DBARS(7),FTANS(7),FAXS(7),DBARR(7),
     1FTANR(7),FAXR(7)
      COMMON RES(8),DALF(6),DSTS(6),DALFE(6),DCPS(6),DSTR(6),
     *DBT2(6),DCPR(6),DSR2(6)
      COMMON/TPT1/PT1(6),TT1(6,8)
      COMMON/DESOPT/RVU1(6,8),RVU2(6,8),WG,EPR
      dimension tangms(6,8),tangmr(6,8),tangm1(6,8),tangm2(6,8),tang0(6)
      common/slope/tangms,tangmr,tangm1,tangm2,tang0,iar,icyl
      K=1
      ETAO1=1.
1     CONTINUE
      E1=(GAMS(K)-1.)/GAMS(K)
      E2=GAM(1,K)/(GAM(1,K)-1.)
      E3=GAM(2,K)/(GAM(2,K)-1.)
      E4=GAM(3,K)/(GAM(3,K)-1.)
      E5=GAM(4,K)/(GAM(4,K)-1.)
      E6=GAM(5,K)/(GAM(5,K)-1.)
C     RELOCATE PITCHLINE VALUES
      HBARS= (DT(1,K)-DR(1,K)+DT(2,K)-DR(2,K))/4.
      WGT0(K)= WGT1(K)/RWG(2,K)*RWG(1,K)
      DW0= WGT0(K)/(G*HBARS)
      DW0D0= DW0/DP0(IP,K)
      DW0D1= DW0/DP1(IP,K)
      HBARR= (DT(3,K)-DR(3,K)+DT(4,K)-DR(4,K))/4.
      DW1A= WGT1A(K)/(G*HBARR)
      DW1AD1= DW1A/DP1A(IP,K)
      DW1AD2= DW1A/DP2(IP,K)
      DRBARS=(DR(1,K)+DR(2,K))/2.
      DRBARR=(DR(3,K)+DR(4,K))/2.
      HBRSH=HBARS/(DT(2,K)-DR(2,K))
      HBRRH=HBARR/(DT(4,K)-DR(4,K))
      GO TO(21,22,23,24,25,26),ISECT
21    KS1=1
      KS=4
      KF=7
c     ks=2
c     kf=2
      KSD=4
      GO TO 97
22    KS=2
      KF=4
      KSD=2
      GO TO 97
23    KS=2
      KF=4
      KSD=1
      GO TO 97
24    KS=2
      KF=6
      KSD=1
      GO TO 97
25    KS=2
      KF=6
      KSD=1
      GO TO 97
26    KS=1
      KF=7
      KSD=1
      GO TO 97
97    GO TO(91,92,93,94,95,96),ISECT
91    KS1=1
      GO TO 27
92    KS1=KS/2
      GO TO 27
93    KS1=KS-1
      GO TO 27
C94    IF(KS-4)32,5,29
C     replaced by ............
94    IF((KS-4).LT.0) THEN
         GO TO 32 
      ELSEIF((KS-4).EQ.0) THEN
         GO TO 5 
      ELSEIF((KS-4).GT.0) THEN
         GO TO 29
      ENDIF
32    KS1=KS-1
      GO TO 27
29    KS1=KS-2
      GO TO 27
95    KS1=KS-1
      GO TO 27
C96    IF(KS-4)30,5,31
C     replaced by ............
96    IF((KS-4).LT.0) THEN
         GO TO 30 
      ELSEIF((KS-4).EQ.0) THEN
         GO TO 5 
      ELSEIF((KS-4).GT.0) THEN
         GO TO 31
      ENDIF
30    KS1=KS
      GO TO 27
31    KS1=KS-1
      GO TO 27
27    STTT0(KS)=TT0(KS1,K)
      STDP0(KS)=DP0(KS1,K)
      STPT0(KS)=PTP(KS1,K)
      STALF(KS)=ALPHA0(KS1,K)*57.2958
      STSI(KS)=SI(KS1,K)*57.2958
      STV0(KS)=V0(KS1,K)
      STVU0(KS)=VU0(KS1,K)
      STVZ0(KS)=VZ0(KS1,K)
      STTS0(KS)=TS0(KS1,K)
      STPS0(KS)=PS0(KS1,K)
      rg0=rg
      if (k.gt.1) rg0=rg2a(k-1)
      STDEN0(KS)=144.*STPS0(KS)/STTS0(KS)/RG0
      STM0(KS)=M0(KS1,K)
      STDP1(KS)=DP1(KS1,K)
      STTT1(KS)=TT1(KS1,K)
      STALFE(KS)=ALF1E(KS1,K)*57.2958
      STDELA(KS)=(ALPHA0(KS1,K)+ALF1E(KS1,K))*57.2958
      STV1(KS)=V1(KS1,K)
      STVU1(KS)=VU1(KS1,K)
      STVZ1(KS)=VZ1(KS1,K)
      STTS1(KS)=TS1(KS1,K)
      STPS1(KS)=PS1(KS1,K)
      STDEN1(KS)=RHOS1(KS1,K)
      STM1(KS)=V1(KS1,K)/(SQRT(GAM(2,K)*G*rg1(k)*TS1(KS1,K)))
      ZS=-2.*ALF1E(KS1,K)-1.570796
      ZWIINC(KS)=-2.*COS(ZS)/(1.0+ANN0(KS1,K)/ANN1(KS1,K))
     1*(SIN(ALPHA0(KS1,K))/COS(ALPHA0(KS1,K))*COS(ALF1E(KS1,K))
     2/SIN(ALF1E(KS1,K))*ANN1(KS1,K)/ANN0(KS1,K)+1.)
      IF(EPR.GT.0.)
     *CALL ETAPR(PT0PS1(KS1,K),etaO1)
      CPS(KS)=ETAO1*ETAS(KS1,K)
      STDP1A(KS)=DP1A(KS1,K)
      STPTR1(KS)=PTR1A(KS1,K)
      STTTR1(KS)=TTR1A(KS1,K)
      STBET1(KS)=BET1A(KS1,K)*57.2958
      STRI(KS)=RI(KS1,K)*57.2958
      STR1A(KS)=R1A(KS1,K)
      STRU1A(KS)=RU1A(KS1,K)
      STMR1A(KS)=MR1A(KS1,K)
      STU1A(KS)=U1A(KS1,K)
      STDP2(KS)=DP2(KS1,K)
      STBET2(KS)=BET2E(KS1,K)*57.2958
      SDBETA(KS)=(BET1A(KS1,K)+BET2E(KS1,K))*57.2958
      SR2(KS)=R2(KS1,K)
      SRU2(KS)=RU2(KS1,K)
      SMR2(KS)=MR2(KS1,K)
      SU2(KS)=U2(KS1,K)
      RX(KS)=1.-(1.-(PS1(KS1,K)/PTP(KS1,K))**E1)/(1.-(PS2(KS1,K)
     1/PTP(KS1,K))**E1)
      STDELH(KS)=DELHTu(KS1,K)
      STPSI(KS)=   G*AJ*DELHT(KS1,K)/(U1A(KS1,K)*U1A(KS1,K)
     1+U2(KS1,K)*U2(KS1,K))
      SETATT(KS)=ETATT(KS1,K)
      SETATS(KS)=ETATS(KS1,K)
      SETAAT(KS)=ETATAT(KS1,K)
      ZR=-2.*BET2E(KS1,K)-1.570796
      RZWINC(KS)=-2.*COS(ZR)/(1.+ANN1A(KS1,K)/ANN2(KS1,K))
     1*(SIN(BET1A(KS1,K))/COS(BET1A(KS1,K))*COS(BET2E(KS1,K))
     2/SIN(BET2E(KS1,K))*ANN2(KS1,K)/ANN1A(KS1,K)+1.)
      IF(EPR.GT.0.)
     *CALL ETAPR(PTRS2 (KS1,K),etaO1)
      CPR(KS)=ETAO1*ETAR(KS1,K)
      STDP2A(KS)=DP2A(KS1,K)
      STPT2(KS)=PT2A(KS1,K)
      STTT2(KS)=TT2A(KS1,K)
      STV2(KS)=V2A(KS1,K)
      STVU2(KS)=VU2A(KS1,K)
      STALF2(KS)=ALF2A(KS1,K)*57.2958
      STMF2(KS)=MF2A(KS1,K)
      STVZ2(KS)=VZ2A(KS1,K)
      STPS2(KS)=PS2A(KS1,K)
      STTS2(KS)=TS2A(KS1,K)
      STM2(KS)=M2A(KS1,K)
      STDEN2(KS)=144.*STPS2(KS)/STTS2(KS)/rg2(k)
      DBARS(KS)=DRBARS+HBRSH*(STDP1(KS)-DR(2,K))*2.0
      HBRS=H1(KS1,K)*HBRSH*2.
      HBRR=H2(KS1,K)*HBRRH*2.
      FTANS(KS)=-WG1(KS1,K)*(STDP1(KS)*STVU1(KS)+STDP0(KS)
     1*STVU0(KS))/DBARS(KS)/G/HBRS
      if (k.eq.1) then
        cat0=cos(atan(tang0(ks1)))
      else
        cat0=cos(atan(tangm2(ks1,k-1)))
      end if
      cat1=cos(atan(tangm1(ks1,k)))
      cat2=cos(atan(tangm2(ks1,k)))
      FAXS(KS)=((STPS0(KS)-STPS1(KS))*(ANN1(KS1,K) +ANN0(KS1,K))*72.
     1+WG1(KS1,K)/G*(STVZ0(KS)*cat0-STVZ1(KS)*cat1))/HBRS
      DBARR(KS)=DRBARR+HBRRH*(STDP2(KS)-DR(4,K))*2.0
      FTANR(KS)=WG2(KS1,K)*(STDP2A(KS)*STVU2(KS)+STDP1(KS)*STVU1(KS))
     1/DBARR(KS)/G/HBRR*TFR(KS1,K)
      FAXR(KS)=((PS1A(KS1,K)-PS2(KS1,K))*(ANN1A(KS1,K)+ANN2(KS1,K))*72.
     1+WG2(KS1,K)/G*(VZ1A(KS1,K)*cat1-VZ2(KS1,K)*cat2))/HBRR
5     KS=KS+KSD
      IF(KS.GT.KF) GO TO 28
      GO TO 97
28    CALL INST2
      IF(K.LE.KSTG) GO TO 1
      RETURN
      END
