Skip to content

Commit

Permalink
FMS API: Convert real kind of constants
Browse files Browse the repository at this point in the history
Two latent heat constants are imported directly from FMS, which is built
independently of MOM6.  Previously, it was a safe assumption that both
would be built with double precision, but this is no longer the case
since FMS now supports both single and double precision.  This could
cause conflicts with mixed-precision builds.

This patch converts the values from FMS-precision to MOM-precision.

Single->double should not affect reproducibility since every
single-precision number can be exactly represented in double precision.
Double->single could affect reproducibility, but this is not an issue
since MOM6 does not run in single precision.
  • Loading branch information
marshallward committed Dec 8, 2024
1 parent 0337147 commit b9a4965
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 7 additions & 3 deletions config_src/infra/FMS1/MOM_constants.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ module MOM_constants

! This file is part of MOM6. See LICENSE.md for the license.

use constants_mod, only : HLV, HLF
use constants_mod, only : FMS_HLV => HLV
use constants_mod, only : FMS_HLF => HLF

implicit none ; private

!> The constant offset for converting temperatures in Kelvin to Celsius
real, public, parameter :: CELSIUS_KELVIN_OFFSET = 273.15
public :: HLV, HLF
!< The constant offset for converting temperatures in Kelvin to Celsius [K]
real, public, parameter :: HLV = real(FMS_HLV, kind=kind(1.0))
!< Latent heat of vaporization [J kg-1]
real, public, parameter :: HLF = real(FMS_HLF, kind=kind(1.0))
!< Latent heat of fusion [J kg-1]

end module MOM_constants
10 changes: 7 additions & 3 deletions config_src/infra/FMS2/MOM_constants.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ module MOM_constants

! This file is part of MOM6. See LICENSE.md for the license.

use constants_mod, only : HLV, HLF
use constants_mod, only : FMS_HLV => HLV
use constants_mod, only : FMS_HLF => HLF

implicit none ; private

!> The constant offset for converting temperatures in Kelvin to Celsius
real, public, parameter :: CELSIUS_KELVIN_OFFSET = 273.15
public :: HLV, HLF
!< The constant offset for converting temperatures in Kelvin to Celsius [K]
real, public, parameter :: HLV = real(FMS_HLV, kind=kind(1.0))
!< Latent heat of vaporization [J kg-1]
real, public, parameter :: HLF = real(FMS_HLF, kind=kind(1.0))
!< Latent heat of fusion [J kg-1]

end module MOM_constants

0 comments on commit b9a4965

Please sign in to comment.