C
C
      SUBROUTINE COLUMN (T1,X3,I,JQ,JP)
C
C     --------------------------------------------------------------
C
C      SUBROUTINE PURPOSE:
C        DETERMINING THE ADVANCING DISTANCE OF AIR COLUMNS.
C
C     --------------------------------------------------------------
C
      INCLUDE 'CMMNW.DAT'
C
      IF (DPPA(JQ,JP,5).LT.3.0) THEN
         X3=0.1
         RETURN
      ENDIF
      KK=0
      X1=1.0
      X2=100.0
      CP=0.2376+0.000024*TMRD(I)
      IF (NHM.EQ.0) THEN
         C1=TROCK(I)+460.0
         C2=T1-TROCK(I)
         C3=-HK(I)*DCOAGE(I)*O(I)*O(I)/(DR*QQ(I)*CP*120.0*A(I))
      ELSE
         C1=2.0*A(I)*CNT(I)/(HK(I)*O(I)*DCOAGE(I))+460.0
         C2=T1-2.0*A(I)*CNT(I)/(HK(I)*O(I)*DCOAGE(I))
         C3=-FAW(I)
      ENDIF
      AC=DPPA(JQ,JP,5)*53.34/(144.0*14.7*A(I))
10    EXPR=0.0
      IF (C3*X1.GT.-25.0) EXPR=EXP(C3*X1)
      XXX=(C1+C2*EXPR)/(C1+C2)
      ALOGR=0.0
      IF (ABS(XXX-1.0).GT.1.E-4) ALOGR=ALOG(XXX)
      QM1=X1/C1-ALOGR/(C1*C3)
      IF (QM1.GT.AC) THEN
         X1=X1/5.0
         IF (X1.GT.1.E-3) GO TO 10
         WRITE (8,*) 'QM1 FAILED',QM1,X1,C1,C2,C3,AC,T1
      ENDIF
20    EXPR=0.0
      IF (C3*X2.GT.-25.0) EXPR=EXP(C3*X2)
      XXX=(C1+C2*EXPR)/(C1+C2)
      ALOGR=0.0
      IF (ABS(XXX-1.0).GT.1.E-4) ALOGR=ALOG(XXX)
      QM2=X2/C1-ALOGR/(C1*C3)
      IF (QM2.LT.AC) THEN
         X2=X2*2.0
         IF (X2.LT.10000.0) GO TO 20
         WRITE (8,*) 'QM2 FAILED',QM2,X2,C1,C2,C3,AC,T1
      ENDIF
25    X4=X2/5.0
      EXPR=0.0
      IF (C3*X4.GT.-25.0) EXPR=EXP(C3*X4)
      XXX=(C1+C2*EXPR)/(C1+C2)
      ALOGR=0.0
      IF(ABS(XXX-1.0).GT.1.E-4) ALOGR=ALOG(XXX)
      QM4=X4/C1-ALOGR/(C1*C3)
      IF (QM4.GT.AC) THEN
         X2=X4
         QM2=QM4
         IF (X2.GT.10.0) GO TO 25
      ENDIF
30    X3=X1+(X2-X1)*(AC-QM1)/(QM2-QM1)
      IF (X3.LT.1.E-10) WRITE (8,*) 'X3 FAILED',I,X1,X2,X3,DPPA(JQ,JP,5)
      EXPR=0.0
      IF (C3*X3.GT.-25.0) EXPR=EXP(C3*X3)
      XXX=(C1+C2*EXPR)/(C1+C2)
      ALOGR=0.0
      IF (ABS(XXX-1.0).GT.1.E-4) ALOGR=ALOG(XXX)
      QM3=X3/C1-ALOGR/(C1*C3)
      IF (QM3.LT.QM1.OR.QM3.GT.QM2) WRITE (8,*) 'QM3 FAILED',
     !         QM1,QM2,QM3,C1,C2,C3,X1,X2,X3,T1
      IF (ABS(QM3-AC).GT.(5.E-4*AC)) THEN
         IF (QM3.LE.AC) THEN
            X1=X3
            QM1=QM3
         ELSE
            X2=X3
            QM2=QM3
         ENDIF
         KK=KK+1
         IF (KK.LE.40) GO TO 30
         WRITE (8,*) 'COLUMN FAILED',I,QM1,QM2,AC,' X',X1,X2,X3,T1
      ENDIF
      IF (X3.LT.0.1) X3=0.1
C
C
      RETURN
      END

