Skip to content

Commit 88bb6d4

Browse files
committed
Let config_len_disp default to 0.0, in which case its value is set by nominalMinDc
With this commit, the config_len_disp namelist option defaults to 0.0 and is hidden by default. Additionally, a new variable, nominalMinDc, is read from the input file and read/written from/to restart files. If a positive value for config_len_disp is supplied in the &nhyd_model namelist group, then that value is used for the horizontal length scale in the model; otherwise, if a positive value for the nominalMinDc variable is found in the input file, that value is used. If both config_len_disp and nominalMinDc values are positive real values, and if they differ by very much (~1.0e-6 relative difference), then a warning is printed to the log file, and the value specified in the namelist for config_len_disp is used to set nominalMinDc. If neither config_len_disp was specified in namelist.atmosphere file nor a valid value for nominalMinDc was read from the input file, the atmosphere core initialization will stop with an error: ERROR: Both config_len_disp and nominalMinDc are <= 0.0. ERROR: Please either specify config_len_disp in the &nhyd_model namelist group, ERROR: or use an input file that provides a valid value for the nominalMinDc variable.
1 parent fb00fe1 commit 88bb6d4

2 files changed

Lines changed: 60 additions & 2 deletions

File tree

src/core_atmosphere/Registry.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,10 @@
142142
description="Formulation of horizontal mixing"
143143
possible_values="`2d_fixed' or `2d_smagorinsky'"/>
144144

145-
<nml_option name="config_len_disp" type="real" default_value="120000.0"
145+
<nml_option name="config_len_disp" type="real" default_value="0.0" in_defaults="false"
146146
units="m"
147147
description="Horizontal length scale, used by the Smagorinsky formulation of horizontal diffusion and by 3-d divergence damping"
148-
possible_values="Positive real values"/>
148+
possible_values="Positive real values. A zero value implies that the length scale is prescribed by the nominalMinDc value in the input file."/>
149149

150150
<nml_option name="config_visc4_2dsmag" type="real" default_value="0.05"
151151
units="-"
@@ -457,6 +457,7 @@
457457
<var name="fEdge"/>
458458
<var name="fVertex"/>
459459
<var name="meshDensity"/>
460+
<var name="nominalMinDc"/>
460461
<var name="bdyMaskCell"/>
461462
<var name="bdyMaskEdge"/>
462463
<var name="bdyMaskVertex"/>
@@ -592,6 +593,7 @@
592593
<var name="fEdge"/>
593594
<var name="fVertex"/>
594595
<var name="meshDensity"/>
596+
<var name="nominalMinDc"/>
595597
<var name="bdyMaskCell"/>
596598
<var name="bdyMaskEdge"/>
597599
<var name="bdyMaskVertex"/>
@@ -1305,6 +1307,9 @@
13051307
<var name="meshDensity" type="real" dimensions="nCells" units="unitless"
13061308
description="Mesh density function (used when generating the mesh) evaluated at a cell"/>
13071309

1310+
<var name="nominalMinDc" type="real" dimensions="" units="m"
1311+
description="Nominal minimum dcEdge value where meshDensity == 1.0"/>
1312+
13081313
<var name="meshScalingDel2" type="real" dimensions="nEdges" units="unitless"
13091314
description="Scaling coefficient for $\nabla^2$ eddy viscosity"/>
13101315

src/core_atmosphere/mpas_atm_core.F

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ function atm_core_init(domain, startTimeStamp) result(ierr)
7171
character (len=StrKIND), pointer :: initial_time1, initial_time2
7272
type (MPAS_Time_Type) :: startTime
7373

74+
real (kind=RKIND), pointer :: nominalMinDc
75+
real (kind=RKIND), pointer :: config_len_disp
76+
7477
integer, pointer :: nVertLevels, maxEdges, maxEdges2, num_scalars
7578
character (len=ShortStrKIND) :: init_stream_name
7679
real (kind=R8KIND) :: input_start_time, input_stop_time
@@ -149,6 +152,56 @@ function atm_core_init(domain, startTimeStamp) result(ierr)
149152
call MPAS_stream_mgr_reset_alarms(domain % streamManager, streamID='restart', direction=MPAS_STREAM_INPUT, ierr=ierr)
150153
call mpas_log_write(' ----- done reading initial state -----')
151154

155+
156+
!
157+
! Determine horizontal length scale used by horizontal diffusion and 3-d divergence damping
158+
!
159+
call mpas_pool_get_subpool(domain % blocklist % structs, 'mesh', mesh)
160+
nullify(nominalMinDc)
161+
call mpas_pool_get_array(mesh, 'nominalMinDc', nominalMinDc)
162+
163+
nullify(config_len_disp)
164+
call mpas_pool_get_config(domain % blocklist % configs, 'config_len_disp', config_len_disp)
165+
166+
call mpas_log_write('')
167+
168+
!
169+
! If config_len_disp was specified as a valid value, use that
170+
!
171+
if (config_len_disp > 0.0_RKIND) then
172+
call mpas_log_write('Setting nominalMinDc to $r based on namelist option config_len_disp', realArgs=[config_len_disp])
173+
174+
!
175+
! But if nominalMinDc was available in the input file and is different, print a warning
176+
!
177+
if (nominalMinDc > 0.0_RKIND .and. abs(nominalMinDc - config_len_disp) > 1.0e-6_RKIND * config_len_disp) then
178+
call mpas_log_write('nominalMinDc was read from input file as a positive value ($r) that differs', &
179+
realArgs=[nominalMinDc], messageType=MPAS_LOG_WARN)
180+
call mpas_log_write('from the specified config_len_disp value ($r)', &
181+
realArgs=[config_len_disp], messageType=MPAS_LOG_WARN)
182+
end if
183+
184+
nominalMinDc = config_len_disp
185+
186+
!
187+
! Otherwise, try to use nominalMinDc
188+
!
189+
else
190+
if (nominalMinDc > 0.0_RKIND) then
191+
call mpas_log_write('Setting config_len_disp to $r based on nominalMinDc value in input file', realArgs=[nominalMinDc])
192+
config_len_disp = nominalMinDc
193+
else
194+
call mpas_log_write('Both config_len_disp and nominalMinDc are <= 0.0.', messageType=MPAS_LOG_ERR)
195+
call mpas_log_write('Please either specify config_len_disp in the &nhyd_model namelist group,', &
196+
messageType=MPAS_LOG_ERR)
197+
call mpas_log_write('or use an input file that provides a valid value for the nominalMinDc variable.', &
198+
messageType=MPAS_LOG_ERR)
199+
ierr = 1
200+
return
201+
end if
202+
end if
203+
204+
152205
!
153206
! Read all other inputs
154207
! For now we don't do this here to match results with previous code; to match requires

0 commit comments

Comments
 (0)