ESMF_MeshCreateEasyElems1Type Function

private function ESMF_MeshCreateEasyElems1Type(parametricDim, coordSys, elementIds, elementType, elementCornerCoords, elementMask, elementArea, elementCoords, elementDistgrid, rc)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: parametricDim
type(ESMF_CoordSys_Flag), intent(in), optional :: coordSys
integer, intent(in), optional :: elementIds(:)
integer, intent(in) :: elementType
real(kind=ESMF_KIND_R8), intent(in) :: elementCornerCoords(:,:,:)
integer, intent(in), optional :: elementMask(:)
real(kind=ESMF_KIND_R8), intent(in), optional :: elementArea(:)
real(kind=ESMF_KIND_R8), intent(in), optional :: elementCoords(:,:)
type(ESMF_DistGrid), intent(in), optional :: elementDistgrid
integer, intent(out), optional :: rc

Return Value type(ESMF_Mesh)


Source Code

    function  ESMF_MeshCreateEasyElems1Type(parametricDim, coordSys, &
                   elementIds, elementType, elementCornerCoords, &
                   elementMask, elementArea, elementCoords, &
                   elementDistgrid, rc)
!
!
! !RETURN VALUE:
    type(ESMF_Mesh) :: ESMF_MeshCreateEasyElems1Type
! !ARGUMENTS:
    integer,                  intent(in)            :: parametricDim
    type(ESMF_CoordSys_Flag), intent(in),  optional :: coordSys
    integer,                  intent(in),  optional :: elementIds(:)
    integer,                  intent(in)            :: elementType
    real(ESMF_KIND_R8),       intent(in)            :: elementCornerCoords(:,:,:)
    integer,                  intent(in),  optional :: elementMask(:)
    real(ESMF_KIND_R8),       intent(in),  optional :: elementArea(:)
    real(ESMF_KIND_R8),       intent(in),  optional :: elementCoords(:,:)
    type(ESMF_DistGrid),      intent(in),  optional :: elementDistgrid
    integer,                  intent(out), optional :: rc
