Skip to content

BiomeEP: make ready for calibration to DBH distributions - #330

Merged
fabern merged 80 commits into
masterfrom
biomee-establish-restart-with-full-initialization
Sep 25, 2026
Merged

fabern merged 80 commits into
masterfrom
biomee-establish-restart-with-full-initialization

Conversation

@fabern

@fabern fabern commented Apr 23, 2026 •

Copy link
Copy Markdown
Member

This PR results from changes in

All the changes that are user-facing are documented in NEWS.md.

Specifics for this PR:

This PR adds print statements for debugging the restarting.

Validation:

With a better diff tool than GitHub (e.g. such as GtiKraken), the change in file rsofun/tests/testthat/_snaps/model-runs-snapshot-biomee.md shows:

  • negligible changes in biomee_res$out_daily_tile results at year 1 and at year 251
  • negligible changes in biomee_res$out_annual_tile results
  • negligible changes in biomee_res$out_annual_cohort results at year 1 (initialization) but
  • some changes in the biomee_res$out_annual_cohort results at year
    • due to a different demographic structure:
      • 7 cohorts instead of 4 in mod_BiomeE_Pmodel_oac_yr251 and mod_BiomeE_PLULUC_primary_oac_yr251,
      • and 11 cohorts instead of 10 in mod_BiomeE_gsLeun_oac_yr251

~~Current status: test fails. ~~

Judging the print output of the test, it appears that

  • cohorts are correctly initialized.
  • cohorts are (in printout) not yet summarised on tile level (e.g. pleaf_c=0)
  • dtemp_pvy and wscal_pvy are not initialized
  • wscal_alldays is different

Previously, cohorts within 20% relative DBH difference were merged. This has been reduced to 2%, with the aim to enable comparison with observed size distributions.
Thereby removing the more complicated relative threshold applied previously.
Colum order of these variables was wrong:
"NSN","seedC","leafC","rootC","sapwoodC","heartwoodC"
Caused by warning:
! `case_match()` was deprecated in dplyr 1.2.0.
i Please use `recode_values()` instead.
── Failure ('test-model-runs.R:64:3'): biomee output check (gs leuning) ────────
Expected `all.equal(...)` to be TRUE.
Differences:
`actual` is a character vector ('Mean relative difference: 0.0002914499')
`expected` is a logical vector (TRUE)
Following deprecation warnings starting with devtools 2.5.0 and following the instructions on
https://devtools.r-lib.org/reference/install-deprecated.html
This streamlines the input preparation of the BiomeEP simulation
Namely: 'phenotype','Vmax','alphaBM','leafLS','lAImax','CNleaf0'
Namely: 'phenotype','Vmax','alphaBM','leafLS','lAImax','CNleaf0'
I.e. store them as part of the params_species_biomee and params_tile_biomee. Currently still hardcoded, but this allows for exposure of these in a next step.
… API)

This change is currently undocumented, since without specifying these parameters, BiomeEP continues to use the former hardcoded values as default.

This concerns parameters:
 ("kphio","beta","rd_to_vcmax","kc_jmax","kphio_par_a","kphio_par_b") in params_species and ("tau_acclim") in params_tile.

Small fix
Namely: 'gamma_L','Vannual','betaOFF','betaON', 'leaf_size' (all unused)
…th `mortrate_d_c`)

Change value of mortrate_d_c in the example BiomeEP data set
This allows to use gdb instead of lldb. lldb has some shortcomings with Fortran, namely it can't explore variables at a breakpoint. The recommendation is therefore to use gdb. Since this is not available for arm-based "M4" Macs, we run an arm-based Linux in a Docker container. Use VSCode extension "Dev Containers" together with the specified Docker file. Step 1: "Dev Containers: Reopen in Container"
Step 2: set a breakpoin in code. Step 3: go to the debug Tab in VSCode and click Play on the correct debug action "(gdb) Launch - MacBook Air M4".
…ohort_age`)

If not provided it recovers old default of 0 years old at initialization.
…tion of NSC pool

Since the function to compute bl_max and br_max war recently moved from Fortran to R (for the restarting), there had been a small bug (used `max()` instead of `pmax()`) which changed the initialization of NSC pools in case there were multiple species and one of them had LAI_light larger than 0.5.
@fabern
fabern force-pushed the biomee-redefine-parameters branch from f38c7c8 to 072fe00 Compare September 23, 2026 09:10
@fabern fabern mentioned this pull request Sep 23, 2026
1 task done
@fabern
fabern marked this pull request as ready for review September 23, 2026 09:37
@fabern fabern changed the title BiomeEP: Add further output useful to restart BiomeEP: make ready for calibration to DBH distributions Sep 23, 2026
@fabern
fabern changed the base branch from biomee-redefine-parameters to master September 23, 2026 10:08

@fabern fabern left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabern Please check the comments added within self code review.

Comment thread data-raw/generate_biomee_drivers.R Outdated
params_species <- tibble(
lifeform = c(0, 1, 1, 1, 1), # 0: grass; 1 Woody
phenotype = c(0, 0, 1, 1, 1), # 0: Deciduous; 1 Evergreen
phenotype = c(0, 1, 1, 1, 1), # 0: Deciduous; 1 Evergreen

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this changed? Better to change it back so that we still have a deciduous tree species in the example driver.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, do this in a next commit.

do_relayer = .false.

! update vegn GDD and tk_pheno
vegn%gdd = vegn%gdd + max(0.0, vegn%tk_daily - 278.15)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: check why this could be removed

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was removed because it was unused. The gdd (growing degrees days) we use is actually computed on the cohort level cc%gdd. It would actually not be needed to be computed on the cohort level since it anyway uses a hardcoded threshold of 5 degC. But technically that approach would enable a species-specific critical threshold for GDD accumulation.

Comment thread src/vegetation_tile_biomee.mod.f90 Outdated
Comment on lines +769 to +770
self%out_annual_cohorts(:, ANNUAL_COHORTS_ID) = 0
self%out_annual_cohorts(:, ANNUAL_COHORTS_CID) = 0

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change needed/usesful? If I remember correctly this was added to diagnose during debugging.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it is not needed. It would give addtional safety if a row in the output corresponds to an existing cohort, but at slight additional code and computational complexity. => not needed.

We need a way to filter out on R side rows of out_annual_cohorts that were not filled by the output loop over all cohorts. These rows exist because there can be less cohorts simulated than NCohortMax. This filtering is done on column ANNUAL_COHORTS_YEAR. If this is zero then it indicates that the row was not overwritten. We don't need ANNUAL_COHORTS_ID or ANNUAL_COHORTS_CID for that.

# BiomeE: test model outputs, repeatability and agreement with reference values from subfolder ./_snaps/
set.seed(10)

test_that("BiomeEP Tksoil initial days (rolling mean, smoothed)", {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it useful to have this test?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it does not hurt.

… default simulation by changing

This also switches back the second species to be deciduous. And the third species to be evergreen. NOTE: tests only use evergreen species.
@fabern
fabern force-pushed the biomee-establish-restart-with-full-initialization branch from cf52b9d to 89a30d0 Compare September 24, 2026 15:52
@fabern
fabern force-pushed the biomee-establish-restart-with-full-initialization branch from 0232080 to 56e15b5 Compare September 24, 2026 16:30
@fabern

fabern commented Sep 24, 2026

Copy link
Copy Markdown
Member Author

This is ready to merge.

@fabern
fabern merged commit 0bf91fc into master Sep 25, 2026
7 checks passed
@fabern
fabern deleted the biomee-establish-restart-with-full-initialization branch September 25, 2026 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant