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"
call ESMF_LogWrite (msg='User Coupler Run starting', &
logmsgFlag=ESMF_LOGMSG_TRACE)
! Access source, final, and destination Fields
call ESMF_StateGet(importState, "srcField", srcField, rc=rc)
if (rc/=ESMF_SUCCESS) return ! bail out
call ESMF_StateGet(importState, "finalField", finalField, rc=rc)
if (rc/=ESMF_SUCCESS) return ! bail out
call ESMF_StateGet(exportState, "dstField", dstField, rc=rc)
if (rc/=ESMF_SUCCESS) return ! bail out
! Access the Redist RouteHandle that was kept in the importState
call ESMF_StateGet(importState, "Redist", rh, rc=rc)
if (rc/=ESMF_SUCCESS) return ! bail out
! Execute the Redist operation: srcField -> dstField
call ESMF_FieldRedist(srcField, dstField, routehandle=rh, rc=rc)
if (rc/=ESMF_SUCCESS) return ! bail out
! Access the Regrid RouteHandle that was kept in the importState
call ESMF_StateGet(importState, "Regrid", rh, rc=rc)
if (rc/=ESMF_SUCCESS) return ! bail out
! Execute the Redist operation: dstField -> finalField
call ESMF_FieldRedist(dstField, finalField, routehandle=rh, rc=rc)
if (rc/=ESMF_SUCCESS) return ! bail out
call ESMF_LogWrite (msg='User Coupler Run complete', &
logmsgFlag=ESMF_LOGMSG_TRACE)
print *, "User Coupler Run returning"
end subroutine user_run