Skip to content

Conversation

@kvrigor
Copy link
Member

@kvrigor kvrigor commented Jan 21, 2026

Equivalent to CLM5_FruitTree_v1.1 by @odombro.

Dombrowski, O., Brogi, C., Hendricks Franssen, H. J., Zanotelli, D., & Bogena, H. (2022). CLM5-FruitTree: a new sub-model for deciduous fruit trees in the Community Land Model (CLM5). Geoscientific model development, 15(13), 5167-5193, https://doi.org/10.5194/gmd-15-5167-2022

@kvrigor kvrigor linked an issue Jan 21, 2026 that may be closed by this pull request
@kvrigor
Copy link
Member Author

kvrigor commented Jan 21, 2026

Patching strategy

#
# 1. Create working directories
#
PATCH_WORKDIR=$HOME/CLM_FruitTree
PATCHFILES_DIR=$PATCH_WORKDIR/patch_files
eCLM_DIR=$PATCH_WORKDIR/eCLM
CLM5_DIR=$PATCH_WORKDIR/CLM5
mkdir -vp ${PATCHFILES_DIR}

#
# 2. Clone repos 
#
cd ${PATCH_WORKDIR}
git clone -b master https://github.com/HPSCTerrSys/eCLM.git
git clone -b release-clm5.0_FruitTree https://github.com/odombro/CTSM CLM5

#
# 3. Get a grasp of changed files
# 

# Show last 20 commits leading to the official release (CLM5_FruitTree_v1.1)
cd $CLM5_DIR
git log --pretty=format:"%h  %as  %<(15,trunc)%an  %<(30,trunc)%s %d" -20 CLM5_FruitTree_v1.1 | cat
# 
# 59b6a3009  2023-07-17  OlgaDom          Corrected flux assignment fr..  (tag: CLM5_FruitTree_v1.1)
# 7edde0ba8  2022-11-15  OlgaDom          cleaned up some scripts, add.. 
# a6bd8ded3  2022-11-15  OlgaDom          added new subroutine for orc.. 
# 2a21cb018  2022-11-04  OlgaDom          Fix orchard rotation carbon .. 
# 17f3e8ae6  2022-10-18  OlgaDom          debug planting of fruit tree.. 
# 7c9a3bbc8  2022-08-17  OlgaDom          Included harvest trigger whe.. 
# ad3d25b07  2022-05-30  OlgaDom          Bug fix in CNPhenology and C.. 
# 57586d70e  2022-05-22  OlgaDom          added references to CLM-Palm.. 
# 2a6d95e08  2022-05-05  OlgaDom          Update parameter file with t.. 
# 093c985b9  2022-05-05  OlgaDom          Make taper and nstem PFT par.. 
# 87b35bed2  2022-03-14  OlgaDom          Correct orchard rotation/rep.. 
# 64c874934  2022-02-09  OlgaDom          Update README                   (tag: CLM5_FruitTree)
# 7b823206d  2022-02-09  OlgaDom          Update README                  
# 2a1f5b91d  2022-02-09  odombro          Update README                  
# c4f164e92  2022-02-08  odombro          Update README                  
# 9fa4d0dfe  2022-02-08  Olga Dombrowski  Implement CLM-FruitTree sub-.. 
# d2b270654  2021-11-30  Bill Sacks       Merge pull request #1568 fro..  (origin/release-clm5.0)
# d035667e3  2021-11-30  Keith Oleson     Fix errors in technical note.. 
# 4d9bb14b9  2021-09-08  Bill Sacks       Merge pull request #1480 fro.. 
# 3c00edf2b  2021-09-07  Samuel Levis     Bringing a copy of master_li..
#

# List modified files under src/ folder starting from the commit after release-clm5.0 (9fa4d0dfe) to CLM5_FruitTree_v1.1 (59b6a3009)
git diff origin/release-clm5.0..CLM5_FruitTree_v1.1 --numstat -- src | cat
# +++     ---
# 3       3       src/biogeochem/CNBalanceCheckMod.F90
# 13      3       src/biogeochem/CNCIsoFluxMod.F90
# 97      38      src/biogeochem/CNCStateUpdate1Mod.F90
# 0       2       src/biogeochem/CNCStateUpdate2Mod.F90
# 6       3       src/biogeochem/CNDriverMod.F90
# 5       3       src/biogeochem/CNFUNMod.F90
# 21      9       src/biogeochem/CNGRespMod.F90
# 3       2       src/biogeochem/CNGapMortalityMod.F90
# 4       1       src/biogeochem/CNMRespMod.F90
# 73      27      src/biogeochem/CNNStateUpdate1Mod.F90
# 1875    581     src/biogeochem/CNPhenologyMod.F90
# 65      5       src/biogeochem/CNVegCarbonFluxType.F90
# 51      13      src/biogeochem/CNVegCarbonStateType.F90
# 2       2       src/biogeochem/CNVegComputeSeedMod.F90
# 39      2       src/biogeochem/CNVegNitrogenFluxType.F90
# 38      2       src/biogeochem/CNVegNitrogenStateType.F90
# 157     5       src/biogeochem/CNVegStateType.F90
# 31      27      src/biogeochem/CNVegStructUpdateMod.F90
# 9       2       src/biogeochem/CropType.F90
# 383     120     src/biogeochem/NutrientCompetitionFlexibleCNMod.F90
# 6       6       src/biogeochem/dynHarvestMod.F90
# 31      1       src/biogeophys/TemperatureType.F90
# 91      2       src/main/pftconMod.F90
#

