Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Landuse fixes history interface deconflict with the latest tag #26

Merged
merged 159 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
159 commits
Select commit Hold shift + click to select a range
b47072f
get rid of unnused unit_test_shr
adrifoster Mar 20, 2024
902f842
code cleanup; add updatelivegrass subroutine
adrifoster Mar 20, 2024
f7258c6
code cleanup
adrifoster Mar 20, 2024
81835a7
call grass
adrifoster Mar 25, 2024
f103987
add sum loading
adrifoster Mar 26, 2024
187b2a4
get rid of sum_fuel
adrifoster Mar 26, 2024
0e74ffc
Merge branch 'main' into fire_refactor_fuel
adrifoster Apr 1, 2024
f4f940d
more updates
May 2, 2024
283a7a8
merge in upstream changes
May 2, 2024
3894aa1
merge in functional unit tests framework
May 2, 2024
a8a13af
change folder names
May 2, 2024
7cce284
remove old cmakelists
May 2, 2024
7396655
add fire test dir
May 2, 2024
861f84c
adding test file
May 2, 2024
0b66d3f
adding fire tests
May 3, 2024
6427692
Merge branch 'main' into fire_refactor_fuel
May 3, 2024
19f5237
testing
May 3, 2024
b57f581
Merge branch 'fire_weather_wind' into fire_refactor_fuel
May 3, 2024
e4be4c4
update fuel characteristics subroutine
May 6, 2024
2abf3de
merge in testing changes
May 6, 2024
7c84992
add files
May 6, 2024
7bf630b
get rid of patch-level variables moved into fuel class
May 7, 2024
8104707
first set of changes to move growth respiration calculation from half…
ckoven May 7, 2024
d03b44f
starting to modify history vars
ckoven May 8, 2024
2df2832
more edits to history fields
ckoven May 9, 2024
a494d3b
Merge branch 'main' into fire_refactor_fuel
Jun 3, 2024
57df197
fix merge errors
Jun 3, 2024
50e4887
update graph
Jun 4, 2024
b6cad14
Update main/FatesHistoryInterfaceMod.F90
JessicaNeedham Jul 1, 2024
dfd7297
Merge branch 'main' into fire_refactor_fuel
Aug 30, 2024
ce55f1c
add rest of fuel models
Aug 30, 2024
d9ff87b
rename some things
Aug 30, 2024
ca3ed12
refactor
Aug 30, 2024
2263e6f
fix bugs
adrifoster Sep 4, 2024
b1500c9
updates
Sep 4, 2024
3cfb2b1
Merge branch 'fire_refactor_fuel' of https://github.com/adrifoster/fa…
Sep 4, 2024
4a16132
fix plotting
Sep 4, 2024
7b00ed3
fix b4b changes
adrifoster Sep 6, 2024
06070a3
Merge branch 'fire_refactor_fuel' of https://github.com/adrifoster/fa…
adrifoster Sep 6, 2024
f208cb8
fix write of inventory init
JessicaNeedham Sep 9, 2024
20ceac2
remove space
Sep 9, 2024
d58d0b1
fix testing errors
Sep 10, 2024
c42cda9
updates
adrifoster Sep 11, 2024
bd213db
Merge branch 'fire_refactor_fuel' of https://github.com/adrifoster/fa…
adrifoster Sep 11, 2024
3d9d014
fixing errors
adrifoster Sep 12, 2024
59053b9
updates
adrifoster Sep 13, 2024
00d02de
fix parameter file
Sep 17, 2024
d072dc9
Merge branch 'fire_refactor_fuel' of https://github.com/adrifoster/fa…
adrifoster Sep 19, 2024
82b3f04
fix div zero issues
adrifoster Sep 24, 2024
b7f1a01
fix comments
adrifoster Sep 24, 2024
3136ebb
fuel plotting
Sep 24, 2024
981958d
Merge branch 'fire_refactor_fuel' of https://github.com/adrifoster/fa…
Sep 24, 2024
6eed280
updates for b4b testing
adrifoster Oct 2, 2024
817491b
update zero checking
adrifoster Oct 17, 2024
81d45c2
Merge branch 'main' into fire_refactor_fuel
adrifoster Oct 17, 2024
04d06d9
remove dbugging lines
adrifoster Oct 17, 2024
a001c71
add subroutine to calculate sapwood cross-sectional area for grass PFT
XiulinGao Oct 23, 2024
8627068
correct area calculation
XiulinGao Oct 23, 2024
0628cb7
update in-code documentation
XiulinGao Oct 23, 2024
9080ba3
Apply suggestions from code review
ckoven Oct 29, 2024
b5f3956
update nfsc variable name
Oct 29, 2024
195dce4
change total_loading to non_trunk_loading
Oct 29, 2024
6f6ac0b
other updates
Oct 29, 2024
b436783
updating variable names
Oct 29, 2024
0831336
updates to testing
Oct 30, 2024
920c549
big fixes
Oct 30, 2024
7fc2242
more updates
Oct 30, 2024
a0dea3b
Added respiration excess to sub-daily npp tracking by holding it like…
rgknox Oct 30, 2024
f5a7caa
removing resp_g_acc
rgknox Oct 30, 2024
1d52034
removing resp_g_acc, it is unnecessary
rgknox Oct 30, 2024
366b73a
merge resolution between growth_respiration and main
rgknox Oct 30, 2024
ee9e919
fix typo in modify_fates_paramfile.py
ckoven Oct 30, 2024
3f688d7
various bug fixes for growth respiration update
rgknox Oct 31, 2024
a9758b3
Added hard-coded override to revert to original format for inventory …
rgknox Oct 31, 2024
50bf6b9
syntax updates and minor bug fix for respiration update
rgknox Oct 31, 2024
e0c7058
fix comment
Oct 31, 2024
de61028
Merge branch 'main' into fire_refactor_fuel
Oct 31, 2024
cd33abc
Added recursive checks for singularity in two-stream
rgknox Oct 31, 2024
9d28eb6
Merge pull request #24 from rgknox/growth_respiration
ckoven Oct 31, 2024
1be3962
Merge pull request #1244 from JessicaNeedham/jfn-invinit-write-fix
glemieux Nov 1, 2024
52842b3
fix variable names
adrifoster Nov 4, 2024
d422c12
Merge branch 'main' into fire_refactor_fuel
adrifoster Nov 4, 2024
fb6ab8c
Merge branch 'fire_refactor_fuel' of https://github.com/adrifoster/fa…
adrifoster Nov 8, 2024
128e0a9
fix class vs. type
adrifoster Nov 12, 2024
bdb253f
fix capitalization
adrifoster Nov 12, 2024
4b6fd9b
refactor singularity check loop
glemieux Nov 13, 2024
c81282b
remove the need for a check variable
glemieux Nov 13, 2024
e3e7d2c
Merge pull request #1247 from adrifoster/fire_refactor_fuel
adrifoster Nov 13, 2024
2202c46
update subroutine case to PascalCase
glemieux Nov 13, 2024
1365dee
formatting space alignment
glemieux Nov 13, 2024
de5f266
Merge pull request #1197 from ckoven/growth_respiration
glemieux Nov 14, 2024
205fc98
initial cleanup
Nov 14, 2024
a3cf233
minor updates
Nov 15, 2024
291096a
Minor fix in FatesPFTIndexSwapper.py. At least with my scipy configur…
mpaiao Nov 18, 2024
fd7922f
Editing modify_fates_paramfile.py similarly to FatesPFTIndexSwapper.p…
mpaiao Nov 18, 2024
7539b40
Updating ncvarsort.py so it uses the same netcdf libraries as other p…
mpaiao Nov 18, 2024
7d30a3f
Append extension nc to the temporary files. In some combinations of p…
mpaiao Nov 18, 2024
5cb89ad
Additional edits to ncvarsort.py to align with the scipy/io/netcdf li…
mpaiao Nov 18, 2024
f2b4498
Force integer in createDimension in ncvarsort.py
mpaiao Nov 18, 2024
b417a78
Dropping attribute size from "the_dim" in ncvartsort.py
mpaiao Nov 18, 2024
612d4e0
Bug fix when retrieving variables in ncvarsort.py.
mpaiao Nov 18, 2024
7bf2f7c
Replacing datatype with typecode in ncvarsort.py
mpaiao Nov 18, 2024
f36f34a
More fixes in ncvarsort.py to be compatible to scipy.io.netcdf
mpaiao Nov 18, 2024
14a5cb4
Fix typo in my last update
mpaiao Nov 18, 2024
9b2384c
Multiple fixes to ncvarsort.py to be compatible with scipy.io.netcdf
mpaiao Nov 18, 2024
08f2410
Merge pull request #1268 from XiulinGao/xlg-grass-sapwood-area-fix
glemieux Nov 18, 2024
a1e1797
Merge pull request #13 from glemieux/two-stream-sing-fix-refactor
rgknox Nov 18, 2024
c07ef10
fix CNP allocation when reproductive frac is 1
JessicaNeedham Nov 19, 2024
589f263
fix if then typo around Kb_sing
glemieux Nov 20, 2024
e7b332f
fix Kb_sing calculation
glemieux Nov 20, 2024
c1d04c4
reverse logic for if statement
JessicaNeedham Nov 20, 2024
df6c5e7
Bug fix for issue #1289
sshu88 Nov 20, 2024
8bca0fb
updates
Dec 2, 2024
f7ed823
create temp variable
Dec 2, 2024
0802e4b
Merge pull request #1290 from JessicaNeedham/jfn-cnp-alloc-fix
glemieux Dec 2, 2024
0eb912c
Update EDLoggingMortalityMod.F90
sshu88 Dec 2, 2024
914393a
Update FatesConstantsMod.F90
sshu88 Dec 2, 2024
02ee145
Merge pull request #1277 from rgknox/two-stream-singularity-fix
glemieux Dec 2, 2024
77e8948
Merge tag 'sci.1.80.3_api.37.0.0' into fatesluc_cbasedhrv_v2
glemieux Dec 3, 2024
ac035e0
Merge branch 'main' into fire_refactor_ros
adrifoster Dec 3, 2024
599cc11
Merge branch 'fire_refactor_ros' of https://github.com/adrifoster/fat…
adrifoster Dec 3, 2024
51a6a37
bug fix
adrifoster Dec 5, 2024
4b5a670
updates
Dec 5, 2024
8fb9f1f
Merge branch 'fire_refactor_ros' of https://github.com/adrifoster/fat…
Dec 5, 2024
bc03799
add ros
adrifoster Dec 6, 2024
d5c1ac9
merge in changes
adrifoster Dec 6, 2024
426899b
full refactor of ros
adrifoster Dec 6, 2024
acde77c
fix bugs
adrifoster Dec 6, 2024
211deda
Merge branch 'main' into fire_refactor_ros
adrifoster Dec 6, 2024
a1c587d
Update FatesHistoryInterfaceMod.F90
adrifoster Dec 6, 2024
31a4bb6
add ros tests
Dec 6, 2024
c2f6a99
Merge branch 'fire_refactor_ros' of https://github.com/adrifoster/fat…
Dec 6, 2024
0aef731
test for propagating flux
Dec 6, 2024
a2ce597
add tests
Dec 6, 2024
2b62d7a
remove blank line
Dec 6, 2024
296e1d6
Merge pull request #1291 from sshu88/fatesluc_cbasedhrv_v2
glemieux Dec 9, 2024
e7a7c54
update test
Dec 9, 2024
79fb219
initial fix
adrifoster Dec 11, 2024
e04e140
add idisttype
adrifoster Dec 11, 2024
f5119a3
fix typo
adrifoster Dec 11, 2024
8e91998
zero frac_burnt at top of fire mod
adrifoster Dec 11, 2024
4c565cc
suggested changes
adrifoster Dec 11, 2024
48e9fa4
fix
Dec 12, 2024
f11b673
remove zero of frac_burnt in split_patch
adrifoster Dec 16, 2024
da4ed44
requested changes
Dec 16, 2024
fe1d2e8
pylint
Dec 16, 2024
6a44ef4
Removing print statement added for debugging.
mpaiao Dec 17, 2024
3a1f17b
Merge pull request #1287 from mpaiao/mpaiao-pr-pft-swapper
rgknox Dec 26, 2024
91e4b21
Merge pull request #1275 from NGEET/ckoven-patch-1
rgknox Dec 26, 2024
56ecefd
remove greater than one check
Dec 30, 2024
5c6fb7a
Merge pull request #1303 from adrifoster/cmake_bug_fix
glemieux Jan 2, 2025
d50c906
Merge pull request #1297 from adrifoster/fire_refactor_ros
glemieux Jan 3, 2025
1689466
Merge pull request #1302 from adrifoster/fuel_frac_fix
glemieux Jan 3, 2025
73838b3
Merge tag 'sci.1.80.6_api.37.0.0' into landuse_fixes-deconflict
glemieux Jan 4, 2025
96aeedb
fix npp by age calculation
glemieux Jan 6, 2025
cd6931f
fix bad merge deconflict and remove old secondary history variable
glemieux Jan 6, 2025
69e7433
remove npp by age from high frequency history
glemieux Jan 7, 2025
e4a163d
move npp by land use out of high frequency section
glemieux Jan 7, 2025
70c21a3
fix update frequency setting for FATES_NPP_LU
glemieux Jan 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update fuel characteristics subroutine
  • Loading branch information
