ESMF_GeomCreateXGrid Function

private function ESMF_GeomCreateXGrid(xgrid, xgridSide, gridIndex, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_XGrid), intent(in) :: xgrid
type(ESMF_XGridSide_Flag), intent(in), optional :: xgridSide
integer, intent(in), optional :: gridIndex
integer, intent(out), optional :: rc

Return Value type(ESMF_Geom)


Source Code

      function ESMF_GeomCreateXGrid(xgrid, xgridside, gridIndex, rc)
!
 ! !RETURN VALUE:
      type(ESMF_Geom) :: ESMF_GeomCreateXGrid
!
! !ARGUMENTS:
       type(ESMF_XGrid),     intent(in)                :: xgrid
       type(ESMF_XGridSide_Flag), intent(in), optional :: xgridSide
       integer,              intent(in), optional      :: gridIndex
       integer,              intent(out),optional      :: rc
!
! !DESCRIPTION:
! Create an {\tt ESMF\_Geom} object from an {\tt ESMF\_XGrid} object.
!
! The arguments are:
! \begin{description}
! \item[xgrid]
!      {\tt ESMF\_XGrid} object from which to create the Geom.
! \item[{[xgridSide]}]
!       Which side of the XGrid to create the Field on (either ESMF\_XGRIDSIDE\_A,
!       ESMF\_XGRIDSIDE\_B, or ESMF\_XGRIDSIDE\_BALANCED). If not specified, then
!       defaults to ESMF\_XGRIDSIDE\_BALANCED.
! \item [{[gridindex]}]
!       If xgridSide is  ESMF\_XGRIDSIDE\_A or ESMF\_XGRIDSIDE\_B then
!       this index tells which Grid or Mesh on that side is being
!       referred to. If not provided, defaults to 1.      
! \item[{[rc]}]
!      Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
! \end{description}
!
!EOP
    type(ESMF_GeomClass),pointer :: gbcp
    integer :: localrc ! local error status
    integer :: localGridIndex
    type(ESMF_XGridSide_Flag) :: localXGridSide

    ! 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_XGridGetInit, xgrid, rc)

    ! Set defaults
    if (present(XGridSide)) then
       localXGridSide=xgridSide
    else
       localXGridSide=ESMF_XGRIDSIDE_BALANCED
    endif

    if (present(gridIndex)) then
       localGridIndex=gridIndex
    else
       localGridIndex=1
    endif

    ! initialize pointers
    nullify(gbcp)
    nullify( ESMF_GeomCreateXGrid%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_XGRID
    gbcp%xgrid = xgrid
    gbcp%xgridside = localXGridSide
    gbcp%xgridIndex = localGridIndex

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

    ! Set init status
    ESMF_INIT_SET_CREATED(ESMF_GeomCreateXGrid)

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

    end function ESMF_GeomCreateXGrid