ESMF_ReconcileInitialize Subroutine

private subroutine ESMF_ReconcileInitialize(state, vm, siwrap, nitems_all, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_State), intent(inout) :: state
type(ESMF_VM), intent(in) :: vm
type(ESMF_StateItemWrap), pointer :: siwrap(:)
integer, pointer :: nitems_all(:)
integer, intent(out) :: rc

Calls

proc~~esmf_reconcileinitialize~~CallsGraph proc~esmf_reconcileinitialize ESMF_ReconcileInitialize interface~esmf_containerget~2 ESMF_ContainerGet proc~esmf_reconcileinitialize->interface~esmf_containerget~2 interface~esmf_vmallgather ESMF_VMAllGather proc~esmf_reconcileinitialize->interface~esmf_vmallgather interface~esmf_vmget ESMF_VMGet proc~esmf_reconcileinitialize->interface~esmf_vmget proc~esmf_logfoundallocerror ESMF_LogFoundAllocError proc~esmf_reconcileinitialize->proc~esmf_logfoundallocerror proc~esmf_logfounderror ESMF_LogFoundError proc~esmf_reconcileinitialize->proc~esmf_logfounderror proc~esmf_reconcilezapproxies ESMF_ReconcileZapProxies proc~esmf_reconcileinitialize->proc~esmf_reconcilezapproxies proc~esmf_traceregionenter ESMF_TraceRegionEnter proc~esmf_reconcileinitialize->proc~esmf_traceregionenter proc~esmf_traceregionexit ESMF_TraceRegionExit proc~esmf_reconcileinitialize->proc~esmf_traceregionexit proc~esmf_containergetfield ESMF_ContainerGetField interface~esmf_containerget~2->proc~esmf_containergetfield proc~esmf_containergetfieldlist ESMF_ContainerGetFieldList interface~esmf_containerget~2->proc~esmf_containergetfieldlist proc~esmf_containergetfieldlistall ESMF_ContainerGetFieldListAll interface~esmf_containerget~2->proc~esmf_containergetfieldlistall proc~esmf_vmallgatheri4 ESMF_VMAllGatherI4 interface~esmf_vmallgather->proc~esmf_vmallgatheri4 proc~esmf_vmallgatheri8 ESMF_VMAllGatherI8 interface~esmf_vmallgather->proc~esmf_vmallgatheri8 proc~esmf_vmallgatherlogical ESMF_VMAllGatherLogical interface~esmf_vmallgather->proc~esmf_vmallgatherlogical proc~esmf_vmallgatherr4 ESMF_VMAllGatherR4 interface~esmf_vmallgather->proc~esmf_vmallgatherr4 proc~esmf_vmallgatherr8 ESMF_VMAllGatherR8 interface~esmf_vmallgather->proc~esmf_vmallgatherr8 proc~esmf_vmgetdefault ESMF_VMGetDefault interface~esmf_vmget->proc~esmf_vmgetdefault proc~esmf_vmgetpetspecific ESMF_VMGetPetSpecific interface~esmf_vmget->proc~esmf_vmgetpetspecific esmf_breakpoint esmf_breakpoint proc~esmf_logfoundallocerror->esmf_breakpoint proc~esmf_logrc2msg ESMF_LogRc2Msg proc~esmf_logfoundallocerror->proc~esmf_logrc2msg proc~esmf_logwrite ESMF_LogWrite proc~esmf_logfoundallocerror->proc~esmf_logwrite proc~esmf_logfounderror->esmf_breakpoint proc~esmf_logfounderror->proc~esmf_logrc2msg proc~esmf_logfounderror->proc~esmf_logwrite proc~esmf_reconcilezapproxies->interface~esmf_containerget~2 proc~esmf_reconcilezapproxies->proc~esmf_logfounderror esmf_stateremove esmf_stateremove proc~esmf_reconcilezapproxies->esmf_stateremove proc~esmf_isproxy ESMF_IsProxy proc~esmf_reconcilezapproxies->proc~esmf_isproxy proc~esmf_stateitemget ESMF_StateItemGet proc~esmf_reconcilezapproxies->proc~esmf_stateitemget proc~esmf_traceregionenter->proc~esmf_logfounderror c_esmftrace_region_enter c_esmftrace_region_enter proc~esmf_traceregionenter->c_esmftrace_region_enter proc~esmf_traceregionexit->proc~esmf_logfounderror c_esmftrace_region_exit c_esmftrace_region_exit proc~esmf_traceregionexit->c_esmftrace_region_exit

