checkGrid Subroutine

private subroutine checkGrid(grid, staggerloc, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_Grid) :: grid
type(ESMF_StaggerLoc) :: staggerloc
integer, intent(out), optional :: rc

Calls

proc~~checkgrid~2~~CallsGraph proc~checkgrid~2 checkGrid interface~esmf_gridget ESMF_GridGet proc~checkgrid~2->interface~esmf_gridget proc~esmf_gridgetdecomptype ESMF_GridGetDecompType proc~checkgrid~2->proc~esmf_gridgetdecomptype proc~esmf_logfounderror ESMF_LogFoundError proc~checkgrid~2->proc~esmf_logfounderror proc~esmf_logseterror ESMF_LogSetError proc~checkgrid~2->proc~esmf_logseterror 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_gridgetdecomptype->proc~esmf_logfounderror c_esmc_gridgetdecomptype c_esmc_gridgetdecomptype proc~esmf_gridgetdecomptype->c_esmc_gridgetdecomptype 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 proc~esmf_logseterror->esmf_breakpoint proc~esmf_logseterror->proc~esmf_logrc2msg proc~esmf_logseterror->proc~esmf_logwrite

Called by

proc~~checkgrid~2~~CalledByGraph proc~checkgrid~2 checkGrid proc~esmf_xgridcreate ESMF_XGridCreate proc~esmf_xgridcreate->proc~checkgrid~2 proc~f_esmf_xgridcreate f_esmf_xgridcreate proc~f_esmf_xgridcreate->proc~esmf_xgridcreate proc~test2d_masking_single test2d_masking_single proc~test2d_masking_single->proc~esmf_xgridcreate proc~test3d_masking_global test3d_masking_global proc~test3d_masking_global->proc~esmf_xgridcreate proc~test3d_masking_regional test3d_masking_regional proc~test3d_masking_regional->proc~esmf_xgridcreate proc~test4 test4 proc~test4->proc~esmf_xgridcreate proc~test5 test5 proc~test5->proc~esmf_xgridcreate proc~test6 test6 proc~test6->proc~esmf_xgridcreate proc~test7 test7 proc~test7->proc~esmf_xgridcreate proc~test8 test8 proc~test8->proc~esmf_xgridcreate proc~test_cart_bilinear_xgrid test_cart_bilinear_xgrid proc~test_cart_bilinear_xgrid->proc~esmf_xgridcreate proc~test_cartmeshtomesh_2nd test_CartMeshToMesh_2nd proc~test_cartmeshtomesh_2nd->proc~esmf_xgridcreate proc~test_csgridtogrid_2nd test_CSGridToGrid_2nd proc~test_csgridtogrid_2nd->proc~esmf_xgridcreate proc~test_meshtomesh_2nd test_MeshToMesh_2nd proc~test_meshtomesh_2nd->proc~esmf_xgridcreate proc~test_regrid2xg_online test_regrid2xg_online proc~test_regrid2xg_online->proc~esmf_xgridcreate proc~test_regrid2xgsph~2 test_regrid2xgSph proc~test_regrid2xgsph~2->proc~esmf_xgridcreate proc~test_side_and_elem_info test_side_and_elem_info proc~test_side_and_elem_info->proc~esmf_xgridcreate proc~test_sph_bilinear_xgrid test_sph_bilinear_xgrid proc~test_sph_bilinear_xgrid->proc~esmf_xgridcreate proc~test_xgrid_w_ngon_mesh test_xgrid_w_ngon_mesh proc~test_xgrid_w_ngon_mesh->proc~esmf_xgridcreate proc~user_init~7 user_init proc~user_init~7->proc~esmf_xgridcreate proc~user_init~9 user_init proc~user_init~9->proc~esmf_xgridcreate program~esmf_xgridex ESMF_XGridEx program~esmf_xgridex->proc~esmf_xgridcreate program~esmf_xgridutest ESMF_XGridUTest program~esmf_xgridutest->proc~esmf_xgridcreate program~esmf_xgridutest->proc~test4 program~esmf_xgridutest->proc~test5 program~esmf_xgridutest->proc~test6 program~esmf_xgridutest->proc~test7 program~esmf_xgridutest->proc~test8 program~esmf_xgridutest->proc~test_cartmeshtomesh_2nd program~esmf_xgridutest->proc~test_csgridtogrid_2nd program~esmf_xgridutest->proc~test_meshtomesh_2nd program~esmf_xgridutest->proc~test_side_and_elem_info program~esmf_xgridutest->proc~test_xgrid_w_ngon_mesh program~esmf_xgridmaskingutest ESMF_XGridMaskingUTest program~esmf_xgridmaskingutest->proc~test2d_masking_single program~esmf_xgridmaskingutest->proc~test3d_masking_global program~esmf_xgridmaskingutest->proc~test3d_masking_regional

Source Code

subroutine checkGrid(grid,staggerloc,rc)
!
! !ARGUMENTS:
    type (ESMF_Grid) :: grid
    type(ESMF_StaggerLoc) :: staggerloc
    integer, intent(out), optional :: rc
!
! !DESCRIPTION:
!      Check the grid to make sure it can be used to create XGrid
!
!     The arguments are:
!     \begin{description}
!     \item [grid]
!           the {\tt ESMF\_Grid} object.
!     \item [staggerloc]
!           the {\tt ESMF\_STAGGERLOC} object.
!     \item [{[rc]}]
!           Return code; equals {\tt ESMF\_SUCCESS} only if successful.
!     \end{description}
!
!EOPI
    type(ESMF_GridDecompType) :: decompType
    integer :: localDECount, lDE, ec(ESMF_MAXDIM)
    integer :: localrc, i, dimCount

    if (present(rc)) rc = ESMF_RC_NOT_IMPL

    ! Make sure Grid isn't arbitrarily distributed
    call ESMF_GridGetDecompType(grid, decompType, rc=localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT, rcToReturn=rc)) return

   ! Error if decompType is ARBITRARY
   if (decompType .eq. ESMF_GRID_ARBITRARY) then
         call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_BAD, & 
             msg="- can't currently regrid an arbitrarily distributed Grid", & 
             ESMF_CONTEXT, rcToReturn=rc) 
          return
   endif        

   ! Make sure Grid doesn't contain width 1 DEs
   call ESMF_GridGet(grid,localDECount=localDECount, dimCount=dimCount, &
          rc=localrc)
   if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT, rcToReturn=rc)) return

   if (dimCount .ne. 2) then
         call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_BAD, & 
         msg="- can currently only create xgrid on 2D grids", & 
         ESMF_CONTEXT, rcToReturn=rc) 
      return
    endif
   
   ! loop through checking DEs
   do lDE=0,localDECount-1
       
       ! Get bounds of DE
       call ESMF_GridGet(grid,staggerloc=staggerloc, localDE=lDE, &
              exclusivecount=ec,rc=localrc)
       if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
           ESMF_CONTEXT, rcToReturn=rc)) return

       ! loop and make sure they aren't too small in any dimension
       do i=1,dimCount
          if (ec(i) .lt. 2) then
             call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_BAD, & 
          msg="- can't currently regrid a grid that contains a DE of width less than 2", & 
             ESMF_CONTEXT, rcToReturn=rc) 
          return
          endif
       enddo
   enddo

   if(present(rc)) rc = ESMF_SUCCESS
end subroutine checkGrid