getPointListOnFieldLoc Subroutine

private subroutine getPointListOnFieldLoc(field, maskValues, addOrigCoords, createdTmpPointList, pointlist, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_Field), intent(in) :: field
integer(kind=ESMF_KIND_I4), intent(in), optional :: maskValues(:)
logical, intent(in), optional :: addOrigCoords
logical, intent(out) :: createdTmpPointList
type(ESMF_PointList), intent(out) :: pointlist
integer, intent(out), optional :: rc

Source Code

    subroutine getPointListOnFieldLoc(field, maskValues, addOrigCoords, &
         createdTmpPointList, pointlist, rc)

      type(ESMF_Field), intent(in)  :: field
      integer(ESMF_KIND_I4), intent(in),  optional :: maskValues(:)
      logical, intent(in), optional :: addOrigCoords
      logical,          intent(out) :: createdTmpPointList
      type(ESMF_PointList),  intent(out) :: pointlist
      integer,          intent(out),   optional :: rc 
      
      integer :: localrc
      type(ESMF_GeomType_Flag)  :: geomtype
      type(ESMF_Grid)      :: grid
      type(ESMF_Mesh)      :: tmpMesh
      type(ESMF_MeshLoc)   :: meshloc
      type(ESMF_StaggerLoc) :: staggerLoc
      type(ESMF_LocStream)  :: tmpLocStream
      type(ESMF_XGrid)      :: xgrid

      ! Init variable
      createdTmpPointList=.false.

      ! Get information from field that we need to create the mesh
      call ESMF_FieldGet(field, geomtype=geomtype, rc=localrc)
      if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
           ESMF_CONTEXT, rcToReturn=rc)) return
                
      ! Get the mesh based on the geomtype
      if (geomtype .eq. ESMF_GEOMTYPE_GRID) then

         ! Get information about Grid from Field
         call ESMF_FieldGet(field, grid=grid, &
              staggerloc=staggerloc, rc=localrc)
         if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
              ESMF_CONTEXT, rcToReturn=rc)) return
         
         ! Check Grid
         call checkGridLite(grid,staggerloc,rc=localrc)
         if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
              ESMF_CONTEXT, rcToReturn=rc)) return
              
         ! Create PointList
         pointlist=ESMF_PointListCreate(grid,staggerloc, &
              maskValues=maskValues, addOrigCoords=addOrigCoords, &
              rc=localrc)
         if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
              ESMF_CONTEXT, rcToReturn=rc)) return
      
         ! Record that we created the PointList
         createdTmpPointList=.true.

      else if (geomtype .eq. ESMF_GEOMTYPE_MESH) then

         ! Get information about mesh from field
          call ESMF_FieldGet(field, mesh=tmpMesh, meshloc=meshloc, rc=localrc)
          if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
            ESMF_CONTEXT, rcToReturn=rc)) return

          ! Create PointList from Mesh
          pointlist=ESMF_PointListCreate(tmpMesh, meshloc, addOrigCoords=addOrigCoords, &
               maskValues=maskValues, &
               rc=localrc)
          if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
               ESMF_CONTEXT, rcToReturn=rc)) return

         ! Record that we created the PointList
         createdTmpPointList=.true.
             
       else if (geomtype .eq. ESMF_GEOMTYPE_XGRID) then

          ! Get information about XGrid from field
          call ESMF_FieldGet(field, xgrid=xgrid, rc=localrc)
          if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
               ESMF_CONTEXT, rcToReturn=rc)) return
          
          ! Get XGrid Mesh
          call ESMF_XGridGet(xgrid, mesh=tmpMesh, rc=localrc)
          if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
               ESMF_CONTEXT, rcToReturn=rc)) return

          ! Create PointList from Mesh
          ! (Until we have an XGrid location indicator, assume center/element) 
          pointlist=ESMF_PointListCreate(tmpMesh, ESMF_MESHLOC_ELEMENT, addOrigCoords=addOrigCoords, &
               maskValues=maskValues, &
               rc=localrc)
          if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
               ESMF_CONTEXT, rcToReturn=rc)) return

          ! Record that we created the PointList
          createdTmpPointList=.true.

       else if (geomtype .eq. ESMF_GEOMTYPE_LOCSTREAM) then

          ! Get locstream from field
          call ESMF_FieldGet(field, locStream=tmpLocStream, rc=localrc)
          if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
            ESMF_CONTEXT, rcToReturn=rc)) return


          ! Create PointList 
          pointlist=ESMF_PointListCreate(tmpLocStream, &
               maskValues=maskValues, addOrigCoords=addOrigCoords, &
               rc=localrc)          
          if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
               ESMF_CONTEXT, rcToReturn=rc)) return

          ! Record that we created the PointList
          createdTmpPointList=.true.

       else
          call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_BAD, &
               msg=" Unrecognized geometry type in ESMF Field", &
               ESMF_CONTEXT, rcToReturn=rc)
          return
        endif


    end subroutine getPointListOnFieldLoc