Skip to content

Commit 4564272

Browse files
authored
MAPL: fix vector component naming lifecycle (#4946)
* VectorClassAspect - name vector components during create() * Update changelog for vector component naming fix
1 parent f737cd4 commit 4564272

3 files changed

Lines changed: 11 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
### Fixed
1313

1414
- Relaxed the comparison standard for grid_is_ok in case a grid is r4
15+
- Fix vector component naming lifecycle in `superstructure/generic/specs/VariableSpec.F90`
16+
and `superstructure/generic/specs/VectorClassAspect.F90` by using resolved
17+
`vector_component_names` when constructing `VectorClassAspect` and setting
18+
component field names during create-time rather than deferring in add-to-state
19+
(PR #4946).
1520

1621
### Added
1722
- Extended StatisticsGridComp to support variance of a single field.

superstructure/generic/specs/VariableSpec.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ function make_ClassAspect(this, registry, rc) result(aspect)
679679
else
680680
basis_kind = VECTOR_BASIS_KIND_NS
681681
end if
682-
aspect = VectorClassAspect(this%vector_component_names, &
682+
aspect = VectorClassAspect(vector_component_names, &
683683
[ &
684684
FieldClassAspect(standard_name=std_name_1, fill_value=this%fill_value), &
685685
FieldClassAspect(standard_name=std_name_2, fill_value=this%fill_value) &

superstructure/generic/specs/VectorClassAspect.F90

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,17 @@ subroutine allocate(this, other_aspects, rc)
155155
type(AspectMap), intent(in) :: other_aspects
156156
integer, optional, intent(out) :: rc
157157

158-
integer :: status
159-
integer :: i
158+
type(ESMF_Field), allocatable :: field
159+
integer :: i, status
160160

161161
do i = 1, NUM_COMPONENTS
162162
call this%component_specs(i)%create(other_aspects, _RC)
163163
call update_payload(this%component_specs(i), other_aspects, _RC)
164164
call this%component_specs(i)%allocate(other_aspects, _RC)
165165
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)
166169
end do
167170

168171
_RETURN(ESMF_SUCCESS)
@@ -338,13 +341,6 @@ subroutine add_to_state(this, multi_state, actual_pt, rc)
338341
end if
339342
call ESMF_StateAddReplace(substate, [alias], _RC)
340343

341-
! Also update the names of the components
342-
call MAPL_FieldBundleGet(this%payload, fieldList=field_list, _RC)
343-
if (size(field_list) > 0) then ! might be empty if import item
344-
call ESMF_FieldSet(field_list(1), name=trim(this%short_names%at(1)), _RC)
345-
call ESMF_FieldSet(field_list(2), name=trim(this%short_names%at(2)), _RC)
346-
end if
347-
348344
_RETURN(_SUCCESS)
349345
end subroutine add_to_state
350346

0 commit comments

Comments
 (0)