ESMF_LocStreamCreateFromDG Function

private function ESMF_LocStreamCreateFromDG(distgrid, keywordEnforcer, indexflag, coordSys, name, vm, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_DistGrid), intent(in) :: distgrid
type(ESMF_KeywordEnforcer), optional :: keywordEnforcer
type(ESMF_Index_Flag), intent(in), optional :: indexflag
type(ESMF_CoordSys_Flag), intent(in), optional :: coordSys
character(len=*), intent(in), optional :: name
type(ESMF_VM), intent(in), optional :: vm
integer, intent(out), optional :: rc

Return Value type(ESMF_LocStream)


Calls

proc~~esmf_locstreamcreatefromdg~~CallsGraph proc~esmf_locstreamcreatefromdg ESMF_LocStreamCreateFromDG c_esmc_vmaddfobject c_esmc_vmaddfobject proc~esmf_locstreamcreatefromdg->c_esmc_vmaddfobject interface~esmf_distgridget ESMF_DistGridGet proc~esmf_locstreamcreatefromdg->interface~esmf_distgridget proc~esmf_basecreate ESMF_BaseCreate proc~esmf_locstreamcreatefromdg->proc~esmf_basecreate proc~esmf_distgridgetinit ESMF_DistGridGetInit proc~esmf_locstreamcreatefromdg->proc~esmf_distgridgetinit proc~esmf_imerr ESMF_IMErr proc~esmf_locstreamcreatefromdg->proc~esmf_imerr proc~esmf_logfoundallocerror ESMF_LogFoundAllocError proc~esmf_locstreamcreatefromdg->proc~esmf_logfoundallocerror proc~esmf_logfounderror ESMF_LogFoundError proc~esmf_locstreamcreatefromdg->proc~esmf_logfounderror proc~esmf_vmgetthis ESMF_VMGetThis proc~esmf_locstreamcreatefromdg->proc~esmf_vmgetthis proc~esmf_distgridgetdefault ESMF_DistGridGetDefault interface~esmf_distgridget->proc~esmf_distgridgetdefault proc~esmf_distgridgetplocalde ESMF_DistGridGetPLocalDe interface~esmf_distgridget->proc~esmf_distgridgetplocalde proc~esmf_distgridgetplocaldepdim ESMF_DistGridGetPLocalDePDim interface~esmf_distgridget->proc~esmf_distgridgetplocaldepdim proc~esmf_basecreate->proc~esmf_logfounderror c_esmc_basecreate c_esmc_basecreate proc~esmf_basecreate->c_esmc_basecreate proc~esmf_imerr->proc~esmf_logfounderror proc~esmf_initcheckdeep ESMF_InitCheckDeep proc~esmf_imerr->proc~esmf_initcheckdeep esmf_breakpoint esmf_breakpoint proc~esmf_logfoundallocerror->esmf_breakpoint proc~esmf_logrc2msg ESMF_LogRc2Msg proc~esmf_logfoundallocerror->proc~esmf_logrc2msg proc~esmf_logwrite ESMF_LogWrite proc~esmf_logfoundallocerror->proc~esmf_logwrite proc~esmf_logfounderror->esmf_breakpoint proc~esmf_logfounderror->proc~esmf_logrc2msg proc~esmf_logfounderror->proc~esmf_logwrite

Called by

proc~~esmf_locstreamcreatefromdg~~CalledByGraph proc~esmf_locstreamcreatefromdg ESMF_LocStreamCreateFromDG interface~esmf_locstreamcreate ESMF_LocStreamCreate interface~esmf_locstreamcreate->proc~esmf_locstreamcreatefromdg proc~esmf_locstreamcreatefromlocal ESMF_LocStreamCreateFromLocal proc~esmf_locstreamcreatefromlocal->proc~esmf_locstreamcreatefromdg proc~esmf_locstreamcreatefromnewdg ESMF_LocStreamCreateFromNewDG proc~esmf_locstreamcreatefromnewdg->proc~esmf_locstreamcreatefromdg proc~esmf_locstreamcreateirreg ESMF_LocStreamCreateIrreg proc~esmf_locstreamcreateirreg->proc~esmf_locstreamcreatefromdg proc~esmf_locstreamcreatereg ESMF_LocStreamCreateReg proc~esmf_locstreamcreatereg->proc~esmf_locstreamcreatefromdg

Source Code

      function ESMF_LocStreamCreateFromDG(distgrid, keywordEnforcer, &
        indexflag, coordSys, name, vm, rc )
!
! !RETURN VALUE:
      type(ESMF_LocStream) :: ESMF_LocStreamCreateFromDG

 !
! !ARGUMENTS:
      type(ESMF_DistGrid),      intent(in)            :: distgrid
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
      type(ESMF_Index_Flag),    intent(in),  optional :: indexflag    
      type(ESMF_CoordSys_Flag), intent(in),  optional :: coordSys
      character (len=*),        intent(in),  optional :: name
      type(ESMF_VM),            intent(in),  optional :: vm
      integer,                  intent(out), optional :: rc
