MAPL_GetAllExchangeGrids Subroutine

public recursive subroutine MAPL_GetAllExchangeGrids(GC, LSADDR, RC)

Arguments

Type IntentOptional Attributes Name
type(ESMF_GridComp), intent(inout) :: GC
integer(kind=INT64), pointer :: LSADDR(:)
integer, intent(out) :: RC

Calls

proc~~mapl_getallexchangegrids~~CallsGraph proc~mapl_getallexchangegrids MAPL_GetAllExchangeGrids proc~mapl_getallexchangegrids->proc~mapl_getallexchangegrids ESMF_GridCompGet ESMF_GridCompGet proc~mapl_getallexchangegrids->ESMF_GridCompGet c_mapl_locstreamretrieveptr c_mapl_locstreamretrieveptr proc~mapl_getallexchangegrids->c_mapl_locstreamretrieveptr interface~mapl_getobjectfromgc MAPL_GetObjectFromGC proc~mapl_getallexchangegrids->interface~mapl_getobjectfromgc none~get_child_gridcomp MAPL_MetaComp%get_child_gridcomp proc~mapl_getallexchangegrids->none~get_child_gridcomp none~get_num_children~5 CompositeComponent%get_num_children proc~mapl_getallexchangegrids->none~get_num_children~5 proc~mapl_return MAPL_Return proc~mapl_getallexchangegrids->proc~mapl_return proc~mapl_verify MAPL_Verify proc~mapl_getallexchangegrids->proc~mapl_verify none~get_gridcomp~2 MaplGenericComponent%get_gridcomp none~get_child_gridcomp->none~get_gridcomp~2 none~get_ith_child MAPL_MetaComp%get_ith_child none~get_child_gridcomp->none~get_ith_child none~get_num_children~3 ConcreteComposite%get_num_children none~get_num_children~5->none~get_num_children~3 at at proc~mapl_return->at insert insert proc~mapl_return->insert proc~mapl_throw_exception MAPL_throw_exception proc~mapl_return->proc~mapl_throw_exception proc~mapl_verify->proc~mapl_throw_exception none~is_threading_active MaplGenericComponent%is_threading_active none~get_gridcomp~2->none~is_threading_active proc~get_current_thread get_current_thread none~get_gridcomp~2->proc~get_current_thread none~get_child~57 MAPL_MetaComp%get_child none~get_ith_child->none~get_child~57 none~get_child_by_index~3 CompositeComponent%get_child_by_index none~get_child~57->none~get_child_by_index~3 none~get_child_by_name~4 CompositeComponent%get_child_by_name none~get_child~57->none~get_child_by_name~4

Source Code

   recursive subroutine MAPL_GetAllExchangeGrids ( GC, LSADDR, RC )


      type(ESMF_GridComp),  intent(INOUT) :: GC         ! Gridded component
      integer(kind=INT64),            pointer       :: LSADDR(:)
      integer,              intent(  OUT) :: RC         ! Return code


      integer :: status

      type (MAPL_MetaComp),              pointer  :: MAPLOBJ
      type (MAPL_LocStream)                       :: LocStream

      character(len=ESMF_MAXSTR)   :: CNAME
      integer(kind=INT64)                    :: ADDR
      integer                      :: I
      integer                      :: N
      integer(kind=INT64), pointer           :: TMP(:)
      logical                      :: found

      type(ESMF_GridComp), pointer :: gridcomp
      ! Retrieve the pointer to the internal state
      ! --------------------------------------------

      call MAPL_GetObjectFromGC ( GC, MAPLOBJ, RC=status)
      _VERIFY(status)

      LocStream = MAPLOBJ%LocStream
      call c_MAPL_LocStreamRetrievePtr(LocStream, ADDR)

      call ESMF_GridCompGet(GC, NAME = cname, rc=status)
      _VERIFY(status)

      if (ADDR /= 0) then
         N = 0
         if (associated(LSADDR)) then
            N = SIZE(LSADDR)
         end if

         found = .false.
         do I = 1, N
            if (addr == LSADDR(I)) then
               found = .true.
               exit
            end if
         end do

         if (.not. found) then
            allocate(tmp(N+1), stat=status)
            _VERIFY(status)
            if (N > 0) then
               tmp(1:N) = LSADDR
               deallocate(LSADDR)
            end if
            N = N + 1
            tmp(N) = addr
            LSADDR => TMP
         end if
      end if

      do I = 1, MAPLOBJ%get_num_children()
         gridcomp => MAPLOBJ%GET_CHILD_GRIDCOMP(I)
         call MAPL_GetAllExchangeGrids(gridcomp, LSADDR, RC=status)
         _VERIFY(status)
      end do

      _RETURN(ESMF_SUCCESS)
   end subroutine MAPL_GetAllExchangeGrids