#
# 4. Generate FruitTree patchset
#
git -C ${CLM5_DIR} format-patch --output-directory ${PATCHFILES_DIR} origin/release-clm5.0..CLM5_FruitTree_v1.1
#
#  /home/user/CLM_FruitTree/patch_files/0001-Implement-CLM-FruitTree-sub-model-for-deciduous-frui.patch
#  /home/user/CLM_FruitTree/patch_files/0002-Update-README.patch
#  /home/user/CLM_FruitTree/patch_files/0003-Update-README.patch
#  /home/user/CLM_FruitTree/patch_files/0004-Update-README.patch
#  /home/user/CLM_FruitTree/patch_files/0005-Update-README.patch
#  /home/user/CLM_FruitTree/patch_files/0006-Correct-orchard-rotation-replanting-trigger.patch
#  /home/user/CLM_FruitTree/patch_files/0007-Make-taper-and-nstem-PFT-parameters-to-be-set-in-par.patch
#  /home/user/CLM_FruitTree/patch_files/0008-Update-parameter-file-with-taper-and-nstem-parameter.patch
#  /home/user/CLM_FruitTree/patch_files/0009-added-references-to-CLM-Palm-Fan-et-al.-2015.patch
#  /home/user/CLM_FruitTree/patch_files/0010-Bug-fix-in-CNPhenology-and-CNVegStructUpdateMod-and-.patch
#  /home/user/CLM_FruitTree/patch_files/0011-Included-harvest-trigger-when-leaf-offset-starts.patch
#  /home/user/CLM_FruitTree/patch_files/0012-debug-planting-of-fruit-trees-make-two-more-CFTs-act.patch
#  /home/user/CLM_FruitTree/patch_files/0013-Fix-orchard-rotation-carbon-balance-error.patch
#  /home/user/CLM_FruitTree/patch_files/0014-added-new-subroutine-for-orchard-rotation.patch
#  /home/user/CLM_FruitTree/patch_files/0015-cleaned-up-some-scripts-added-some-crop-types-to-act.patch
#  /home/user/CLM_FruitTree/patch_files/0016-Corrected-flux-assignment-from-column-to-patch-level.patch
#  /home/user/CLM_FruitTree/patch_files/0017-Update-README.patch
#  /home/user/CLM_FruitTree/patch_files/0018-Update-README.patch
#  

#
# 5. Transform CLM5 paths in patchfiles into their equivalent eCLM paths
#

# Show instances of CLM5 paths
grep -RE "src/(biogeochem|biogeophys|main)" $PATCHFILES_DIR

