f_esmf_stateaddarray Subroutine

subroutine f_esmf_stateaddarray(state, array, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_State) :: state
type(ESMF_Array) :: array
integer, intent(out) :: rc

Source Code

   subroutine f_esmf_stateaddarray(state, array, rc)
#undef  ESMF_METHOD
#define ESMF_METHOD "f_esmf_stateaddarray"

       use ESMF_UtilTypesMod
       use ESMF_LogErrMod
      !use ESMF_BaseMod    ! ESMF base class
       use ESMF_StateMod
       use ESMF_ArrayCreateMod
       implicit none

       type(ESMF_State) :: state        !inout
       type(ESMF_Array) :: array        !in
       integer, intent(out) :: rc       !out

       ! local variable
       type(ESMF_Array) :: farray

       integer :: localrc

       ! Must first create a proper ESMF_Array that contains the 
       ! required "isInit" class member.
       
       ! Initialize return code; assume routine not implemented
       rc = ESMF_RC_NOT_IMPL

       ! Copy the this pointer a new ESMF_Array object
       call ESMF_ArrayCopyThis(array, farray, localrc)
       if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU,  &
           ESMF_CONTEXT, rcToReturn=rc)) return

       !  set the valid init code of the new object
       call ESMF_ArraySetInitCreated(farray, localrc)
       if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU,  &
           ESMF_CONTEXT, rcToReturn=rc)) return

       call ESMF_StateAdd(state=state, arrayList=(/farray/), rc=localrc)
       if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU,  &
           ESMF_CONTEXT, rcToReturn=rc)) return

       rc = localrc

   end subroutine f_esmf_stateaddarray