From 302ddc1053adf2781e886ba1eba9b9f16efdab02 Mon Sep 17 00:00:00 2001 From: Darian Boggs Date: Mon, 25 Nov 2024 13:44:30 -0500 Subject: [PATCH 1/5] Add accumulation_type to VariableSpec --- generic3g/ComponentSpecParser.F90 | 1 + generic3g/ComponentSpecParser/parse_var_specs.F90 | 12 +++++++++++- generic3g/specs/VariableSpec.F90 | 6 +++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/generic3g/ComponentSpecParser.F90 b/generic3g/ComponentSpecParser.F90 index bb0e73abf658..e62cd8d0105e 100644 --- a/generic3g/ComponentSpecParser.F90 +++ b/generic3g/ComponentSpecParser.F90 @@ -61,6 +61,7 @@ module mapl3g_ComponentSpecParser character(*), parameter :: KEY_UNGRIDDED_DIM_EXTENT = 'extent' character(*), parameter :: KEY_UNGRIDDED_DIM_COORDINATES = 'coordinates' character(*), parameter :: KEY_VERTICAL_DIM_SPEC = 'vertical_dim_spec' + character(*), parameter :: KEY_ACCUMULATION_TYPE = 'accumulation_type' !> ! Submodule declarations diff --git a/generic3g/ComponentSpecParser/parse_var_specs.F90 b/generic3g/ComponentSpecParser/parse_var_specs.F90 index 92f9c43eb50e..e6333ad606a4 100644 --- a/generic3g/ComponentSpecParser/parse_var_specs.F90 +++ b/generic3g/ComponentSpecParser/parse_var_specs.F90 @@ -47,6 +47,7 @@ subroutine parse_state_specs(var_specs, hconfig, state_intent, rc) type(UngriddedDims) :: ungridded_dims character(:), allocatable :: standard_name character(:), allocatable :: units + character(len=:), allocatable :: accumulation_type type(ESMF_StateItem_Flag), allocatable :: itemtype type(ESMF_StateIntent_Flag) :: esmf_state_intent @@ -55,6 +56,7 @@ subroutine parse_state_specs(var_specs, hconfig, state_intent, rc) logical :: has_state logical :: has_standard_name logical :: has_units + logical :: has_accumulation_type type(ESMF_HConfig) :: subcfg type(StringVector) :: dependencies @@ -86,6 +88,12 @@ subroutine parse_state_specs(var_specs, hconfig, state_intent, rc) units = ESMF_HConfigAsString(attributes,keyString='units', _RC) end if + has_accumulation_type = ESMF_HConfigIsDefined(accumulation_type, key=KEY_ACCUMULATION_TYPE, _RC) + if(has_accumulation_type) then + accumulation_type = ESMF_HConfigAsString(attributes, keyString=KEY_ACCUMULATION_TYPE, _RC) + end if + + call to_itemtype(itemtype, attributes, _RC) call to_service_items(service_items, attributes, _RC) @@ -102,10 +110,12 @@ subroutine parse_state_specs(var_specs, hconfig, state_intent, rc) default_value=default_value, & vertical_dim_spec=vertical_dim_spec, & ungridded_dims=ungridded_dims, & - dependencies=dependencies & + dependencies=dependencies, & + accumulation_type=accumulation_type & ) if (allocated(units)) deallocate(units) if (allocated(standard_name)) deallocate(standard_name) + if (allocated(accumulation_type) deallocate(accumulation_type) call var_specs%push_back(var_spec) diff --git a/generic3g/specs/VariableSpec.F90 b/generic3g/specs/VariableSpec.F90 index 30d255cbf247..6c732db00cb1 100644 --- a/generic3g/specs/VariableSpec.F90 +++ b/generic3g/specs/VariableSpec.F90 @@ -44,6 +44,7 @@ module mapl3g_VariableSpec real, allocatable :: default_value type(StringVector) :: attributes integer, allocatable :: bracket_size + character(len=:), allocatable :: accumulation_type ! Geometry type(ESMF_Geom), allocatable :: geom @@ -69,7 +70,8 @@ function new_VariableSpec( & units, substate, itemtype, typekind, vertical_dim_spec, ungridded_dims, default_value, & service_items, attributes, & bracket_size, & - dependencies, regrid_param) result(var_spec) + dependencies, regrid_param, & + accumulation_type) result(var_spec) type(VariableSpec) :: var_spec type(ESMF_StateIntent_Flag), intent(in) :: state_intent @@ -90,6 +92,7 @@ function new_VariableSpec( & integer, optional, intent(in) :: bracket_size type(StringVector), optional, intent(in) :: dependencies type(EsmfRegridderParam), optional, intent(in) :: regrid_param + character(len=*), optional, intent(in) :: accumulation_type type(ESMF_RegridMethod_Flag), allocatable :: regrid_method integer :: status @@ -115,6 +118,7 @@ function new_VariableSpec( & _SET_OPTIONAL(attributes) _SET_OPTIONAL(bracket_size) _SET_OPTIONAL(dependencies) + _SET_OPTIONAL(accumulation_type) call var_spec%set_regrid_param_(regrid_param) From 0df318cae73b9a7d85affc5646b89744058a8237 Mon Sep 17 00:00:00 2001 From: Darian Boggs Date: Mon, 25 Nov 2024 14:06:12 -0500 Subject: [PATCH 2/5] Fix bugs with adding accumulation_type parameter --- generic3g/ComponentSpecParser/parse_var_specs.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generic3g/ComponentSpecParser/parse_var_specs.F90 b/generic3g/ComponentSpecParser/parse_var_specs.F90 index e6333ad606a4..327c9fee40fa 100644 --- a/generic3g/ComponentSpecParser/parse_var_specs.F90 +++ b/generic3g/ComponentSpecParser/parse_var_specs.F90 @@ -88,7 +88,7 @@ subroutine parse_state_specs(var_specs, hconfig, state_intent, rc) units = ESMF_HConfigAsString(attributes,keyString='units', _RC) end if - has_accumulation_type = ESMF_HConfigIsDefined(accumulation_type, key=KEY_ACCUMULATION_TYPE, _RC) + has_accumulation_type = ESMF_HConfigIsDefined(attributes, keyString=KEY_ACCUMULATION_TYPE, _RC) if(has_accumulation_type) then accumulation_type = ESMF_HConfigAsString(attributes, keyString=KEY_ACCUMULATION_TYPE, _RC) end if @@ -115,7 +115,7 @@ subroutine parse_state_specs(var_specs, hconfig, state_intent, rc) ) if (allocated(units)) deallocate(units) if (allocated(standard_name)) deallocate(standard_name) - if (allocated(accumulation_type) deallocate(accumulation_type) + if (allocated(accumulation_type)) deallocate(accumulation_type) call var_specs%push_back(var_spec) From 3101d25e9a918f36ffde84a7d53e1c9b9574285b Mon Sep 17 00:00:00 2001 From: Darian Boggs Date: Mon, 2 Dec 2024 17:11:58 -0500 Subject: [PATCH 3/5] Add accumulation_type to VariableSpec; set FieldSpec accumulation_type from VariableSpec accumulation_type --- generic3g/specs/FieldSpec.F90 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/generic3g/specs/FieldSpec.F90 b/generic3g/specs/FieldSpec.F90 index b69d9b71e42c..58091ba3516d 100644 --- a/generic3g/specs/FieldSpec.F90 +++ b/generic3g/specs/FieldSpec.F90 @@ -250,6 +250,8 @@ function new_FieldSpec_varspec(variable_spec) result(field_spec) field_spec%long_name = 'unknown' field_spec%accumulation_type = NO_ACCUMULATION + _SET_ALLOCATED_FIELD(field_spec, variable_spec, accumulation_type) + end function new_FieldSpec_varspec subroutine set_geometry(this, geom, vertical_grid, rc) From 772b1f6989642c1db50eba245eea0b38b286e2cd Mon Sep 17 00:00:00 2001 From: Darian Boggs Date: Mon, 2 Dec 2024 17:29:23 -0500 Subject: [PATCH 4/5] Remove extra blank line --- generic3g/ComponentSpecParser/parse_var_specs.F90 | 1 - 1 file changed, 1 deletion(-) diff --git a/generic3g/ComponentSpecParser/parse_var_specs.F90 b/generic3g/ComponentSpecParser/parse_var_specs.F90 index 327c9fee40fa..c86d0a35e033 100644 --- a/generic3g/ComponentSpecParser/parse_var_specs.F90 +++ b/generic3g/ComponentSpecParser/parse_var_specs.F90 @@ -93,7 +93,6 @@ subroutine parse_state_specs(var_specs, hconfig, state_intent, rc) accumulation_type = ESMF_HConfigAsString(attributes, keyString=KEY_ACCUMULATION_TYPE, _RC) end if - call to_itemtype(itemtype, attributes, _RC) call to_service_items(service_items, attributes, _RC) From cb8a036a767a501edd684fff6a194bf94119b708 Mon Sep 17 00:00:00 2001 From: Darian Boggs Date: Mon, 2 Dec 2024 17:35:36 -0500 Subject: [PATCH 5/5] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29f8a0cb6649..e85e4b17af32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add time accumulation for output from ESMF_Field objects. - Add tests for time accumulation - Add variable to FieldSpec for accumulation type +- Add accumulation type variable to VariableSpec and ComponentSpecParser ### Changed