Skip to content

Commit 65b3ab8

Browse files
committed
Initial changes for a more flexible fire state initialization
1 parent 9a8f659 commit 65b3ab8

File tree

1 file changed

+88
-51
lines changed

1 file changed

+88
-51
lines changed

state/state_mod.F90

+88-51
Original file line numberDiff line numberDiff line change
@@ -229,49 +229,72 @@ subroutine Handle_wrfdata_update (this, wrf, config_flags)
229229

230230
end subroutine Handle_wrfdata_update
231231

232-
subroutine Init_domain (this, config_flags, geogrid)
232+
subroutine Init_domain (this, config_flags, geogrid, &
233+
ifds, ifde, ifms, ifme, ifps, ifpe, &
234+
jfds, jfde, jfms, jfme, jfps, jfpe, &
235+
kfds, kfde, kfms, kfme, kfps, kfpe, &
236+
kfts, kfte, i_start, i_end, j_start, j_end, num_tiles)
233237

234238
implicit none
235239

236240
class (state_fire_t), intent(in out) :: this
237241
type (namelist_t), intent (in) :: config_flags
238-
type (geogrid_t), intent (in) :: geogrid
239-
242+
type (geogrid_t), intent (in), optional :: geogrid
243+
integer, intent (in), optional :: ifds, ifde, ifms, ifme, ifps, ifpe, &
244+
jfds, jfde, jfms, jfme, jfps, jfpe, &
245+
kfds, kfde, kfms, kfme, kfps, kfpe, &
246+
kfts, kfte, num_tiles
247+
real, dimension(:), allocatable, intent (in), optional :: i_start, i_end, j_start, j_end
248+
249+
integer, parameter :: INIT_MODE_NONE = 0, INIT_MODE_GEOGRID = 1
240250
type (proj_lc_t) :: proj
241251
logical, parameter :: DEBUG_LOCAL = .false.
242-
integer :: ids0, ide0, jds0, jde0
252+
integer :: ids0, ide0, jds0, jde0, init_mode
253+
243254

255+
init_mode = INIT_MODE_NONE
256+
if (present (geogrid)) init_mode = INIT_MODE_GEOGRID
257+
if (init_mode == INIT_MODE_NONE) &
258+
call Stop_simulation ('Not enough information to initialize domain')
244259

245260
! Set dimensions
246-
ids0 = geogrid%ifds
247-
ide0 = geogrid%ifde
248-
jds0 = geogrid%jfds
249-
jde0 = geogrid%jfde
250-
251-
this%ifds = ids0
252-
this%ifde = ide0
253-
this%ifms = ids0 - N_POINTS_IN_HALO
254-
this%ifme = ide0 + N_POINTS_IN_HALO
255-
this%ifps = ids0
256-
this%ifpe = ide0
257-
258-
this%jfds = jds0
259-
this%jfde = jde0
260-
this%jfms = jds0 - N_POINTS_IN_HALO
261-
this%jfme = jde0 + N_POINTS_IN_HALO
262-
this%jfps = jds0
263-
this%jfpe = jde0
264-
265-
this%kfds = config_flags%kds
266-
this%kfde = config_flags%kde
267-
this%kfms = config_flags%kds
268-
this%kfme = config_flags%kde
269-
this%kfps = config_flags%kds
270-
this%kfpe = config_flags%kde
271-
this%kfts = config_flags%kds
272-
this%kfte = config_flags%kde
273-
274-
call this%Init_tiles (config_flags)
261+
Set_dims: select case (init_mode)
262+
case (INIT_MODE_GEOGRID)
263+
ids0 = geogrid%ifds
264+
ide0 = geogrid%ifde
265+
jds0 = geogrid%jfds
266+
jde0 = geogrid%jfde
267+
268+
this%ifds = ids0
269+
this%ifde = ide0
270+
this%ifms = ids0 - N_POINTS_IN_HALO
271+
this%ifme = ide0 + N_POINTS_IN_HALO
272+
this%ifps = ids0
273+
this%ifpe = ide0
274+
275+
this%jfds = jds0
276+
this%jfde = jde0
277+
this%jfms = jds0 - N_POINTS_IN_HALO
278+
this%jfme = jde0 + N_POINTS_IN_HALO
279+
this%jfps = jds0
280+
this%jfpe = jde0
281+
282+
this%kfds = config_flags%kds
283+
this%kfde = config_flags%kde
284+
this%kfms = config_flags%kds
285+
this%kfme = config_flags%kde
286+
this%kfps = config_flags%kds
287+
this%kfpe = config_flags%kde
288+
this%kfts = config_flags%kds
289+
this%kfte = config_flags%kde
290+
291+
call this%Init_tiles (config_flags)
292+
293+
case default
294+
295+
call Stop_simulation ('Not ready to complete fire state initialization 1')
296+
297+
end select Set_dims
275298

