Skip to content

Commit 41f0c43

Browse files
committed
Attempt to make hlv configurable via namelist
1 parent 7fe0efe commit 41f0c43

2 files changed

Lines changed: 56 additions & 3 deletions

File tree

constants/constants.F90

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ module constants_mod
4848
real, public, parameter :: RDGAS = 287.05_r8_kind !< Gas constant for dry air [J/kg/deg]
4949
real, public, parameter :: RVGAS = 461.50_r8_kind !< Gas constant for water vapor [J/kg/deg]
5050
! Extra:
51-
real, public, parameter :: HLV = 2.501e6_r8_kind !< Latent heat of evaporation [J/kg] try CICE/UM value for esm1.6
51+
real, public :: HLV = 2.500e6_r8_kind !< Latent heat of evaporation [J/kg]
5252
real, public, parameter :: HLF = 3.3358e5_r8_kind !< Latent heat of fusion [J/kg]
5353
real, public, parameter :: con_cliq = 4.1855e+3_r8_kind !< spec heat H2O liq [J/kg/K]
5454
real, public, parameter :: con_csol = 2.1060e+3_r8_kind !< spec heat H2O ice [J/kg/K]
@@ -77,7 +77,7 @@ module constants_mod
7777
real, public, parameter :: RDGAS = 287.04_r8_kind !< Gas constant for dry air [J/kg/deg]
7878
real, public, parameter :: RVGAS = 461.50_r8_kind !< Gas constant for water vapor [J/kg/deg]
7979
! Extra:
80-
real, public, parameter :: HLV = 2.500e6_r8_kind !< Latent heat of evaporation [J/kg]
80+
real, public :: HLV = 2.500e6_r8_kind !< Latent heat of evaporation [J/kg]
8181
real, public, parameter :: HLF = 3.34e5_r8_kind !< Latent heat of fusion [J/kg]
8282
real, public, parameter :: KAPPA = 2.0_r8_kind/7.0_r8_kind !< RDGAS / CP_AIR [dimensionless]
8383
real, public, parameter :: CP_AIR = RDGAS/KAPPA !< Specific heat capacity of dry air at constant pressure [J/kg/deg]
@@ -132,7 +132,7 @@ module constants_mod
132132
real, public, parameter :: C2DBARS = 1.e-4_r8_kind !< Converts rho*g*z (in mks) to dbars: 1dbar = 10^4 (kg/m^3)(m/s^2)m [dbars]
133133
real, public, parameter :: KELVIN = 273.15_r8_kind !< Degrees Kelvin at zero Celsius [K]
134134

135-
public :: constants_init
135+
public :: constants_init, read_fms_constants
136136

137137
contains
138138

@@ -141,6 +141,56 @@ subroutine constants_init
141141

142142
end subroutine constants_init
143143

144+
! <SUBROUTINE NAME="read_fms_constants">
145+
! <OVERVIEW>
146+
! Read runtime configurable constants from the fms_constants_nml namelist.
147+
! </OVERVIEW>
148+
! <TEMPLATE>
149+
! call read_fms_constants ()
150+
! </TEMPLATE>
151+
! <DESCRIPTION>
152+
! Some constants can be configured in the fms_constants_nml namelist. Read the namelist
153+
! and overwrite the default values.
154+
! </DESCRIPTION>
155+
! <INOUT NAME="output_field" TYPE="TYPE(output_field_type)">Output field that needs the cell_measures</INOUT>
156+
! <IN NAME="area" TYPE="INTEGER, OPTIONAL">Field ID for area</IN>
157+
! <IN NAME="volume" TYPE="INTEGER, OPTIONAL">Field ID for volume</IN>
158+
! <OUT NAME="err_msg" TYPE="CHARACTER(len=*), OPTIONAL"> </OUT>
159+
subroutine read_fms_constants
160+
161+
USE fms_mod, ONLY: check_nml_error, stdlog
162+
USE mpp_mod, ONLY: mpp_pe, mpp_root_pe
163+
#ifdef INTERNAL_FILE_NML
164+
USE mpp_mod, ONLY: input_nml_file
165+
#else
166+
USE fms_mod, ONLY: open_namelist_file, close_file
167+
INTEGER :: nml_unit
168+
#endif
169+
integer :: mystat, ierr, stdlog_unit
170+
171+
NAMELIST /fms_constants_nml/ hlv
172+
173+
#ifdef INTERNAL_FILE_NML
174+
READ (input_nml_file, NML=fms_constants_nml, IOSTAT=mystat)
175+
#else
176+
if ( file_exist('input.nml') ) then
177+
nml_unit = open_namelist_file ( )
178+
ierr=1
179+
do while (ierr > 0)
180+
read (nml_unit, nml=fms_constants_nml, iostat=mystat)
181+
ierr = check_nml_error(mystat,'fms_constants_nml')
182+
enddo
183+
call close_file (nml_unit)
184+
endif
185+
#endif
186+
187+
stdlog_unit = stdlog()
188+
IF ( mpp_pe() == mpp_root_pe() ) THEN
189+
WRITE (stdlog_unit, fms_constants_nml)
190+
END IF
191+
192+
end subroutine read_fms_constants
193+
144194
end module constants_mod
145195

146196
! <FUTURE>

fms/fms.F90

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ module fms_mod
166166

167167
use memutils_mod, only: print_memuse_stats, memutils_init
168168
use constants_mod, only: constants_version=>version !pjp: PI not computed
169+
use constants_mod, only: read_fms_constants
169170

170171

171172
implicit none
@@ -447,6 +448,8 @@ subroutine fms_init (localcomm )
447448

448449
call write_version_number("CONSTANTS_MOD", constants_version)
449450

451+
call read_fms_constants()
452+
450453
end subroutine fms_init
451454
! </SUBROUTINE>
452455

0 commit comments

Comments
 (0)