adrifoster committed May 6, 2024
commit e4be4c4fb8b62983619eeda813fa11aa179d18ab
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,6 @@ link_directories(${CMAKE_CURRENT_BINARY_DIR})
# carefully: for example, include_directories and link_directories needs to be
# done before adding the tests themselves.
add_subdirectory(${HLM_ROOT}/src/fates/unit_testing/allometry fates_allom_test)
#add_subdirectory(${HLM_ROOT}/src/fates/unit_testing/math_utils fates_math_test)
#add_subdirectory(${HLM_ROOT}/src/fates/unit_testing/fire fates_fuel_test)
#add_subdirectory(${HLM_ROOT}/src/fates/fire/test/fire_weather_test fates_fireweather_test)
add_subdirectory(${HLM_ROOT}/src/fates/unit_testing/math_utils fates_math_test)
add_subdirectory(${HLM_ROOT}/src/fates/unit_testing/fire fates_fuel_test)
add_subdirectory(${HLM_ROOT}/src/fates/fire/test/fire_weather_test fates_fireweather_test)
2 changes: 1 addition & 1 deletion biogeochem/EDPatchDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2755,12 +2755,12 @@ subroutine fuse_2_patches(csite, dp, rp)
rp%fuel_eff_moist = (dp%fuel_eff_moist*dp%area + rp%fuel_eff_moist*rp%area) * inv_sum_area
rp%livegrass = (dp%livegrass*dp%area + rp%livegrass*rp%area) * inv_sum_area
rp%fuel%total_loading = (dp%fuel%total_loading*dp%area + rp%fuel%total_loading*rp%area) * inv_sum_area
rp%fuel%frac_loading = (dp%fuel%frac_loading(:)*dp%area + rp%fuel%frac_loading(:)*rp%area) * inv_sum_area
rp%fuel_bulkd = (dp%fuel_bulkd*dp%area + rp%fuel_bulkd*rp%area) * inv_sum_area
rp%fuel_sav = (dp%fuel_sav*dp%area + rp%fuel_sav*rp%area) * inv_sum_area
rp%fuel_mef = (dp%fuel_mef*dp%area + rp%fuel_mef*rp%area) * inv_sum_area
rp%ros_front = (dp%ros_front*dp%area + rp%ros_front*rp%area) * inv_sum_area
rp%tau_l = (dp%tau_l*dp%area + rp%tau_l*rp%area) * inv_sum_area
rp%fuel_frac(:) = (dp%fuel_frac(:)*dp%area + rp%fuel_frac(:)*rp%area) * inv_sum_area
rp%tfc_ros = (dp%tfc_ros*dp%area + rp%tfc_ros*rp%area) * inv_sum_area
rp%fi = (dp%fi*dp%area + rp%fi*rp%area) * inv_sum_area
rp%fd = (dp%fd*dp%area + rp%fd*rp%area) * inv_sum_area
Expand Down
13 changes: 0 additions & 13 deletions biogeochem/FatesLitterMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,6 @@ module FatesLitterMod
integer, public, parameter :: ilabile = 1 ! Array index for labile portion
integer, public, parameter :: icellulose = 2 ! Array index for cellulose portion
integer, public, parameter :: ilignin = 3 ! Array index for the lignin portion

