Skip to content

Commit

Permalink
Merge pull request #2637 from GEOS-ESM/feature/ygyu/fix_error_transpo…
Browse files Browse the repository at this point in the history
…se_route_handles_spec

Fix a bug in subroutine destroy_route_handle
  • Loading branch information
mathomp4 authored Mar 8, 2024
2 parents 1725a5c + e4d9925 commit cb26296
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Added
- Add `if (compute_transpose)` to sub. destroy_route_handle to avoid destroying a nonexisting route handle
- Add option to MAPL regridding layer to write and retrieve ESMF weights.
- Add options to History and ExtData to turn on the ability to write and read route handle weights
- Add option to renable the transpose computation when calling make\_regridder
Expand Down
14 changes: 9 additions & 5 deletions base/MAPL_EsmfRegridder.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1665,6 +1665,7 @@ subroutine destroy_route_handle(this, kind, rc)
type(ESMF_RouteHandle) :: route_handle
type(RegridderSpecRouteHandleMapIterator) :: iter
integer :: status
logical :: compute_transpose

if (kind == ESMF_TYPEKIND_R4) then
route_handles => route_handles_r4
Expand All @@ -1684,11 +1685,14 @@ subroutine destroy_route_handle(this, kind, rc)
iter = route_handles%find(spec)
call route_handles%erase(iter)

_ASSERT(transpose_route_handles%count(spec) == 1, 'Did not find this spec in route handle table.')
route_handle = transpose_route_handles%at(spec)
call ESMF_RouteHandleDestroy(route_handle, noGarbage=.true., _RC)
iter = transpose_route_handles%find(spec)
call transpose_route_handles%erase(iter)
compute_transpose = IAND(spec%hints,REGRID_HINT_COMPUTE_TRANSPOSE) /= 0
if (compute_transpose) then
_ASSERT(transpose_route_handles%count(spec) == 1, 'Did not find this spec in route handle table.')
route_handle = transpose_route_handles%at(spec)
call ESMF_RouteHandleDestroy(route_handle, noGarbage=.true., _RC)
iter = transpose_route_handles%find(spec)
call transpose_route_handles%erase(iter)
end if

_RETURN(_SUCCESS)
end subroutine destroy_route_handle
Expand Down

0 comments on commit cb26296

Please sign in to comment.