subroutine user_run(comp, importState, exportState, clock, rc)
type(ESMF_CplComp) :: comp
type(ESMF_State) :: importState, exportState
type(ESMF_Clock) :: clock
integer, intent(out) :: rc
! Local variables
type(ESMF_Field) :: srcField, dstField, finalField
type(ESMF_RouteHandle) :: rh
! Initialize return code
rc = ESMF_SUCCESS
print *, "User Coupler Run starting"
! Access source, final, and destination Fields
call ESMF_StateGet(importState, "srcField", srcField, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=__FILE__)) return ! bail out
call ESMF_StateGet(importState, "finalField", finalField, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=__FILE__)) return ! bail out
call ESMF_StateGet(exportState, "dstField", dstField, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=__FILE__)) return ! bail out
! Access the Redist RouteHandle that was kept in the importState
call ESMF_StateGet(importState, "Redist", rh, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=__FILE__)) return ! bail out
! Execute the Redist operation: srcField -> dstField
call ESMF_FieldRedist(srcField, dstField, routehandle=rh, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=__FILE__)) return ! bail out
! Access the Regrid RouteHandle that was kept in the importState
call ESMF_StateGet(importState, "Regrid", rh, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=__FILE__)) return ! bail out
! Execute the Redist operation: dstField -> finalField
call ESMF_FieldRedist(dstField, finalField, routehandle=rh, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=__FILE__)) return ! bail out
print *, "User Coupler Run returning"
end subroutine user_run