ESMF_XGridGetSMMSpecFrac Subroutine

private subroutine ESMF_XGridGetSMMSpecFrac(xgrid, srcSide, srcGridIndex, dstSide, dstGridIndex, keywordEnforcer, sparseMat, srcFracArray, dstFracArray, srcFrac2Array, dstFrac2Array, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_XGrid), intent(in) :: xgrid
type(ESMF_XGridSide_Flag), intent(in) :: srcSide
integer, intent(in) :: srcGridIndex
type(ESMF_XGridSide_Flag), intent(in) :: dstSide
integer, intent(in) :: dstGridIndex
type(ESMF_KeywordEnforcer), optional :: keywordEnforcer
type(ESMF_XGridSpec), intent(out), optional :: sparseMat
type(ESMF_Array), intent(inout), optional :: srcFracArray
type(ESMF_Array), intent(inout), optional :: dstFracArray
type(ESMF_Array), intent(inout), optional :: srcFrac2Array
type(ESMF_Array), intent(inout), optional :: dstFrac2Array
integer, intent(out), optional :: rc

Source Code

subroutine ESMF_XGridGetSMMSpecFrac(xgrid, srcSide, srcGridIndex, &
    dstSide, dstGridIndex, keywordEnforcer, &
    sparseMat, srcFracArray, dstFracArray, &
    srcFrac2Array, dstFrac2Array, &
    rc) 

