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

Add accumulation_type to VariableSpec and ComponentSpecParser #3205

Merged
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions generic3g/ComponentSpecParser.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion generic3g/ComponentSpecParser/parse_var_specs.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -86,6 +88,11 @@ subroutine parse_state_specs(var_specs, hconfig, state_intent, rc)
units = ESMF_HConfigAsString(attributes,keyString='units', _RC)
end if

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

call to_itemtype(itemtype, attributes, _RC)
call to_service_items(service_items, attributes, _RC)

Expand All @@ -102,10 +109,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)

Expand Down
2 changes: 2 additions & 0 deletions generic3g/specs/FieldSpec.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion generic3g/specs/VariableSpec.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)

Expand Down
Loading