subroutine user_final(comp, importState, exportState, clock, rc)
type(ESMF_CplComp) :: comp
type(ESMF_State) :: importState, exportState
type(ESMF_Clock) :: clock
integer, intent(out) :: rc
type(ESMF_Field) :: flux
type(ESMF_XGrid) :: xgrid
type(ESMF_RouteHandle) :: rh1, rh2, rh3
! Initialize return code
rc = ESMF_SUCCESS
print *, "User Coupler Final starting"
call ESMF_StateGet(exportState, "xgrid_flux", flux, rc=rc)
if (rc/=ESMF_SUCCESS) return ! bail out
call ESMF_StateGet(exportState, "lnd2xgrid", rh1, rc=rc)
if (rc/=ESMF_SUCCESS) return ! bail out
call ESMF_StateGet(exportState, "ocn2xgrid", rh2, rc=rc)
if (rc/=ESMF_SUCCESS) return ! bail out
call ESMF_StateGet(exportState, "xgrid2atm", rh3, rc=rc)
if (rc/=ESMF_SUCCESS) return ! bail out
call ESMF_FieldGet(flux, xgrid=xgrid, rc=rc)
if (rc/=ESMF_SUCCESS) return ! bail out
call ESMF_XGridDestroy(xgrid, rc=rc)
if (rc/=ESMF_SUCCESS) return ! bail out
call ESMF_FieldDestroy(flux, rc=rc)
if (rc/=ESMF_SUCCESS) return ! bail out
! Release resources stored for the ArrayRedist.
call ESMF_FieldRegridRelease(routehandle=rh1, rc=rc)
if (rc/=ESMF_SUCCESS) return ! bail out
call ESMF_FieldRegridRelease(routehandle=rh2, rc=rc)
if (rc/=ESMF_SUCCESS) return ! bail out
call ESMF_FieldRegridRelease(routehandle=rh3, rc=rc)
if (rc/=ESMF_SUCCESS) return ! bail out
print *, "User Coupler Final returning"
end subroutine user_final