!
      subroutine cpktkm(tn,ch4,h2,fcp,fkt,fkm,lev0,lev1,lon0,lon1,lat)
!
! ------------------------------------------------------------------
! Define diagnostics CP, KT, and KM for Titan.
! Latest revision ; 09/15/04 S. w. BOUGHER
! ------------------------------------------------------------------
!
      use cons_module,only: rmassinv_ch4,rmassinv_h2,rmassinv_n2,gask,t0
      implicit none
!
! Args:
      integer,intent(in) :: lev0,lev1,lon0,lon1,lat
      real,dimension(lev0:lev1,lon0-2:lon1+2),intent(in) :: 
     |  tn,  ! neutral temperature (deg K)
     |  ch4, ! methane (mmr)  
     |  h2   ! molecular hydrogen (mmr) 
      real,dimension(lev0:lev1,lon0-2:lon1+2),intent(out) :: 
     |  fcp, ! specific heat at constant pressure (ergs/deg/gm)
     |  fkt, ! molecular diffusion (ergs/cm/deg/sec)
     |  fkm  ! molecular viscosity (gm/cm/sec)
!
! Local:
      integer :: k,i
      real,dimension(lev0:lev1,lon0:lon1) ::
     |  fmbar,        ! mean mass
     |  pch4,ph2,pn2  ! mixing ratios
      integer :: nlons,nlevs
!
      nlons = lon1-lon0+1
      nlevs = lev1-lev0+1

!     call addfsech('tn_cp',' ',' ',tn(:,lon0:lon1),lon0,lon1,nlevs,
!    |  nlevs-1,lat)
!     call addfsech('ch4_cp',' ',' ',o2(:,lon0:lon1),lon0,lon1,nlevs,
!    |  nlevs-1,lat)
!     call addfsech('h2_cp',' ',' ',o1(:,lon0:lon1),lon0,lon1,nlevs,
!    |  nlevs-1,lat)
!
      do i=lon0,lon1
        do k=lev0,lev1
          fmbar(k,i) = 1./(ch4(k,i)*rmassinv_ch4 + h2(k,i)*rmassinv_h2
     |                 + (1.-ch4(k,i)-h2(k,i))*rmassinv_n2)
          pch4(k,i) = fmbar(k,i)*ch4(k,i)*rmassinv_ch4
          ph2(k,i) = fmbar(k,i)*h2(k,i)*rmassinv_h2
          pn2(k,i) = 1.-pch4(k,i)-ph2(k,i)
!    cp : only N2 and CH4 dependencies are included.
          fcp(k,i) = gask*.5*(pn2(k,i)*7./28.+ pch4(k,i)*7./16)
!    km : only N2 dependencies are included.
          fkm(k,i) = pn2(k,i)*3.42
!    kt : only N2 dependencies are included.
          fkt(k,i) = pn2(k,i)*56.0
        enddo
      enddo      
!     call addfsech('fcp1',' ',' ',fcp,nlons,nlevs,nlevs,lat)
!     call addfsech('fkm1',' ',' ',fkm,nlons,nlevs,nlevs,lat)
!     call addfsech('fkt1',' ',' ',fkt,nlons,nlevs,nlevs,lat)
!
      do i=lon0,lon1
        do k=lev0,lev1-1
          fkm(k,i) = fkm(k,i)*tn(k,i)**0.69*1.e-6
          fkt(k,i) = fkt(k,i)*tn(k,i)**0.69
        enddo
      enddo
!     Top level Calculations : 
      do i=lon0,lon1
        fkm(lev1,i) = 1.e-6*fkm(lev1,i)*tn(lev1-1,i)**0.69
        fkt(lev1,i) = fkt(lev1,i)*tn(lev1-1,i)**0.69
      enddo
!     call addfsech('fcp2',' ',' ',fcp,nlons,nlevs,nlevs,lat)
!     call addfsech('fkm2',' ',' ',fkm,nlons,nlevs,nlevs,lat)
!     call addfsech('fkt2',' ',' ',fkt,nlons,nlevs,nlevs,lat)
!
!     Interfaces to midlevels conversion
      do i=lon0,lon1
        do k=lev1,lev0+1,-1
          fcp(k,i) = .5*(fcp(k,i)+fcp(k-1,i))
          fkm(k,i) = .5*(fkm(k,i)+fkm(k-1,i))
          fkt(k,i) = .5*(fkt(k,i)+fkt(k-1,i))
!	  write(6,"('i=',i3,' k=',i3,' fcp,km,kt=',3e12.4)")
!    |      i,k,fcp(k,i),fkm(k,i),fkt(k,i)
        enddo 
      enddo
!     Ghost cells?
      do i=lon0,lon1
        fcp(1,i) = 2.*fcp(1,i)-fcp(2,i)
        fkm(1,i) = 2.*fkm(1,i)-fkm(2,i)
        fkt(1,i) = 2.*fkt(1,i)-fkt(2,i)
      enddo

!     call addfsech('CP',' ',' ',fcp(:,lon0:lon1),lon0,lon1,nlevs,
!    |  nlevs,lat)
!     call addfsech('KT',' ',' ',fkt(:,lon0:lon1),lon0,lon1,nlevs,
!    |  nlevs,lat)
!     call addfsech('KM',' ',' ',fkm(:,lon0:lon1),lon0,lon1,nlevs,
!    |  nlevs,lat)

      end subroutine cpktkm
