MAPL_GenericStateRestore Subroutine

public recursive subroutine MAPL_GenericStateRestore(GC, IMPORT, EXPORT, CLOCK, RC)

Arguments

Type IntentOptional Attributes Name
type(ESMF_GridComp), intent(inout) :: GC
type(ESMF_State), intent(inout) :: IMPORT
type(ESMF_State), intent(inout) :: EXPORT
type(ESMF_Clock), intent(inout) :: CLOCK
integer, intent(out), optional :: RC

Calls

proc~~mapl_genericstaterestore~~CallsGraph proc~mapl_genericstaterestore MAPL_GenericStateRestore proc~mapl_genericstaterestore->proc~mapl_genericstaterestore ESMF_GridCompGet ESMF_GridCompGet proc~mapl_genericstaterestore->ESMF_GridCompGet interface~mapl_getresource MAPL_GetResource proc~mapl_genericstaterestore->interface~mapl_getresource interface~mapl_timeron MAPL_TimerOn proc~mapl_genericstaterestore->interface~mapl_timeron none~get_child_export_state MAPL_MetaComp%get_child_export_state proc~mapl_genericstaterestore->none~get_child_export_state none~get_child_gridcomp MAPL_MetaComp%get_child_gridcomp proc~mapl_genericstaterestore->none~get_child_gridcomp none~get_child_import_state MAPL_MetaComp%get_child_import_state proc~mapl_genericstaterestore->none~get_child_import_state none~get_internal_state~2 MaplGenericComponent%get_internal_state proc~mapl_genericstaterestore->none~get_internal_state~2 none~get_num_children~5 CompositeComponent%get_num_children proc~mapl_genericstaterestore->none~get_num_children~5 proc~getfile GETFILE proc~mapl_genericstaterestore->proc~getfile proc~mapl_esmfstatereadfromfile MAPL_ESMFStateReadFromFile proc~mapl_genericstaterestore->proc~mapl_esmfstatereadfromfile proc~mapl_internalstateretrieve MAPL_InternalStateRetrieve proc~mapl_genericstaterestore->proc~mapl_internalstateretrieve proc~mapl_return MAPL_Return proc~mapl_genericstaterestore->proc~mapl_return proc~mapl_verify MAPL_Verify proc~mapl_genericstaterestore->proc~mapl_verify

Source Code

   recursive subroutine MAPL_GenericStateRestore ( GC, IMPORT, EXPORT, CLOCK, RC )

      ! !ARGUMENTS:

      type(ESMF_GridComp), intent(inout) :: GC     ! composite gridded component
      type(ESMF_State),    intent(inout) :: IMPORT ! import state
      type(ESMF_State),    intent(inout) :: EXPORT ! export state
      type(ESMF_Clock),    intent(inout) :: CLOCK  ! the clock
      integer, optional,   intent(  out) :: RC     ! Error code:
      ! = 0 all is well
      ! otherwise, error
      !EOPI

      ! LOCAL VARIABLES

      character(len=ESMF_MAXSTR)                  :: IAm
      character(len=ESMF_MAXSTR)                  :: comp_name
      character(len=ESMF_MAXSTR)                  :: CHILD_NAME
      integer                                     :: status
      integer                                     :: I
      type (MAPL_MetaComp), pointer               :: STATE
      integer                                     :: hdr, unit
      type(ESMF_GridComp), pointer :: gridcomp
      type(ESMF_State), pointer :: child_import_state
      type(ESMF_State), pointer :: child_export_state
      type(ESMF_State), pointer :: internal_state
      !=============================================================================

      !  Begin...

      _UNUSED_DUMMY(EXPORT)
      Iam = "MAPL_GenericStateRestore"
      call ESMF_GridCompGet(GC, name=comp_name, RC=status )
      _VERIFY(status)
      Iam = trim(comp_name) // Iam

      ! Retrieve the pointer to the state
      !----------------------------------

      call MAPL_InternalStateRetrieve(GC, STATE, RC=status)
      _VERIFY(status)

      ! Refresh the children
      ! ---------------------
      do I=1,STATE%get_num_children()
         gridcomp => STATE%GET_CHILD_GRIDCOMP(I)
         call ESMF_GridCompGet( gridcomp, NAME=CHILD_NAME, RC=status )
         _VERIFY(status)
         child_import_state => STATE%get_child_import_state(i)
         child_export_state => STATE%get_child_export_state(i)
         call MAPL_GenericStateRestore (gridcomp, child_import_state, child_export_state, CLOCK, &
              RC=status )
         _VERIFY(status)
      enddo

      ! Do my "own" refresh
      ! ------------------
      call MAPL_TimerOn(STATE,"GenRefreshMine")

      if (allocated(STATE%initial_state%imp_fname)) then
         call MAPL_ESMFStateReadFromFile(IMPORT, CLOCK, &
              STATE%initial_state%IMP_FNAME, &
              STATE, .FALSE., RC=status)
         _VERIFY(status)
      end if

      if (allocated(state%initial_state%int_fname)) then
         call MAPL_GetResource( STATE   , hdr,         &
              default=0, &
              LABEL="INTERNAL_HEADER:", &
              RC=status)
         _VERIFY(status)
         internal_state => state%get_internal_state()
         call MAPL_ESMFStateReadFromFile(internal_state, CLOCK, &
              STATE%initial_state%INT_FNAME, &
              STATE, hdr/=0, RC=status)
         _VERIFY(status)
         UNIT = GETFILE(STATE%initial_state%INT_FNAME, RC=status)
         _VERIFY(status)
      end if

      _RETURN(ESMF_SUCCESS)
   end subroutine MAPL_GenericStateRestore