! SPITFIRE

integer, parameter, public :: NFSC = NCWD+2 ! number fuel size classes (4 cwd size classes, leaf litter, and grass)
integer, parameter, public :: tw_sf = 1 ! array index of twig pool for spitfire
integer, parameter, public :: sb_sf = 2 ! array index of large branch pool for spitfire
integer, parameter, public :: lb_sf = 3 ! array index of large branch pool for spitfire
integer, parameter, public :: tr_sf = 4 ! array index of dead trunk pool for spitfire
integer, parameter, public :: dl_sf = 5 ! array index of dead leaf pool for spitfire (dead grass and dead leaves)
integer, parameter, public :: lg_sf = 6 ! array index of live grass pool for spitfire



type, public :: litter_type

! This object is allocated for each element (C, N, P, etc) that we wish to track.
Expand Down
24 changes: 1 addition & 23 deletions biogeochem/FatesPatchMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module FatesPatchMod
use FatesUtilsMod, only : check_var_real
use FatesCohortMod, only : fates_cohort_type
use FatesRunningMeanMod, only : rmean_type, rmean_arr_type
use FatesLitterMod, only : nfsc
use FatesFuelClassesMod, only : nfsc
use FatesLitterMod, only : litter_type
use FatesFuelMod, only : fuel_type
use PRTGenericMod, only : num_elements
Expand Down Expand Up @@ -197,17 +197,7 @@ module FatesPatchMod

