ESMF_GridFillStaggerCoordsUfrm Subroutine

private subroutine ESMF_GridFillStaggerCoordsUfrm(grid, minCornerCoord, maxCornerCoord, staggerloc, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_Grid), intent(in) :: grid
real(kind=ESMF_KIND_R8), intent(in) :: minCornerCoord(:)
real(kind=ESMF_KIND_R8), intent(in) :: maxCornerCoord(:)
type(ESMF_StaggerLoc), intent(in) :: staggerloc
integer, intent(out), optional :: rc

Calls

proc~~esmf_gridfillstaggercoordsufrm~~CallsGraph proc~esmf_gridfillstaggercoordsufrm ESMF_GridFillStaggerCoordsUfrm interface~esmf_gridaddcoord ESMF_GridAddCoord proc~esmf_gridfillstaggercoordsufrm->interface~esmf_gridaddcoord interface~esmf_gridget ESMF_GridGet proc~esmf_gridfillstaggercoordsufrm->interface~esmf_gridget interface~esmf_gridgetcoord ESMF_GridGetCoord proc~esmf_gridfillstaggercoordsufrm->interface~esmf_gridgetcoord interface~esmf_staggerlocget ESMF_StaggerLocGet proc~esmf_gridfillstaggercoordsufrm->interface~esmf_staggerlocget proc~esmf_logfounderror ESMF_LogFoundError proc~esmf_gridfillstaggercoordsufrm->proc~esmf_logfounderror proc~esmf_gridaddcoordnovalues ESMF_GridAddCoordNoValues interface~esmf_gridaddcoord->proc~esmf_gridaddcoordnovalues proc~esmf_gridgetdefault ESMF_GridGetDefault interface~esmf_gridget->proc~esmf_gridgetdefault proc~esmf_gridgetplocalde ESMF_GridGetPLocalDe interface~esmf_gridget->proc~esmf_gridgetplocalde proc~esmf_gridgetplocaldepsloc ESMF_GridGetPLocalDePSloc interface~esmf_gridget->proc~esmf_gridgetplocaldepsloc proc~esmf_gridgetpsloc ESMF_GridGetPSloc interface~esmf_gridget->proc~esmf_gridgetpsloc proc~esmf_gridgetpslocptile ESMF_GridGetPSlocPTile interface~esmf_gridget->proc~esmf_gridgetpslocptile proc~esmf_gridgetcoord1dr4 ESMF_GridGetCoord1DR4 interface~esmf_gridgetcoord->proc~esmf_gridgetcoord1dr4 proc~esmf_gridgetcoord1dr8 ESMF_GridGetCoord1DR8 interface~esmf_gridgetcoord->proc~esmf_gridgetcoord1dr8 proc~esmf_gridgetcoord2dr4 ESMF_GridGetCoord2DR4 interface~esmf_gridgetcoord->proc~esmf_gridgetcoord2dr4 proc~esmf_gridgetcoord2dr8 ESMF_GridGetCoord2DR8 interface~esmf_gridgetcoord->proc~esmf_gridgetcoord2dr8 proc~esmf_gridgetcoord3dr4 ESMF_GridGetCoord3DR4 interface~esmf_gridgetcoord->proc~esmf_gridgetcoord3dr4 proc~esmf_gridgetcoord3dr8 ESMF_GridGetCoord3DR8 interface~esmf_gridgetcoord->proc~esmf_gridgetcoord3dr8 proc~esmf_gridgetcoordinfo ESMF_GridGetCoordInfo interface~esmf_gridgetcoord->proc~esmf_gridgetcoordinfo proc~esmf_gridgetcoordintoarray ESMF_GridGetCoordIntoArray interface~esmf_gridgetcoord->proc~esmf_gridgetcoordintoarray proc~esmf_gridgetcoordr4 ESMF_GridGetCoordR4 interface~esmf_gridgetcoord->proc~esmf_gridgetcoordr4 proc~esmf_gridgetcoordr8 ESMF_GridGetCoordR8 interface~esmf_gridgetcoord->proc~esmf_gridgetcoordr8 proc~esmf_staggerlocgetdim ESMF_StaggerLocGetDim interface~esmf_staggerlocget->proc~esmf_staggerlocgetdim esmf_breakpoint esmf_breakpoint proc~esmf_logfounderror->esmf_breakpoint proc~esmf_logrc2msg ESMF_LogRc2Msg proc~esmf_logfounderror->proc~esmf_logrc2msg proc~esmf_logwrite ESMF_LogWrite proc~esmf_logfounderror->proc~esmf_logwrite

Called by

proc~~esmf_gridfillstaggercoordsufrm~~CalledByGraph proc~esmf_gridfillstaggercoordsufrm ESMF_GridFillStaggerCoordsUfrm proc~esmf_gridcreate1peridimufrmb ESMF_GridCreate1PeriDimUfrmB proc~esmf_gridcreate1peridimufrmb->proc~esmf_gridfillstaggercoordsufrm proc~esmf_gridcreate1peridimufrmr ESMF_GridCreate1PeriDimUfrmR proc~esmf_gridcreate1peridimufrmr->proc~esmf_gridfillstaggercoordsufrm proc~esmf_gridcreatenoperidimufrmr ESMF_GridCreateNoPeriDimUfrmR proc~esmf_gridcreatenoperidimufrmr->proc~esmf_gridfillstaggercoordsufrm interface~esmf_gridcreate1peridimufrm ESMF_GridCreate1PeriDimUfrm interface~esmf_gridcreate1peridimufrm->proc~esmf_gridcreate1peridimufrmb interface~esmf_gridcreate1peridimufrm->proc~esmf_gridcreate1peridimufrmr interface~esmf_gridcreatenoperidimufrm ESMF_GridCreateNoPeriDimUfrm interface~esmf_gridcreatenoperidimufrm->proc~esmf_gridcreatenoperidimufrmr