!
! !ARGUMENTS:
type(ESMF_XGrid),          intent(in)               :: xgrid
type(ESMF_XGridSide_Flag), intent(in)               :: srcSide
integer,                   intent(in)               :: srcGridIndex
type(ESMF_XGridSide_Flag), intent(in)               :: dstSide
integer,                   intent(in)               :: dstGridIndex
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
type(ESMF_XGridSpec),      intent(out),   optional  :: sparseMat
type(ESMF_Array),          intent(inout), optional  :: srcFracArray
type(ESMF_Array),          intent(inout), optional  :: dstFracArray
type(ESMF_Array),          intent(inout), optional  :: srcFrac2Array
type(ESMF_Array),          intent(inout), optional  :: dstFrac2Array
integer,                   intent(out),   optional  :: rc 
!
! !DESCRIPTION:
!      Get information about XGrid
!
!     The arguments are:
!     \begin{description}
!     \item [xgrid]
!       The {\tt ESMF\_XGrid} object used to retrieve information from.
!     \item [srcSide] 
!       Side of the XGrid from (either ESMF\_XGRIDSIDE\_A,
!       ESMF\_XGRIDSIDE\_B, or ESMF\_XGRIDSIDE\_BALANCED).
!     \item [srcGridIndex] 
!       If xgridSide is  ESMF\_XGRIDSIDE\_A or ESMF\_XGRIDSIDE\_B then this index tells which Grid on
!       that side.
!     \item [dstSide]
!       Side of the XGrid from (either ESMF\_XGRIDSIDE\_A,
!       ESMF\_XGRIDSIDE\_B, or ESMF\_XGRIDSIDE\_BALANCED).
!     \item [dstGridIndex] 
!       If xgridSide is  ESMF\_XGRIDSIDE\_A or ESMF\_XGRIDSIDE\_B then this index tells which Grid on
!       that side.
!     \item [{[sparseMat]}]
!       SparseMat corresponding to the src and dst Grid or Mesh.
!     \item [{[srcFracArray]}]
!       src Frac Array corresponding to the src Grid or Mesh.
!     \item [{[dstFracArray]}]
!       dst Frac Array corresponding to the dst Grid or Mesh.
!     \item [{[srcFrac2Array]}]
!       src Frac2 Array corresponding to the src Grid or Mesh.
!     \item [{[dstFrac2Array]}]
!       dst Frac2 Array corresponding to the dst Grid or Mesh.
!     \item [{[rc]}]
!       Return code; equals {\tt ESMF\_SUCCESS} only if the {\tt ESMF\_XGrid} 
!       is created.
!     \end{description}
!
!EOPI

    type(ESMF_XGridType), pointer :: xgtypep
    integer                       :: localrc

    ! Initialize return code   
    if(present(rc)) rc = ESMF_RC_NOT_IMPL

    ! check init status of input XGrid
    ESMF_INIT_CHECK_DEEP(ESMF_XGridGetInit,xgrid,rc)

    xgtypep => xgrid%xgtypep

    if(srcSide .eq. ESMF_XGRIDSIDE_A .and. dstSide .eq. ESMF_XGRIDSIDE_BALANCED) then
        if(present(sparseMat)) sparseMat = xgtypep%SparseMatA2X(srcGridIndex)

        if(present(srcFracArray)) then
          if(xgtypep%online == 0) then
            call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_WRONG, & 
               msg="- Cannot query srcFracArray for xgrid created offline", &
               ESMF_CONTEXT, rcToReturn=rc) 
            return
          endif
          call ESMF_ArrayCopy(srcFracArray, xgtypep%fracA2X(srcGridIndex), rc=localrc)
          if (ESMF_LogFoundError(localrc, &
              ESMF_ERR_PASSTHRU, &
              ESMF_CONTEXT, rcToReturn=rc)) return
        endif
        if(present(dstFracArray)) then
          if(xgtypep%online == 0) then
            call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_WRONG, & 
               msg="- Cannot query dstFracArray for xgrid created offline", &
               ESMF_CONTEXT, rcToReturn=rc) 
            return
          endif
          call ESMF_ArrayCopy(dstFracArray, xgtypep%fracX, rc=localrc)
          if (ESMF_LogFoundError(localrc, &
              ESMF_ERR_PASSTHRU, &
              ESMF_CONTEXT, rcToReturn=rc)) return
        endif

        if(present(srcFrac2Array)) then
          if(xgtypep%online == 0) then
            call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_WRONG, & 
               msg="- Cannot query srcFrac2Array for xgrid created offline", &
               ESMF_CONTEXT, rcToReturn=rc) 
            return
          endif
          call ESMF_ArrayCopy(srcFrac2Array, xgtypep%frac2A(srcGridIndex), rc=localrc)
          if (ESMF_LogFoundError(localrc, &
              ESMF_ERR_PASSTHRU, &
              ESMF_CONTEXT, rcToReturn=rc)) return
        endif
        if(present(dstFrac2Array)) then
          if(xgtypep%online == 0) then
            call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_WRONG, & 
               msg="- Cannot query dstFracArray for xgrid created offline", &
               ESMF_CONTEXT, rcToReturn=rc) 
            return
          endif
          call ESMF_ArrayCopy(dstFrac2Array, xgtypep%fracX, rc=localrc)
          if (ESMF_LogFoundError(localrc, &
              ESMF_ERR_PASSTHRU, &
              ESMF_CONTEXT, rcToReturn=rc)) return
        endif
    endif

    if(srcSide .eq. ESMF_XGRIDSIDE_B .and. dstSide .eq. ESMF_XGRIDSIDE_BALANCED) then
        if(present(sparseMat)) sparseMat = xgtypep%SparseMatB2X(srcGridIndex)
        if(present(srcFracArray)) then
          if(xgtypep%online == 0) then
            call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_WRONG, & 
               msg="- Cannot query srcFracArray for xgrid created offline", &
               ESMF_CONTEXT, rcToReturn=rc) 
            return
          endif
          call ESMF_ArrayCopy(srcFracArray, xgtypep%fracB2X(srcGridIndex), rc=localrc)
          if (ESMF_LogFoundError(localrc, &
              ESMF_ERR_PASSTHRU, &
              ESMF_CONTEXT, rcToReturn=rc)) return
        endif
        if(present(dstFracArray)) then
          if(xgtypep%online == 0) then
            call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_WRONG, & 
               msg="- Cannot query dstFracArray for xgrid created offline", &
               ESMF_CONTEXT, rcToReturn=rc) 
            return
          endif
          call ESMF_ArrayCopy(dstFracArray, xgtypep%fracX, rc=localrc)
          if (ESMF_LogFoundError(localrc, &
              ESMF_ERR_PASSTHRU, &
              ESMF_CONTEXT, rcToReturn=rc)) return
        endif

        if(present(srcFrac2Array)) then
          if(xgtypep%online == 0) then
            call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_WRONG, & 
               msg="- Cannot query srcFrac2Array for xgrid created offline", &
               ESMF_CONTEXT, rcToReturn=rc) 
            return
          endif
          call ESMF_ArrayCopy(srcFrac2Array, xgtypep%frac2B(srcGridIndex), rc=localrc)
          if (ESMF_LogFoundError(localrc, &
              ESMF_ERR_PASSTHRU, &
              ESMF_CONTEXT, rcToReturn=rc)) return
        endif
        if(present(dstFrac2Array)) then
          if(xgtypep%online == 0) then
            call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_WRONG, & 
               msg="- Cannot query dstFrac2Array for xgrid created offline", &
               ESMF_CONTEXT, rcToReturn=rc) 
            return
          endif
          call ESMF_ArrayCopy(dstFrac2Array, xgtypep%fracX, rc=localrc)
          if (ESMF_LogFoundError(localrc, &
              ESMF_ERR_PASSTHRU, &
              ESMF_CONTEXT, rcToReturn=rc)) return
        endif
    endif

    if(srcSide .eq. ESMF_XGRIDSIDE_BALANCED .and. dstSide .eq. ESMF_XGRIDSIDE_A) then
        if(present(sparseMat)) sparseMat = xgtypep%SparseMatX2A(dstGridIndex)
        if(present(srcFracArray)) then
          if(xgtypep%online == 0) then
            call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_WRONG, & 
               msg="- Cannot cannot query srcFracArray for xgrid created offline", &
               ESMF_CONTEXT, rcToReturn=rc) 
            return
          endif
          call ESMF_ArrayCopy(srcFracArray, xgtypep%fracX, rc=localrc)
          if (ESMF_LogFoundError(localrc, &
              ESMF_ERR_PASSTHRU, &
              ESMF_CONTEXT, rcToReturn=rc)) return
        endif
        if(present(dstFracArray)) then
          if(xgtypep%online == 0) then
            call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_WRONG, & 
               msg="- Cannot cannot query dstFracArray for xgrid created offline", &
               ESMF_CONTEXT, rcToReturn=rc) 
            return
          endif
          call ESMF_ArrayCopy(dstFracArray, xgtypep%fracX2A(dstGridIndex), rc=localrc)
          if (ESMF_LogFoundError(localrc, &
              ESMF_ERR_PASSTHRU, &
              ESMF_CONTEXT, rcToReturn=rc)) return
        endif

        if(present(srcFrac2Array)) then
          if(xgtypep%online == 0) then
            call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_WRONG, & 
               msg="- Cannot cannot query srcFrac2Array for xgrid created offline", &
               ESMF_CONTEXT, rcToReturn=rc) 
            return
          endif
          call ESMF_ArrayCopy(srcFrac2Array, xgtypep%fracX, rc=localrc)
          if (ESMF_LogFoundError(localrc, &
              ESMF_ERR_PASSTHRU, &
              ESMF_CONTEXT, rcToReturn=rc)) return
        endif
        if(present(dstFrac2Array)) then
          if(xgtypep%online == 0) then
            call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_WRONG, & 
               msg="- Cannot cannot query dstFrac2Array for xgrid created offline", &
               ESMF_CONTEXT, rcToReturn=rc) 
            return
          endif
          call ESMF_ArrayCopy(dstFrac2Array, xgtypep%frac2A(dstGridIndex), rc=localrc)
          if (ESMF_LogFoundError(localrc, &
              ESMF_ERR_PASSTHRU, &
              ESMF_CONTEXT, rcToReturn=rc)) return
        endif
    endif

    if(srcSide .eq. ESMF_XGRIDSIDE_BALANCED .and. dstSide .eq. ESMF_XGRIDSIDE_B) then
        if(present(sparseMat)) sparseMat = xgtypep%SparseMatX2B(dstGridIndex)
        if(present(srcFracArray)) then
          if(xgtypep%online == 0) then
            call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_WRONG, & 
               msg="- Cannot cannot query srcFracArray for xgrid created offline", &
               ESMF_CONTEXT, rcToReturn=rc) 
            return
          endif
          call ESMF_ArrayCopy(srcFracArray, xgtypep%fracX, rc=localrc)
          if (ESMF_LogFoundError(localrc, &
              ESMF_ERR_PASSTHRU, &
              ESMF_CONTEXT, rcToReturn=rc)) return
        endif
        if(present(dstFracArray)) then
          if(xgtypep%online == 0) then
            call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_WRONG, & 
               msg="- Cannot cannot query dstFracArray for xgrid created offline", &
               ESMF_CONTEXT, rcToReturn=rc) 
            return
          endif
          call ESMF_ArrayCopy(dstFracArray, xgtypep%fracX2B(dstGridIndex), rc=localrc)
          if (ESMF_LogFoundError(localrc, &
              ESMF_ERR_PASSTHRU, &
              ESMF_CONTEXT, rcToReturn=rc)) return
        endif

        if(present(srcFrac2Array)) then
          if(xgtypep%online == 0) then
            call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_WRONG, & 
               msg="- Cannot cannot query srcFrac2Array for xgrid created offline", &
               ESMF_CONTEXT, rcToReturn=rc) 
            return
          endif
          call ESMF_ArrayCopy(srcFrac2Array, xgtypep%fracX, rc=localrc)
          if (ESMF_LogFoundError(localrc, &
              ESMF_ERR_PASSTHRU, &
              ESMF_CONTEXT, rcToReturn=rc)) return
        endif
        if(present(dstFrac2Array)) then
          if(xgtypep%online == 0) then
            call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_WRONG, & 
               msg="- Cannot cannot query dstFrac2Array for xgrid created offline", &
               ESMF_CONTEXT, rcToReturn=rc) 
            return
          endif
          call ESMF_ArrayCopy(dstFrac2Array, xgtypep%frac2B(dstGridIndex), rc=localrc)
          if (ESMF_LogFoundError(localrc, &
              ESMF_ERR_PASSTHRU, &
              ESMF_CONTEXT, rcToReturn=rc)) return
        endif
    endif

    ! success
    if(present(rc)) rc = ESMF_SUCCESS

end subroutine ESMF_XGridGetSMMSpecFrac