user_run Subroutine

public 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
        integer :: status = ESMF_SUCCESS
        type(ESMF_Array) :: sorted_data1, sorted_data2

        print *, "User Coupler Run starting"
        
        ! query data from States
        call ESMF_StateGet(importState, "sorted_data1", sorted_data1, rc=status)    
        if (ESMF_LogFoundError(status, ESMF_ERR_PASSTHRU, &
            ESMF_CONTEXT, rcToReturn=rc)) return

        call ESMF_StateGet(exportState, "sorted_data2", sorted_data2, rc=status)    
        if (ESMF_LogFoundError(status, ESMF_ERR_PASSTHRU, &
            ESMF_CONTEXT, rcToReturn=rc)) return

        ! preform data redistribution
        ! deliver sorted result from component 1 to component 2
        ! component 2 will verify component 1 result
        call ESMF_ArrayRedist(srcArray=sorted_data1, dstArray=sorted_data2, &
          routehandle=redistRH12, checkflag=.true., rc=status)
        if (ESMF_LogFoundError(status, ESMF_ERR_PASSTHRU, &
            ESMF_CONTEXT, rcToReturn=rc)) return

        rc = status

    end subroutine user_run