elemental subroutine qmmr_hPa(t, p1, es, qm)
!elemental subroutine qmmr_hPa(t, p, es, qm)
  !use wv_saturation, only: qmmr

    integer , parameter :: r8 = selected_real_kind(12)
    real(r8), parameter :: epsilo = 18.016_r8/28.966_r8
    real(r8), parameter :: tboil = 373.15_r8
    real(r8), parameter :: tmelt = 273.15_r8
    real(r8), parameter :: c1 = 611.2_r8
    real(r8), parameter :: c2 = 17.67_r8
    real(r8), parameter :: c3 = 243.5_r8

  ! Inputs
  real(r8), intent(in) :: t    ! Temperature (K)
  !real(r8), intent(in) :: p    ! Pressure (hPa)
  real(r8), intent(in) :: p1   ! Pressure (hPa)
  real(r8) :: p

  ! Outputs
  real(r8), intent(out) :: es  ! Saturation vapor pressure (hPa)
  real(r8), intent(out) :: qm  ! Saturation mass mixing ratio
                               ! (vapor mass over dry mass, kg/kg)

  !call qmmr(t, p*100._r8, es, qm)
  p = p1*100._r8
  es = c1*exp( (c2*(t - tmelt))/((t - tmelt)+c3) )

  if ( (p - es) < epsilon(1.0_r8)**2 ) then
      qm = huge(1.0_r8)
  else
      qm = epsilo*es / (p - es)
      !wx: 20191211
      !qm = epsilo*es / (p - 0.378*es)
  end if

  es = min(es, p)
  es = es*0.01_r8

end subroutine qmmr_hPa
