Skip to content

Commit 7f5344c

Browse files
removed lbc domain
1 parent f5c4af8 commit 7f5344c

File tree

3 files changed

+27
-128
lines changed

3 files changed

+27
-128
lines changed

models/mpas_atm/model_mod.f90

+3-110
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,8 @@ module model_mod
165165
cell_next_to_boundary_edge
166166

167167
public :: update_u_from_reconstruct, &
168-
set_lbc_variables, &
169-
force_u_into_state, &
170168
use_increments_for_u_update, &
171-
anl_domid, lbc_domid ! HK todo accessor functions?
172-
173-
! set_lbc_variables sets the lbc_variables string array
174-
! force_u_into_state sets a logical add_u_to_state_list that forces u to be in state
169+
anl_domid ! HK todo accessor functions?
175170

176171
character(len=*), parameter :: source = 'models/mpas_atm/model_mod.f90'
177172

@@ -231,7 +226,6 @@ module model_mod
231226
logical :: search_initialized = .false.
232227

233228
integer :: anl_domid = -1
234-
integer :: lbc_domid = -1
235229

236230
!------------------------------------------------------------------------
237231
! variables which are in the model_nml namelist
@@ -265,11 +259,6 @@ module model_mod
265259
! assimilation, and use only the increments to update the edge winds
266260
logical :: use_increments_for_u_update = .true.
267261

268-
! if set by: call force_u_into_state() *BEFORE* calling static_init_model(),
269-
! the code will add U (edge normal winds) to the mpas state vector even if it
270-
! isn't in the namelist.
271-
logical :: add_u_to_state_list = .false.
272-
273262
! if > 0, amount of distance in fractional model levels that a vertical
274263
! point can be above or below the top or bottom of the grid and still be
275264
! evaluated without error.
@@ -323,27 +312,9 @@ module model_mod
323312
!------------------------------------------------------------------------
324313
! for regional MPAS
325314
real(r8) :: dxmax ! max distance between two adjacent cell centers in the mesh (in meters)
326-
327-
! when updating boundary files for regional mpas, note whether the boundary
328-
! file has the reconstructed winds (lbc_ur, lbc_vr) or not. (this is set by
329-
! looking at the bdy template file and seeing if those variables are there.)
330-
! if not, the other two options are ignored.
331-
! if they are in the lbc file, then the other logicals control whether to use
332-
! them instead of updating the U edge winds directly, and whether to use the
333-
! reconstructed increments or not.
334-
! the latter two options could be added to the namelist if someone wanted to
335-
! explore the options for how the edge winds are updated in the boundary file.
336-
! for now they're not - they're hardcoded true.
337-
! note that these are for the boundary file update only - there are separate
338-
! options for how to update the U winds in the main assimilation state.
339-
340-
logical :: lbc_file_has_reconstructed_winds = .false.
341-
342-
! this is special and not in the namelist. boundary files have a fixed
343-
! set of variables with fixed names.
344-
character(len=vtablenamelength) :: lbc_variables(MAX_STATE_VARIABLES) = ''
345315
!------------------------------------------------------------------------
346316

317+
347318
! Grid parameters - the values will be read from an mpas analysis file.
348319
integer :: nCells = -1 ! Total number of cells making up the grid
349320
integer :: nVertices = -1 ! Unique points in grid that are corners of cells
@@ -432,7 +403,7 @@ subroutine static_init_model()
432403
integer :: iunit, io, ivar, i
433404
integer :: ss, dd, z1, m1
434405
integer :: nDimensions, nVariables, nAttributes, unlimitedDimID, TimeDimID
435-
integer :: nfields, lbc_nfields
406+
integer :: nfields
436407
logical :: both
437408
real(r8) :: variable_bounds(MAX_STATE_VARIABLES, 2)
438409
integer :: variable_qtys(MAX_STATE_VARIABLES)
@@ -479,25 +450,6 @@ subroutine static_init_model()
479450

480451
model_size = get_domain_size(anl_domid)
481452

482-
lbc_nfields = 0
483-
484-
! if we have a lateral boundary file, add it to the domain
485-
! so we have access to the corresponding lbc_xxx fields.
486-
if (.not. global_grid .and. lbc_variables(1) /= '') then
487-
! regional: count number of lbc fields to read in
488-
COUNTUP: do i=1, MAX_STATE_VARIABLES
489-
if (lbc_variables(i) /= '') then
490-
lbc_nfields = lbc_nfields + 1
491-
else
492-
exit COUNTUP
493-
endif
494-
enddo COUNTUP
495-
lbc_domid = add_domain(bdy_template_filename, lbc_nfields, &
496-
var_names = lbc_variables)
497-
! FIXME clamp_vals = variable_bounds(1:nfields,:) )
498-
model_size = model_size + get_domain_size(lbc_domid)
499-
endif
500-
501453
! if you have at least one of these wind components in the state vector,
502454
! you have to have them both. the subroutine will error out if only one
503455
! is found and not both.
@@ -1402,57 +1354,6 @@ end subroutine get_close_state
14021354
! (these are not required by dart but are used by other programs)
14031355
!==================================================================
14041356

