Skip to content

Commit

Permalink
Merge pull request #168 from ESCOMP/mvertens/bilnr_cart3d
Browse files Browse the repository at this point in the history
addition of bilnr_cart3d mapping
  • Loading branch information
jedwards4b authored Mar 22, 2021
2 parents ad106b0 + 04b8b08 commit 1a32ab7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 21 deletions.
14 changes: 8 additions & 6 deletions mediator/esmFlds.F90
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@ module esmflds
integer , public, parameter :: mapnstod_consd = 7 ! nearest source to destination followed by conservative dst
integer , public, parameter :: mapnstod_consf = 8 ! nearest source to destination followed by conservative frac
integer , public, parameter :: mappatch_uv3d = 9 ! rotate u,v to 3d cartesian space, map from src->dest, then rotate back
integer , public, parameter :: map_rof2ocn_ice = 10 ! custom smoothing map to map ice from rof->ocn (cesm only)
integer , public, parameter :: map_rof2ocn_liq = 11 ! custom smoothing map to map liq from rof->ocn (cesm only)
integer , public, parameter :: map_glc2ocn_liq = 12 ! custom smoothing map to map liq from glc->ocn (cesm only)
integer , public, parameter :: map_glc2ocn_ice = 13 ! custom smoothing map to map ice from glc->ocn (cesm only)
integer , public, parameter :: mapfillv_bilnr = 14 ! fill value followed by bilinear
integer , public, parameter :: nmappers = 14
integer , public, parameter :: mapbilnr_uv3d = 10 ! rotate u,v to 3d cartesian space, map from src->dest, then rotate back
integer , public, parameter :: map_rof2ocn_ice = 11 ! custom smoothing map to map ice from rof->ocn (cesm only)
integer , public, parameter :: map_rof2ocn_liq = 12 ! custom smoothing map to map liq from rof->ocn (cesm only)
integer , public, parameter :: map_glc2ocn_liq = 13 ! custom smoothing map to map liq from glc->ocn (cesm only)
integer , public, parameter :: map_glc2ocn_ice = 14 ! custom smoothing map to map ice from glc->ocn (cesm only)
integer , public, parameter :: mapfillv_bilnr = 15 ! fill value followed by bilinear
integer , public, parameter :: nmappers = 15

character(len=*) , public, parameter :: mapnames(nmappers) = &
(/'bilnr ',&
Expand All @@ -65,6 +66,7 @@ module esmflds
'nstod_consd',&
'nstod_consf',&
'patch_uv3d ',&
'bilnr_uv3d ',&
'rof2ocn_ice',&
'rof2ocn_liq',&
'glc2ocn_ice',&
Expand Down
39 changes: 24 additions & 15 deletions mediator/med_map_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ subroutine med_map_routehandles_initfrom_field(n1, n2, fldsrc, flddst, mapindex,
use ESMF , only : ESMF_REGRIDMETHOD_BILINEAR, ESMF_REGRIDMETHOD_PATCH
use ESMF , only : ESMF_REGRIDMETHOD_CONSERVE, ESMF_NORMTYPE_DSTAREA, ESMF_NORMTYPE_FRACAREA
use ESMF , only : ESMF_UNMAPPEDACTION_IGNORE, ESMF_REGRIDMETHOD_NEAREST_STOD
use esmFlds , only : mapbilnr, mapconsf, mapconsd, mappatch, mappatch_uv3d, mapfcopy
use esmFlds , only : mapbilnr, mapconsf, mapconsd, mappatch, mappatch_uv3d, mapbilnr_uv3d, mapfcopy
use esmFlds , only : mapunset, mapnames, nmappers
use esmFlds , only : mapnstod, mapnstod_consd, mapnstod_consf, mapnstod_consd
use esmFlds , only : mapfillv_bilnr
Expand Down Expand Up @@ -305,19 +305,21 @@ subroutine med_map_routehandles_initfrom_field(n1, n2, fldsrc, flddst, mapindex,
ignoreUnmatchedIndices=.true., &
srcTermProcessing=srcTermProcessing_Value, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
else if (mapindex == mapbilnr) then
if (mastertask) then
write(logunit,'(A)') trim(subname)//' creating RH '//trim(mapname)//' for '//trim(string)
else if (mapindex == mapbilnr .or. mapindex == mapbilnr_uv3d) then
if (.not. ESMF_RouteHandleIsCreated(routehandles(mapbilnr))) then
if (mastertask) then
write(logunit,'(A)') trim(subname)//' creating RH '//trim(mapname)//' for '//trim(string)
end if
call ESMF_FieldRegridStore(fldsrc, flddst, routehandle=routehandles(mapbilnr), &
srcMaskValues=(/srcMaskValue/), &
dstMaskValues=(/dstMaskValue/), &
regridmethod=ESMF_REGRIDMETHOD_BILINEAR, &
polemethod=polemethod, &
srcTermProcessing=srcTermProcessing_Value, &
ignoreDegenerate=.true., &
unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
end if
call ESMF_FieldRegridStore(fldsrc, flddst, routehandle=routehandles(mapbilnr), &
srcMaskValues=(/srcMaskValue/), &
dstMaskValues=(/dstMaskValue/), &
regridmethod=ESMF_REGRIDMETHOD_BILINEAR, &
polemethod=polemethod, &
srcTermProcessing=srcTermProcessing_Value, &
ignoreDegenerate=.true., &
unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
else if (mapindex == mapfillv_bilnr) then
if (mastertask) then
write(logunit,'(A)') trim(subname)//' creating RH '//trim(mapname)//' for '//trim(string)
Expand Down Expand Up @@ -566,7 +568,7 @@ subroutine med_map_mapnorm_init(gcomp, rc)
call ESMF_FieldGet(fieldlist(1), mesh=mesh_dst, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

! Createis_local%wrap%field_NormOne(n1,n2,m)
! Create is_local%wrap%field_NormOne(n1,n2,m)
do m = 1,nmappers
if (med_map_RH_is_created(is_local%wrap%RH,n1,n2,m,rc=rc)) then
is_local%wrap%field_NormOne(n1,n2,m) = ESMF_FieldCreate(mesh_dst, &
Expand Down Expand Up @@ -791,7 +793,8 @@ subroutine med_map_field_packed(FBSrc, FBDst, FBFracSrc, field_normOne, packed_d
use ESMF , only : ESMF_FieldBundle, ESMF_FieldBundleGet
use ESMF , only : ESMF_FieldBundleIsCreated
use ESMF , only : ESMF_FieldRedist, ESMF_RouteHandle
use esmFlds , only : nmappers, mapfcopy, mappatch_uv3d, mappatch
use esmFlds , only : nmappers, mapfcopy
use esmFlds , only : mappatch_uv3d, mappatch, mapbilnr_uv3d, mapbilnr
use med_internalstate_mod , only : packed_data_type

! input/output variables
Expand Down Expand Up @@ -853,6 +856,12 @@ subroutine med_map_field_packed(FBSrc, FBDst, FBFracSrc, field_normOne, packed_d
call med_map_uv_cart3d(FBsrc, FBdst, routehandles, mappatch, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

else if (mapindex == mapbilnr_uv3d) then

! For mapbilnr_uv3d do not use packed field bundles
call med_map_uv_cart3d(FBsrc, FBdst, routehandles, mapbilnr, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

else

! -----------------------------------
Expand Down

0 comments on commit 1a32ab7

Please sign in to comment.