module hitranconst

  use vtype_module

  implicit none

  private

!  integer      , parameter :: NHITRANMolNum = 49
  integer      , parameter :: NHITRANMolNum = 49+1+40+1
                              ! 49 by HITRAN + 41 blanks + 1 additional one
  integer      , parameter :: NHITRANIsoNum = 11
  real(DP)     , save      :: m_HITRANMolWt  ( NHITRANMolNum )
  character(10), save      :: m_HITRANMolName( NHITRANMolNum )
  real(sp)     , save      :: im_HITRANMolWt( NHITRANIsoNum, NHITRANMolNum )


  ! Below comes from program in radmodels/k-dist/data/HITRAN2012/molparam
  ! Original data comes from http://hitran.org/media/molparam.txt and
  ! http://hitran.org/docs/iso-meta/
  !
  ! But, He is added as No. 91.
  !
  ! Molecular name:
  data m_HITRANMolName &
    / &
    & "H2O     ", "CO2     ", "O3      ",  &
    & "N2O     ", "CO      ", "CH4     ",  &
    & "O2      ", "NO      ", "SO2     ",  &
    & "NO2     ", "NH3     ", "HNO3    ",  &
    & "OH      ", "HF      ", "HCl     ",  &
    & "HBr     ", "HI      ", "ClO     ",  &
    & "OCS     ", "H2CO    ", "HOCl    ",  &
    & "N2      ", "HCN     ", "CH3Cl   ",  &
    & "H2O2    ", "C2H2    ", "C2H6    ",  &
    & "PH3     ", "COF2    ", "SF6     ",  &
    & "H2S     ", "HCOOH   ", "HO2     ",  &
    & "O       ", "ClONO2  ", "NO+     ",  &
    & "HOBr    ", "C2H4    ", "CH3OH   ",  &
    & "CH3Br   ", "CH3CN   ", "CF4     ",  &
    & "C4H2    ", "HC3N    ", "H2      ",  &
    & "CS      ", "SO3     ", "C2N2    ",  &
    & "COCl2   ",                          &
    ! No. 50
    & "        ", &
    ! No. 51-90
    & 40*"        ", &
    ! He as No. 91
    & "He      " &
    /

  ! Mean molecular weight (kg mol-1):
  data m_HITRANMolWt &
    / &
    &    1.80152636E-02 ,    4.40097786E-02 ,    4.79970984E-02 ,  &
    &    4.40113507E-02 ,    2.80104484E-02 ,    1.60430688E-02 ,  &
    &    3.19984369E-02 ,    2.99942717E-02 ,    6.32543117E-02 ,  &
    &    4.56073023E-02 ,    1.70222539E-02 ,    6.25422969E-02 ,  &
    &    1.70005895E-02 ,    2.00063828E-02 ,    3.64607014E-02 ,  &
    &    8.09115693E-02 ,   0.127912432     ,    5.13256155E-02 ,  &
    &    5.99990338E-02 ,    3.00044846E-02 ,    5.23229130E-02 ,  &
    &    2.80182268E-02 ,    2.70203035E-02 ,    4.98920977E-02 ,  &
    &    3.38338241E-02 ,    2.60346122E-02 ,    3.00372057E-02 ,  &
    &    3.39813642E-02 ,    6.58462718E-02 ,   0.138690650     ,  &
    &    3.40629481E-02 ,    4.52647023E-02 ,    3.28361988E-02 ,  &
    &    1.59569755E-02 ,    9.63944271E-02 ,    2.98172217E-02 ,  &
    &    9.66614708E-02 ,    2.80324109E-02 ,    3.15756090E-02 ,  &
    &    9.38285887E-02 ,    3.99543643E-02 ,    8.70160088E-02 ,  &
    &    4.78148647E-02 ,    4.91411462E-02 ,    2.01596250E-03 ,  &
    &    4.40405197E-02 ,    7.54312649E-02 ,    5.04850745E-02 ,  &
    &    9.16662812E-02 ,                                          &
    ! No. 50
    &    0.0d0, &
    ! No. 51-90
    &    40*0.0d0, &
    ! He as No. 91
    &    4.0d-3 &
    /

  !
  ! Molecular weight (kg mol-1):
  data im_HITRANMolWt &
    / &
    &    1.80105660E-02 ,    2.00148113E-02 ,    1.90147813E-02 ,  &
    &    1.90167408E-02 ,    2.10209861E-02 ,    2.00209562E-02 ,  &
    &    2.00229157E-02 ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    4.39898334E-02 ,    4.49931845E-02 ,    4.59940769E-02 ,  &
    &    4.49940488E-02 ,    4.69974354E-02 ,    4.59973998E-02 ,  &
    &    4.79983240E-02 ,    4.69982922E-02 ,    4.59982641E-02 ,  &
    &    4.90016788E-02 ,    4.80016470E-02 ,  &
    &    4.79847491E-02 ,    4.99889925E-02 ,    4.99889925E-02 ,  &
    &    4.89889644E-02 ,    4.89889644E-02 ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    4.40010615E-02 ,    4.49980982E-02 ,    4.49980982E-02 ,  &
    &    4.60053086E-02 ,    4.50052805E-02 ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    2.79949158E-02 ,    2.89982706E-02 ,    2.99991630E-02 ,  &
    &    2.89991312E-02 ,    3.10025178E-02 ,    3.00024860E-02 ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    1.60313006E-02 ,    1.70346554E-02 ,    1.70374755E-02 ,  &
    &    1.80408321E-02 ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    3.19898315E-02 ,    3.39940786E-02 ,    3.29940468E-02 ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    2.99979914E-02 ,    3.09950244E-02 ,    3.20022367E-02 ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    6.39619082E-02 ,    6.59576952E-02 ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    4.59929071E-02 ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    1.70265492E-02 ,    1.80235840E-02 ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    6.29956499E-02 ,    6.39926791E-02 ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    1.70027409E-02 ,    1.90069880E-02 ,    1.80089157E-02 ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    2.00062301E-02 ,    2.10124049E-02 ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    3.59766781E-02 ,    3.79737318E-02 ,    3.69828530E-02 ,  &
    &    3.89799066E-02 ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    7.99261630E-02 ,    8.19241256E-02 ,    8.09323415E-02 ,  &
    &    8.29302967E-02 ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &   0.127912313     ,   0.128918484     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    5.09637706E-02 ,    5.29608205E-02 ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    5.99669889E-02 ,    6.19627833E-02 ,    6.09703436E-02 ,  &
    &    6.09663725E-02 ,    6.19712323E-02 ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    3.00105661E-02 ,    3.10139209E-02 ,    3.20148133E-02 ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    5.19715957E-02 ,    5.39686456E-02 ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    2.80061495E-02 ,    2.90031824E-02 ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    2.70108990E-02 ,    2.80142557E-02 ,    2.80079339E-02 ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    4.99923304E-02 ,    5.19893840E-02 ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    3.40054817E-02 ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    2.60156505E-02 ,    2.70190053E-02 ,    2.70218272E-02 ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    3.00469510E-02 ,    3.10503058E-02 ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    3.39972414E-02 ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    6.59917220E-02 ,    6.69950917E-02 ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &   0.145962507     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    3.39877233E-02 ,    3.59835178E-02 ,    3.49871069E-02 ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    4.60054837E-02 ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    3.29976566E-02 ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    1.59949157E-02 ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    9.69566777E-02 ,    9.89537239E-02 ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    2.99979914E-02 ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    9.59210768E-02 ,    9.79190320E-02 ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    2.80313008E-02 ,    2.90346555E-02 ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    3.20262164E-02 ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    9.39418152E-02 ,    9.59397703E-02 ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    4.10265513E-02 ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    8.79936218E-02 ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    5.00156544E-02 ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    5.10108992E-02 ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    2.01565004E-03 ,    3.02182510E-03 ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    4.39710356E-02 ,    4.59667891E-02 ,    4.49743718E-02 ,  &
    &    4.49704006E-02 ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    7.99568221E-02 ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    5.20061515E-02 ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    &    9.79326218E-02 ,    9.99296755E-02 ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,   -1.00000000     ,  &
    &   -1.00000000     ,   -1.00000000     ,  &
    ! No. 50
    &    11*-1.00000000  ,  &
    ! No. 51-90
    &    440*-1.00000000  ,  &
    ! He as No. 91
    &    4.0e-03        ,   10*-1.00000000     &
    /


  public :: NHITRANMolNum
  public :: NHITRANIsoNum
  public :: m_HITRANMolWt
  public :: m_HITRANMolName
!!$  public :: im_HITRANMolWt

  public :: HITRANConstIsoMolWt


  !----------------------------------------------------------------------------

contains

  !----------------------------------------------------------------------------

  function HITRANConstIsoMolWt( IMol, iiso ) result( mw )

    integer(i4b), intent(in ) :: IMol
    integer(i4b), intent(in ) :: iiso

    real(dp)                  :: mw


    ! Local variables
    !

    if ( ( iiso < 1 ) .or. ( NHITRANIsoNum < iiso ) ) then
      write( 6, * ) 'In HITRANConstIsoMolWt, iiso is inappropriate: ', iiso, '.'
      stop
    end if
    if ( ( IMol < 1 ) .or. ( NHITRANMolNum < IMol ) ) then
      write( 6, * ) 'In HITRANConstIsoMolWt, IMol is inappropriate: ', IMol, '.'
      stop
    end if

    mw = dble( im_HITRANMolWt( iiso, IMol ) )

    if ( mw < 0.0 ) then
      write( 6, * ) 'Unexpected isotope number, ', iiso, &
        ', of molecular number, ', IMol, '.'
      stop
    end if


  end function HITRANConstIsoMolWt

  !----------------------------------------------------------------------------

end module hitranconst