1405-
1406-
!-------------------------------------------------------------------
1407-
! modify what static_init_model does. this *must* be called before !HK Nope this is not good.
1408-
! calling static_init_model().
1409-
! the boundary file variables are fixed by the model and so we
1410-
! don't allow the user to set them via namelist
1411-
1412-
subroutine set_lbc_variables(template_filename)
1413-
1414-
character(len=*), intent(in) :: template_filename
1415-
1416-
integer :: ncid
1417-
1418-
bdy_template_filename = template_filename
1419-
1420-
! this initial list always exists. hardcode them for now,
1421-
! and query to see if the reconstructed winds are there or not.
1422-
1423-
lbc_variables(1) = 'lbc_qc'
1424-
lbc_variables(2) = 'lbc_qr'
1425-
lbc_variables(3) = 'lbc_qv'
1426-
lbc_variables(4) = 'lbc_rho'
1427-
lbc_variables(5) = 'lbc_theta'
1428-
lbc_variables(6) = 'lbc_u'
1429-
lbc_variables(7) = 'lbc_w'
1430-
1431-
ncid = nc_open_file_readonly(template_filename, 'set_lbc_variables')
1432-
if (nc_variable_exists(ncid, 'lbc_ur')) then
1433-
lbc_variables(8) = 'lbc_ur'
1434-
lbc_variables(9) = 'lbc_vr'
1435-
lbc_file_has_reconstructed_winds = .true.
1436-
endif
1437-
call nc_close_file(ncid)
1438-
1439-
end subroutine set_lbc_variables
1440-
1441-
1442-
!-------------------------------------------------------------------
1443-
! modify what static_init_model does. this *must* be called before
1444-
! calling static_init_model().
1445-
! set a logical add_u_to_state_list that forces u to be in state
1446-
1447-
subroutine force_u_into_state()
1448-
1449-
add_u_to_state_list = .true.
1450-
1451-
end subroutine force_u_into_state
1452-
1453-
1454-
!------------------------------------------------------------------
1455-
14561357
function get_analysis_time_ncid( ncid, filename )
14571358