276299
this%nx = this%ifde
277300
this%ny = this%jfde
@@ -281,30 +304,44 @@ subroutine Init_domain (this, config_flags, geogrid)
281304
call this%Allocate_vars (this%ifms, this%ifme, this%jfms, this%jfme)
282305

283306
! Set projection
284-
proj = geogrid%Get_atm_proj ()
285-
call this%Init_latlons (proj, srx = geogrid%sr_x, sry = geogrid%sr_y)
307+
Set_proj: select case (init_mode)
308+
case (INIT_MODE_GEOGRID)
309+
proj = geogrid%Get_atm_proj ()
310+
call this%Init_latlons (proj, srx = geogrid%sr_x, sry = geogrid%sr_y)
311+
312+
this%cen_lat = geogrid%cen_lat
313+
this%cen_lon = geogrid%cen_lon
286314

287-
this%cen_lat = geogrid%cen_lat
288-
this%cen_lon = geogrid%cen_lon
315+
this%dx = geogrid%dx / geogrid%sr_x
316+
this%dy = geogrid%dy / geogrid%sr_y
289317

290-
this%dx = geogrid%dx / geogrid%sr_x
291-
this%dy = geogrid%dy / geogrid%sr_y
318+
case default
319+
call Stop_simulation ('Not ready to complete fire state initialization 2')
320+
321+
end select Set_proj
292322

293323
! Init vars
294324
call this%Set_vars_to_default (config_flags)
295325

296-
this%zsf(this%ifds:this%ifde, this%jfds:this%jfde) = geogrid%elevations
297-
this%dzdxf(this%ifds:this%ifde, this%jfds:this%jfde) = geogrid%dz_dxs
298-
this%dzdyf(this%ifds:this%ifde, this%jfds:this%jfde) = geogrid%dz_dys
299-
this%nfuel_cat(this%ifds:this%ifde, this%jfds:this%jfde) = geogrid%fuel_cats
300-
301-
if (config_flags%fire_is_real_perim) then
302-
if (allocated (geogrid%lfn_init)) then
303-
this%lfn_hist(this%ifds:this%ifde, this%jfds:this%jfde) = geogrid%lfn_init
304-
else
305-
Call Stop_simulation ('Attenting to initialize fire from given perimeter but no initialization data present')
306-
end if
307-
end if
326+
Set_topo_fuels: select case (init_mode)
327+
case (INIT_MODE_GEOGRID)
328+
this%zsf(this%ifds:this%ifde, this%jfds:this%jfde) = geogrid%elevations
329+
this%dzdxf(this%ifds:this%ifde, this%jfds:this%jfde) = geogrid%dz_dxs
330+
this%dzdyf(this%ifds:this%ifde, this%jfds:this%jfde) = geogrid%dz_dys
331+
this%nfuel_cat(this%ifds:this%ifde, this%jfds:this%jfde) = geogrid%fuel_cats
332+
333+
if (config_flags%fire_is_real_perim) then
334+
if (allocated (geogrid%lfn_init)) then
335+
this%lfn_hist(this%ifds:this%ifde, this%jfds:this%jfde) = geogrid%lfn_init
336+
else
337+
Call Stop_simulation ('Attenting to initialize fire from given perimeter but no initialization data present')
338+
end if
339+
end if
340+
341+
case default
342+
call Stop_simulation ('Not ready to complete fire state initialization 3')
343+
344+
end select Set_topo_fuels
308345

309346
if (config_flags%fuel_opt == FUEL_ANDERSON) call this%Convert_sb_to_ander ()
310347

0 commit comments

Comments
 (0)