Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
[submodule "fates"]
path = src/fates
url = https://github.com/NGEET/fates
fxtag = sci.1.81.1_api.38.0.0
fxtag = sci.1.82.3_api.39.0.0
fxrequired = AlwaysRequired
# Standard Fork to compare to with "git fleximod test" to ensure personal forks aren't committed
fxDONOTUSEurl = https://github.com/NCAR/fates-release
Expand Down
29 changes: 0 additions & 29 deletions cime_config/testdefs/ExpectedTestFails.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,17 +185,6 @@
</phase>
</test>

<test name="ERI_D_Ld20.f45_f45_mg37.I2000Clm50FatesRs.izumi_nag.clm-FatesColdTwoStream">
<phase name="COMPARE_base_rest">
<status>FAIL</status>
<issue>#2325</issue>
</phase>
<phase name="RUN">
<status>FAIL</status>
<issue>#2325</issue>
</phase>
</test>

<test name="ERS_Ld60.f45_f45_mg37.I2000Clm50FatesCruRsGs.derecho_intel.clm-FatesColdST3">
<phase name="RUN">
<status>FAIL</status>
Expand Down Expand Up @@ -277,24 +266,6 @@
</phase>
</test>

<test name="ERI_D_Ld20.f45_f45_mg37.I2000Clm50FatesRs.derecho_intel.clm-FatesColdTwoStream">
<phase name="COMPARE_base_rest">
<status>FAIL</status>
<issue>#2325</issue>
</phase>
<phase name="RUN">
<status>FAIL</status>
<issue>#2325</issue>
</phase>
</test>

<test name="ERS_D_Ld20.f45_f45_mg37.I2000Clm50FatesRs.derecho_gnu.clm-FatesColdTwoStreamNoCompFixedBioGeo">
<phase name="COMPARE_base_rest">
<status>FAIL</status>
<issue>#2325</issue>
</phase>
</test>

<test name="SMS_Ld10_D_Mmpi-serial.CLM_USRDAT.I1PtClm60Fates.derecho_intel.clm-FatesFireLightningPopDens--clm-NEON-FATES-NIWO">
<phase name="SHAREDLIB_BUILD">
<status>FAIL</status>
Expand Down
1 change: 1 addition & 0 deletions cime_config/testdefs/testlist_clm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3250,6 +3250,7 @@
<test name="ERS_D_Ld20" grid="f45_f45_mg37" compset="I2000Clm50FatesRs" testmods="clm/FatesColdTwoStreamNoCompFixedBioGeo">
<machines>
<machine name="derecho" compiler="gnu" category="fates"/>
<machine name="derecho" compiler="gnu" category="aux_clm"/>
</machines>
<options>
<option name="wallclock">00:30:00</option>
Expand Down
72 changes: 72 additions & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,76 @@
===============================================================
Tag name: ctsm5.3.034
Originator(s): rgknox (Ryan Knox)
Date: Thu Mar 27 16:03:56 MDT 2025
One-line Summary: Fixes to enable passing FATES two-stream ERS and ERI restart tests.

Purpose and description of changes
----------------------------------

This set of changes refactors the calculation of zenith angles by putting them
into a separate call, and enables FATES to make updates to its albedo solve
on all timesteps regardless of the doalb flag. The FATES side of the code
will not perform calculations unless the zenith angle is positive anyway.
These refactors were necessary to have restart tests passing for FATES
when two-stream radiation is enabled. Further, the zenith angle boundary
condition is now passed to fates at the column level, which is more
scale consistent.

Significant changes to scientifically-supported configurations
--------------------------------------------------------------

This set of changes to ctsm code does not make any significant changes that affect model results.
This set of changes does update the pointer to the FATES tag, which since the previous
ctsm api change with fates, has improved code stability for photosynthesis. Those
changes result in non-trivial but non-significant deviations in answers in FATES
configurations.

There are no changes to non-FATES answers.


Bugs fixed
----------

List of CTSM issues fixed:
Fixes 2903: FATES doesn't work in branch runs
Fixes 2325: ERS FatesColdTwoStreamNoCompFixedBioGeo Restart Test Fails

Notes of particular relevance for users
---------------------------------------

This set of changes is a necessary milestone towards FATES using
two-stream radiation as its default configuration.

Notes of particular relevance for developers:
---------------------------------------------
Changes to tests or testing:
Added ERS_D_Ld20_f45_f45_mg37_I2000Clm50FatesRs_FatesColdTwoStreamNoCompFixedBioGeo to aux_clm

Testing summary:
----------------

