Skip to content

Commit

Permalink
Merge pull request #1666 from GEOS-ESM/feature/bmauer/fixes-#1665
Browse files Browse the repository at this point in the history
Feature/bmauer/fixes #1665
  • Loading branch information
tclune authored Sep 9, 2022
2 parents 3518cea + bb6c948 commit a2ba020
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Fixed bug that required a /dev/null ExtData entry to still have a file variable name
- Fixed bug with checking for duplicate alias in collection

### Added

Expand Down
24 changes: 13 additions & 11 deletions gridcomps/History/MAPL_HistoryGridComp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ subroutine Initialize ( gc, import, dumexport, clock, rc )
if (old_fields_style) then
field_set_name = trim(string) // 'fields'
allocate(field_set)
call parse_fields(cfg, trim(field_set_name), field_set, list(n)%items, _RC)
call parse_fields(cfg, trim(field_set_name), field_set, collection_name = list(n)%collection, items = list(n)%items, _RC)
end if

list(n)%field_set => field_set
Expand Down Expand Up @@ -3165,20 +3165,27 @@ function extract_unquoted_item(string_list) result(item)
end function extract_unquoted_item


subroutine parse_fields(cfg, label, field_set, items, rc)
subroutine parse_fields(cfg, label, field_set, collection_name, items, rc)
type(ESMF_Config), intent(inout) :: cfg
character(*), intent(in) :: label
type (FieldSet), intent(inout) :: field_set
character(*), intent(in), optional :: collection_name
type(GriddedIOitemVector), intent(inout), optional :: items
integer, optional, intent(out) :: rc
logical :: table_end
logical :: vectorDone,match_short_name,match_alias,match_component
logical :: vectorDone,match_alias
integer :: m,i,j
character(ESMF_MAXSTR), pointer:: fields (:,:)

type(GriddedIOitem) :: item
integer :: status
character(len=:), allocatable :: usable_collection_name

if (present(collection_name)) then
usable_collection_name = trim(collection_name)
else
usable_collection_name = "unknown"
end if
call ESMF_ConfigFindLabel ( cfg, label=label//':', rc=status)
_VERIFY(status)

Expand Down Expand Up @@ -3320,17 +3327,12 @@ subroutine parse_fields(cfg, label, field_set, items, rc)
! check for duplicates
do i=1,field_set%nfields-1
do j=i+1,field_set%nfields
match_short_name = field_set%fields(1,i) == field_set%fields(1,j)

match_alias = field_set%fields(3,i) == field_set%fields(3,j)
match_component = field_set%fields(2,i) == field_set%fields(2,j)
if (match_short_name) then
if (match_component) then
_FAIL("Caught collection with duplicate short name: "//trim(field_set%fields(1,i))//" and duplicate component")
end if
end if
if (match_alias) then
_FAIL("Caught collection with duplicate alias: "//trim(field_set%fields(3,i)))
_FAIL("Caught collection "//usable_collection_name//" with this duplicate alias or shortname if no alias provided: "//trim(field_set%fields(3,i)))
end if

enddo
enddo

Expand Down

0 comments on commit a2ba020

Please sign in to comment.