ESMF_DistGridSetDefault Subroutine

private subroutine ESMF_DistGridSetDefault(distgrid, collocationPDim, name, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_DistGrid), intent(inout) :: distgrid
integer, intent(in), optional :: collocationPDim(:)
character(len=*), intent(in), optional :: name
integer, intent(out), optional :: rc

Source Code

  subroutine ESMF_DistGridSetDefault(distgrid, collocationPDim, name, rc)
!
! !ARGUMENTS:
    type(ESMF_DistGrid),  intent(inout)           :: distgrid
    integer,              intent(in),   optional  :: collocationPDim(:)
    character(len = *),   intent(in),   optional  :: name
    integer,              intent(out),  optional  :: rc  
!
! !DESCRIPTION:
!      Set the sequence index collocation labels in {\tt distgrid}.
!      The method returns an error code if problems are found.  
!
!     The arguments are:
!     \begin{description}
!     \item[distgrid] 
!          Specified {\tt ESMF\_DistGrid} object.
!     \item[{[collocationPDim]}] 
!          List of size {\tt dimCount} specifying which dimensions are
!          covered by which sequence index. Each entry is associated with the
!          corresponding dimension. Dimensions with identical entries in the
!          {\tt collocationPDim} argument are collocated within the same
!          sequence index space. Dimensions with different entries are located
!          in orthogonal sequence index spaces.
!     \item [{[name]}]
!          The DistGrid name.
!     \item[{[rc]}] 
!          Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
!     \end{description}
!
!EOPI
!------------------------------------------------------------------------------
    integer               :: localrc      ! local return code
    type(ESMF_InterArray) :: collocationPDimAux  ! helper variable

    ! initialize return code; assume routine not implemented
    localrc = ESMF_RC_NOT_IMPL
    if (present(rc)) rc = ESMF_RC_NOT_IMPL

    ! Check init status of arguments
    ESMF_INIT_CHECK_DEEP(ESMF_DistGridGetInit, distgrid, rc)

    ! Set the name in Base object
    if (present(name)) then
      call c_ESMC_SetName(distgrid, "DistGrid", name, localrc)
      if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT, rcToReturn=rc)) return
    endif

    ! Set collocationPDim
    if (present(collocationPDim)) then
      collocationPDimAux = ESMF_InterArrayCreate(collocationPDim, rc=localrc)
      if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT, rcToReturn=rc)) return

      ! Call into the C++ interface, which will sort out optional arguments.
      call c_ESMC_DistGridSet(distgrid, collocationPDimAux, localrc)
      if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT, rcToReturn=rc)) return

      ! garbage collection
      call ESMF_InterArrayDestroy(collocationPDimAux, rc=localrc)
      if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT, rcToReturn=rc)) return
    endif

    ! return successfully
    if (present(rc)) rc = ESMF_SUCCESS
    
  end subroutine ESMF_DistGridSetDefault