Skip to content

Commit

Permalink
Merge pull request #2000 from adrifoster/fates_refactor
Browse files Browse the repository at this point in the history
FATES API Updates to facilitate refactor
  • Loading branch information
ekluzek authored Aug 10, 2023
2 parents 0f7e5d4 + 3897807 commit 942de5c
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 58 deletions.
2 changes: 1 addition & 1 deletion Externals.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ hash = 34723c2
required = True

[ccs_config]
tag = ccs_config_cesm0.0.64
tag = ccs_config_cesm0.0.65
protocol = git
repo_url = https://github.com/ESMCI/ccs_config_cesm.git
local_path = ccs_config
Expand Down
2 changes: 1 addition & 1 deletion Externals_CLM.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
local_path = src/fates
protocol = git
repo_url = https://github.com/NGEET/fates
tag = sci.1.66.1_api.25.5.0
tag = sci.1.67.1_api.26.0.0
required = True

[externals_description]
Expand Down
14 changes: 14 additions & 0 deletions cime_config/testdefs/ExpectedTestFails.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@
</phase>
</test>

<test name="SMS.f45_f45_mg37.I2000Clm51FatesSpRsGs.cheyenne_nvhpc.clm-FatesColdSatPhen">
<phase name="RUN">
<status>FAIL</status>
<issue>#1733</issue>
</phase>
</test>

<test name="SMS.f10_f10_mg37.I2000Clm50BgcCrop.cheyenne_nvhpc.clm-crop">
<phase name="RUN">
<status>FAIL</status>
<issue>#1733</issue>
</phase>
</test>

<!-- fates test suite failures -->

<test name="ERS_Lm12.1x1_brazil.I2000Clm50FatesCruRsGs.cheyenne_intel.clm-FatesFireLightningPopDens">
Expand Down
102 changes: 97 additions & 5 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,100 @@
===============================================================
Tag name: ctsm5.1.dev133
Originator(s): adrifoster (Adrianna Foster), glemieux (Gregory Lemieux, LBL/NGEET)
Date: Wed Aug 9 22:44:46 MDT 2023
One-line Summary: FATES API update to facilitate fates refactor

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

This updates a number of FATES type names and module use statements
which correspond with a refactoring effort that moves FATES
patches and cohorts into their own respective modules.

With the FATES update is a minor science update, so there are
changes to answers for FATES.

This also incorporates a minor update to a more recent version
of the ccs config external.

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

Does this tag change answers significantly for any of the following physics configurations?
(Details of any changes will be given in the "Answer changes" section below.)

[Put an [X] in the box for any configuration with significant answer changes.]

[ ] clm5_1

[ ] clm5_0

[ ] ctsm5_0-nwp

[ ] clm4_5


Bugs fixed or introduced
------------------------
Issues updated:

Updated #1733 -- nvhpc compiler tests failing on cheyenne

Notes of particular relevance for developers:
---------------------------------------------
Caveats for developers (e.g., code that is duplicated that requires double maintenance):

- Note that the fates patch and cohort types now use the `fates_` prefix instead
of the `ed_` prefix.
- The expected failures list of tests has been expanded to include the remaining
nvhpc compiler tests on cheyenne with this update

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

[PASS means all tests PASS; OK means tests PASS other than expected fails.]

build-namelist tests (if CLMBuildNamelist.pm has changed):

cheyenne - PASS

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

cheyenne ---- OK
izumi ------- OK

fates tests: (give name of baseline if different from CTSM tagname, normally fates baselines are fates-<FATES TAG>-<CTSM TAG>)
cheyenne ---- OK
izumi ------- OK

If the tag used for baseline comparisons was NOT the previous tag, note that here:

Note that the previous ctsm5.1.dev132 tag was generated using FATES tagname
sci.1.66.1_api.25.5.0. This api update includes intermediate FATES science
tags that are non-b4b, so aux_clm FATES tests result in DIFFs as expected.

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

Changes answers relative to baseline: Yes, but only for aux_clm fates tests.

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

List any externals directories updated (cime, rtm, mosart, cism, fates, etc.):

sci.1.66.1_api.25.5.0 -> sci.1.67.1_api.26.0.0
ccs_config_cesm0.0.64 -> ccs_config_cesm0.0.65

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

https://github.com/ESCOMP/CTSM/pull/2000 -- refactor
https://github.com/ESCOMP/CTSM/pull/2089 -- Change template update
https://github.com/NGEET/fates/pull/1024 -- FATES refactor

===============================================================
===============================================================
Tag name: ctsm5.1.dev132
Originator(s): mvdebolskiy (NORCE, Bergen, Norway), slevis (Samuel Levis,UCAR/TSS,303-665-1310)
Date: Fri Aug 4 17:52:45 MDT 2023
Expand Down Expand Up @@ -91,13 +187,9 @@ Testing summary:

cheyenne - PASS

tools-tests (test/tools) (if tools have been changed):

cheyenne -

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

cheyenne ---- OK
heyenne ---- OK
izumi ------- OK

