Skip to content

Commit 7c6d194

Browse files
authored
MAPL3 generic: remove vector_component_names from specs and parser (#4956)
* MAPL3 generic: remove vector_component_names from specs and parser Drop support for vector_component_names in YAML parsing and VariableSpec/VectorClassAspect construction, and update vector test inputs accordingly. Also simplify vector component alias generation in RestartHandler. * MAPL_Generic: stub out vector_component_names argument in gridcomp_add_spec Add vector_component_names as an accepted but unused optional argument to gridcomp_add_spec to preserve API compatibility while the implementation is handled elsewhere in the vector spec pathway. * RestartHandler: trim whitespace from integer-formatted vector bundle alias names
1 parent 6ae9db9 commit 7c6d194

11 files changed

Lines changed: 19 additions & 86 deletions

File tree

infrastructure/fields/field_bundle/FieldBundleGet.F90

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ subroutine bundle_get(fieldBundle, unusable, &
4444
bracket_updated, &
4545
has_deferred_aspects, &
4646
regridder_param_info, &
47-
vector_basis_kind, &
48-
quantity_type_metadata, &
49-
normalization_metadata, &
50-
conservation_metadata, &
51-
rc)
47+
vector_basis_kind, &
48+
quantity_type_metadata, &
49+
normalization_metadata, &
50+
conservation_metadata, &
51+
rc)
5252