! FUELS AND FIRE
! fuel characteristics
real(r8) :: fuel_frac(nfsc) ! fraction of each litter class in the ros_fuel [0-1]
real(r8) :: livegrass ! total aboveground grass biomass in patch [kgC/m2]
real(r8) :: fuel_bulkd ! average fuel bulk density of the ground fuel. [kg/m3]
! (incl. live grasses, omits 1000hr fuels)
real(r8) :: fuel_sav ! average surface area to volume ratio of the ground fuel [cm-1]
! (incl. live grasses, omits 1000hr fuels)
real(r8) :: fuel_mef ! average moisture of extinction factor
! of the ground fuel (incl. live grasses, omits 1000hr fuels)
real(r8) :: fuel_eff_moist ! effective avearage fuel moisture content of the ground fuel
! (incl. live grasses. omits 1000hr fuels)
real(r8) :: litter_moisture(nfsc) ! moisture of litter [m3/m3]

! fire spread
real(r8) :: ros_front ! rate of forward spread of fire [m/min]
Expand Down Expand Up @@ -380,13 +370,7 @@ subroutine NanValues(this)
this%fragmentation_scaler(:) = nan

! FUELS AND FIRE
this%fuel_frac(:) = nan
this%livegrass = nan
this%fuel_bulkd = nan
this%fuel_sav = nan
this%fuel_mef = nan
this%fuel_eff_moist = nan
this%litter_moisture(:) = nan
this%ros_front = nan
this%ros_back = nan
this%tau_l = nan
Expand Down Expand Up @@ -456,13 +440,7 @@ subroutine ZeroValues(this)
this%fragmentation_scaler(:) = 0.0_r8

