ESMF_XGridDistGrids Subroutine

private subroutine ESMF_XGridDistGrids(xgtype, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_XGridType), intent(inout) :: xgtype
integer, intent(out), optional :: rc

Calls

proc~~esmf_xgriddistgrids~~CallsGraph proc~esmf_xgriddistgrids ESMF_XGridDistGrids proc~esmf_logfoundallocerror ESMF_LogFoundAllocError proc~esmf_xgriddistgrids->proc~esmf_logfoundallocerror proc~esmf_logfounderror ESMF_LogFoundError proc~esmf_xgriddistgrids->proc~esmf_logfounderror proc~esmf_xgriddg ESMF_XGridDG proc~esmf_xgriddistgrids->proc~esmf_xgriddg proc~esmf_xgriddgoverlay ESMF_XGridDGOverlay proc~esmf_xgriddistgrids->proc~esmf_xgriddgoverlay esmf_breakpoint esmf_breakpoint proc~esmf_logfoundallocerror->esmf_breakpoint proc~esmf_logrc2msg ESMF_LogRc2Msg proc~esmf_logfoundallocerror->proc~esmf_logrc2msg proc~esmf_logwrite ESMF_LogWrite proc~esmf_logfoundallocerror->proc~esmf_logwrite proc~esmf_logfounderror->esmf_breakpoint proc~esmf_logfounderror->proc~esmf_logrc2msg proc~esmf_logfounderror->proc~esmf_logwrite proc~esmf_xgriddg->proc~esmf_logfoundallocerror interface~esmf_distgridcreate ESMF_DistGridCreate proc~esmf_xgriddg->interface~esmf_distgridcreate proc~esmf_xgriddgoverlay->proc~esmf_logfoundallocerror proc~esmf_xgriddgoverlay->proc~esmf_logfounderror proc~esmf_xgriddgoverlay->interface~esmf_distgridcreate proc~esmf_logseterror ESMF_LogSetError proc~esmf_xgriddgoverlay->proc~esmf_logseterror proc~esmf_distgridcreatedb ESMF_DistGridCreateDB interface~esmf_distgridcreate->proc~esmf_distgridcreatedb proc~esmf_distgridcreatedbai ESMF_DistGridCreateDBAI interface~esmf_distgridcreate->proc~esmf_distgridcreatedbai proc~esmf_distgridcreatedbai1d ESMF_DistGridCreateDBAI1D interface~esmf_distgridcreate->proc~esmf_distgridcreatedbai1d proc~esmf_distgridcreatedbai1d1de ESMF_DistGridCreateDBAI1D1DE interface~esmf_distgridcreate->proc~esmf_distgridcreatedbai1d1de proc~esmf_distgridcreatedbai1d1dei8 ESMF_DistGridCreateDBAI1D1DEI8 interface~esmf_distgridcreate->proc~esmf_distgridcreatedbai1d1dei8 proc~esmf_distgridcreatedbf ESMF_DistGridCreateDBF interface~esmf_distgridcreate->proc~esmf_distgridcreatedbf proc~esmf_distgridcreatedbt ESMF_DistGridCreateDBT interface~esmf_distgridcreate->proc~esmf_distgridcreatedbt proc~esmf_distgridcreatedbtf ESMF_DistGridCreateDBTF interface~esmf_distgridcreate->proc~esmf_distgridcreatedbtf proc~esmf_distgridcreatedg ESMF_DistGridCreateDG interface~esmf_distgridcreate->proc~esmf_distgridcreatedg proc~esmf_distgridcreatedgt ESMF_DistGridCreateDGT interface~esmf_distgridcreate->proc~esmf_distgridcreatedgt proc~esmf_distgridcreaterd ESMF_DistGridCreateRD interface~esmf_distgridcreate->proc~esmf_distgridcreaterd proc~esmf_distgridcreaterdf ESMF_DistGridCreateRDF interface~esmf_distgridcreate->proc~esmf_distgridcreaterdf proc~esmf_distgridcreaterdt ESMF_DistGridCreateRDT interface~esmf_distgridcreate->proc~esmf_distgridcreaterdt proc~esmf_distgridcreaterdtf ESMF_DistGridCreateRDTF interface~esmf_distgridcreate->proc~esmf_distgridcreaterdtf c_esmc_loggeterrormsg c_esmc_loggeterrormsg proc~esmf_logrc2msg->c_esmc_loggeterrormsg proc~esmf_logseterror->esmf_breakpoint proc~esmf_logseterror->proc~esmf_logrc2msg proc~esmf_logseterror->proc~esmf_logwrite c_esmc_vmwtime c_esmc_vmwtime proc~esmf_logwrite->c_esmc_vmwtime proc~esmf_logclose ESMF_LogClose proc~esmf_logwrite->proc~esmf_logclose proc~esmf_logflush ESMF_LogFlush proc~esmf_logwrite->proc~esmf_logflush proc~esmf_logopenfile ESMF_LogOpenFile proc~esmf_logwrite->proc~esmf_logopenfile proc~esmf_utiliounitflush ESMF_UtilIOUnitFlush proc~esmf_logwrite->proc~esmf_utiliounitflush proc~esmf_utilstring2array ESMF_UtilString2Array proc~esmf_logwrite->proc~esmf_utilstring2array

