Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FATES API Updates to facilitate refactor #2000

Merged
merged 36 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
b34a2e5
initial refactoring
Apr 5, 2023
1191b58
update default parameter file
adrifoster Apr 6, 2023
4070ca1
Merge branch 'master' into fates_refactor
adrifoster Apr 7, 2023
d9bf4ce
move cohort type into its own module
Apr 7, 2023
2910e3f
remove unused dependency
Apr 7, 2023
7af882a
move patch type to its own module
Apr 10, 2023
255e1b2
update for better unit testing
Apr 20, 2023
ea56996
put use statements back
Apr 24, 2023
bc1c4d2
put use statements back
Apr 24, 2023
3d75c33
remove fates_sources
Apr 25, 2023
3816c1f
update for refactor
Apr 27, 2023
a0e6e98
update for refactor
May 4, 2023
e01c443
Merge branch 'master' into fates_refactor
May 4, 2023
2e8d710
fix deleted allocate statement
May 4, 2023
9d65648
add back missing Cmakelist file
May 9, 2023
abbe133
update cmakelist
May 9, 2023
dec0cd6
get rid of whitespace
May 9, 2023
363cdf8
remove old printing statements
May 9, 2023
a194f85
remove old variable
May 9, 2023
3953f44
remove unused variable
May 9, 2023
29cc075
update utils cmakelist
May 9, 2023
3386bfa
remove unused variables
May 9, 2023
70d408f
update to latest ccsconfig
adrifoster May 9, 2023
8c53885
Merge branch 'master' into fates_refactor
May 23, 2023
fa1bcdb
Merge branch 'master' into fates_refactor
Jul 27, 2023
c960b55
Merge branch 'master' into fates_refactor
Jul 28, 2023
1e27985
address comments
Jul 28, 2023
7afc5ff
remove comment
Jul 28, 2023
b9f8587
update fates tag in externals
glemieux Aug 8, 2023
72b979c
Merge tag 'ctsm5.1.dev132' into fates_refactor
glemieux Aug 8, 2023
4121c25
update changelog
glemieux Aug 8, 2023
6a13704
updating expected failures with nvhpc tests
glemieux Aug 9, 2023
782a80b
updating ChangeLog
glemieux Aug 9, 2023
73a6189
correcting changelog attribution
glemieux Aug 9, 2023
33ab140
Merge remote-tracking branch 'escomp/master' into fates_refactor
ekluzek Aug 10, 2023
3897807
Update changelog
ekluzek Aug 10, 2023
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 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
ekluzek marked this conversation as resolved.
Show resolved Hide resolved
protocol = git
repo_url = https://github.com/ESMCI/ccs_config_cesm.git
local_path = ccs_config
glemieux marked this conversation as resolved.
Show resolved Hide resolved
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
67 changes: 32 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,41 @@ 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
adrifoster marked this conversation as resolved.
Show resolved Hide resolved
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 calss in Synchronized params mod, only operates on fates_params class
adrifoster marked this conversation as resolved.
Show resolved Hide resolved

is_host_file = .false.
call ParametersFromNetCDF(fates_paramfile, is_host_file, fates_params)
is_host_file = .false.
! actually inside this module
glemieux marked this conversation as resolved.
Show resolved Hide resolved
!uses ncdio_pio module (should be a library)
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 +208,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