Skip to content

Commit

Permalink
fix: force shortest_time_between_assimilations to be at least the mod…
Browse files Browse the repository at this point in the history
…el dt

Previous code would let you set assimilation_period_seconds = 0
which gave you a 0 sized assimilation window
#404 (comment)
  • Loading branch information
hkershaw-brown committed Sep 12, 2023
1 parent 216a3f4 commit efb64ef
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions models/wrf/model_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ module model_mod
! module variables
character(len=256), parameter :: source = "wrf/model_mod.f90"
logical :: module_initialized = .false.
type(time_type) :: assimilation_time_step

integer, parameter :: MAX_STATE_VARIABLES = 100
integer, parameter :: NUM_STATE_TABLE_COLUMNS = 4
Expand Down Expand Up @@ -209,6 +208,7 @@ module model_mod
integer :: wes, sns ! west-east staggered, south-north staggered number of grid points
integer :: bt ! bottom-top number of grid points
integer :: bt_stag ! staggered bottom-top number of grid points
real(r8) :: dt ! time step

! wrf options, apply to domain 1 only.
logical :: polar = .false.
Expand Down Expand Up @@ -251,7 +251,6 @@ subroutine static_init_model()
integer :: nfields
logical, allocatable :: domain_mask(:)
integer :: i, field ! loop indices
integer :: model_dt, assim_dt
character (len=1) :: idom ! assumes <=9

module_initialized = .true.
Expand All @@ -266,11 +265,6 @@ subroutine static_init_model()

call set_calendar_type(calendar_type)

model_dt = 1
print*, 'FAKE model_dt', model_dt
assim_dt = (assimilation_period_seconds / model_dt) * model_dt
assimilation_time_step = set_time(assim_dt) ! assimilation window

allocate(wrf_dom(num_domains), grid(num_domains), stat_dat(num_domains))

call verify_state_variables(nfields, varname, state_qty, update_var, in_domain)
Expand Down Expand Up @@ -451,10 +445,17 @@ end subroutine model_interpolate
function shortest_time_between_assimilations()

type(time_type) :: shortest_time_between_assimilations
integer :: model_dt

if ( .not. module_initialized ) call static_init_model

shortest_time_between_assimilations = assimilation_time_step
model_dt = nint(grid(1)%dt) ! model time step in seconds lowest res domain

if (assimilation_period_seconds < model_dt ) then
shortest_time_between_assimilations = set_time(model_dt)
else
shortest_time_between_assimilations = set_time(assimilation_period_seconds)
endif

end function shortest_time_between_assimilations

Expand Down Expand Up @@ -952,7 +953,8 @@ subroutine read_grid()
call nc_get_global_attribute(ncid, 'TRUELAT1', grid(i)%truelat1)
call nc_get_global_attribute(ncid, 'TRUELAT2', grid(i)%truelat2)
call nc_get_global_attribute(ncid, 'STAND_LON', grid(i)%stand_lon)

call nc_get_global_attribute(ncid, 'DT', grid(i)%dt)

grid(i)%bt = nc_get_dimension_size(ncid, 'bottom_top', routine)
grid(i)%bt_stag = nc_get_dimension_size(ncid, 'bottom_top_stag', routine)

Expand Down

0 comments on commit efb64ef

Please sign in to comment.