subroutine f_esmf_regrid(srcField, dstField, routehandle, zeroregion, zrpresent, rc)
use ESMF_UtilTypesMod
use ESMF_BaseMod
use ESMF_LogErrMod
use ESMF_RHandleMod
use ESMF_FieldRegridMod
use ESMF_FieldMod
implicit none
type(ESMF_Field) :: srcField
type(ESMF_Field) :: dstField
type(ESMF_RouteHandle) :: routehandle
type(ESMF_Region_Flag) :: zeroregion
integer, intent(in) :: zrpresent
integer :: rc
integer :: localrc
type(ESMF_RouteHandle) :: l_routehandle
! initialize return code; assume routine not implemented
rc = ESMF_RC_NOT_IMPL
localrc = ESMF_RC_NOT_IMPL
! Must first create a proper ESMF_RouteHandle that contains the
! required "isInit" class member.
! Copy the this pointer a new ESMF_RouteHandle object
call ESMF_RouteHandleCopyThis(routehandle, l_routehandle, localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! set the valid init code of the new object
call ESMF_RouteHandleSetInitCreated(l_routehandle, localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! handle the zeroregion flag
if (zrpresent == 0) then
call ESMF_FieldRegrid(srcField, dstField, routehandle=l_routehandle, &
rc=localrc)
elseif (zrpresent == 1) then
call ESMF_FieldRegrid(srcField, dstField, routehandle=l_routehandle, &
zeroregion=zeroregion, rc=localrc)
endif
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
rc = ESMF_SUCCESS
end subroutine f_esmf_regrid