! Copyright 2008-2021 Earth Sciences Department, BSC-CNS
!
! This file is part of MONARCH.
!
! MONARCH is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
!
! MONARCH is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with MONARCH. If not, see <http://www.gnu.org/licenses/>.

!> \file
!> The monarch_constants_t object

!> Physical constants
module monarch_constants

#ifdef DO_PARTMC
  use pmc_constants,                 only : i_kind, dp, sp
#endif

  implicit none

#ifdef DO_PARTMC
  !> Kind of an integer
  integer, parameter :: mint = i_kind
  !> Kind of a single precision real number
  integer, parameter :: mflt = sp
  !> Kind of a double precision real number
  integer, parameter :: mdbl = dp
#else
  !> Kind of an integer
  integer, parameter :: mint = kind(1)
  !> Kind of a single precision real number
  integer, parameter :: mflt = kind(0.0)
  !> Kind of a double precision real number
  integer, parameter :: mdbl = kind(0.0d0)
#endif

  !> Physical constants
  type monarch_constants_t
    !> Pi.
    real(kind=mdbl) :: pi = 3.14159265358979323846d0
    !> Molecular weight of dry air [kg mol-1]
    real(kind=mdbl) :: molec_weight_dry_air__kgmol = 0.0289628d0
    !> Molecular weight of water [kg mol-1]
    real(kind=mdbl) :: molec_weight_water__kgmol = 0.0180153d0
    !> Universal gas constant [J mol-1 K-1]
    real(kind=mdbl) :: gas_const__JmolK = 8.314472d0
  end type monarch_constants_t

  !> Instance of physical constants type.
  !!
  !! Include this in your module to access the physical constants.
  type(monarch_constants_t), save :: const

end module monarch_constants