any other testing (give details below):
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.1.dev133 glemieux 08/09/2023 FATES API update to facilitate fates refactor
ctsm5.1.dev132 slevis 08/04/2023 Add parameterization to allow excess ice in soil and subsidence
ctsm5.1.dev131 samrabin 07/27/2023 Enable prescribed crop calendars
ctsm5.1.dev130 glemieux 07/09/2023 FATES parameter file and test definition update
Expand Down
6 changes: 3 additions & 3 deletions src/main/histFileMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ module histFileMod
use LandunitType , only : lun
use ColumnType , only : col
use PatchType , only : patch
use EDTypesMod , only : nclmax
use EDTypesMod , only : nlevleaf
use EDParamsMod , only : nclmax
use EDParamsMod , only : nlevleaf
use FatesInterfaceTypesMod , only : nlevsclass, nlevage, nlevcoage
use FatesInterfaceTypesMod , only : nlevheight
use FatesInterfaceTypesMod , only : nlevdamage
use EDTypesMod , only : nfsc
use FatesLitterMod , only : nfsc
use FatesLitterMod , only : ncwd
use PRTGenericMod , only : num_elements_fates => num_elements
use FatesInterfaceTypesMod , only : numpft_fates => numpft
Expand Down
25 changes: 12 additions & 13 deletions src/utils/clmfates_interfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ module CLMFatesInterfaceMod
use FatesHistoryInterfaceMod, only : fates_hist
use FatesRestartInterfaceMod, only : fates_restart_interface_type

