Skip to content

Commit

Permalink
Added dist_frequency to params_siml
Browse files Browse the repository at this point in the history
  • Loading branch information
Laura Marques committed Apr 21, 2024
1 parent 3b3e24f commit 1cc2473
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
3 changes: 3 additions & 0 deletions R/run_biomee_f_bysite.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#' runs to recover N balance.}
#' \item{do_reset_veg}{A logical value indicating whether reseting vegetation
#' for disturbance runs.}
#' \item{dist_frequency}{Value indicating the frequency of the disturbance event (in years)
#' (e.g. 100 indicates a disturbance event occurs every 100 years, i.e., at a rate of 0.01)}
#' \item{code_method_photosynth}{String specifying the method of photosynthesis
#' used in the model, either "pmodel" or "gs_leuning".}
#' \item{code_method_mortality}{String indicating the type of mortality in the
Expand Down Expand Up @@ -514,6 +516,7 @@ run_biomee_f_bysite <- function(
update_annualLAImax = as.logical(params_siml$update_annualLAImax),
do_closedN_run = as.logical(params_siml$do_closedN_run),
do_reset_veg = as.logical(params_siml$do_reset_veg),
dist_frequency = as.integer(params_siml$dist_frequency),
code_method_photosynth= as.integer(code_method_photosynth),
code_method_mortality = as.integer(code_method_mortality),

Expand Down
3 changes: 2 additions & 1 deletion data-raw/generate_biomee_driver_data_DBEN.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ params_siml <- tibble(
do_U_shaped_mortality = TRUE,
update_annualLAImax = TRUE,
do_closedN_run = TRUE,
do_reset_veg = FALSE,
do_reset_veg = FALSE, # TRUE
dist_frequency = 0, # 100, 75, 50, 25, 15, 10
method_photosynth = "gs_leuning",
method_mortality = "dbh"
)
Expand Down
12 changes: 5 additions & 7 deletions src/biosphere_biomee.mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ subroutine biosphere_annual(out_biosphere)
integer :: year0
integer :: i
integer :: idata
integer :: nfrequency
integer, save :: simu_steps !, datalines
integer, save :: iyears
integer, save :: idays
Expand Down Expand Up @@ -203,15 +202,14 @@ subroutine biosphere_annual(out_biosphere)

if(myinterface%params_siml%do_reset_veg) then

if (iyears==myinterface%params_siml%spinupyears+31) then
if (iyears==myinterface%params_siml%spinupyears + 31) then
call reset_vegn_initial(vegn)
endif

nfrequency = 0 ! 100,75,50,25,15,10

if(nfrequency > 0) then
do i = myinterface%params_siml%spinupyears+31+nfrequency, &
myinterface%params_siml%spinupyears + myinterface%params_siml%nyeartrend, nfrequency
if(myinterface%params_siml%dist_frequency > 0) then
do i = myinterface%params_siml%spinupyears + 31 + myinterface%params_siml%dist_frequency, &
myinterface%params_siml%spinupyears + myinterface%params_siml%nyeartrend, &
myinterface%params_siml%dist_frequency
if (iyears == i) call reset_vegn_initial(vegn)
enddo

Expand Down
1 change: 1 addition & 0 deletions src/params_siml_biomee.mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module md_params_siml_biomee
logical :: update_annualLAImax
logical :: do_closedN_run
logical :: do_reset_veg
integer :: dist_frequency
character(len=30) :: method_photosynth
character(len=30) :: method_mortality

Expand Down
7 changes: 5 additions & 2 deletions src/sofun_r.f90
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ subroutine biomee_f( &
do_U_shaped_mortality, &
update_annualLAImax, &
do_closedN_run, &
do_reset_veg, &
do_reset_veg, &
dist_frequency, &
code_method_photosynth, &
code_method_mortality, &
longitude, &
Expand Down Expand Up @@ -371,6 +372,7 @@ subroutine biomee_f( &
logical(kind=c_bool), intent(in) :: update_annualLAImax
logical(kind=c_bool), intent(in) :: do_closedN_run
logical(kind=c_bool), intent(in) :: do_reset_veg
integer(kind=c_int), intent(in) :: dist_frequency
integer(kind=c_int), intent(in) :: code_method_photosynth
integer(kind=c_int), intent(in) :: code_method_mortality

Expand Down Expand Up @@ -520,7 +522,8 @@ subroutine biomee_f( &
myinterface%params_siml%do_U_shaped_mortality = do_U_shaped_mortality
myinterface%params_siml%update_annualLAImax = update_annualLAImax
myinterface%params_siml%do_closedN_run = do_closedN_run
myinterface%params_siml%do_reset_veg = do_reset_veg
myinterface%params_siml%do_reset_veg = do_reset_veg
myinterface%params_siml%dist_frequency = dist_frequency

! this needs to be consistent with translation to code in run_biomee_f_bysite.R
if (code_method_photosynth == 1) then
Expand Down
7 changes: 5 additions & 2 deletions src/wrappersc.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ void F77_NAME(biomee_f)(
int *do_U_shaped_mortality,
int *update_annualLAImax,
int *do_closedN_run,
int *do_reset_veg,
int *do_reset_veg,
int *dist_frequency,
int *code_method_photosynth,
int *code_method_mortality,
double *longitude,
Expand Down Expand Up @@ -237,6 +238,7 @@ extern SEXP biomee_f_C(
SEXP update_annualLAImax,
SEXP do_closedN_run,
SEXP do_reset_veg,
SEXP dist_frequency,
SEXP code_method_photosynth,
SEXP code_method_mortality,
SEXP longitude,
Expand Down Expand Up @@ -360,6 +362,7 @@ extern SEXP biomee_f_C(
LOGICAL(update_annualLAImax),
LOGICAL(do_closedN_run),
LOGICAL(do_reset_veg),
INTEGER(dist_frequency),
INTEGER(code_method_photosynth),
INTEGER(code_method_mortality),
REAL(longitude),
Expand Down Expand Up @@ -542,7 +545,7 @@ extern SEXP biomee_f_C(
/////////////////////////////////////////////////////////////
static const R_CallMethodDef CallEntries[] = {
{"pmodel_f_C", (DL_FUNC) &pmodel_f_C, 23}, // Specify number of arguments to C wrapper as the last number here
{"biomee_f_C", (DL_FUNC) &biomee_f_C, 47}, // Number of the SEXP variables (not the output)
{"biomee_f_C", (DL_FUNC) &biomee_f_C, 48}, // Number of the SEXP variables (not the output)
{NULL, NULL, 0}
};

Expand Down

0 comments on commit 1cc2473

Please sign in to comment.