user_init Subroutine

public subroutine user_init(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_init(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_Array) :: srcArray1, srcArray2
    integer          :: srcF90(100,150)
    type(ESMF_VM) :: vm

    ! Initialize return code
    rc = ESMF_SUCCESS

    print *, "User Coupler Init starting"

    ! Need to reconcile import and export states
    call ESMF_CplCompGet(comp, vm=vm, rc=rc)
    if (rc/=ESMF_SUCCESS) return ! bail out
    call ESMF_StateReconcile(importState, vm=vm, rc=rc)
    if (rc/=ESMF_SUCCESS) return ! bail out
    call ESMF_StateReconcile(exportState, vm=vm, rc=rc)
    if (rc/=ESMF_SUCCESS) return ! bail out
    
    ! Get the Arrays from the states
    call ESMF_StateGet(importState, "srcArray1", srcArray1, rc=rc)
    if (rc/=ESMF_SUCCESS) return ! bail out
    call ESMF_StateGet(exportState, "srcArray2", srcArray2, rc=rc)
    if (rc/=ESMF_SUCCESS) return ! bail out

    ! ArrayGather() srcArray1 into srcF90 on rootPet=5
    call ESMF_ArrayGather(srcArray1, srcF90, rootPet=5, rc=rc)
    if (rc/=ESMF_SUCCESS) return ! bail out
    
    ! ArrayScatter() srcF90 on rootPet=5 across srcArray2 
    call ESMF_ArrayScatter(srcArray2, srcF90, rootPet=5, rc=rc)
    if (rc/=ESMF_SUCCESS) return ! bail out
  
    print *, "User Coupler Init returning"
   
  end subroutine user_init