    !**************************************************************************
    ! subroutine tempcorrect
    ! calculate line strength, lorentz halfwidth, doppler halfwidth
    !**************************************************************************
    ! tpress            : total pressure (Pa)
    ! ppress            : partial pressure (Pa)
    ! temp              : temperature (K)
    ! mmass             : molecular mass (kg)
    ! imol              : molecular number
    ! linen             : number of lines
    ! iiso              : isotopomer index
    ! wnlc0(linen)      : wave number at line center (m^-1)
    ! stren0(linen)     : line strength (m^-1 / molecule m^-2)
    ! lowene(linen)     : lower level energy of the transition (m^-1)
    ! abwid0(linen)     : air-broadened half width (m^-1 @ 296K)
    ! sbwid0(linen)     : self-broadened half width (m^-1 @ 296K)
    ! tdep_abw(linen)   : coefficient of temperature dependence of
    !                   : air-broadened halfwidth
    ! tdep_sbw(linen)   : coefficient of temperature dependence of
    !                   : self-broadened halfwidth
    ! stren1(linen)     : line strength after temperature/pressure correction 
    !                   : (m^-1 / molecule m^-2)
    ! lowid1(linen)     : lorentz halfwidth
    !                   : after temperature/pressure correction (m^-1)
    ! dowid1(linen)     : doppler halfwidth
    !                   : after temperature/pressure correction (m^-1)
    ! kmingn
    ! kmaxgn
    !**************************************************************************

    subroutine tempcorrect( tpress, ppress, temp, mmass, &
         imol, linen, iiso, wnlc0, stren0, lowene, &
         abwid0, sbwid0, tdep_abw, tdep_sbw, &
         stren1, pbwid1, dowid1, &
         ls, le )

      use vtype_module
      use const_module

      implicit none

      real(dp)    , intent(in ) :: tpress, ppress, temp, mmass
      integer(i4b), intent(in ) :: imol
      integer(i4b), intent(in ) :: linen
      integer(i4b), intent(in ) :: iiso( linen )
      real(dp)    , intent(in ) :: wnlc0( linen ), stren0( linen ), &
           lowene( linen ), abwid0( linen ), sbwid0( linen ), &
           tdep_abw( linen ), tdep_sbw( linen )
      real(dp)    , intent(out) :: stren1( linen ), pbwid1( linen ), &
           dowid1( linen )
      integer(i4b), intent(in ) :: ls, le


      !
      ! local variables
      !
      real(dp)                  :: press0 = 101325.0d0, temp0 = 296.0d0
      real(dp)                  :: c2 = planc * c / boltz
      real(dp)    , allocatable :: tips0( : ), tips( : )
      integer(i4b)              :: niso
      real(dp)                  :: gi
      integer(i4b)              :: i, l


      niso = 1
!!$      do l = 1, linen
!!$         niso = max( iiso( l ), niso )
!!$      end do
      do l = ls, le
         niso = max( iiso( l ), niso )
      end do
      allocate( tips0( niso ), tips( niso ) )
      do i = 1, niso
         call BD_TIPS_2003( imol, temp0, iiso( i ), gi, tips0( i ) )
         call BD_TIPS_2003( imol, temp , iiso( i ), gi, tips ( i ) )
      end do
!!$      tips0( : ) = 1.0d0
!!$      tips ( : ) = 1.0d0


!!$!      stren1( : ) = stren0( : ) * ( temp0 / temp ) &
!!$!           * exp( planc * c / boltz * lowene( : ) &
!!$!           * ( 1.0d0 / temp0 - 1.0d0 / temp ) )
!!$      stren1( : ) = stren0( : ) &
!!$           * tips0( iiso( : ) ) / tips( iiso( : ) ) &
!!$           * exp( c2 * lowene( : ) * ( 1.0d0 / temp0 - 1.0d0 / temp ) ) &
!!$           * ( 1.0d0 - exp( -c2 * wnlc0( : ) / temp  ) ) &
!!$           / ( 1.0d0 - exp( -c2 * wnlc0( : ) / temp0 ) )
!!$
!!$      pbwid1( : ) &
!!$           = abwid0(:)*((tpress-ppress)/press0) * (temp0/temp)**tdep_abw(:) &
!!$           + sbwid0(:)*(ppress         /press0) * (temp0/temp)**tdep_sbw(:)
!!$
!!$      dowid1( : ) = wnlc0( : ) / c * sqrt( 2.0d0 * boltz * temp / mmass )



      do l = 1, ls-1
         stren1( l ) = 1.0d100
         pbwid1( l ) = 1.0d100      
         dowid1( l ) = 1.0d100
      end do
      do l = ls, le
         stren1( l ) = stren0( l ) &
              * tips0( iiso( l ) ) / tips( iiso( l ) ) &
              * exp( c2 * lowene( l ) * ( 1.0d0 / temp0 - 1.0d0 / temp ) ) &
              * ( 1.0d0 - exp( -c2 * wnlc0( l ) / temp  ) ) &
              / ( 1.0d0 - exp( -c2 * wnlc0( l ) / temp0 ) )

         pbwid1( l ) &
              = abwid0(l)*((tpress-ppress)/press0)*(temp0/temp)**tdep_abw(l) &
              + sbwid0(l)*(ppress         /press0)*(temp0/temp)**tdep_sbw(l)
      
         dowid1( l ) = wnlc0( l ) / c * sqrt( 2.0d0 * boltz * temp / mmass )
      end do
      do l = le+1, linen
         stren1( l ) = 1.0d100
         pbwid1( l ) = 1.0d100      
         dowid1( l ) = 1.0d100
      end do


      deallocate( tips0, tips )


    end subroutine tempcorrect
