ESMF_GeomCreateGrid Function

private function ESMF_GeomCreateGrid(grid, staggerloc, rc)

Arguments

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

Return Value type(ESMF_Geom)


Source Code

      function ESMF_GeomCreateGrid(grid,staggerloc, rc)
!
! !RETURN VALUE:
      type(ESMF_Geom) :: ESMF_GeomCreateGrid
!
! !ARGUMENTS:
       type(ESMF_Grid),       intent(in)             :: grid
       type(ESMF_StaggerLoc), intent(in), optional   :: staggerloc
       integer,               intent(out), optional  :: rc
!
! !DESCRIPTION:
! Create an {\tt ESMF\_Geom} object from an {\tt ESMF\_Grid} object.
!
! The arguments are:
! \begin{description}
! \item[grid]
!      {\tt ESMF\_Grid} object from which to create the Geom.
! \item [{[staggerloc]}]
!       Stagger location of data in grid cells.  For valid
!       predefined values see section \ref{const:staggerloc}.
!       If not specified, defaults to {\tt ESMF\_STAGGERLOC\_CENTER}.
! \item[{[rc]}]
!      Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
! \end{description}
!
!EOP
    type(ESMF_GeomClass),pointer :: gbcp
    type(ESMF_StaggerLoc)  :: localStaggerLoc
    integer :: localrc ! local error status

    ! Initialize return code; assume failure until success is certain
    localrc = ESMF_RC_NOT_IMPL
    if (present(rc)) rc = ESMF_RC_NOT_IMPL
       
    ! Check init status of arguments
    ESMF_INIT_CHECK_DEEP_SHORT(ESMF_GridGetInit, grid, rc)

    ! Set default staggerloc
    if (present(staggerloc)) then   
       localStaggerloc=staggerloc
    else
       localStaggerLoc = ESMF_STAGGERLOC_CENTER
    endif


    ! initialize pointers
    nullify(gbcp)
    nullify(ESMF_GeomCreateGrid%gbcp)

    ! allocate Geom type
    allocate(gbcp, stat=localrc)
    if (ESMF_LogFoundAllocError(localrc, msg="Allocating Geom type object", &
                                     ESMF_CONTEXT, rcToReturn=rc)) return

    ! Set values in Geom
    gbcp%type = ESMF_GEOMTYPE_GRID
    gbcp%grid = grid
    gbcp%staggerloc = localStaggerloc

    ! Set Geom Type into Geom
     ESMF_GeomCreateGrid%gbcp=>gbcp

    ! Set init status
    ESMF_INIT_SET_CREATED(ESMF_GeomCreateGrid)

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

    end function ESMF_GeomCreateGrid