Skip to content

Commit 0fdb47c

Browse files
marshallwardHallberg-NOAA
authored andcommitted
FMS API: Convert real kind of constants
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.
1 parent 0337147 commit 0fdb47c

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

config_src/infra/FMS1/MOM_constants.F90

+7-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ module MOM_constants
33

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

6-
use constants_mod, only : HLV, HLF
6+
use constants_mod, only : FMS_HLV => HLV
7+
use constants_mod, only : FMS_HLF => HLF
78

89
implicit none ; private
910

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

1418
end module MOM_constants

config_src/infra/FMS2/MOM_constants.F90

+7-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ module MOM_constants
33

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

6-
use constants_mod, only : HLV, HLF
6+
use constants_mod, only : FMS_HLV => HLV
7+
use constants_mod, only : FMS_HLF => HLF
78

89
implicit none ; private
910

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

1418
end module MOM_constants

0 commit comments

Comments
 (0)