Source Code

  subroutine ESMF_GridFillStaggerCoordsUfrm(grid, &
        minCornerCoord, maxCornerCoord, staggerloc, &
        rc)

    type(ESMF_Grid),           intent(in) :: grid
    real(ESMF_KIND_R8),        intent(in) :: minCornerCoord(:)
    real(ESMF_KIND_R8),        intent(in) :: maxCornerCoord(:)
    type(ESMF_StaggerLoc),     intent(in) :: staggerloc
    integer,                   intent(out), optional :: rc


    integer :: localrc
    integer :: lDE, localDECount
     integer :: clbnd(ESMF_MAXDIM), cubnd(ESMF_MAXDIM), i
    real(ESMF_KIND_R8), pointer :: coordPtr(:)
    integer :: d, dimCount, loc
    real(ESMF_KIND_R8) :: p, p_plus1
    real(ESMF_KIND_R8) :: hcornerIndexDiffR8
    integer :: staggerMinIndex(ESMF_MAXDIM)
    integer :: staggerMaxIndex(ESMF_MAXDIM)
    integer :: hcornerMinIndex(ESMF_MAXDIM)
    integer :: hcornerMaxIndex(ESMF_MAXDIM)
    integer :: centerMinIndex(ESMF_MAXDIM)
    integer :: centerMaxIndex(ESMF_MAXDIM)


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

     ! Get number of local DEs and dimCount
    call ESMF_GridGet(grid, localDECount=localDECount, dimCount=dimCount, rc=localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return

    ! Calculate hypothetical span of corner index space without
    ! padding. To do this get corner min and add number of corners
    ! (which is the number of cells (center stagger) plus 1 in each dimension)
     call ESMF_GridGet(grid,1,ESMF_STAGGERLOC_CENTER, &
         minIndex=centerMinIndex, maxIndex=centerMaxIndex, &
         rc=localrc)
     if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
       ESMF_CONTEXT, rcToReturn=rc)) return

     call ESMF_GridGet(grid,1,ESMF_STAGGERLOC_CORNER, &
         minIndex=hcornerMinIndex, &
         rc=localrc)
     if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
       ESMF_CONTEXT, rcToReturn=rc)) return

     ! Compute hypothetical corner span
      ! use minCorners + off set of number of cells + 1
     do d=1,dimCount
        hcornerMaxIndex(d)=hcornerMinIndex(d)+ &
             (centerMaxIndex(d)-centerMinIndex(d))+1
     enddo

    ! Add coordinates
    call ESMF_GridAddCoord(grid, staggerloc=staggerloc, rc=localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
       ESMF_CONTEXT, rcToReturn=rc)) return


    ! Get the min and max indices for this stagger
    ! Assuming 1 tile (because we're building the grid that way above)
     call ESMF_GridGet(grid,1,staggerloc, &
         minIndex=staggerMinIndex, maxIndex=staggerMaxIndex, &
         rc=localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return


    ! Loop through dimensions setting coordinates
    do d=1,dimCount

       ! Get the location in the cell of this dimension in the stagger
       call ESMF_StaggerLocGet(staggerloc, d, loc, rc=localrc)
       if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
            ESMF_CONTEXT, rcToReturn=rc)) return

       ! Compute width of corner index space
       hcornerIndexDiffR8=REAL(hcornerMaxIndex(d)-hcornerMinIndex(d),ESMF_KIND_R8)

       ! Loop through DEs setting coordinates
       do lDE=0,localDECount-1

          ! Get coordinate memory
          call ESMF_GridGetCoord(grid, localDE=lDE, staggerLoc=staggerloc, coordDim=d, &
               computationalLBound=clbnd, computationalUBound=cubnd, farrayPtr=coordPtr, rc=localrc)
           if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
               ESMF_CONTEXT, rcToReturn=rc)) return


          ! Set each coordinates for this dim
          do i=clbnd(1),cubnd(1)

             ! Compute [0.0,1.0] parametric position of this coord
             p=REAL(i-hcornerMinIndex(d),ESMF_KIND_R8)/hcornerIndexDiffR8

             ! If stagger is in the center of this dim, then compute p in
             ! the center
             if (loc .eq. 0) then
                p_plus1=REAL(i+1-hcornerMinIndex(d),ESMF_KIND_R8)/hcornerIndexDiffR8
                p=(p+p_plus1)/2.0_ESMF_KIND_R8
             endif

              ! Compute value of coord based on parametric position
             coordPtr(i)=minCornerCoord(d)*(1.0-p)+maxCornerCoord(d)*p
          enddo
       enddo
    enddo


    ! Return successfully
    if (present(rc)) rc = ESMF_SUCCESS
  end subroutine ESMF_GridFillStaggerCoordsUfrm