# src/* -> src/clm5/*
sed -i 's#src/biogeochem#src/clm5/biogeochem#g' ${PATCHFILES_DIR}/*.patch
sed -i 's#src/biogeophys#src/clm5/biogeophys#g' ${PATCHFILES_DIR}/*.patch
sed -i 's#src/main#src/clm5/main#g' $PATCHFILES_DIR/*.patch

# Check if sed worked
grep -RE "src/(biogeochem|biogeophys|main)" $PATCHFILES_DIR         # should show no results                          
grep -RE "src/clm5/(biogeochem|biogeophys|main)" $PATCHFILES_DIR    # show transformed paths  

#
# 6. Apply FruitTree patchset to eCLM
#

cd ${eCLM_DIR}
git checkout -b CLM5_FruitTree_v1.1

# Start interactive patching
git am --ignore-whitespace $PATCHFILES_DIR/*

#  The ff. patches include README updates which isn't in eCLM and thus skipped:
#
#  /home/user/CLM_FruitTree/patch_files/0002-Update-README.patch
#  /home/user/CLM_FruitTree/patch_files/0003-Update-README.patch
#  /home/user/CLM_FruitTree/patch_files/0004-Update-README.patch
#  /home/user/CLM_FruitTree/patch_files/0005-Update-README.patch
git am --show-current-patch=diff
git am --skip

# Show diff summary after patching
git log --pretty=format:"%h  %as  %<(15,trunc)%an  %<(30,trunc)%s %d" -20 | cat
#
#  acf0b4cbc  2023-07-17  OlgaDom          Corrected flux assignment fr..  (HEAD -> CLM5_FruitTree_v1.1, origin/CLM5_FruitTree_v1.1)
#  1d07087dc  2022-11-15  OlgaDom          cleaned up some scripts, add.. 
#  be24b9368  2022-11-15  OlgaDom          added new subroutine for orc.. 
#  1dbab6aeb  2022-11-04  OlgaDom          Fix orchard rotation carbon .. 
#  cbf5e76d5  2022-10-18  OlgaDom          debug planting of fruit tree.. 
#  288c754ca  2022-08-17  OlgaDom          Included harvest trigger whe.. 
#  27db3e604  2022-05-30  OlgaDom          Bug fix in CNPhenology and C.. 
#  9e8401d62  2022-05-22  OlgaDom          added references to CLM-Palm.. 
#  3eef0a65b  2022-05-05  OlgaDom          Update parameter file with t.. 
#  99dca29bc  2022-05-05  OlgaDom          Make taper and nstem PFT par.. 
#  50fddc120  2022-03-14  OlgaDom          Correct orchard rotation/rep.. 
#  3fe2de2d8  2022-02-09  OlgaDom          Update README                  
#  1bcfffbd5  2022-02-08  Olga Dombrowski  Implement CLM-FruitTree sub-.. 
#  e1781edc1  2025-12-02  Johannes Keller  PDAF-related: GRACE-DA chang..  (origin/master, origin/dev-merge-eclm_with_FT_WC, origin/HEAD, master)
#  cece7aa74  2025-12-02  Johannes Keller  Set cpl_inst_tag from pdaf_i.. 
#  91d5f7b40  2025-11-25  Johannes Keller  Soil Hydraulic Parameter fro.. 
#  7877e5cc2  2025-11-21  Johannes Keller  Soil Hydraulic Parameter Per.. 
#  860a68c49  2025-11-20  Johannes Keller  PDAF-related perturbation ro.. 
#  7853ec4db  2025-11-04  Johannes Keller  docs: secure jupyter-book v1.. 
#  923b0fcd1  2025-10-02  Paul Rigor       Fixed wrong working director..

# Show eCLM files modified by the FruitTree patchset 
git diff master..acf0b4cbc --numstat | cat
# +++    ---
# -       -       clm5_params.c171117__FruitTree.nc
# 3       3       src/clm5/biogeochem/CNBalanceCheckMod.F90
# 13      3       src/clm5/biogeochem/CNCIsoFluxMod.F90
# 97      38      src/clm5/biogeochem/CNCStateUpdate1Mod.F90
# 0       2       src/clm5/biogeochem/CNCStateUpdate2Mod.F90
# 6       3       src/clm5/biogeochem/CNDriverMod.F90
# 5       3       src/clm5/biogeochem/CNFUNMod.F90
# 21      9       src/clm5/biogeochem/CNGRespMod.F90
# 3       2       src/clm5/biogeochem/CNGapMortalityMod.F90
# 4       1       src/clm5/biogeochem/CNMRespMod.F90
# 73      27      src/clm5/biogeochem/CNNStateUpdate1Mod.F90
# 1875    581     src/clm5/biogeochem/CNPhenologyMod.F90
# 65      5       src/clm5/biogeochem/CNVegCarbonFluxType.F90
# 51      13      src/clm5/biogeochem/CNVegCarbonStateType.F90
# 2       2       src/clm5/biogeochem/CNVegComputeSeedMod.F90
# 39      2       src/clm5/biogeochem/CNVegNitrogenFluxType.F90
# 38      2       src/clm5/biogeochem/CNVegNitrogenStateType.F90
# 157     5       src/clm5/biogeochem/CNVegStateType.F90
# 31      27      src/clm5/biogeochem/CNVegStructUpdateMod.F90
# 9       2       src/clm5/biogeochem/CropType.F90
# 383     120     src/clm5/biogeochem/NutrientCompetitionFlexibleCNMod.F90
# 6       6       src/clm5/biogeochem/dynHarvestMod.F90
# 31      1       src/clm5/biogeophys/TemperatureType.F90
# 91      2       src/clm5/main/pftconMod.F90

call ncd_io('season_decid', this%season_decid, 'read', ncid, readvar=readv, posNOTonfile=.true.)
if ( .not. readv ) call endrun(msg=' ERROR: error in reading in pft data'//errMsg(sourcefile, __LINE__))

call ncd_io('perennial', this%perennial, 'read', ncid, readvar=readv, posNOTonfile=.true.)
Copy link
Member Author

Choose a reason for hiding this comment

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

Requiring perennial and mulch_pruning in the PFT file is causing the CI failure. Some adjustments are necessary to make this parameters optional.

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.

CLM5-FruitTree implementation in eCLM

3 participants