user_run Subroutine

private subroutine user_run(comp, importState, exportState, clock, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_CplComp) :: comp
type(ESMF_State) :: importState
type(ESMF_State) :: exportState
type(ESMF_Clock) :: clock
integer, intent(out) :: rc

Source Code

  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) :: F_lnd, F_atm, flux
    type(ESMF_Grid)  :: lnd_grid, atm_grid
    type(ESMF_RouteHandle) :: rh1, rh2, rh3

    ! Initialize return code
    rc = ESMF_SUCCESS

    print *, "User Coupler Run starting"

    ! Get source Fields out of import state
    call ESMF_StateGet(importState, itemName="F_lnd", field=F_lnd, &
        rc=rc)
    if (rc/=ESMF_SUCCESS) return ! bail out

    ! Get destination Field out of export state
    call ESMF_StateGet(exportState, "F_atm", F_atm, rc=rc)
    if (rc/=ESMF_SUCCESS) return ! bail out
    call ESMF_StateGet(exportState, "xgrid_flux", flux, rc=rc)
    if (rc/=ESMF_SUCCESS) return ! bail out

    call ESMF_StateGet(exportState, "lnd2xgrid", routehandle=rh1, rc=rc)
    if (rc/=ESMF_SUCCESS) return ! bail out
    call ESMF_StateGet(exportState, "xgrid2atm", routehandle=rh3, rc=rc)
    if (rc/=ESMF_SUCCESS) return ! bail out

    ! compute regridding
    call ESMF_FieldRegrid(F_lnd, flux, routehandle=rh1, zeroregion=ESMF_REGION_EMPTY, rc=rc)
    if (rc/=ESMF_SUCCESS) return ! bail out
    call ESMF_FieldRegrid(flux, F_atm, routehandle=rh3, rc=rc)
    if (rc/=ESMF_SUCCESS) return ! bail out
  
    print *, "User Coupler Run returning"

  end subroutine user_run