ESMF_GridLUADefault Subroutine

private subroutine ESMF_GridLUADefault(dimCount, lWidthIn, uWidthIn, alignIn, lWidthOut, uWidthOut, alignOut, rc)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: dimCount
integer, intent(in), optional, target :: lWidthIn(:)
integer, intent(in), optional, target :: uWidthIn(:)
integer, intent(in), optional, target :: alignIn(:)
integer, intent(out), target :: lWidthOut(:)
integer, intent(out), target :: uWidthOut(:)
integer, intent(out), target :: alignOut(:)
integer, intent(out), optional :: rc

Source Code

      subroutine ESMF_GridLUADefault(dimCount, &
                                     lWidthIn, uWidthIn, alignIn, &
                                     lWidthOut, uWidthOut, alignOut, &
                                     rc)
!
! !ARGUMENTS:
       integer,               intent(in)              :: dimCount
       integer,       target, intent(in),   optional  :: lWidthIn(:)
       integer,       target, intent(in),   optional  :: uWidthIn(:)
       integer,       target, intent(in),   optional  :: alignIn(:)
       integer,       target, intent(out)             :: lWidthOut(:)
       integer,       target, intent(out)             :: uWidthOut(:)
       integer,       target, intent(out)             :: alignOut(:)
       integer,               intent(out),  optional  :: rc
!
! !DESCRIPTION:
! This routine sets the default values of the lwidth, uwidth, and align
! based on the user's passed in values for these.
!
! The arguments are:
! \begin{description}
! \item[{[lWidthIn]}]
!     The lower width from the user.
! \item[{[uWidthIn]}]
!     The upper width from the user.
! \item[{[alignIn]}]
!     The lower width from the user.
! \item[{[lWidthOut]}]
!     The lower width based on user input.
! \item[{[uWidthIn]}]
!     The upper width based on user input.
! \item[{[alignIn]}]
!     The lower width based on user input.
! \item[{[rc]}]
!      Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
! \end{description}
!
!EOPI
    integer :: localrc ! local error status
    type(ESMF_InterArray) :: lWidthInArg  ! Language Interface Helper Var
    type(ESMF_InterArray) :: uWidthInArg  ! Language Interface Helper Var
    type(ESMF_InterArray) :: alignInArg  ! Language Interface Helper Var
    type(ESMF_InterArray) :: lWidthOutArg  ! Language Interface Helper Var
    type(ESMF_InterArray) :: uWidthOutArg  ! Language Interface Helper Var
    type(ESMF_InterArray) :: alignOutArg  ! Language Interface Helper Var


    ! Initialize return code; assume failure until success is certain
    localrc = ESMF_RC_NOT_IMPL
    if (present(rc)) rc = ESMF_RC_NOT_IMPL

    ! Check DimCount of gridWidths and Aligns
    if (present(lWidthIn)) then
        if (size(lWidthIn) /= dimCount) then
           call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_SIZE, &
                     msg="- gridEdgeLWidth must be of size equal to Grid dimCount", &
                     ESMF_CONTEXT, rcToReturn=rc)
              return
        endif
    endif

    if (present(uWidthIn)) then
        if (size(uWidthIn) /= dimCount) then
           call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_SIZE, &
                     msg="- gridEdgeUWidth must be of size equal to Grid dimCount", &
                     ESMF_CONTEXT, rcToReturn=rc)
              return
        endif
    endif

    if (present(alignIn)) then
        if (size(alignIn) /= dimCount) then
           call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_SIZE, &
                     msg="- gridAlign must be of size equal to Grid dimCount", &
                     ESMF_CONTEXT, rcToReturn=rc)
              return
        endif
    endif

    ! turn to InterArray
    lWidthInArg = ESMF_InterArrayCreate(lWidthIn, rc=localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return
    uWidthInArg = ESMF_InterArrayCreate(uWidthIn, rc=localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return
    alignInArg = ESMF_InterArrayCreate(alignIn, rc=localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return
    lWidthOutArg = ESMF_InterArrayCreate(lWidthOut, rc=localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return
    uWidthOutArg = ESMF_InterArrayCreate(uWidthOut, rc=localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return
    alignOutArg = ESMF_InterArrayCreate(alignOut, rc=localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return

    ! Call C++ Subroutine for the default
    call c_ESMC_gridluadefault(dimCount, &
                               lWidthInArg, uWidthInArg, alignInArg, &
                               lWidthOutArg, uWidthOutArg, alignOutArg, &
                               localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return

    ! Deallocate helper variables
    call ESMF_InterArrayDestroy(lWidthInArg, rc=localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return
    call ESMF_InterArrayDestroy(uWidthInArg, rc=localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return
    call ESMF_InterArrayDestroy(alignInArg, rc=localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return
    call ESMF_InterArrayDestroy(lWidthOutArg, rc=localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return
    call ESMF_InterArrayDestroy(uWidthOutArg, rc=localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return
    call ESMF_InterArrayDestroy(alignOutArg, rc=localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return

    ! Return successfully
    if (present(rc)) rc = ESMF_SUCCESS

    end subroutine ESMF_GridLUADefault