5353
type(ESMF_FieldBundle), intent(in) :: fieldBundle
5454
class(KeywordEnforcer), optional, intent(in) :: unusable
@@ -71,11 +71,11 @@ subroutine bundle_get(fieldBundle, unusable, &
7171
logical, optional, intent(out) :: bracket_updated
7272
logical, optional, intent(out) :: has_deferred_aspects
7373
type(esmf_Info), optional, allocatable, intent(out) :: regridder_param_info
74-
type(VectorBasisKind), optional, intent(out) :: vector_basis_kind
75-
type(QuantityTypeMetadata), optional, intent(out) :: quantity_type_metadata
76-
type(NormalizationMetadata), optional, intent(out) :: normalization_metadata
77-
type(ConservationMetadata), optional, intent(out) :: conservation_metadata
78-
integer, optional, intent(out) :: rc
74+
type(VectorBasisKind), optional, intent(out) :: vector_basis_kind
75+
type(QuantityTypeMetadata), optional, intent(out) :: quantity_type_metadata
76+
type(NormalizationMetadata), optional, intent(out) :: normalization_metadata
77+
type(ConservationMetadata), optional, intent(out) :: conservation_metadata
78+
integer, optional, intent(out) :: rc
7979

8080
integer :: status
8181
integer :: fieldCount_

superstructure/generic/ComponentSpecParser.F90

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ module mapl_ComponentSpecParser
7474
character(*), parameter :: KEY_VERTICAL_STAGGER = 'vertical_dim_spec'
7575
character(*), parameter :: KEY_TIMESTEP = 'timestep'
7676
character(*), parameter :: KEY_RUN_TIME_OFFSET = 'run_time_offset'
77-
character(*), parameter :: KEY_VECTOR_COMPONENT_NAMES = 'vector_component_names'
7877

7978
!>
8079
! Submodule declarations

superstructure/generic/ComponentSpecParser/parse_var_specs.F90

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ subroutine parse_state_specs(var_specs, hconfig, state_intent, component_name, r
6464
logical :: has_expression
6565
type(ESMF_HConfig) :: subcfg
6666
type(StringVector) :: dependencies
67-
type(StringVector) :: vector_component_names
6867

6968
type(GeometrySpec) :: geometry_spec
7069
type(MaplGeom), pointer :: mapl_geom
@@ -106,8 +105,6 @@ subroutine parse_state_specs(var_specs, hconfig, state_intent, component_name, r
106105
expression = ESMF_HConfigAsString(attributes,keyString='expression', _RC)
107106
end if
108107

109-
vector_component_names = get_vector_component_names(attributes, _RC)
110-
111108
itemtype = to_itemtype(attributes, _RC)
112109
call to_service_items(service_items, attributes, _RC)
113110

@@ -137,8 +134,7 @@ subroutine parse_state_specs(var_specs, hconfig, state_intent, component_name, r
137134
dependencies=dependencies, &
138135
expression=expression, &
139136
geom=geom, &
140-
vertical_grid=vertical_grid, &
141-
vector_component_names=vector_component_names, _RC)
137+
vertical_grid=vertical_grid, _RC)
142138

143139
if (allocated(units)) deallocate(units)
144140
if (allocated(standard_name)) deallocate(standard_name)
@@ -340,35 +336,6 @@ function to_dependencies(attributes, rc) result(dependencies)
340336
_RETURN(_SUCCESS)
341337
end function to_dependencies
342338

343-
function get_vector_component_names(attributes, rc) result(names)
344-
type(StringVector) :: names
345-
type(ESMF_HConfig), intent(in) :: attributes
346-
integer, optional, intent(out) :: rc
347-
348-
integer :: status
349-
logical :: has_vector_components
350-
type(ESMF_HConfig) :: names_cfg
351-
type(ESMF_HConfigIter) :: b, e, iter
352-
character(:), allocatable :: name
353-
354-
names = StringVector()
355-
has_vector_components = ESMF_HConfigIsDefined(attributes, keyString=KEY_VECTOR_COMPONENT_NAMES, _RC)
356-
_RETURN_UNLESS(has_vector_components)
357-
358-
names_cfg = ESMF_HConfigCreateAt(attributes, keyString=KEY_VECTOR_COMPONENT_NAMES, _RC)
359-
b = ESMF_HConfigIterBegin(names_cfg, _RC)
360-
e = ESMF_HConfigIterEnd(names_cfg, _RC)
361-
iter = b
362-
do while (ESMF_HConfigIterLoop(iter,b,e))
363-
name = ESMF_HConfigAsString(iter, _RC)
364-
call names%push_back(name)
365-
end do
366-
call ESMF_HConfigDestroy(names_cfg, _RC)
367-
368-
_RETURN(_SUCCESS)
369-
end function get_vector_component_names
370-
371-
372339
end function parse_var_specs
373340

374341
end submodule parse_var_specs_smod

superstructure/generic/MAPL_Generic.F90

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,6 @@ subroutine gridcomp_add_spec( &
590590
type(ComponentSpec), pointer :: component_spec
591591
character(len=:), allocatable :: units_
592592
type(UngriddedDims), allocatable :: dim_specs_vec
593-
type(StringVector) :: vector_component_names_vec
594593
integer :: status
595594

596595
_ASSERT((dims=="xyz") .or. (dims=="xy") .or. (dims=="z"), "dims can be one of xyz/xy/z")
@@ -602,14 +601,6 @@ subroutine gridcomp_add_spec( &
602601
! If input units is present, override using input values
603602
if (present(units)) units_ = units
604603
if (present(ungridded_dims)) dim_specs_vec = UngriddedDims(ungridded_dims)
605-
! vector_component_names
606-
if (present(vector_component_names)) then
607-
_ASSERT(present(itemType), "itemType must be present if vector_component_names is present")
608-
_ASSERT((itemType==MAPL_STATEITEM_VECTOR), "valid only for vector items")
609-
_ASSERT((size(vector_component_names)==2), "vector_component_names must have 2 components")
610-
call vector_component_names_vec%push_back(trim(vector_component_names(1)))
611-
call vector_component_names_vec%push_back(trim(vector_component_names(2)))
612-
end if
613604
var_spec = make_VariableSpec( &
614605
state_intent, &
615606
short_name, &
@@ -624,7 +615,6 @@ subroutine gridcomp_add_spec( &
624615
has_deferred_aspects=has_deferred_aspects, &
625616
service_items=service_items, &
626617
restart_mode=restart, &
627-
vector_component_names=vector_component_names_vec, &
628618
_RC)
629619
call MAPL_GridCompGetOuterMeta(gridcomp, outer_meta, _RC)
630620
component_spec => outer_meta%get_component_spec()
@@ -645,6 +635,7 @@ subroutine gridcomp_add_spec( &
645635

646636
_RETURN(_SUCCESS)
647637
_UNUSED_DUMMY(unusable)
638+
_UNUSED_DUMMY(vector_component_names)
648639
end subroutine gridcomp_add_spec
649640

650641
subroutine gridcomp_advertise_variable(gridcomp, var_spec, rc)

superstructure/generic/RestartHandler.F90

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ recursive function get_field_bundle_from_state_(this, state, rc) result(bundle)
153153
type(ESMF_FieldBundle) :: bundle2
154154
type (ESMF_StateItem_Flag), allocatable :: item_types(:)
155155
character(len=ESMF_MAXSTR), allocatable :: item_names(:)
156-
character(len=:), allocatable :: item_name, short_name
156+
character(len=:), allocatable :: item_name
157+
character(len=ESMF_MAXSTR) :: short_name
157158
integer :: idx, jdx, item_count, status
158159

159160
bundle = ESMF_FieldBundleCreate(_RC)
@@ -169,10 +170,10 @@ recursive function get_field_bundle_from_state_(this, state, rc) result(bundle)
169170
call MAPL_FieldBundleAdd(bundle, [field], _RC)
170171
else if (item_types(idx) == ESMF_STATEITEM_FIELDBUNDLE) then
171172
call ESMF_StateGet(state, item_name, bundle2, _RC)
172-
call MAPL_FieldBundleGet(bundle2, fieldList=field_list, _RC)
173+
call MAPL_FieldBundleGet(bundle2, fieldList=field_list, _RC) ! addorder
173174
do jdx = 1, size(field_list)
174-
call MAPL_FieldGet(field_list(jdx), short_name=short_name, _RC)
175-
alias = ESMF_NamedAlias(field_list(jdx), name=item_name//"_"//short_name, _RC)
175+
write(short_name, '(I0)') jdx
176+
alias = ESMF_NamedAlias(field_list(jdx), name=item_name//"_"//trim(short_name), _RC)
176177
call MAPL_FieldBundleAdd(bundle, [alias], _RC)
177178
end do
178179
else

superstructure/generic/specs/VariableSpec.F90

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ module mapl_VariableSpec
8181
!---------------------
8282
! Vector
8383
!---------------------
84-
type(StringVector) :: vector_component_names ! default empty
8584
type(VectorBasisKind), allocatable :: vector_basis_kind
8685
real(kind=ESMF_KIND_R4), allocatable :: fill_value
8786
!---------------------
@@ -180,7 +179,6 @@ function make_VariableSpec( &
180179
dependencies, &
181180
regrid_param, &
182181
horizontal_dims_spec, &
183-
vector_component_names, &
184182
vector_basis_kind, &
185183
has_deferred_aspects, &
186184
use_field_dictionary, &
@@ -210,7 +208,6 @@ function make_VariableSpec( &
210208
type(StringVector), optional, intent(in) :: dependencies
211209
type(EsmfRegridderParam), optional, intent(in) :: regrid_param
212210
type(HorizontalDimsSpec), optional, intent(in) :: horizontal_dims_spec
213-
type(StringVector), optional, intent(in) :: vector_component_names
214211
character(*), optional, intent(in) :: vector_basis_kind
215212
logical, optional, intent(in) :: has_deferred_aspects
216213
logical, optional, intent(in) :: use_field_dictionary
@@ -247,7 +244,6 @@ function make_VariableSpec( &
247244
_SET_OPTIONAL(dependencies)
248245
_SET_OPTIONAL(regrid_param)
249246
_SET_OPTIONAL(horizontal_dims_spec)
250-
_SET_OPTIONAL(vector_component_names)
251247
_SET_OPTIONAL(has_deferred_aspects)
252248
_SET_OPTIONAL(use_field_dictionary)
253249
_SET_OPTIONAL(restart_mode)
@@ -649,7 +645,6 @@ function make_ClassAspect(this, registry, rc) result(aspect)
649645

650646
integer :: status
651647
character(:), allocatable :: std_name_1, std_name_2
652-
type(StringVector) :: vector_component_names
653648
type(VectorBasisKind) :: basis_kind
654649

655650
select case (this%itemType%ot)
@@ -668,18 +663,12 @@ function make_ClassAspect(this, registry, rc) result(aspect)
668663
if (allocated(this%standard_name)) then
669664
call split_name(this%standard_name, std_name_1, std_name_2, _RC)
670665
end if
671-
if (this%vector_component_names%size() == 0) then
672-
call vector_component_names%push_back("unknown1")
673-
call vector_component_names%push_back("unknown2")
674-
else
675-
vector_component_names = this%vector_component_names
676-
end if
677666
if (allocated(this%vector_basis_kind)) then
678667
basis_kind = this%vector_basis_kind
679668
else
680669
basis_kind = VECTOR_BASIS_KIND_NS
681670
end if
682-
aspect = VectorClassAspect(vector_component_names, &
671+
aspect = VectorClassAspect( &
683672
[ &
684673
FieldClassAspect(standard_name=std_name_1, fill_value=this%fill_value), &
685674
FieldClassAspect(standard_name=std_name_2, fill_value=this%fill_value) &

superstructure/generic/specs/VectorClassAspect.F90

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ module mapl_VectorClassAspect
5050
type, extends(ClassAspect) :: VectorClassAspect
5151
private
5252
type(ESMF_FieldBundle) :: payload
53-
type(StringVector) :: short_names
5453
type(FieldClassAspect) :: component_specs(2)
5554
type(VectorBasisKind) :: basis_kind
5655
contains
@@ -78,13 +77,11 @@ module mapl_VectorClassAspect
7877

7978
contains
8079

81-
function new_VectorClassAspect_basic(short_names, component_specs, basis_kind) result(aspect)
80+
function new_VectorClassAspect_basic(component_specs, basis_kind) result(aspect)
8281
type(VectorClassAspect) :: aspect
83-
type(StringVector), intent(in) :: short_names
8482
type(FieldClassAspect), intent(in) :: component_specs(2)
8583
type(VectorBasisKind), intent(in) :: basis_kind
8684

87-
aspect%short_names = short_names
8885
aspect%component_specs = component_specs
8986
aspect%basis_kind = basis_kind
9087
end function new_VectorClassAspect_basic
@@ -163,9 +160,6 @@ subroutine allocate(this, other_aspects, rc)
163160
call update_payload(this%component_specs(i), other_aspects, _RC)
164161
call this%component_specs(i)%allocate(other_aspects, _RC)
165162
call this%component_specs(i)%add_to_bundle(this%payload, _RC)
166-
! update the name of the component
167-
call this%component_specs(i)%get_payload(field=field, _RC)
168-
call ESMF_FieldSet(field, name=trim(this%short_names%at(i)), _RC)
169163
end do
170164

171165
_RETURN(ESMF_SUCCESS)
@@ -239,9 +233,6 @@ subroutine connect_to_export(this, export, actual_pt, rc)
239233
call this%destroy(_RC) ! import is replaced by export/extension
240234
this%payload = export_%payload
241235

242-
! mirror short names since they are required in add_to_state routine
243-
this%short_names = export_%short_names
244-
245236
_RETURN(_SUCCESS)
246237
_UNUSED_DUMMY(actual_pt)
247238
end subroutine connect_to_export

superstructure/generic/tests/scenarios/vector_1/child_A.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ mapl:
1919
uv:
2020
class: vector
2121
standard_name: '(eastward,northward) horizontal velocity'
22-
vector_component_names: [u, v]
2322
units: 'm s-1'
2423
fill_value: 1
2524
vertical_dim_spec: center

superstructure/generic/tests/scenarios/vector_1/child_B.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ mapl:
1717
uv:
1818
class: vector
1919
standard_name: '(eastward,northward) horizontal velocity'
20-
vector_component_names: [u, v]
2120
units: 'm s-1'
2221
fill_value: 1
2322
vertical_dim_spec: center

tests/MAPL3G_Component_Testing_Framework/test_cases/case18/GCM1.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ mapl:
1818
UV:
1919
class: vector
2020
standard_name: '(eastward_wind, northward_wind) horizontal velocity'
21-
vector_component_names: [U, V]
2221
units: "m s-1"
2322
typekind: R4
2423
fill_value: 17.

0 commit comments

Comments
 (0)