!
! !DESCRIPTION:
!   Create a Mesh object in one step by just specifying the corner coordinates of each element.
!   Internally these corners are turned into nodes forming the outside edges of the elements.
!   This call assumes that each element is the same type to make the specification of the elements
!   a bit easier.
!   After this call the Mesh is usable, for
!   example, a Field may be built on the created Mesh object and
!   this Field may be used in {\tt ESMF\_FieldRegridStore()}. However, the Mesh created by this
!   call consists of a set of disconnected elements, and so shouldn't be used in a situation where
!   connections between elements are necessary (e.g. bilinear regridding on element centers, patch regridding,
!   or second-order conservative regridding). 
!
!   This call sets the dimension of the elements in the Mesh
!   via {\tt parametricDim} and the number of coordinate dimensions in the mesh
!   is determined from the first dimension of {\tt elementCornerCoords}.
!
!   The parameters to this call {\tt elementIds}, {\tt elementTypes}, and
!   {\tt elementCornerCoords} describe the elements to be created. The description
!   for a particular element lies at the same index location in {\tt elementIds}
!   and {\tt elementTypes}. The argument {\tt elementCornerCoords} contains the coordinates of the
!   corners used to create each element. The first dimension of this argument are across the coordinate dimensions.
!   The second dimension of this argument is across the corners of a
!   particular element. The last dimension of this argument is across the list
!   of elements on this PET, so the coordinates of corner c in element e on this PET
!   would be in {\tt elementCornerCoords(:,c,e)}.
!
!   This call is {\em collective} across the current VM.
!
!   \begin{description}
!   \item [parametricDim]
!         Dimension of the topology of the Mesh. (E.g. a mesh constructed of squares would
!         have a parametric dimension of 2, whereas a Mesh constructed of cubes would have one
!         of 3.)
!   \item[{[coordSys]}]
!         The coordinate system of the grid coordinate data.
!         For a full list of options, please see Section~\ref{const:coordsys}.
!         If not specified then defaults to ESMF\_COORDSYS\_SPH\_DEG.
!   \item [{[elementIds]}]
!          An array containing the global ids of the elements to be created on this PET.
!          This input consists of a 1D array the size of the number of elements on this PET.
!          Each element id must be a number equal to or greater than 1. An id should be
!          unique in the sense that different elements must have different ids (the same element
!          that appears on different processors must have the same id). There may be gaps in the sequence
!          of ids, but if these gaps are the same scale as the length of the sequence it can lead to
!          inefficiencies when the Mesh is used (e.g. in {\tt ESMF\_FieldRegridStore()}).
!          If not specified, then elements are numbered in sequence starting with the first element
!          on PET 0.
!   \item[elementType]
!          An variable containing the type of the elements to be created in this Mesh. The type used
!          must be appropriate for the parametric dimension of the Mesh. Please see
!          Section~\ref{const:meshelemtype} for the list of options.
!   \item[elementCornerCoords]
!         A 3D array containing the coordinates of the corners of the elements
!         to be created on this PET. The first dimension of this array is for the
!         coordinates and should be of size 2 or 3. The size of this dimension will be
!         used to determine the spatialDim of the Mesh. The second dimension is the number
!         of corners for an element. The 3rd dimension is a list of all the elements on this PET.
!   \item [{[elementMask]}]
!          An array containing values which can be used for element masking. Which values indicate
!          masking are chosen via the {\tt srcMaskValues} or {\tt dstMaskValues} arguments to
!          {\tt ESMF\_FieldRegridStore()} call. This input consists of a 1D array the
!          size of the number of elements on this PET.
!   \item [{[elementArea]}]
!          An array containing element areas. If not specified, the element areas are internally calculated.
!          This input consists of a 1D array the size of the number of elements on this PET.
!          {\bf NOTE:} ESMF doesn't currently do unit conversion on areas. If these areas are going to be used
!                in a process that also involves the areas of another Grid or Mesh (e.g. conservative regridding), then
!                it is the user's responsibility to make sure that the area units are consistent between the two sides.
!                If ESMF calculates an area on the surface of a sphere, then it is in units of square radians. If
!                it calculates the area for a Cartesian grid, then it is in the same units as the coordinates, but squared.
!   \item[{[elementCoords]}]
!          An array containing the physical coordinates of the elements to be created on this
!          PET. This input consists of a 2D array with the first dimension that same size as the first dimension of {\tt elementCornerCoords}.
!          The second dimension should be the same size as the {\tt elementTypes} argument.
!   \item [{[elementDistgrid]}]
!          If present, use this as the element Distgrid for the Mesh.
!          The passed in Distgrid
!          needs to contain a local set of sequence indices matching the set of local element ids (i.e. those in {\tt elementIds}).
!          However, specifying an externally created Distgrid gives the user more control over aspects of
!          the Distgrid containing those sequence indices (e.g. how they are broken into DEs).
!          If not present, a 1D Distgrid will be created internally consisting of one DE per PET.
!   \item [{[rc]}]
!         Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
!   \end{description}
!
!EOP
!------------------------------------------------------------------------------
    integer                 :: localrc      ! local return code
    integer                 :: num_elems, num_elemCorners,spatialDim
    integer, allocatable    :: elementTypes(:)

    ! initialize return code; assume routine not implemented
    localrc = ESMF_RC_NOT_IMPL
    if (present(rc)) rc = ESMF_RC_NOT_IMPL

    ! This is just a simple wrapper function, so most error
    ! checking happens inside ESMF_MeshCreateEasyElems()

    ! Get number of spatial dimensions
    spatialDim=size(elementCornerCoords,1)
    num_elemCorners=size(elementCornerCoords,2)
    num_elems = size(elementCornerCoords,3)

    ! Create elem type array
    allocate(elementTypes(num_elems))
    elementTypes=elementType

    ! Call into more general function
    ESMF_MeshCreateEasyElems1Type= &
         ESMF_MeshCreateEasyElemsGen(parametricDim, coordSys, &
                   elementIds, elementTypes, &
                   reshape(elementCornerCoords,(/spatialDim,num_elemCorners*num_elems/)), &
                   elementMask, elementArea, elementCoords, &
                   elementDistgrid, rc)

    ! deallocate array
    deallocate(elementTypes)

  end function ESMF_MeshCreateEasyElems1Type