ESMF_LogGet Subroutine

public subroutine ESMF_LogGet(log, keywordEnforcer, flush, logmsgAbort, logkindflag, maxElements, trace, fileName, highResTimestampFlag, indentCount, noPrefix, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_Log), intent(in), optional :: log
type(ESMF_KeywordEnforcer), optional :: keywordEnforcer
logical, intent(out), optional :: flush
type(ESMF_LogMsg_Flag), optional, pointer :: logmsgAbort(:)
type(ESMF_LogKind_Flag), intent(out), optional :: logkindflag
integer, intent(out), optional :: maxElements
logical, intent(out), optional :: trace
character(len=*), intent(out), optional :: fileName
logical, intent(out), optional :: highResTimestampFlag
integer, intent(out), optional :: indentCount
logical, intent(out), optional :: noPrefix
integer, intent(out), optional :: rc

Source Code

      subroutine ESMF_LogGet(log, keywordEnforcer,  &
                             flush,    &
                             logmsgAbort, logkindflag, &
                             maxElements, trace, fileName,  &
                             highResTimestampFlag, indentCount,  &
                             noPrefix, rc)
!
! !ARGUMENTS:
!
      type(ESMF_Log),          intent(in),  optional :: log
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
      logical,                 intent(out), optional :: flush
      type(ESMF_LogMsg_Flag),  pointer,     optional :: logmsgAbort(:)
      type(ESMF_LogKind_Flag), intent(out), optional :: logkindflag
      integer,                 intent(out), optional :: maxElements
      logical,                 intent(out), optional :: trace
      character(*),            intent(out), optional :: fileName
      logical,                 intent(out), optional :: highResTimestampFlag
      integer,                 intent(out), optional :: indentCount
      logical,                 intent(out), optional :: noPrefix
      integer,                 intent(out), optional :: rc

! !DESCRIPTION:
!      This subroutine returns properties about a Log object.
!
!      The arguments are:
!      \begin{description}
!
!      \item [{[log]}]
!            An optional {\tt ESMF\_Log} object that can be used instead
!            of the default Log.
!      \item [{[flush]}]
!            Flush flag.
!      \item [{[logmsgAbort]}]
!            Returns an array containing current message halt settings.
!            If the array is not pre-allocated, {\tt ESMF\_LogGet} will
!            allocate an array of the correct size.  If no message types
!            are defined, an array of length zero is returned.  It is the
!            callers responsibility to deallocate the array.
!      \item [{[logkindflag]}]
!            Defines either single or multilog.
!      \item [{[maxElements]}]
!            Maximum number of elements in the Log.
!      \item [{[trace]}]
!            Current setting of the Log call tracing flag.
!      \item [{[fileName]}]
!            Current file name.  When the log has been opened with
!            {\tt ESMF\_LOGKIND\_MULTI}, the filename has a PET number
!            prefix.
!      \item [{[highResTimestampFlag]}]
!            Current setting of the extended elapsed timestamp flag.
!      \item [{[indentCount]}]
!            Current setting of the leading white space padding.
!      \item [{[noPrefix]}]
!            Current setting of the message prefix enable/disable flag.
!      \item [{[rc]}]
!            Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
!      \end{description}
!
!EOP

        type(ESMF_LogPrivate),pointer          :: alog
        integer :: localrc
        integer :: memstat
        integer :: lma_size

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

        ESMF_INIT_CHECK_SET_SHALLOW(ESMF_LogGetInit,ESMF_LogInit,log)

    nullify(alog) ! ensure that the association status is well defined

    if (present(log)) then
      if (log%logTableIndex > 0) then
         alog => ESMF_LogTable(log%logTableIndex)
      endif
    else
      if (ESMF_LogDefault%logTableIndex > 0) then
        alog => ESMF_LogTable(ESMF_LogDefault%logTableIndex)
      end if
    endif

    if (associated(alog)) then

      ESMF_INIT_CHECK_SET_SHALLOW(ESMF_LogPrivateGetInit,ESMF_LogPrivateInit,alog)

        if (present(flush)) then
          flush=alog%flushImmediately
        endif
        if (present(logkindflag)) then
          logkindflag=alog%logkindflag
        endif
        if (present(maxElements)) then
          maxElements=alog%maxElements
        endif
        if (present(trace)) then
          trace=alog%traceFlag
        endif
        if (present(fileName)) then
          fileName=alog%nameLogErrFile
          if (len (fileName) < len_trim (alog%nameLogErrFile)) then
            if (ESMF_LogFoundError (ESMF_RC_LONG_STR,   &
                msg='fileName argument string too short', &
                ESMF_CONTEXT, rcToReturn=rc)) return
          end if
        endif
        if (present (highResTimestampFlag)) then
          highResTimestampFlag = alog%highResTimestampFlag
        endif
        if (present (indentCount)) then
          indentCount = alog%indentCount
        endif
        if (present (noPrefix)) then
          noPrefix = alog%noPrefix
        endif

      ! Return an array with the current values.  If the user has not
      ! pre-allocated an array, do the allocation here.
        if (present(logmsgAbort)) then
          if (associated (alog%logmsgAbort)) then
            lma_size = size (alog%logmsgAbort)
          else
            lma_size = 0
          end if

          if (associated (logmsgAbort)) then
            if (size (logmsgAbort) < lma_size) then
              if (ESMF_LogFoundError (ESMF_RC_ARG_SIZE,   &
                  msg='logmsgAbort array size too small', &
                  ESMF_CONTEXT, rcToReturn=rc)) return
            end if
          else
            allocate (logmsgAbort(lma_size), stat=memstat)
              if (ESMF_LogFoundAllocError (memstat,   &
                  msg='allocating logmsgAbort array', &
                  ESMF_CONTEXT, rcToReturn=rc)) return
          end if

          if (associated (alog%logmsgAbort)) then
            logmsgAbort = alog%logmsgAbort(:lma_size)
          end if
        endif
    endif

    localrc = ESMF_SUCCESS
    if (present(rc)) then
      rc=localrc
    endif

end subroutine ESMF_LogGet