ESMF_LocStreamAddKeyI4 Subroutine

private subroutine ESMF_LocStreamAddKeyI4(locstream, keyName, farray, keywordEnforcer, datacopyflag, keyUnits, keyLongName, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_LocStream), intent(in) :: locstream
character(len=*), intent(in) :: keyName
integer(kind=ESMF_KIND_I4), intent(in), dimension(:) :: farray
type(ESMF_KeywordEnforcer), optional :: keywordEnforcer
type(ESMF_DataCopy_Flag), intent(in), optional :: datacopyflag
character(len=*), intent(in), optional :: keyUnits
character(len=*), intent(in), optional :: keyLongName
integer, intent(out), optional :: rc

Source Code

  subroutine ESMF_LocStreamAddKeyI4(locstream, keyName, farray, keywordEnforcer, &
       datacopyflag, keyUnits, keyLongName, rc)
!
! !ARGUMENTS:
    type(ESMF_Locstream),                intent(in)            :: locstream
    character (len=*),                   intent(in)            :: keyName
    integer(ESMF_KIND_I4), dimension(:), intent(in)            :: farray
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
    type(ESMF_DataCopy_Flag),            intent(in),  optional :: datacopyflag
    character (len=*),                   intent(in),  optional :: keyUnits 
    character (len=*),                   intent(in),  optional :: keyLongName 
    integer,                             intent(out), optional :: rc
!
! !DESCRIPTION:
!  Add a key to a locstream with a required keyName and a required 
!  Fortran array.  The user is responsible for the creation of the 
!  Fortran array that will hold the key values, including 
!  the maintenance of any allocated memory.
!
! The arguments are:
! \begin{description}
! \item [locstream]
! The {\tt ESMF\_LocStream} object to add key to.
! \item [keyName]
! The name of the key to add. 
! \item[farray] 
! Valid native Fortran array, i.e. memory must be associated with the 
! actual argument. The type/kind/rank information of {\tt farray} will be 
! used to set the key Array's properties accordingly. 
! \item[{[datacopyflag]}] 
! Specifies whether the Array object will reference the memory allocation 
! provided by {\tt farray} directly or will copy the data from 
! {\tt farray} into a new memory allocation. Valid options are 
! {\tt ESMF\_DATACOPY\_REFERENCE} (default) or {\tt ESMF\_DATACOPY\_VALUE}. 
! Depending on the specific situation the {\tt ESMF\_DATACOPY\_REFERENCE} option 
! may be unsafe when specifying an array slice for {\tt farray}. 
! \item [{[keyUnits]}]
! The units of the key data. 
! If not specified, then the item remains blank.  
! \item [{[keyLongName]}]
! The long name of the key data. 
! If not specified, then the item remains blank.  
! \item [{[rc]}]
! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
! \end{description}
!EOPI
!------------------------------------------------------------------------------
    type(ESMF_LocStreamType), pointer :: lstypep
    type(ESMF_Array) :: array
    integer :: localrc

    ! Initialize
    localrc = ESMF_RC_NOT_IMPL
    if (present(rc)) rc = ESMF_RC_NOT_IMPL

    ! check variables
    ESMF_INIT_CHECK_DEEP(ESMF_LocStreamGetInit,locstream,rc)

    ! get the pointer to the locstream
    lstypep => locstream%lstypep

   ! Create Array
   array=ESMF_ArrayCreate(lstypep%distgrid, farray, &
                           datacopyflag=datacopyflag, indexflag=lstypep%indexflag,  &
                           name=keyName, rc=localrc)
   if (ESMF_LogFoundError(localrc, &
         ESMF_ERR_PASSTHRU, &
         ESMF_CONTEXT, rcToReturn=rc)) return


   ! Add key to structure
   call ESMF_LocStreamAddKeyArray(locstream, keyName, keyArray=array, destroyKey=.true., &
               keyUnits=keyUnits, keyLongName=keyLongName, rc=localrc)
   if (ESMF_LogFoundError(localrc, &
         ESMF_ERR_PASSTHRU, &
         ESMF_CONTEXT, rcToReturn=rc)) return


   ! return success
   if (present(rc)) rc = ESMF_SUCCESS

  end subroutine ESMF_LocStreamAddKeyI4