! FIRE
this%fuel_frac(:) = 0.0_r8
this%livegrass = 0.0_r8
this%fuel_bulkd = 0.0_r8
this%fuel_sav = 0.0_r8
this%fuel_mef = 0.0_r8
this%fuel_eff_moist = 0.0_r8
this%litter_moisture(:) = 0.0_r8
this%ros_front = 0.0_r8
this%ros_back = 0.0_r8
this%tau_l = 0.0_r8
Expand Down
9 changes: 5 additions & 4 deletions fire/FatesFuelClassesMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ module FatesFuelClassesMod
implicit none
private

integer, parameter, public :: nfsc = ncwd + 2
integer, parameter, public :: nfsc = ncwd + 2 ! number of total fuel classes
integer, parameter, public :: nfsc_notrunks = ncwd + 1 ! number of fuel classes without trunks

type :: fuel_classes_type
! There are six fuel classes:
Expand All @@ -14,9 +15,9 @@ module FatesFuelClassesMod
integer, private :: twigs_i = 1 ! array index for twigs pool
integer, private :: small_branches_i = 2 ! array index for small branches pool
integer, private :: large_branches_i = 3 ! array index for large branches pool
integer, private :: dead_leaves_i = 5 ! array index for dead leaves pool
integer, private :: live_grass_i = 6 ! array index for live grass pool
integer, private :: trunks_i = 4 ! array index for trunks pool
integer, private :: dead_leaves_i = 4 ! array index for dead leaves pool
integer, private :: live_grass_i = 5 ! array index for live grass pool
integer, private :: trunks_i = 6 ! array index for trunks pool