regular tests (aux_clm: https://github.com/ESCOMP/CTSM/wiki/System-Testing-Guide#pre-merge-system-testing):

derecho ----- OK (new passes)
izumi ------- OK

Answer changes
--------------

As mentioned above, answers only changed for FATES.
Answers changed trivially due to zenith angle coupling changes and updates to the FATES tag.


Other details
-------------

The FATES git-fleximod pointer was updated to sci.1.82.3_api.39.0.0

Pull Requests that document the changes (include PR ids):
2949: https://github.com/ESCOMP/CTSM/pull/2949

===============================================================
===============================================================
Tag name: ctsm5.3.033
Originator(s): wwieder, slevis (Will Wieder, Sam Levis, UCAR/TSS)
Date: Wed 19 Mar 2025 02:43:55 PM MDT
Expand Down
1 change: 1 addition & 0 deletions doc/ChangeSum
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Tag Who Date Summary
============================================================================================================================
ctsm5.3.034 rgknox 03/27/2025 Fixes to enable passing FATES two-stream ERS and ERI restart tests.
ctsm5.3.033 multiple 03/19/2025 Add new mimics_fi param = frac of litter inputs bypassing litter pools
ctsm5.3.032 slevis 03/17/2025 Add option to use CRUJRA2024 with clm6 and clm5
ctsm5.3.031 slevis 03/13/2025 Merge b4b-dev
Expand Down
14 changes: 13 additions & 1 deletion src/biogeophys/BalanceCheckMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,7 @@ subroutine BalanceCheck( bounds, &

indexp = maxloc( abs(errsol(bounds%begp:bounds%endp)), 1 , mask = (errsol(bounds%begp:bounds%endp) /= spval) ) + bounds%begp -1
indexg = patch%gridcell(indexp)
indexc = patch%column(indexp)
write(iulog,*)'WARNING:: BalanceCheck, solar radiation balance error (W/m2)'
write(iulog,*)'nstep = ',nstep
write(iulog,*)'errsol = ',errsol(indexp)
Expand All @@ -969,7 +970,18 @@ subroutine BalanceCheck( bounds, &
write(iulog,*)'forc_solai(1) = ',forc_solai(indexg,1)
write(iulog,*)'forc_solai(2) = ',forc_solai(indexg,2)
write(iulog,*)'forc_tot = ',forc_solad(indexg,1)+forc_solad(indexg,2) &
+forc_solai(indexg,1)+forc_solai(indexg,2)
+forc_solai(indexg,1)+forc_solai(indexg,2)

write(iulog,*)'coszen_col:',surfalb_inst%coszen_col(indexc)
write(iulog,*)'fabd:',fabd(indexp,:)
write(iulog,*)'fabi:',fabi(indexp,:)
write(iulog,*)'albd:',albd(indexp,:)
write(iulog,*)'albi:',albi(indexp,:)
write(iulog,*)'ftdd:',ftdd(indexp,:)
write(iulog,*)'ftid:',ftid(indexp,:)
write(iulog,*)'ftii:',ftii(indexp,:)


write(iulog,*)'CTSM is stopping'
call endrun(subgrid_index=indexp, subgrid_level=subgrid_level_patch, msg=errmsg(sourcefile, __LINE__))
end if
Expand Down
91 changes: 63 additions & 28 deletions src/biogeophys/SurfaceAlbedoMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ module SurfaceAlbedoMod
public :: SurfaceAlbedo_readnl
public :: SurfaceAlbedoInitTimeConst
public :: SurfaceAlbedo ! Surface albedo and two-stream fluxes
public :: UpdateZenithAngles

!
! !PRIVATE MEMBER FUNCTIONS:
private :: SoilAlbedo ! Determine ground surface albedo
Expand Down Expand Up @@ -224,7 +226,57 @@ subroutine SurfaceAlbedoInitTimeConst(bounds)

end subroutine SurfaceAlbedoInitTimeConst

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

subroutine UpdateZenithAngles(bounds, surfalb_inst, nextsw_cday, declinp1)

! Incorporate surface slopes to generate column level zenith angles

use clm_varctl , only : downscale_hillslope_meteorology
use shr_orb_mod

type(bounds_type) , intent(in) :: bounds ! bounds
type(surfalb_type) , intent(inout) :: surfalb_inst
real(r8) , intent(in) :: nextsw_cday ! calendar day at Greenwich (1.00, ..., days/year)
real(r8) , intent(in) :: declinp1 ! declination angle (radians) for next time step

integer :: c,g ! indices

associate( &
azsun_grc => surfalb_inst%azsun_grc , & ! Output: [real(r8) (:) ] cosine of solar zenith angle
coszen_grc => surfalb_inst%coszen_grc , & ! Output: [real(r8) (:) ] cosine of solar zenith angle
coszen_col => surfalb_inst%coszen_col) ! Output: [real(r8) (:) ] cosine of solar zenith angle


! Cosine solar zenith angle for next time step
! First calculate grid-scale zenith based on time and location, no topographic effects
do g = bounds%begg,bounds%endg
coszen_grc(g) = shr_orb_cosz (nextsw_cday, grc%lat(g), grc%lon(g), declinp1)
azsun_grc(g) = shr_orb_azimuth(nextsw_cday, grc%lat(g), grc%lon(g), declinp1, acos(coszen_grc(g)))
end do

! calculate local incidence angle based on column slope and aspect
do c = bounds%begc,bounds%endc
g = col%gridcell(c)
if (col%is_hillslope_column(c) .and. downscale_hillslope_meteorology) then

! hill_slope is [m/m], convert to radians with atan function
coszen_col(c) = shr_orb_cosinc(acos(coszen_grc(g)),azsun_grc(g),atan(col%hill_slope(c)),col%hill_aspect(c))

if(coszen_grc(g) > 0._r8 .and. coszen_col(c) < 0._r8) coszen_col(c) = 0._r8
else
coszen_col(c) = coszen_grc(g)
endif

end do

end associate

return
end subroutine UpdateZenithAngles

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

subroutine SurfaceAlbedo(bounds,nc, &
num_nourbanc, filter_nourbanc, &
num_nourbanp, filter_nourbanp, &
Expand Down Expand Up @@ -256,13 +308,13 @@ subroutine SurfaceAlbedo(bounds,nc, &
! only computed over active points.
!
! !USES:
use shr_orb_mod
!use shr_orb_mod
use clm_time_manager , only : get_nstep
use abortutils , only : endrun
use clm_varctl , only : use_subgrid_fluxes, use_snicar_frc, use_fates
use CLMFatesInterfaceMod, only : hlm_fates_interface_type
use landunit_varcon , only : istsoil
use clm_varctl , only : downscale_hillslope_meteorology


! !ARGUMENTS:
type(bounds_type) , intent(in) :: bounds ! bounds
Expand Down Expand Up @@ -427,32 +479,18 @@ subroutine SurfaceAlbedo(bounds,nc, &
fabi_sha_z => surfalb_inst%fabi_sha_z_patch & ! Output: [real(r8) (:,:) ] absorbed shaded leaf diffuse PAR (per unit lai+sai) for each canopy layer
)

! Cosine solar zenith angle for next time step

do g = bounds%begg,bounds%endg
coszen_grc(g) = shr_orb_cosz (nextsw_cday, grc%lat(g), grc%lon(g), declinp1)
end do

do c = bounds%begc,bounds%endc
g = col%gridcell(c)
if (col%is_hillslope_column(c) .and. downscale_hillslope_meteorology) then
! calculate local incidence angle based on column slope and aspect
zenith_angle = acos(coszen_grc(g))

azsun_grc(g) = shr_orb_azimuth(nextsw_cday, grc%lat(g), grc%lon(g), declinp1, zenith_angle)
! hill_slope is [m/m], convert to radians
coszen_col(c) = shr_orb_cosinc(zenith_angle,azsun_grc(g),atan(col%hill_slope(c)),col%hill_aspect(c))

if(coszen_grc(g) > 0._r8 .and. coszen_col(c) < 0._r8) coszen_col(c) = 0._r8

else
coszen_col(c) = coszen_grc(g)
endif
end do
call UpdateZenithAngles(bounds,surfalb_inst, nextsw_cday, declinp1)

! Apply column level zenith angles to the patch level
do fp = 1,num_nourbanp
p = filter_nourbanp(fp)
c = patch%column(p)
coszen_patch(p) = coszen_col(c)
if(patch%is_fates(p))then
coszen_patch(p) = spval
else
coszen_patch(p) = coszen_col(c)
end if
end do

! Initialize output because solar radiation only done if coszen > 0
Expand Down Expand Up @@ -1045,10 +1083,7 @@ subroutine SurfaceAlbedo(bounds,nc, &

if (use_fates) then

call clm_fates%wrap_canopy_radiation(bounds, nc, &
num_vegsol, filter_vegsol, &
coszen_patch(bounds%begp:bounds%endp), &
fcansno(bounds%begp:bounds%endp), surfalb_inst)
call clm_fates%wrap_canopy_radiation(bounds, nc, fcansno(bounds%begp:bounds%endp), surfalb_inst)

else

Expand Down
2 changes: 1 addition & 1 deletion src/fates
Submodule fates updated 42 files
+3 −2 biogeochem/EDCanopyStructureMod.F90
+4 −3 biogeochem/EDPatchDynamicsMod.F90
+2 −2 biogeochem/EDPhysiologyMod.F90
+8 −44 biogeochem/FatesAllometryMod.F90
+3 −10 biogeochem/FatesPatchMod.F90
+260 −0 biogeophys/FatesLeafBiophysParamsMod.F90
+359 −1,418 biogeophys/FatesPlantRespPhotosynthMod.F90
+2,232 −0 biogeophys/LeafBiophysicsMod.F90
+96 −2 fire/FatesFuelMod.F90
+150 −1 fire/SFEquationsMod.F90
+170 −297 fire/SFMainMod.F90
+89 −0 functional_unit_testing/leaf_biophys/CtypesLeafBiophys.py
+1,045 −0 functional_unit_testing/leaf_biophys/DriveFUnitLeafBiophys.py
+436 −0 functional_unit_testing/leaf_biophys/DriveSmokeTestLeafBiophys.py
+1 −0 functional_unit_testing/leaf_biophys/bld/README
+29 −0 functional_unit_testing/leaf_biophys/build_leafbiophys_objects.sh
+150 −0 functional_unit_testing/leaf_biophys/f90_src/LeafBiophysSuppMod.F90
+108 −0 functional_unit_testing/leaf_biophys/f90_src/WrapShrMod.F90
+46 −0 functional_unit_testing/leaf_biophys/leaf_biophys_controls.xml
+3 −2 functional_unit_testing/radiation/RadiationUTestDriver.py
+0 −1 functional_unit_testing/radiation/f90_src/RadiationWrapMod.F90
+1 −0 main/EDInitMod.F90
+1 −23 main/EDParamsMod.F90
+38 −170 main/EDPftvarcon.F90
+3 −0 main/EDTypesMod.F90
+14 −14 main/FatesConstantsMod.F90
+26 −18 main/FatesInterfaceMod.F90
+6 −10 main/FatesInterfaceTypesMod.F90
+1 −1 main/FatesInventoryInitMod.F90
+2 −2 main/FatesParametersInterface.F90
+99 −114 main/FatesRestartInterfaceMod.F90
+27 −5 main/FatesUtilsMod.F90
+1 −1 parameter_files/patch_default_bciopt224.xml
+271 −267 parteh/PRTAllometricCNPMod.F90
+3 −1 radiation/FatesNormanRadMod.F90
+122 −173 radiation/FatesRadiationDriveMod.F90
+66 −24 radiation/FatesTwoStreamUtilsMod.F90
+55 −21 radiation/TwoStreamMLPEMod.F90
+1 −0 testing/CMakeLists.txt
+6 −0 testing/unit_testing/fire_equations_test/CMakeLists.txt
+879 −0 testing/unit_testing/fire_equations_test/test_FireEquations.pf
+2 −1 testing/unit_tests.cfg
19 changes: 17 additions & 2 deletions src/main/clm_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ module clm_driver
use AerosolMod , only : AerosolMasses
use SnowSnicarMod , only : SnowAge_grain
use SurfaceAlbedoMod , only : SurfaceAlbedo
use SurfaceAlbedoMod , only : UpdateZenithAngles
use UrbanAlbedoMod , only : UrbanAlbedo
!
use SurfaceRadiationMod , only : SurfaceRadiation, CanopySunShadeFracs
Expand Down Expand Up @@ -1223,8 +1224,22 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro
! ============================================================================
! Determine albedos for next time step
! ============================================================================

if (doalb) then

if (.not.doalb) then


if(use_fates) then
! During branch runs and non continue_run restarts, the doalb flag
Comment thread
slevis-lmwg marked this conversation as resolved.
Resolved
! does not trigger correctly for fates runs (and non-fates?), and thus
! the zenith angles are not calculated and ready when radiation scattering
! needs to occur.
call UpdateZenithAngles(bounds_clump, surfalb_inst, nextsw_cday, declinp1)
call clm_fates%wrap_canopy_radiation(bounds_clump, nc, &
water_inst%waterdiagnosticbulk_inst%fcansno_patch(bounds_clump%begp:bounds_clump%endp), &
surfalb_inst)
end if

else

! Albedos for non-urban columns
call t_startf('surfalb')
Expand Down
Loading