MAPL_VarSpecReconnect Subroutine

public subroutine MAPL_VarSpecReconnect(SPEC, ITEM, RC)

Arguments

Type IntentOptional Attributes Name
type(MAPL_VarSpec), pointer :: SPEC(:)
type(MAPL_VarSpec), intent(inout) :: ITEM
integer, intent(out), optional :: RC

Calls

proc~~mapl_varspecreconnect~~CallsGraph proc~mapl_varspecreconnect MAPL_VarSpecReconnect interface~mapl_varspecget MAPL_VarSpecGet proc~mapl_varspecreconnect->interface~mapl_varspecget interface~mapl_varspecgetindex MAPL_VarSpecGetIndex proc~mapl_varspecreconnect->interface~mapl_varspecgetindex interface~mapl_varspecset MAPL_VarSpecSet proc~mapl_varspecreconnect->interface~mapl_varspecset proc~mapl_return MAPL_Return proc~mapl_varspecreconnect->proc~mapl_return proc~mapl_verify MAPL_Verify proc~mapl_varspecreconnect->proc~mapl_verify 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

Source Code

   subroutine MAPL_VarSpecReconnect(SPEC,ITEM,RC)

      type (MAPL_VarSpec ), pointer         :: SPEC(:)
      type (MAPL_VarSpec ), intent(INOUT)   :: ITEM
      integer, optional   , intent(OUT)     :: RC



      integer                               :: STATUS

      type(ESMF_Field), pointer             :: FIELD
      type(ESMF_FieldBundle), pointer       :: BUNDLE
      type(ESMF_State), pointer       :: STATE
      integer I

      if(.not.associated(ITEM%SPECPtr)) then
         _RETURN(ESMF_FAILURE)
      endif

      if(.not.associated(SPEC)) then
         _RETURN(ESMF_FAILURE)
      endif

      I=MAPL_VarSpecGetIndex(SPEC, ITEM, RC=STATUS)
      _VERIFY(STATUS)

      if (I == -1) then
         _RETURN(ESMF_FAILURE)
      endif

      if (associated(ITEM%SPECptr%FIELD)) then
         deallocate(ITEM%SPECptr%FIELD, STAT=STATUS)
         _VERIFY(STATUS)
      end if
      call MAPL_VarSpecGet(SPEC(I), FIELDPTR=FIELD, RC=STATUS)
      _VERIFY(STATUS)

      call MAPL_VarSpecSet(ITEM, FIELDPTR=FIELD, RC=STATUS)
      _VERIFY(STATUS)

      if (associated(ITEM%SPECptr%BUNDLE)) then
         deallocate(ITEM%SPECptr%BUNDLE, STAT=STATUS)
         _VERIFY(STATUS)
      end if
      call MAPL_VarSpecGet(SPEC(I), BUNDLEPTR=BUNDLE, RC=STATUS)
      _VERIFY(STATUS)

      call MAPL_VarSpecSet(ITEM, BUNDLEPTR=BUNDLE, RC=STATUS)
      _VERIFY(STATUS)

      if (associated(ITEM%SPECptr%STATE)) then
         deallocate(ITEM%SPECptr%STATE, STAT=STATUS)
         _VERIFY(STATUS)
      end if
      call MAPL_VarSpecGet(SPEC(I), STATEPTR=STATE, RC=STATUS)
      _VERIFY(STATUS)

      call MAPL_VarSpecSet(ITEM, STATEPTR=STATE, RC=STATUS)
      _VERIFY(STATUS)

      !      deallocate(ITEM%SPECptr, stat=status)
      !      _VERIFY(STATUS)

      !      ITEM%SPECptr => SPEC(I)%SPECPtr

      _RETURN(ESMF_SUCCESS)


   end subroutine MAPL_VarSpecReconnect