contains

Expand Down
209 changes: 181 additions & 28 deletions fire/FatesFuelMod.F90
Original file line number Diff line number Diff line change
@@ -1,50 +1,58 @@
module FatesFuelMod

use FatesFuelClassesMod, only : nfsc, fuel_classes
use FatesFuelClassesMod, only : nfsc, nfsc_notrunks, fuel_classes
use FatesConstantsMod, only : r8 => fates_r8
use FatesConstantsMod, only : nearzero
use SFNesterovMod, only : nesterov_index
use SFFireWeatherMod, only : fire_weather
use FatesGlobals, only : fates_log
use FatesGlobals, only : endrun => fates_endrun
use shr_log_mod, only : errMsg => shr_log_errMsg

implicit none
private

integer, parameter :: r8 = selected_real_kind(12)

type, public :: fuel_type
real(r8) :: loading(nfsc) ! fuel loading of each fuel class [kgC/m2]
real(r8) :: moisture(nfsc) ! fuel moisture of each fuel class [m3/m3]
real(r8) :: frac_loading(nfsc) ! fractional loading of non-trunk fuel classes [0-1]
real(r8) :: total_loading ! total fuel loading - DOES NOT INCLUDE TRUNKS [kgC/m2]
real(r8) :: average_moisture ! weighted average of fuel moisture across non-trunk fuel classes [m3/m3]
real(r8) :: bulk_density ! weighted average of bulk density across non-trunk fuel classes [kg/m3]
real(r8) :: SAV ! weighted average of surface area to volume ratio across non-trunk fuel classes [/cm]
real(r8) :: MEF ! weighted average of moisture of extinction across non-trunk fuel classes [m3/m3]

real(r8) :: loading(nfsc_notrunks) ! fuel loading of non-trunks fuel class [kgC/m2]
real(r8) :: effective_moisture(nfsc) ! fuel effective moisture all fuel class [m3/m3]
real(r8) :: frac_loading(nfsc_notrunks) ! fractional loading of non-trunk fuel classes [0-1]
real(r8) :: total_loading ! total fuel loading - DOES NOT INCLUDE TRUNKS [kgC/m2]
real(r8) :: average_moisture ! weighted average of fuel moisture across non-trunk fuel classes [m3/m3]
real(r8) :: bulk_density ! weighted average of bulk density across non-trunk fuel classes [kg/m3]
real(r8) :: SAV ! weighted average of surface area to volume ratio across non-trunk fuel classes [/cm]
real(r8) :: MEF ! weighted average of moisture of extinction across non-trunk fuel classes [m3/m3]

contains

procedure :: Init
procedure :: CalculateLoading
procedure :: SumLoading
procedure :: CalculateFractionalLoading
procedure :: UpdateFuelMoisture
procedure :: AverageBulkDensity
procedure :: AverageSAV

end type fuel_type

contains

subroutine Init(this)
! DESCRIPTION:
! Initialize fuel class

! ARGUMENTS:
class(fuel_type), intent(inout) :: this ! fuel class

class(fuel_type), intent(inout) :: this ! fuel class
! just zero everything
this%loading(:) = 0.0_r8
this%total_loading = 0.0_r8
this%frac_loading(:) = 0.0_r8
this%moisture(:) = 0.0_r8
this%loading(1:nfsc_notrunks) = 0.0_r8
this%frac_loading(1:nfsc_notrunks) = 0.0_r8
this%effective_moisture(1:nfsc) = 0.0_r8
this%total_loading = 0.0_r8
this%average_moisture = 0.0_r8
this%bulk_density = 0.0_r8
this%SAV = 0.0_r8
this%MEF = 0.0_r8
this%bulk_density = 0.0_r8
this%SAV = 0.0_r8
this%MEF = 0.0_r8

