user_run Subroutine

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

Arguments

Type IntentOptional Attributes Name
type(ESMF_GridComp) :: 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_GridComp) :: comp
    type(ESMF_State) :: importState, exportState
    type(ESMF_Clock) :: clock
    integer, intent(out) :: rc

    ! Local variables
    type(ESMF_Array)      :: srcArray2, dstArray2
    type(ESMF_VM)         :: vm
    integer               :: workF90(100,150), localPet
    
    ! Initialize return code
    rc = ESMF_SUCCESS

    print *, "User Comp2 Run starting"

    ! Determine localPet
    call ESMF_GridCompGet(comp, vm=vm, rc=rc)
    if (rc/=ESMF_SUCCESS) return ! bail out
    call ESMF_VMGet(vm, localPet=localPet, rc=rc)
    if (rc/=ESMF_SUCCESS) return ! bail out
    
    ! Get the Arrays from the states
    call ESMF_StateGet(importState, "srcArray2", srcArray2, rc=rc)
    if (rc/=ESMF_SUCCESS) return ! bail out
    call ESMF_StateGet(exportState, "dstArray2", dstArray2, rc=rc)
    if (rc/=ESMF_SUCCESS) return ! bail out
   
    ! ArrayGather() srcArray2 into workF90 on rootPet=0
    call ESMF_ArrayGather(srcArray2, workF90, rootPet=0, rc=rc)
    if (rc/=ESMF_SUCCESS) return ! bail out
    
    ! On localPet 0 add a constant to workF90
    if (localPet==0) workF90 = workF90 + 123456
    
    ! ArrayScatter() workF90 on rootPet=0 across dstArray2
    call ESMF_ArrayScatter(dstArray2, workF90, rootPet=0, rc=rc)
    if (rc/=ESMF_SUCCESS) return ! bail out
      
    print *, "User Comp2 Run returning"

  end subroutine user_run