14581359
! The analysis netcdf files have the start time of the experiment.
@@ -1904,14 +1805,6 @@ subroutine verify_state_variables(ncid, filename, ngood, qty_list, variable_boun
19041805
call error_handler(E_MSG,'verify_state_variables',string1,source,text2=string2)
19051806
endif
19061807

1907-
! if this flag is true and the user hasn't said U should be in the state,
1908-
! add it to the list.
1909-
if (add_u_to_state_list .and. .not. u_already_in_list) then
1910-
ngood = ngood + 1
1911-
variable_table(ngood,1) = "u"
1912-
variable_table(ngood,2) = "QTY_EDGE_NORMAL_SPEED"
1913-
endif
1914-
19151808
end subroutine verify_state_variables
19161809

19171810

models/mpas_atm/update_bc.f90

+23-16
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,16 @@ program update_bc
2727
get_next_filename, E_ERR, E_MSG, error_handler
2828
use time_manager_mod, only : time_type, print_time, print_date, operator(-), &
2929
get_time, get_date, operator(/=)
30-
use direct_netcdf_mod,only : read_variables !HK read_variables?!
3130
use model_mod, only : static_init_model, &
3231
get_model_size, &
3332
get_analysis_time, &
34-
anl_domid, lbc_domid, &
3533
uv_increments_cell_to_edges, &
3634
uv_field_cell_to_edges, &
3735
get_analysis_weight, &
3836
on_boundary_cell, &
3937
on_boundary_edge, &
40-
cell_next_to_boundary_edge
38+
cell_next_to_boundary_edge, &
39+
get_grid_dims
4140

4241

4342
use state_structure_mod, only : get_num_variables, get_domain_size, &
@@ -48,7 +47,8 @@ program update_bc
4847
nc_open_file_readwrite, &
4948
nc_get_dimension_size, &
5049
nc_close_file, &
51-
NF90_MAX_NAME
50+
NF90_MAX_NAME, &
51+
nc_get_variable, nc_put_variable
5252

5353
implicit none
5454

@@ -87,13 +87,16 @@ program update_bc
8787
integer :: vertexDegree = -1 ! Max number of cells/edges that touch any vertex
8888
integer :: nSoilLevels = -1 ! Number of soil layers
8989

90-
integer :: cellid, edgeid, varid
90+
integer :: cellid, edgeid, i
9191

92+
logical :: lbc_file_has_reconstructed_winds ! HK @todo may always be false
93+
character(len=NF90_MAX_NAME), dimension(9) :: lbc_variables
9294
real(r8), allocatable, dimension(:,:) :: lbc_u, lbc_ucell, lbc_vcell, inc_lbc_ucell, inc_lbc_vcell
9395
real(r8), allocatable, dimension(:,:) :: old_lbc_ucell, old_lbc_vcell, delta_u
9496
real(r8), allocatable, dimension(:,:) :: a_var_data, b_var_data, var_data
9597
real(r8) :: weight
9698

99+
97100
character(len=NF90_MAX_NAME) :: bvarname, avarname
98101

99102
!----------------------------------------------------------------------
@@ -107,6 +110,18 @@ program update_bc
107110

108111
call static_init_model()
109112
call get_grid_dims(nCells, nVertices, nEdges, nVertLevels, vertexDegree, nSoilLevels)
113+
114+
lbc_file_has_reconstructed_winds = .false.
115+
lbc_variables(1) = 'lbc_qc'
116+
lbc_variables(2) = 'lbc_qr'
117+
lbc_variables(3) = 'lbc_qv'
118+
lbc_variables(4) = 'lbc_rho'
119+
lbc_variables(5) = 'lbc_theta'
120+
lbc_variables(6) = 'lbc_u'
121+
lbc_variables(7) = 'lbc_w'
122+
lbc_variables(8) = 'lbc_ur' ! may not be in the file
123+
lbc_variables(9) = 'lbc_vr' ! may not be in the file
124+
110125
!----------------------------------------------------------------------
111126
! Reads lists of input mpas (prior) and filter (analysis) files
112127
!HK @todo loop around files, why not run this code in parallel?
@@ -178,8 +193,8 @@ program update_bc
178193
allocate(b_var_data(nVertLevels, nCells))
179194
allocate(var_data(nVertLevels, nCells))
180195

181-
VARLOOP: do varid = 1, get_num_variables(lbc_domid)
182-
bvarname = get_variable_name(lbc_domid, varid)
196+
VARLOOP: do i = 1, size(lbc_variables)
197+
bvarname = lbc_variables(i)
183198
avarname = trim(bvarname(5:)) !corresponding field in analysis domain
184199

185200
! skip edge normal winds
@@ -189,14 +204,6 @@ program update_bc
189204
if (bvarname == 'lbc_ur') avarname = 'uReconstructZonal'
190205
if (bvarname == 'lbc_vr') avarname = 'uReconstructMeridional'
191206

192-
if (bvarname(1:4) /= 'lbc_') then
193-
write(string1, *) 'skipping update of boundary variable ', trim(bvarname) !HK @todo why do you need to tell people this?
194-
write(string2, *) 'because the name does not start with "lbc"'
195-
call error_handler(E_MSG,'statevector_to_boundary_file',string1,&
196-
source, text2=string2)
197-
cycle VARLOOP
198-
endif
199-
200207
call nc_get_variable(ncAnlID, avarname, a_var_data)
201208
call nc_get_variable(ncBdyID, bvarname, b_var_data)
202209

@@ -272,7 +279,7 @@ program update_bc
272279
! has bdyMaskEdge = 0. In this case, even if bdyMaskEdge of the edge is zero,
273280
! cell2 has been updated in the CELLS loop above, so the edge has to be updated.
274281

275-
if (.not. on_boundary_edge(edgeid) .and. .not. cell_next_to_boundary_edge(edgid)) cycle IEDGE
282+
if (.not. on_boundary_edge(edgeid) .and. .not. cell_next_to_boundary_edge(edgeid)) cycle IEDGE
276283

277284
lbc_u(:,edgeid) = lbc_u(:,edgeid) + delta_u(:,edgeid)
278285

models/mpas_atm/update_mpas_states.f90

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ program update_mpas_states
3232
get_model_size, &
3333
get_analysis_time, update_u_from_reconstruct, &
3434
use_increments_for_u_update, uv_increments_cell_to_edges, &
35-
uv_field_cell_to_edges, anl_domid
35+
uv_field_cell_to_edges, dom_id => anl_domid
3636

3737
use state_structure_mod, only : get_num_variables, get_variable_name, &
3838
get_variable_size, get_varid_from_varname, &
@@ -67,7 +67,6 @@ program update_mpas_states
6767
integer :: dims(2) !(nVertLevels, nEdges | nCells)
6868
real(r8), allocatable :: u(:,:), ucell(:,:), vcell(:,:)
6969
real(r8), allocatable :: ucell_dart(:,:), vcell_dart(:,:), increments(:,:)
70-
integer :: dom_id = anl_domid
7170
!----------------------------------------------------------------------
7271

7372
call initialize_utilities(progname=source)

0 commit comments

Comments
 (0)