Called by

proc~~esmf_xgriddistgrids~~CalledByGraph proc~esmf_xgriddistgrids ESMF_XGridDistGrids proc~esmf_xgridconstruct ESMF_XGridConstruct proc~esmf_xgridconstruct->proc~esmf_xgriddistgrids proc~esmf_xgridcreate ESMF_XGridCreate proc~esmf_xgridcreate->proc~esmf_xgridconstruct proc~esmf_xgridcreatefromsparsemat ESMF_XGridCreateFromSparseMat proc~esmf_xgridcreatefromsparsemat->proc~esmf_xgridconstruct

Source Code

subroutine ESMF_XGridDistGrids(xgtype, rc)

!
! !ARGUMENTS:
    type(ESMF_XGridType), intent(inout) :: xgtype
    integer, intent(out), optional      :: rc

!
! !DESCRIPTION:
!      Create the distgrids for the {ESMF\_XGridType} object
!
!     The arguments are:
!     \begin{description}
!     \item [xgtype]
!           the {ESMF\_XGridType} object.
!     \item [{[rc]}]
!           Return code; equals {\tt ESMF\_SUCCESS} only if successful.
!     \end{description}
!
!EOPI

    integer :: i, ngrid, localrc

    ! Initialize
    localrc = ESMF_RC_NOT_IMPL

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

    ! create the A side distgrids
    if(associated(xgtype%sparseMatA2X)) then
        ngrid = size(xgtype%sideA, 1)
        allocate(xgtype%distgridA(ngrid), stat=localrc)
        if (ESMF_LogFoundAllocError(localrc, &
            msg="- Allocating xgtype%distgridA(ngrid) ", &
            ESMF_CONTEXT, rcToReturn=rc)) return
        do i = 1, ngrid
            call ESMF_XGridDG(xgtype%sideA(i), xgtype%distgridA(i), &
                xgtype%sparseMatA2X(i)%factorIndexList, 2, rc=localrc)
            if (ESMF_LogFoundError(localrc, &
                ESMF_ERR_PASSTHRU, &
                ESMF_CONTEXT, rcToReturn=rc)) return
        enddo
    endif

    ! if A2X is not provided and X2A is provided
    ! compute A side distgrids based on X2A 
    if(.not. associated(xgtype%sparseMatA2X) .and. &
        associated(xgtype%sparseMatX2A)) then
        ngrid = size(xgtype%sideA, 1)
        allocate(xgtype%distgridA(ngrid), stat=localrc)
        if (ESMF_LogFoundAllocError(localrc, &
            msg="- Allocating xgtype%distgridA(ngrid) ", &
            ESMF_CONTEXT, rcToReturn=rc)) return
        do i = 1, ngrid
            call ESMF_XGridDG(xgtype%sideA(i), xgtype%distgridA(i), &
                xgtype%sparseMatX2A(i)%factorIndexList, 1, rc=localrc)
            if (ESMF_LogFoundError(localrc, &
                ESMF_ERR_PASSTHRU, &
                ESMF_CONTEXT, rcToReturn=rc)) return
        enddo
    endif

    ! create the B side distgrids
    if(associated(xgtype%sparseMatB2X)) then
        ngrid = size(xgtype%sideB, 1)
        allocate(xgtype%distgridB(ngrid), stat=localrc)
        if (ESMF_LogFoundAllocError(localrc, &
            msg="- Allocating xgtype%distgridB(ngrid) ", &
            ESMF_CONTEXT, rcToReturn=rc)) return
        do i = 1, ngrid
            call ESMF_XGridDG(xgtype%sideB(i), xgtype%distgridB(i), &
                xgtype%sparseMatB2X(i)%factorIndexList, 2, rc=localrc)
            if (ESMF_LogFoundError(localrc, &
                ESMF_ERR_PASSTHRU, &
                ESMF_CONTEXT, rcToReturn=rc)) return
        enddo
    endif

    ! if B2X is not provided and X2B is provided
    ! compute B side distgrids based on X2B 
    if(.not. associated(xgtype%sparseMatB2X) .and. &
        associated(xgtype%sparseMatX2B)) then
        ngrid = size(xgtype%sideB, 1)
        allocate(xgtype%distgridB(ngrid), stat=localrc)
        if (ESMF_LogFoundAllocError(localrc, &
            msg="- Allocating xgtype%distgridB(ngrid) ", &
            ESMF_CONTEXT, rcToReturn=rc)) return
        do i = 1, ngrid
            call ESMF_XGridDG(xgtype%sideB(i), xgtype%distgridB(i), &
                xgtype%sparseMatX2B(i)%factorIndexList, 1, rc=localrc)
            if (ESMF_LogFoundError(localrc, &
                ESMF_ERR_PASSTHRU, &
                ESMF_CONTEXT, rcToReturn=rc)) return
        enddo
    endif

    ! use the union of A2X indices to create the balanced distgrid
    if(associated(xgtype%sparseMatA2X)) then
        xgtype%distgridM = ESMF_XGridDGOverlay(xgtype%sparseMatA2X, 2, rc=localrc)
        if (ESMF_LogFoundError(localrc, &
            ESMF_ERR_PASSTHRU, &
            ESMF_CONTEXT, rcToReturn=rc)) return
    endif

    ! if A2X is not provided and X2A is provided
    ! use the union of X2A indices to create the balanced distgrid
    if(.not. associated(xgtype%sparseMatA2X) .and. &
        associated(xgtype%sparseMatX2A)) then
        xgtype%distgridM = ESMF_XGridDGOverlay(xgtype%sparseMatX2A, 1, rc=localrc)
        if (ESMF_LogFoundError(localrc, &
            ESMF_ERR_PASSTHRU, &
            ESMF_CONTEXT, rcToReturn=rc)) return
    endif

    ! use the union of B2X indices to create the balanced distgrid
    if(.not. associated(xgtype%sparseMatA2X) .and. &
       .not. associated(xgtype%sparseMatX2A) .and. &
        associated(xgtype%sparseMatB2X)) then
        xgtype%distgridM = ESMF_XGridDGOverlay(xgtype%sparseMatB2X, 2, rc=localrc)
        if (ESMF_LogFoundError(localrc, &
            ESMF_ERR_PASSTHRU, &
            ESMF_CONTEXT, rcToReturn=rc)) return
    endif

    ! use the union of X2B indices to create the balanced distgrid
    if(.not. associated(xgtype%sparseMatA2X) .and. &
       .not. associated(xgtype%sparseMatX2A) .and. &
       .not. associated(xgtype%sparseMatB2X) .and. &
        associated(xgtype%sparseMatX2B)) then
        xgtype%distgridM = ESMF_XGridDGOverlay(xgtype%sparseMatX2B, 1, rc=localrc)
        if (ESMF_LogFoundError(localrc, &
            ESMF_ERR_PASSTHRU, &
            ESMF_CONTEXT, rcToReturn=rc)) return
    endif

    !if(.not. associated(xgtype%sparseMatA2X) .and. &
    !   .not. associated(xgtype%sparseMatX2A) .and. &
    !   .not. associated(xgtype%sparseMatB2X) .and. &
    !   .not. associated(xgtype%sparseMatX2B)) then
    !    call ESMF_LogSetError(rcToCheck=ESMF_RC_OBJ_BAD, &
    !       "- one of the sparse matrix arguments must be specified", &
    !       ESMF_CONTEXT, rcToReturn=rc) 
    !    return

    !endif

    if(present(rc)) rc = ESMF_SUCCESS

end subroutine ESMF_XGridDistGrids