From 180c03284c94af10acbf510ff5b26d312a2266ac Mon Sep 17 00:00:00 2001 From: Benjamin Auer Date: Mon, 6 Jan 2025 11:18:37 -0500 Subject: [PATCH 1/2] fixes #3280 --- base/MAPL_EsmfRegridder.F90 | 12 +++++++++--- base/MAPL_XYGridFactory.F90 | 3 +++ shared/Constants/InternalConstants.F90 | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/base/MAPL_EsmfRegridder.F90 b/base/MAPL_EsmfRegridder.F90 index 3fbdf9cf4734..fe41619bcd23 100644 --- a/base/MAPL_EsmfRegridder.F90 +++ b/base/MAPL_EsmfRegridder.F90 @@ -1431,13 +1431,13 @@ subroutine create_route_handle(this, kind, rc) real(real64), pointer :: src_dummy_r8(:,:), dst_dummy_r8(:,:) type (ESMF_Field) :: src_field, dst_field - integer :: srcTermProcessing + integer :: srcTermProcessing, num_mask_values integer, pointer :: factorIndexList(:,:) integer, allocatable :: dstMaskValues(:) real(ESMF_KIND_R8), pointer :: factorList(:) type(ESMF_RouteHandle) :: dummy_rh type(ESMF_UnmappedAction_Flag) :: unmappedaction - logical :: global, isPresent, has_mask + logical :: global, isPresent, has_mask, has_dstMaskValues type(RegridderSpecRouteHandleMap), pointer :: route_handles, transpose_route_handles type(ESMF_RouteHandle) :: route_handle, transpose_route_handle character(len=ESMF_MAXPATHLEN) :: rh_file,rh_trans_file @@ -1512,6 +1512,13 @@ subroutine create_route_handle(this, kind, rc) end if call ESMF_GridGetItem(spec%grid_out,itemflag=ESMF_GRIDITEM_MASK, & staggerloc=ESMF_STAGGERLOC_CENTER, isPresent = has_mask, _RC) + call ESMF_AttributeGet(spec%grid_out, name=MAPL_DESTINATIONMASK, isPresent=has_dstMaskValues, _RC) + if (has_dstMaskValues) then + _ASSERT(has_mask, "masking destination values when no masks is present") + call ESMF_AttributeGet(spec%grid_out, name=MAPL_DESTINATIONMASK, itemcount=num_mask_values, _RC) + allocate(dstMaskValues(num_mask_values), _STAT) + call ESMF_AttributeGet(spec%grid_out, name=MAPL_DESTINATIONMASK, valuelist=dstMaskValues, _RC) + end if counter = counter + 1 @@ -1521,7 +1528,6 @@ subroutine create_route_handle(this, kind, rc) call ESMF_AttributeGet(spec%grid_in, name='Global',value=global,rc=status) if (.not.global) unmappedaction=ESMF_UNMAPPEDACTION_IGNORE end if - if (has_mask) dstMaskValues = [MAPL_MASK_OUT] ! otherwise unallocated select case (spec%regrid_method) case (REGRID_METHOD_BILINEAR, REGRID_METHOD_BILINEAR_MONOTONIC) diff --git a/base/MAPL_XYGridFactory.F90 b/base/MAPL_XYGridFactory.F90 index 1bcbc57ea3ce..a451bbcd7ee0 100644 --- a/base/MAPL_XYGridFactory.F90 +++ b/base/MAPL_XYGridFactory.F90 @@ -1037,6 +1037,9 @@ subroutine add_mask(this,grid,rc) mask = MAPL_MASK_IN where(fptr==MAPL_UNDEF) mask = MAPL_MASK_OUT + call ESMF_AttributeSet(grid, name=MAPL_DESTINATIONMASK, & + itemCount=1, valueList=[MAPL_MASK_OUT], _RC) + _RETURN(_SUCCESS) end subroutine add_mask diff --git a/shared/Constants/InternalConstants.F90 b/shared/Constants/InternalConstants.F90 index 3cad2914e86f..bd02f1fe51d3 100644 --- a/shared/Constants/InternalConstants.F90 +++ b/shared/Constants/InternalConstants.F90 @@ -23,6 +23,7 @@ module MAPL_InternalConstantsMod character(len=*), parameter :: MAPL_GRID_NAME_DEFAULT = 'UNKNOWN' character(len=*), parameter :: MAPL_GRID_FILE_NAME_DEFAULT = 'UNKNOWN' character(len=*), parameter :: MAPL_CF_COMPONENT_SEPARATOR = '.' + character(len=*), parameter :: MAPL_DESTINATIONMASK = "MAPL_DestinationMask" enum, bind(c) enumerator MAPL_TimerModeOld From 573e6b7e60360e0cd4b3ac353ee533945592513f Mon Sep 17 00:00:00 2001 From: Benjamin Auer Date: Mon, 6 Jan 2025 14:31:02 -0500 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7956732c3d7c..6450f26fb9fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Changed MAPL_ESMFRegridder to require the dstMaskValues to be added as grid attribute to use fixed masking, fixes UFS issue - Increased formatting width of time index in ExtData2G diagnostic print ### Fixed