Called by

proc~~esmf_reconcileinitialize~~CalledByGraph proc~esmf_reconcileinitialize ESMF_ReconcileInitialize proc~esmf_statereconcile_driver ESMF_StateReconcile_driver proc~esmf_statereconcile_driver->proc~esmf_reconcileinitialize proc~esmf_statereconcile ESMF_StateReconcile proc~esmf_statereconcile->proc~esmf_statereconcile_driver

Source Code

  subroutine ESMF_ReconcileInitialize(state, vm, siwrap, nitems_all, rc)
!
! !ARGUMENTS:
    type (ESMF_State), intent(inout)   :: state
    type (ESMF_VM),    intent(in)      :: vm
    type (ESMF_StateItemWrap), pointer :: siwrap(:)     ! intent(out)
    integer,                   pointer :: nitems_all(:) ! intent(out)
    integer,           intent(out)     :: rc
!
! !DESCRIPTION:
!
!   The arguments are:
!   \begin{description}
!   \item[state]
!     {\tt ESMF\_State} to collect information from.
!   \item[rc]
!     Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
!   \end{description}
!EOPI

    integer :: localrc
    integer :: memstat
    integer :: nitems_local(1)
    integer :: localPet, petCount

    logical, parameter :: profile = .false.

    localrc = ESMF_RC_NOT_IMPL

    if (associated (siwrap) .or. associated (nitems_all)) then
      if (ESMF_LogFoundError(ESMF_RC_ARG_BAD, ESMF_ERR_PASSTHRU, &
          ESMF_CONTEXT,  &
          rcToReturn=rc)) return
    end if

    call ESMF_VMGet(vm, localPet=localPet, petCount=petCount, rc=localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT,  &
        rcToReturn=rc)) return

    ! Brute force removal of all existing proxies from the State
    ! to handle the re-reconcile case.  If State items were removed
    ! between reconciles, there should be no proxies for them.
    !
    ! TODO: Consider maintaining a flag in the state.  Perform
    ! a communication step to see if any removals have taken place.
    ! Conditionally zap the proxies depending on whether it is actually
    ! needed.
    if (profile) then
      call ESMF_TraceRegionEnter("ESMF_ReconcileZapProxies", rc=localrc)
      if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, &
        rcToReturn=rc)) return
    endif
    call ESMF_ReconcileZapProxies (state, localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT,  &
        rcToReturn=rc)) return
    if (profile) then
      call ESMF_TraceRegionExit("ESMF_ReconcileZapProxies", rc=localrc)
      if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, &
        rcToReturn=rc)) return
    endif

    ! Obtain local PET item list
    siwrap => null ()
    call ESMF_ContainerGet (state%statep%stateContainer,  &
        itemList=siwrap, rc=localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT,  &
        rcToReturn=rc)) return

    if (associated (siwrap)) then
      nitems_local(1) = size (siwrap)
    else
      nitems_local(1) = 0
    end if

    ! All PETs send their item counts to all the other PETs for recv array sizing.
    allocate (nitems_all(0:petCount-1), stat=memstat)
    if (ESMF_LogFoundAllocError(memstat, ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT,  &
        rcToReturn=rc)) return

    if (profile) then
      call ESMF_TraceRegionEnter("ESMF_VMAllGather", rc=localrc)
      if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, &
        rcToReturn=rc)) return
    endif
    call ESMF_VMAllGather (vm,  &
        sendData=nitems_local, recvData=nitems_all,  &
        count=1, rc=localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT,  &
        rcToReturn=rc)) return
    if (profile) then
      call ESMF_TraceRegionExit("ESMF_VMAllGather", rc=localrc)
      if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, &
        rcToReturn=rc)) return
    endif

  end subroutine ESMF_ReconcileInitialize