Skip to content

Commit 3b79c13

Browse files
authored
Merge pull request #21 from pedro-jm/vinterp
More sharable vertical interpolation code
2 parents 4186e32 + 38d635a commit 3b79c13

File tree

10 files changed

+349
-261
lines changed

10 files changed

+349
-261
lines changed

driver/initialize_mod.F90

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,6 @@ subroutine Init_fire_state (grid, config_flags, wrf)
9191
if (DEBUG_LOCAL) call Print_message (' Initializing fire state')
9292
call grid%Initialization (config_flags, geogrid)
9393

94-
if (present (wrf)) then
95-
if (DEBUG_LOCAL) call Print_message (' Initializing atmospheric state')
96-
call grid%Handle_wrfdata_update (wrf, config_flags)
97-
end if
9894
else
9995
! Ideal
10096
if (DEBUG_LOCAL) call Print_message (' Initializing fire state')
@@ -103,6 +99,11 @@ subroutine Init_fire_state (grid, config_flags, wrf)
10399

104100
call Init_fire_components (grid, config_flags)
105101

102+
if (present (wrf)) then
103+
if (DEBUG_LOCAL) call Print_message (' Initializing atmospheric state')
104+
call grid%Handle_wrfdata_update (wrf, config_flags)
105+
end if
106+
106107
if (DEBUG_LOCAL) then
107108
! print lat/lons
108109
open (newunit = unit_out, file = 'latlons_c.dat')

io/coupling_mod.F90

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
module coupling_mod
22

33
use proj_lc_mod, only : proj_lc_t
4-
use interp_mod, only : Interp_horizontal_nearest, Interp_horizontal_bilinear, HINTERP_NEAREST, HINTERP_BILINEAR
4+
use interp_mod, only : Interp_horizontal_nearest, Interp_horizontal_bilinear, HINTERP_NEAREST, HINTERP_BILINEAR, Interp_profile
55
use stderrout_mod, only : Stop_simulation
66

7-
87
implicit none
98

109
private
1110

12-
public :: Interp_horizontal
11+
public :: Interp_horizontal, Calc_fire_wind
1312

1413
contains
1514

@@ -62,4 +61,58 @@ subroutine Interp_horizontal (data_in, proj_data_in, ims, ime, jms, jme, ifms, i
6261

6362
end subroutine Interp_horizontal
6463

64+
subroutine Calc_fire_wind (u3d, v3d, z_at_w, z0, iims, iime, jims, jime, kims, kime, fire_lsm_zcoupling, &
65+
fire_lsm_zcoupling_ref, fire_wind_height, ioms, iome, joms, jome, iops, iope, jops, jope, &
66+
u_out, v_out, cap_winds)
67+
68+
implicit none
69+
70+
integer, intent (in) :: iims, iime, jims, jime, kims, kime, ioms, iome, joms, jome, iops, iope, jops, jope
71+
real, intent (in) :: fire_wind_height, fire_lsm_zcoupling_ref
72+
logical, intent (in) :: fire_lsm_zcoupling
73+
real, dimension(iims:iime, jims:jime, kims:kime), intent (in) :: u3d, v3d, z_at_w
74+
real, dimension(iims:iime, jims:jime), intent (in) :: z0
75+
real, dimension(ioms:iome, joms:joms), intent (out) :: u_out, v_out
76+
logical, intent (in), optional :: cap_winds
77+
78+
real :: wspd
79+
integer :: i, j
80+
logical :: cap_winds_flag
81+
82+
83+
! print *, 'shape u3d = ', shape (u3d)
84+
! print *, 'shape v3d = ', shape (v3d)
85+
! print *, 'shape z_at_w = ', shape (z_at_w)
86+
! print *, 'shape u_out = ', shape (u_out)
87+
! print *, 'shape v_out = ', shape (v_out)
88+
! print *, 'shape z0 = ', shape (z0)
89+
90+
if (present (cap_winds)) then
91+
cap_winds_flag = cap_winds
92+
else
93+
cap_winds_flag = .false.
94+
end if
95+
96+
do j = jops, jope
97+
do i = iops, iope
98+
call Interp_profile (fire_lsm_zcoupling, fire_lsm_zcoupling_ref, fire_wind_height, kims, kime, &
99+
u3d(i, j, :), v3d(i, j, :), z_at_w(i, j, :), z0(i, j), u_out(i, j), v_out(i, j))
100+
end do
101+
end do
102+
103+
! To avoid arithmatic error
104+
if (cap_winds_flag) then
105+
do j = jops, jope
106+
do i = iops, iope
107+
wspd = sqrt (u_out(i, j) ** 2 + v_out(i, j) ** 2)
108+
if (wspd < 0.001) then
109+
u_out(i, j) = sign (0.001, u_out(i, j))
110+
v_out(i, j) = sign (0.001, v_out(i, j))
111+
end if
112+
end do
113+
end do
114+
end if
115+
116+
end subroutine Calc_fire_wind
117+
65118
end module coupling_mod

io/namelist_mod.F90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ module namelist_mod
4949
integer :: fast_dist_reinit_freq = 600 ! Number of time steps to perform a reinit with fast distance reinit method
5050

5151
real :: fire_wind_height = 6.096 ! "height of uah,vah wind in fire spread formula" "m"
52-
integer :: wind_vinterp_opt = 0 ! "wind (adjustment factor) interpolation option"
52+
integer :: wind_vinterp_opt = 0 ! "mid-flame height wind interpolation option: 0) Interp to specified height, 1) Use WAFs"
5353
integer :: hinterp_opt = 1 ! "Horizontal interpolation from atm to fire (offline option): 1) ngp, 2)bi-linear"
5454
logical :: fire_lsm_zcoupling = .false. ! "flag to activate reference velocity at a different height from fire_wind_height"
5555
real :: fire_lsm_zcoupling_ref = 50.0 ! "reference height from wich u at fire_wind_hegiht is calculated using a logarithmic profile" "m"
@@ -139,7 +139,7 @@ module namelist_mod
139139
real :: true_lat_2 = LAT_DEFAULT
140140

141141
! Atmosphere
142-
integer :: kds = 1, kde = 1
142+
integer :: kde = 1
143143
contains
144144
procedure, public :: Broadcast_nml => Broadcast_nml
145145
procedure, public :: Check_nml => Check_nml
@@ -411,7 +411,7 @@ subroutine Init_fire_block (this, file_name)
411411
integer :: fmoist_freq = 0 ! "frequency to run moisture model 0: use fmoist_dt, k>0: every k timesteps" "1"
412412
real :: fmoist_dt = 600 ! "moisture model time step" "s"
413413
real :: fire_wind_height = 6.096 ! "height of uah,vah wind in fire spread formula" "m"
414-
integer :: wind_vinterp_opt = 0 ! "wind (adjustment factor) interpolation option"
414+
integer :: wind_vinterp_opt = 0 ! "mid-flame height wind interpolation option: 0) Interp to specified height, 1) Use WAFs"
415415
integer :: hinterp_opt = 1 ! "Horizontal interpolation from atm to fire (offline option): 1) ngp, 2) bi-linear"
416416
logical :: fire_is_real_perim = .false. ! .false. = point/line ignition, .true. = observed perimeter"
417417
real :: frac_fburnt_to_smoke = 0.02 ! "parts per unit of burned fuel becoming smoke " "g_smoke/kg_air"

0 commit comments

Comments
 (0)