      SUBROUTINE chkdt

      IMPLICIT NONE

      INCLUDE 'param.txt'
      INCLUDE 'common.txt'

      REAL dr2,dz2,df,df2,kcoeff,tmp1,tmp2,tmp3,tmp4,tmp5
      REAL dt1,dt2

      REAL alpha,beta,preexp,incrho,rhoi

      COMMON /heatrl/ alpha,beta,preexp,incrho,rhoi

c------------------------------------------------------------------

      dt = dtmax
      dt1=dtmax
      dt2=dtmax

      DO k=1,kmax
         DO j=1,jmax
            DO i=1,imax

               df  = rp(i)*dphi
               df2 = df*df

               dr2 = dr(i) * dr(i)
               dz2 = dz(k) * dz(k)

               kcoeff = munew(i,j,k)

               tmp1 = ( abs(Unew(i,j,k)) / ( rp(i+1)-rp(i) ) ) +
     &             ( abs(Vnew(i,j,k)) /         df        ) +
     &             ( abs(Wnew(i,j,k)) /    ( zp(k+1)-zp(k) ) )


c *** explicit diffusion in 3-directions

               tmp2 = ( 1.0/dr2 + 1.0/df2 + 1.0/dz2 )
               tmp3 = 1.0 / ( 4.0 * tmp2 * kcoeff + tmp1 )

c *** explicit diffusion in 2-directions, implicit in 1-direction

               tmp4 = ( 1.0/dr2 + 1.0/dz2 )
               tmp5 = 1.0 / ( 4.0 * tmp4 * kcoeff + tmp1 )

c *** Security factor 0.5 according for non-linear instabilities:

c *** 10/02/1993 increased to 0.8 because in non-uniform grid, the time-
c *** is limited almost completely by the molecular diffusion in the
c *** first gridcell near the wall (dr(imax) which is extremely small!).
c *** Non-linear instabilities are related to the non-linear advection
c *** terms and not to the linear diffusion terms.
c *** Therefore, security factor increased to 0.8.
c pipe flow
c               tmp3 = 0.75 * tmp3

c jet flow

c               tmp3 = .3 * tmp3   ! constant, alpha=.4

               tmp3 = .55 * tmp3
               tmp5 = .55 * tmp5
               
               dt1 = MIN(dt1,tmp3)
               dt2 = MIN(dt2,tmp5)

            END DO

         END DO

      END DO

      dt=dt1

      print*,'dt1=',dt1
c      print*,'dt1=',dt1,'dt2=',dt2


      WRITE(18,150) istep,dt
 150  FORMAT('  istep : ',i6,'   dt : ',f12.8)

      RETURN
      END