end subroutine Init

Expand All @@ -69,7 +77,6 @@ subroutine CalculateLoading(this, leaf_litter, twig_litter, small_branch_litter,
this%loading(fuel_classes%small_branches()) = small_branch_litter
this%loading(fuel_classes%large_branches()) = large_branch_litter
this%loading(fuel_classes%live_grass()) = live_grass
this%loading(fuel_classes%trunks()) = trunk_litter

end subroutine CalculateLoading

Expand All @@ -81,16 +88,16 @@ subroutine SumLoading(this)

! ARGUMENTS:
class(fuel_type), intent(inout) :: this ! fuel class

this%total_loading = sum(this%loading(:))
this%total_loading = sum(this%loading(1:nfsc_notrunks))

end subroutine SumLoading

!-------------------------------------------------------------------------------------

subroutine CalculateFractionalLoading(this)
! DESCRIPTION:
! Calculates fractional loading
! Calculates fractional loading for fuel

! ARGUMENTS:
class(fuel_type), intent(inout) :: this ! fuel class
Expand All @@ -99,13 +106,159 @@ subroutine CalculateFractionalLoading(this)
call this%SumLoading()

if (this%total_loading > nearzero) then
this%frac_loading(:) = this%loading(:)/this%total_loading
this%frac_loading(1:nfsc_notrunks) = this%loading(1:nfsc_notrunks)/this%total_loading
else
this%frac_loading(:) = 0.0_r8
this%frac_loading(1:nfsc_notrunks) = 0.0_r8
end if

end subroutine CalculateFractionalLoading

!-------------------------------------------------------------------------------------

subroutine UpdateFuelMoisture(this, sav_fuel, drying_ratio, fireWeatherClass)
! DESCRIPTION:
! Updates fuel moisture depending on what fire weather class is in use

! ARGUMENTS:
class(fuel_type), intent(inout) :: this ! fuel class
real(r8), intent(in) :: sav_fuel(nfsc) ! surface area to volume ratio of all fuel types [/cm]
real(r8), intent(in) :: drying_ratio ! drying ratio
class(fire_weather), intent(in) :: fireWeatherClass ! fireWeatherClass

real(r8) :: moisture(nfsc) ! fuel moisture [m3/m3]
real(r8) :: moisture_of_extinction(nfsc) ! fuel moisture of extinction [m3/m3]
integer :: i ! looping index

if (this%total_loading > nearzero) then
! calculate fuel moisture [m3/m3] for each fuel class depending on what
! fire weather class is in use
select type (fireWeatherClass)
class is (nesterov_index)
call CalculateFuelMoistureNesterov(sav_fuel, drying_ratio, &
fireWeatherClass%fire_weather_index, moisture)
class default
write(fates_log(), *) 'Unknown fire weather class selected.'
write(fates_log(), *) 'Choose a different fire weather class or upate this subroutine.'
call endrun(msg=errMsg( __FILE__, __LINE__))
end select

! calculate moisture of extinction and fuel effective moisture
do i = 1, nfsc
moisture_of_extinction(i) = MoistureOfExtinction(sav_fuel(i))
this%effective_moisture(i) = moisture(i)/moisture_of_extinction(i)
end do

! average fuel moisture across all fuel types except trunks [m3/m3]
this%average_moisture = sum(this%frac_loading(1:nfsc_notrunks)*moisture(1:nfsc_notrunks))

! calculate average moisture of extinction across all fuel types except trunks
this%MEF = sum(this%frac_loading(1:nfsc_notrunks)*moisture_of_extinction(1:nfsc_notrunks))
else
this%effective_moisture(1:nfsc) = 0.0_r8
this%average_moisture = 0.0_r8
this%MEF = 0.0_r8
end if

end subroutine UpdateFuelMoisture

!-------------------------------------------------------------------------------------

subroutine CalculateFuelMoistureNesterov(sav_fuel, drying_ratio, NI, moisture)
!
! DESCRIPTION:
! Updates fuel moisture

! ARGUMENTS:
real(r8), intent(in) :: sav_fuel(nfsc) ! surface area to volume ratio of all fuel types [/cm]
real(r8), intent(in) :: drying_ratio ! drying ratio
real(r8), intent(in) :: NI ! Nesterov Index
real(r8), intent(out) :: moisture(nfsc) ! moisture of litter [m3/m3]

! LOCALS
integer :: i ! looping index
real(r8) :: alpha_FMC ! intermediate variable for calculating fuel moisture

do i = 1, nfsc
if (i == fuel_classes%live_grass()) then
! live grass moisture is a function of SAV and changes via Nesterov Index
! along the same relationship as the 1 hour fuels
! live grass has same SAV as dead grass, but retains more moisture with this calculation
alpha_FMC = sav_fuel(fuel_classes%twigs())/drying_ratio
else
alpha_FMC = sav_fuel(i)/drying_ratio
end if
! Equation
moisture(i) = exp(-1.0_r8*alpha_FMC*NI)
end do

end subroutine CalculateFuelMoistureNesterov

!-------------------------------------------------------------------------------------

real(r8) function MoistureOfExtinction(sav)
!
! DESCRIPTION:
! Calculates moisture of extinction based on input surface area to volume ratio

! MEF (moisure of extinction) depends on compactness of fuel, depth, particle size, wind, slope
! Eqn here is eqn 27 from Peterson and Ryan (1986) "Modeling Postfire Conifer Mortality for Long-Range Planning"
! MEF: pine needles=0.30 (text near EQ 28 Rothermal 1972)
! Table II-1 NFFL mixed fuels models from Rothermal 1983 Gen. Tech. Rep. INT-143
! MEF: short grass=0.12,tall grass=0.25,chaparral=0.20,closed timber litter=0.30,hardwood litter=0.25
! Thonicke 2010 SAV values propagated thru P&R86 eqn below gives MEF:tw=0.355, sb=0.44, lb=0.525, tr=0.63, dg=0.248, lg=0.248
! Lasslop 2014 Table 1 MEF PFT level:grass=0.2,shrubs=0.3,TropEverGrnTree=0.2,TropDecid Tree=0.3, Extra-trop Tree=0.3

! ARGUMENTS:
real(r8), intent(in) :: sav ! fuel surface area to volume ratio [/cm]

! CONSTANTS:
real(r8), parameter :: MEF_a = 0.524_r8
real(r8), parameter :: MEF_b = 0.066_r8

if (sav <= nearzero) then
MoistureOfExtinction = 0.0_r8
else
MoistureOfExtinction = MEF_a - MEF_b*log(sav)
end if

end function MoistureOfExtinction

!-------------------------------------------------------------------------------------

subroutine AverageBulkDensity(this, bulk_density)
! DESCRIPTION:
! Calculates average bulk density (not including trunks)

! ARGUMENTS:
class(fuel_type), intent(inout) :: this ! fuel class
real(r8), intent(in) :: bulk_density(nfsc) ! bulk density of all fuel types [kg/m2]

if (this%total_loading > nearzero) then
this%bulk_density = sum(this%frac_loading(1:nfsc_notrunks)*bulk_density(1:nfsc_notrunks))
else
this%bulk_density = 0.0_r8
end if

end subroutine AverageBulkDensity

!-------------------------------------------------------------------------------------

subroutine AverageSAV(this, sav_fuel)
! DESCRIPTION:
! Calculates average surface area to volume ratio (not including trunks)

! ARGUMENTS:
class(fuel_type), intent(inout) :: this ! fuel class
real(r8), intent(in) :: sav_fuel(nfsc) ! surface area to volume ratio of all fuel types [/cm]

if (this%total_loading > nearzero) then
this%SAV = sum(this%frac_loading(1:nfsc_notrunks)*sav_fuel(1:nfsc_notrunks))
else
this%SAV = 0.0_r8
end if

end subroutine AverageSAV

!-------------------------------------------------------------------------------------

end module FatesFuelMod
Loading