use EDTypesMod , only : ed_patch_type
use FatesPatchMod , only : fates_patch_type
use PRTGenericMod , only : num_elements
use FatesInterfaceTypesMod, only : hlm_stepsize
use FatesInterfaceTypesMod, only : fates_maxPatchesPerSite
Expand Down Expand Up @@ -1053,7 +1053,6 @@ subroutine dynamics_driv(this, nc, bounds_clump, &
call ed_update_site(this%fates(nc)%sites(s), &
this%fates(nc)%bc_in(s), &
this%fates(nc)%bc_out(s))

enddo

! ---------------------------------------------------------------------------------
Expand Down Expand Up @@ -1144,11 +1143,11 @@ subroutine wrap_update_hlmfates_dyn(this, nc, bounds_clump, &
type(waterdiagnosticbulk_type) , intent(inout) :: waterdiagnosticbulk_inst
type(canopystate_type) , intent(inout) :: canopystate_inst
type(soilbiogeochem_carbonflux_type), intent(inout) :: soilbiogeochem_carbonflux_inst


! is this being called during a read from restart sequence (if so then use the restarted fates
! snow depth variable rather than the CLM variable).
logical , intent(in) :: is_initing_from_restart

integer :: npatch ! number of patches in each site
integer :: ifp ! index FATES patch
integer :: p ! HLM patch index
Expand Down Expand Up @@ -1190,7 +1189,7 @@ subroutine wrap_update_hlmfates_dyn(this, nc, bounds_clump, &
! Canopy diagnostics for FATES
call canopy_summarization(this%fates(nc)%nsites, &
this%fates(nc)%sites, &
this%fates(nc)%bc_in)
this%fates(nc)%bc_in)

! Canopy diagnostic outputs for HLM
call update_hlm_dynamics(this%fates(nc)%nsites, &
Expand Down Expand Up @@ -1413,7 +1412,6 @@ subroutine restart( this, bounds_proc, ncid, flag, waterdiagnosticbulk_inst, &
integer :: nvar
integer :: ivar
logical :: readvar

logical, save :: initialized = .false.

call t_startf('fates_restart')
Expand Down Expand Up @@ -1908,7 +1906,7 @@ subroutine wrap_sunfrac(this,nc,atm2lnd_inst,canopystate_inst)
! this is the order increment of patch
! on the site

type(ed_patch_type), pointer :: cpatch ! c"urrent" patch INTERF-TODO: SHOULD
type(fates_patch_type), pointer :: cpatch ! c"urrent" patch INTERF-TODO: SHOULD
! BE HIDDEN AS A FATES PRIVATE

call t_startf('fates_wrapsunfrac')
Expand Down Expand Up @@ -2187,12 +2185,13 @@ subroutine wrap_photosynthesis(this, nc, bounds, fn, filterp, &
use shr_log_mod , only : errMsg => shr_log_errMsg
use abortutils , only : endrun
use decompMod , only : bounds_type
use clm_varcon , only : rgas, tfrz, namep
use clm_varcon , only : tfrz, namep
use clm_varctl , only : iulog
use pftconMod , only : pftcon
use PatchType , only : patch
use quadraticMod , only : quadratic
use EDtypesMod , only : ed_patch_type, ed_cohort_type, ed_site_type
use EDtypesMod , only : ed_site_type
use FatesPatchMod, only : fates_patch_type
use FatesCohortMod , only : fates_cohort_type

!
! !ARGUMENTS:
Expand Down Expand Up @@ -3158,13 +3157,13 @@ end subroutine wrap_hydraulics_drive

subroutine hlm_bounds_to_fates_bounds(hlm, fates)

use FatesIODimensionsMod, only : fates_bounds_type
use FatesIODimensionsMod, only : fates_bounds_type
use FatesInterfaceTypesMod, only : nlevsclass, nlevage, nlevcoage
use FatesInterfaceTypesMod, only : nlevheight
use FatesInterfaceTypesMod, only : nlevdamage
use EDtypesMod, only : nfsc
use FatesLitterMod, only : ncwd
use EDtypesMod, only : nlevleaf, nclmax
use FatesLitterMod, only : nfsc
use FatesLitterMod, only : ncwd
use EDParamsMod, only : nlevleaf, nclmax
use FatesInterfaceTypesMod, only : numpft_fates => numpft


Expand Down
65 changes: 30 additions & 35 deletions src/utils/clmfates_paraminterfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@ module CLMFatesParamInterfaceMod
! NOTE(bja, 2017-01) this code can not go into the main clm-fates
! interface module because of circular dependancies with pftvarcon.

use shr_kind_mod, only : r8 => shr_kind_r8
use FatesGlobals, only : fates_log
use shr_kind_mod, only : r8 => shr_kind_r8, SHR_KIND_CL
use FatesGlobals, only : fates_log
use FatesParametersInterface, only : fates_parameters_type
use EDParamsMod, only : FatesRegisterParams, FatesReceiveParams
use SFParamsMod, only : SpitFireRegisterParams, SpitFireReceiveParams
use PRTInitParamsFATESMod, only : PRTRegisterParams, PRTReceiveParams
use FatesSynchronizedParamsMod, only : FatesSynchronizedParamsInst

implicit none

Expand All @@ -25,49 +30,39 @@ module CLMFatesParamInterfaceMod

!-----------------------------------------------------------------------
subroutine FatesReadParameters()

use clm_varctl, only : use_fates, paramfile, fates_paramfile
use spmdMod, only : masterproc

use FatesParametersInterface, only : fates_parameters_type

use EDParamsMod, only : FatesRegisterParams, FatesReceiveParams
use SFParamsMod, only : SpitFireRegisterParams, SpitFireReceiveParams
use PRTInitParamsFATESMod, only : PRTRegisterParams, PRTReceiveParams
use FatesSynchronizedParamsMod, only : FatesSynchronizedParamsInst
use clm_varctl, only : use_fates, paramfile, fates_paramfile
use spmdMod, only : masterproc

implicit none

character(len=32) :: subname = 'FatesReadParameters'
class(fates_parameters_type), allocatable :: fates_params
logical :: is_host_file

if (use_fates) then
if (masterproc) then
write(fates_log(), *) 'clmfates_interfaceMod.F90::'//trim(subname)//' :: CLM reading ED/FATES '//' parameters '
end if
if (masterproc) then
write(fates_log(), *) 'clmfates_interfaceMod.F90::'//trim(subname)//' :: CLM reading ED/FATES '//' parameters '
end if

allocate(fates_params)
call fates_params%Init()
call FatesRegisterParams(fates_params)
call SpitFireRegisterParams(fates_params)
call PRTRegisterParams(fates_params)
call FatesSynchronizedParamsInst%RegisterParams(fates_params)
allocate(fates_params)
call fates_params%Init() ! fates_params class, in FatesParameterInterfaceMod
call FatesRegisterParams(fates_params) !EDParamsMod, only operates on fates_params class
call SpitFireRegisterParams(fates_params) !SpitFire Mod, only operates of fates_params class
call PRTRegisterParams(fates_params) ! PRT mod, only operates on fates_params class
call FatesSynchronizedParamsInst%RegisterParams(fates_params) !Synchronized params class in Synchronized params mod, only operates on fates_params class

is_host_file = .false.
call ParametersFromNetCDF(fates_paramfile, is_host_file, fates_params)
is_host_file = .false.
call ParametersFromNetCDF(fates_paramfile, is_host_file, fates_params)

is_host_file = .true.
call ParametersFromNetCDF(paramfile, is_host_file, fates_params)
is_host_file = .true.
call ParametersFromNetCDF(paramfile, is_host_file, fates_params)

call FatesReceiveParams(fates_params)
call SpitFireReceiveParams(fates_params)
call PRTReceiveParams(fates_params)
call FatesSynchronizedParamsInst%ReceiveParams(fates_params)
call FatesReceiveParams(fates_params)
call SpitFireReceiveParams(fates_params)
call PRTReceiveParams(fates_params)
call FatesSynchronizedParamsInst%ReceiveParams(fates_params)

call fates_params%Destroy()
deallocate(fates_params)
end if
call fates_params%Destroy()
deallocate(fates_params)

end subroutine FatesReadParameters

Expand Down Expand Up @@ -211,7 +206,7 @@ subroutine ParametersFromNetCDF(filename, is_host_file, fates_params)
call SetParameterDimensions(ncid, is_host_file, fates_params)
max_dim_size = fates_params%GetMaxDimensionSize()
allocate(data(max_dim_size, max_dim_size))

num_params = fates_params%num_params()
do i = 1, num_params
call fates_params%GetMetaData(i, name, dimension_shape, dimension_sizes, dimension_names, is_host_param)
Expand Down

0 comments on commit 942de5c

Please sign in to comment.