!
! !DESCRIPTION:
!     Allocates memory for a new {\tt ESMF\_LocStream} object, constructs its
!     internal derived types. 
!
!     The arguments are:
!     \begin{description}
!     \item[distgrid]
!          Distgrid specifying size and distribution. Only 1D distgrids are allowed.
!     \item[{[indexflag]}]
!          Flag that indicates how the DE-local indices are to be defined.
!          Defaults to {\tt ESMF\_INDEX\_DELOCAL}, which indicates
!          that the index range on each DE starts at 1. See Section~\ref{const:indexflag}
!          for the full range of options. 
!     \item[{[coordSys]}]
!         The coordinate system of the location stream 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[{[name]}]
!          Name of the location stream
!     \item[{[vm]}]
!         If present, the LocStream object is created on the specified 
!         {\tt ESMF\_VM} object. The default is to create on the VM of the 
!         current context.
!     \item[{[rc]}]
!          Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
!   \end{description}
!
!EOP

      integer                             :: localrc  ! Error status
      type (ESMF_LocStreamType), pointer  :: lstypep
      type(ESMF_LocStream)                :: locstream 
      integer                             :: dimCount 
      type(ESMF_Index_Flag)               :: indexflagLocal
      type(ESMF_CoordSys_Flag)            :: coordSysLocal
      type(ESMF_Pointer)                  :: vmThis
      logical                             :: actualFlag

      ! Initialize return code; assume failure until success is certain
      if (present(rc)) rc = ESMF_RC_NOT_IMPL

      ! Init check input types
      ESMF_INIT_CHECK_DEEP_SHORT(ESMF_DistGridGetInit,distgrid,rc)      

      ! Must make sure the local PET is associated with an actual member
      actualFlag = .true.
      if (present(vm)) then
        call ESMF_VMGetThis(vm, vmThis)
        if (vmThis == ESMF_NULL_POINTER) then
          actualFlag = .false.  ! local PET is not for an actual member of Array
        endif
      endif

      if (actualFlag) then
        ! only actual member PETs worry about the DistGrid
      
        ! Make sure DistGrid is 1D
        call ESMF_DistGridGet(distgrid, dimCount=dimCount, rc=localrc)
        if (ESMF_LogFoundError(localrc, &
                                ESMF_ERR_PASSTHRU, &
                                ESMF_CONTEXT, rcToReturn=rc)) return
        if (dimCount .ne. 1) then
          if (ESMF_LogFoundError(ESMF_RC_ARG_RANK, &
            msg=" - DistGrid must be 1D", &
            ESMF_CONTEXT, rcToReturn=rc)) return
        endif

      endif

      ! Initialize pointers
      nullify(lstypep)
      nullify(ESMF_LocStreamCreateFromDG%lstypep)

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

      ! Initialize key member variables
      nullify(lstypep%keyNames)
      nullify(lstypep%keyUnits)
      nullify(lstypep%keyLongNames)
      nullify(lstypep%keys)
      nullify(lstypep%destroyKeys)

      ! Set defaults
      if (present(indexflag)) then
        indexflagLocal=indexflag
      else
        indexflagLocal=ESMF_INDEX_DELOCAL
      endif

      if (present(coordSys)) then
        coordSysLocal=coordSys
      else
        coordSysLocal=ESMF_COORDSYS_SPH_DEG
      endif
      
      ! Set some remaining info into the struct      
      lstypep%indexflag=indexflagLocal
      lstypep%coordSys=coordSysLocal
      lstypep%destroyDistgrid=.false.
      lstypep%keyCount=0

      if (actualFlag) then
        ! only actual member PETs set distgrid
        lstypep%distgrid=distgrid

        ! create base object and set name
        call ESMF_BaseCreate(lstypep%base,"LocStream",name,0,rc=localrc)       
        if (ESMF_LogFoundError(localrc, &
          ESMF_ERR_PASSTHRU, &
          ESMF_CONTEXT, rcToReturn=rc)) return
                              
        ! Set pointer to internal locstream type
        locstream%lstypep=>lstypep

        ! Set return value.
        ESMF_LocStreamCreateFromDG=locstream
      
        ! Add reference to this object into ESMF garbage collection table
        ! Only call this in those Create() methods that do not call other LSCreate()
        call c_ESMC_VMAddFObject(locstream, &
          ESMF_ID_LOCSTREAM%objectID)

      endif

      ! set init status to created
      ESMF_INIT_SET_CREATED(ESMF_LocStreamCreateFromDG)
 
      ! return successfully
      if (present(rc)) rc = ESMF_SUCCESS

      end function ESMF_LocStreamCreateFromDG