ESMF_LogWrite Subroutine

public recursive subroutine ESMF_LogWrite(msg, logmsgFlag, logmsgList, keywordEnforcer, line, file, method, log, rc)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: msg
type(ESMF_LogMsg_Flag), intent(in), optional :: logmsgFlag
type(ESMF_LogMsg_Flag), intent(in), optional :: logmsgList
type(ESMF_KeywordEnforcer), optional :: keywordEnforcer
integer, intent(in), optional :: line
character(len=*), intent(in), optional :: file
character(len=*), intent(in), optional :: method
type(ESMF_Log), intent(inout), optional :: log
integer, intent(out), optional :: rc

Calls

proc~~esmf_logwrite~~CallsGraph proc~esmf_logwrite ESMF_LogWrite c_esmc_vmwtime c_esmc_vmwtime proc~esmf_logwrite->c_esmc_vmwtime proc~esmf_logclose ESMF_LogClose proc~esmf_logwrite->proc~esmf_logclose proc~esmf_logflush ESMF_LogFlush proc~esmf_logwrite->proc~esmf_logflush proc~esmf_logopenfile ESMF_LogOpenFile proc~esmf_logwrite->proc~esmf_logopenfile proc~esmf_utiliounitflush ESMF_UtilIOUnitFlush proc~esmf_logwrite->proc~esmf_utiliounitflush proc~esmf_utilstring2array ESMF_UtilString2Array proc~esmf_logwrite->proc~esmf_utilstring2array proc~esmf_logclose->proc~esmf_logflush proc~esmf_logflush->proc~esmf_utiliounitflush proc~esmf_utilarray2string ESMF_UtilArray2String proc~esmf_logflush->proc~esmf_utilarray2string proc~esmf_logopenfile->proc~esmf_utiliounitflush proc~esmf_utiliounitget ESMF_UtilIOUnitGet proc~esmf_logopenfile->proc~esmf_utiliounitget

Called by

BuildUpdatePacketswESMF_LogWrite
w
CheckImportw
w
CheckImportw
w
Compliance_LogWritew
w
dataMatchArrayListsw
w
dataMatchR4w
w
dataMatchR8w
w
DetermineSrcDstOverlapw
w
ESMF_AppDriverw
w
ESMF_ArrayArbIdxSMMUTestw
w
ESMF_ArrayCreateGetUTestw
w
ESMF_ArrayRedistUTestw
w
ESMF_AttributeGetAttPackArrayw
w
ESMF_AttributeGetAttPackArrayBundlew
w
ESMF_AttributeGetAttPackArrayBundleCHw
w
ESMF_AttributeGetAttPackArrayBundleI4w
w
ESMF_AttributeGetAttPackArrayBundleI8w
w
ESMF_AttributeGetAttPackArrayBundleLGw
w
ESMF_AttributeGetAttPackArrayBundleR4w
w
ESMF_AttributeGetAttPackArrayBundleR8w
w
ESMF_AttributeGetAttPackArrayCHw
w
ESMF_AttributeGetAttPackArrayI4w
w
ESMF_AttributeGetAttPackArrayI8w
w
ESMF_AttributeGetAttPackArrayLGw
w
ESMF_AttributeGetAttPackArrayR4w
w
ESMF_AttributeGetAttPackArrayR8w
w
ESMF_AttributeGetAttPackCplCompw
w
ESMF_AttributeGetAttPackCplCompCHw
w
ESMF_AttributeGetAttPackCplCompI4w
w
ESMF_AttributeGetAttPackCplCompI8w
w
ESMF_AttributeGetAttPackCplCompLGw
w
ESMF_AttributeGetAttPackCplCompR4w
w
ESMF_AttributeGetAttPackCplCompR8w
w
ESMF_AttributeGetAttPackDistGridw
w
ESMF_AttributeGetAttPackDistGridCHw
w
ESMF_AttributeGetAttPackDistGridI4w
w
ESMF_AttributeGetAttPackDistGridI8w
w
ESMF_AttributeGetAttPackDistGridLGw
w
ESMF_AttributeGetAttPackDistGridR4w
w
ESMF_AttributeGetAttPackDistGridR8w
w
ESMF_AttributeGetAttPackFieldw
w
ESMF_AttributeGetAttPackFieldBundlew
w
ESMF_AttributeGetAttPackFieldBundleCHw
w
ESMF_AttributeGetAttPackFieldBundleI4w
w
ESMF_AttributeGetAttPackFieldBundleI8w
w
ESMF_AttributeGetAttPackFieldBundleLGw
w
ESMF_AttributeGetAttPackFieldBundleR4w
w
ESMF_AttributeGetAttPackFieldBundleR8w
w
ESMF_AttributeGetAttPackFieldCHw
w
ESMF_AttributeGetAttPackFieldI4w
w
ESMF_AttributeGetAttPackFieldI8w
w
ESMF_AttributeGetAttPackFieldLGw
w
ESMF_AttributeGetAttPackFieldR4w
w
ESMF_AttributeGetAttPackFieldR8w
w
ESMF_AttributeGetAttPackGridw
w
ESMF_AttributeGetAttPackGridCHw
w
ESMF_AttributeGetAttPackGridCompw
w
ESMF_AttributeGetAttPackGridCompCHw
w
ESMF_AttributeGetAttPackGridCompI4w
w
ESMF_AttributeGetAttPackGridCompI8w
w
ESMF_AttributeGetAttPackGridCompLGw
w
ESMF_AttributeGetAttPackGridCompR4w
w
ESMF_AttributeGetAttPackGridCompR8w
w
ESMF_AttributeGetAttPackGridI4w
w
ESMF_AttributeGetAttPackGridI8w
w
ESMF_AttributeGetAttPackGridLGw
w
ESMF_AttributeGetAttPackGridR4w
w
ESMF_AttributeGetAttPackGridR8w
w
ESMF_AttributeGetAttPackLocStreamw
w
ESMF_AttributeGetAttPackLocStreamCHw
w
ESMF_AttributeGetAttPackLocStreamI4w
w
ESMF_AttributeGetAttPackLocStreamI8w
w
ESMF_AttributeGetAttPackLocStreamLGw
w
ESMF_AttributeGetAttPackLocStreamR4w
w
ESMF_AttributeGetAttPackLocStreamR8w
w
ESMF_AttributeGetAttPackMeshw
w
ESMF_AttributeGetAttPackMeshCHw
w
ESMF_AttributeGetAttPackMeshI4w
w
ESMF_AttributeGetAttPackMeshI8w
w
ESMF_AttributeGetAttPackMeshLGw
w
ESMF_AttributeGetAttPackMeshR4w
w
ESMF_AttributeGetAttPackMeshR8w
w
ESMF_AttributeGetAttPackSciCompw
w
ESMF_AttributeGetAttPackSciCompCHw
w
ESMF_AttributeGetAttPackSciCompI4w
w
ESMF_AttributeGetAttPackSciCompI8w
w
ESMF_AttributeGetAttPackSciCompLGw
w
ESMF_AttributeGetAttPackSciCompR4w
w
ESMF_AttributeGetAttPackSciCompR8w
w
ESMF_AttributeGetAttPackStatew
w
ESMF_AttributeGetAttPackStateCHw
w
ESMF_AttributeGetAttPackStateI4w
w
ESMF_AttributeGetAttPackStateI8w
w
ESMF_AttributeGetAttPackStateLGw
w
ESMF_AttributeGetAttPackStateR4w
w
ESMF_AttributeGetAttPackStateR8w
w
ESMF_AttributeRemoveAttPackArrayw
w
ESMF_AttributeRemoveAttPackArrayBundlew
w
ESMF_AttributeRemoveAttPackCplCompw
w
ESMF_AttributeRemoveAttPackDistGridw
w
ESMF_AttributeRemoveAttPackFieldw
w
ESMF_AttributeRemoveAttPackFieldBundlew
w
ESMF_AttributeRemoveAttPackGridw
w
ESMF_AttributeRemoveAttPackGridCompw
w
ESMF_AttributeRemoveAttPackLocStreamw
w
ESMF_AttributeRemoveAttPackMeshw
w
ESMF_AttributeRemoveAttPackSciCompw
w
ESMF_AttributeRemoveAttPackStatew
w
ESMF_CompTunnelUTestw
w
ESMF_ConfigLoadFilew
w
ESMF_ConfigLogw
w
ESMF_ConfigValidatew
w
ESMF_DELayoutGetw
w
ESMF_FieldLogw
w
ESMF_FieldRedistStoreNFw
w
ESMF_FieldRegridStoreNXw
w
ESMF_Finalizew
w
ESMF_FrameworkInternalInitw
w
ESMF_GeomDeserializew
w
ESMF_GridCreateFrmNCFilew
w
ESMF_GridCreateFrmNCFileDGw
w
ESMF_HConfigExw
w
ESMF_InfoCacheUTestw
w
ESMF_InfoLogw
w
ESMF_InternalStateExw
w
ESMF_InternalStateUTestw
w
ESMF_IOUTestw
w
ESMF_LogErrExw
w
ESMF_LogErrUTestw
w
ESMF_LogFoundAllocErrorw
w
ESMF_LogFoundDeallocErrorw
w
ESMF_LogFoundErrorw
w
ESMF_LogSetw
w
ESMF_LogSetErrorw
w
ESMF_MeshCreateFromFileOldw
w
ESMF_MeshSetMOABw
w
ESMF_MeshUTestw
w
ESMF_ReconcileSerializew
w
ESMF_RHandleBitForBitExw
w
ESMF_STestw
w
ESMF_Testw
w
ESMF_TestEndw
w
ESMF_TestFileComparew
w
ESMF_TestMaxPETsw
w
ESMF_TestMinPETsw
w
ESMF_TestNumPETsw
w
ESMF_TestStartw
w
ESMF_VMAccUTestw
w
ESMF_VMEpochLargeMsgUTestw
w
ESMF_VMSendNbVMRecvNbUTestw
w
ESMF_VMSendRecvNbUTestw
w
ESMF_VMSendVMRecvUTestw
w
ESMF_VMUTestw
w
ESMFIO_FieldAccessw
w
ESMX_Appw
w
ExecuteRunSequencew
w
f_esmf_logwrite0w
w
f_esmf_logwrite1w
w
FieldBundleCplStorew
w
Finalizew
w
Finalizew
w
Finalizew
w
finalizew
w
FinalizeResetw
w
HConfigIterationTestw
w
IInitCheckw
w
IInitModifyCplListsw
w
IInitRealizew
w
initializew
w
initializew
w
initializew
w
InitializeIPDv02p1w
w
InitializeIPDv02p5w
w
InitializeIPDv02p5Dataw
w
InitializeIPDv05p1w
w
InitializeIPDv05p2aw
w
InitializeIPDv05p2bw
w
InitializeIPDv05p3w
w
InitializeIPDv05p4w
w
InitializeIPDv05p5w
w
InitializeIPDv05p6bw
w
InitializeIPDvXp07w
w
InitializeIPDvXp08w
w
InternalInitializeCompletew
w
JSON_LogWritew
w
JSON_LogWritew
w
loopDataDependentInitializew
w
my_finalw
w
my_finalw
w
my_finalw
w
my_finalw
w
my_initw
w
my_initw
w
my_initw
w
my_initw
w
my_runw
w
my_runw
w
my_runw
w
my_runw
w
NUOPC_CompHandleVerbosityExtrow
w
NUOPC_CompHandleVerbosityIntrow
w
NUOPC_ComplianceLogWritew
w
NUOPC_DriverAddCplCompw
w
NUOPC_DriverAddGridCompw
w
NUOPC_DriverAddGridCompSOw
w
NUOPC_DriverIngestRunSequenceFFw
w
NUOPC_FreeFormatLogw
w
NUOPC_LogExtrow
w
NUOPC_LogIntrow
w
NUOPC_LogPetListw
w
NUOPC_RunElementPrintw
w
NUOPC_RunSequenceArrayPrintw
w
NUOPC_RunSequenceHandleEventw
w
NUOPC_RunSequenceSinglePrintw
w
NUOPC_SetVMw
w
perfLogFoundErrorw
w
routine_Runw
w
routine_Runw
w
Runw
w
runw
w
runw
w
run2w
w
run2w
w
test_slicingw
w
test_smmw
w
test_vm_currentw
w
user2_runw
w
user2_runw
w
user_finalw
w
user_finalw
w
user_initP1w
w
user_initP1w
w
user_initP2w
w
user_initP2w
w
user_initP3w
w
user_initP3w
w
user_runw
w
user_runw
w
user_runw
w
usercpl_registerw
w
userm1_runw
w
userm2_registerw
w
userm2_registerw
w
userm2_registerw
w
userm2_setvmw
w
userm2_setvmw
w

Source Code

      recursive subroutine ESMF_LogWrite(msg, logmsgFlag, &
                        logmsgList,      & ! DEPRECATED ARGUMENT
                        keywordEnforcer, line, file, method, log, rc)
!
!
! !ARGUMENTS:
      character(len=*),      intent(in)             :: msg
      type(ESMF_LogMsg_Flag),intent(in),optional    :: logmsgFlag
      type(ESMF_LogMsg_Flag),intent(in),optional::logmsgList ! DEPRECATED ARG
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
      integer,               intent(in),   optional :: line
      character(len=*),      intent(in),   optional :: file
      character(len=*),      intent(in),   optional :: method
      type(ESMF_Log),        intent(inout),optional :: log
      integer,               intent(out),  optional :: rc

!
! !STATUS:
! \begin{itemize}
! \item\apiStatusCompatibleVersion{5.2.0r}
! \item\apiStatusModifiedSinceVersion{5.2.0r}
! \begin{description}
! \item[5.2.0rp1] Added argument {\tt logmsgFlag}.
!                 Started to deprecate argument {\tt logmsgList}.
!                 This corrects inconsistent use of the {\tt List} suffix on
!                 the argument name. In ESMF this suffix indicates
!                 one--dimensional array arguments.
! \end{description}
! \end{itemize}
!
! !DESCRIPTION:
!      This subroutine writes to the file associated with an {\tt ESMF\_Log}.
!      A message is passed in along with the {\tt logmsgFlag}, {\tt line},
!      {\tt file} and {\tt method}.  If the write to the {\tt ESMF\_Log}
!      is successful, the function will return a logical {\tt true}.  This
!      function is the base function used by all the other {\tt ESMF\_Log}
!      writing methods.
!
!      The arguments are:
!      \begin{description}
!
!      \item [msg]
!            User-provided message string.
!      \item [{[logmsgFlag]}]
!            The type of message.  See Section~\ref{const:logmsgflag} for
!            possible values.  If not specified, the default is {\tt ESMF\_LOGMSG\_INFO}.
!      \item [{[logmsgList]}]
!            \apiDeprecatedArgWithReplacement{logmsgFlag}
!      \item [{[line]}]
!            Integer source line number.  Expected to be set by
!            using the preprocessor macro {\tt \_\_LINE\_\_} macro.
!      \item [{[file]}]
!            User-provided source file name.
!      \item [{[method]}]
!            User-provided method string.
!      \item [{[log]}]
!            An optional {\tt ESMF\_Log} object that can be used instead
!            of the default Log.
!      \item [{[rc]}]
!            Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
!      \end{description}
!
!EOP
    interface
      subroutine f_ESMF_VMAbort(rc)
        integer, intent(out), optional :: rc
      end subroutine f_ESMF_VMAbort
    end interface

    integer                         :: argcase
    type(ESMF_LogMsg_Flag)          :: local_logmsgflag

    character(len=10)               :: t
    character(len=8)                :: d
    integer                         :: timevals(8)

    !character(len=7)               :: lt
    character(len=32)               :: tmethod
    character(len=ESMF_MAXPATHLEN)  :: tfile
    integer                         :: tline
    integer                         :: i
    integer                         :: localrc
    integer                         :: memstat
    integer                         :: rc2, index, lenTotal, indentCount
    type(ESMF_LogPrivate), pointer  :: alog

    ESMF_INIT_CHECK_SET_SHALLOW(ESMF_LogGetInit,ESMF_LogInit,log)

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

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

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

    ! Check argument sanity

    argcase = 0
    argcase = argcase + merge (1, 0, present (logmsgFlag))
    argcase = argcase + merge (2, 0, present (logmsgList))
    select case (argcase)
    case (0)
      local_logmsgflag = ESMF_LOGMSG_INFO

    case (1)
      local_logmsgflag = logmsgFlag

    case (2)
      write (ESMF_UtilIOStderr,*) ESMF_METHOD,  &
          ": Deprecated: Use logmsgFlag instead of logmsgList."
      call ESMF_UtilIOUnitFlush(ESMF_UtilIOStderr, rc=rc)
      local_logmsgflag = logmsgList

    case (3)
      write (ESMF_UtilIOStderr,*) ESMF_METHOD,  &
          ": Do not specify both logmsgFlag and logmsgList.  Use logmsgFlag."
      call ESMF_UtilIOUnitFlush(ESMF_UtilIOStderr, rc=rc)
      if (present(rc)) then
        rc=ESMF_RC_ARG_INCOMP
      end if
      return

    end select

    if (associated(alog)) then

      ! Open the log file if necessary
      if (alog%logkindflag /= ESMF_LOGKIND_NONE) then

        if (alog%deferredOpenFlag) then
          if (local_logmsgflag == ESMF_LOGMSG_ERROR) then
            call ESMF_LogOpenFile (alog, rc=localrc)
            if (localrc /= ESMF_SUCCESS) then
              if (present (rc)) then
                rc = localrc
              end if
              return
            end if
            alog%deferredOpenFlag = .false.
          else
            if (present (rc)) then
              rc = ESMF_SUCCESS
            end if
            return
          end if
        end if

        if (alog%FileIsOpen /= ESMF_TRUE) then
          write (ESMF_UtilIOStderr,*) ESMF_METHOD,  &
              ": ESMF_Log not open -- cannot ESMF_LogWrite().  Log message = ", trim (msg)
          call ESMF_UtilIOUnitFlush(ESMF_UtilIOStderr, rc=rc)
          if (present(rc)) rc=ESMF_FAILURE
          return
        endif

        if (associated (alog%logmsgList)) then
          do, i=1, size (alog%logmsgList)
             if (local_logmsgflag == alog%logmsgList(i)) then
               exit
             end if
          end do

          if (i > size (alog%logmsgList)) then
            if (present (rc)) rc=ESMF_SUCCESS
            return
          end if
        end if

        ! Add the message to the message queue awaiting flushing

        index = alog%fIndex

        alog%dirty = ESMF_TRUE
        call DATE_AND_TIME(date=d, time=t, values=timevals)
        if (alog%highResTimestampFlag) then
          call c_ESMC_VMWtime (alog%LOG_ENTRY(index)%highResTimestamp, localrc)
          if (localrc /= ESMF_SUCCESS) then
            if (present (rc)) rc = localrc
            return
          end if
        end if
        alog%LOG_ENTRY(index)%noPrefix = alog%noPrefix
        alog%LOG_ENTRY(index)%highResTimestampFlag = alog%highResTimestampFlag
        alog%LOG_ENTRY(index)%indentCount = alog%indentCount
        alog%LOG_ENTRY(index)%methodflag = .FALSE.
        alog%LOG_ENTRY(index)%lineflag = .FALSE.
        alog%LOG_ENTRY(index)%fileflag = .FALSE.
        if (present(method)) then
            tmethod=adjustl(method)
            alog%LOG_ENTRY(index)%methodflag=.TRUE.
            alog%LOG_ENTRY(index)%method = tmethod
        endif
        if (present(line)) then
            tline=line
            alog%LOG_ENTRY(index)%lineflag = .TRUE.
            alog%LOG_ENTRY(index)%line = tline
        endif
        if (present(file)) then
            tfile=adjustl(file)
            alog%LOG_ENTRY(index)%fileflag = .TRUE.
            alog%LOG_ENTRY(index)%file = tfile
        endif
        select case (local_logmsgflag%mtype)
        case (:0, size (ESMF_LogMsgString)+1:)
            alog%LOG_ENTRY(index)%lt="INTERNAL ERROR"
        case default
            alog%LOG_ENTRY(index)%lt= ESMF_LogMsgString(local_logmsgflag%mtype)
        end select
        alog%LOG_ENTRY(alog%fIndex)%d  = d
        alog%LOG_ENTRY(alog%fIndex)%h  = timevals(5)
        alog%LOG_ENTRY(alog%fIndex)%m  = timevals(6)
        alog%LOG_ENTRY(alog%fIndex)%s  = timevals(7)
        alog%LOG_ENTRY(alog%fIndex)%ms = timevals(8)
        indentCount = alog%LOG_ENTRY(index)%indentCount
        lenTotal = len_trim(msg) + indentCount
        allocate (alog%LOG_ENTRY(alog%fIndex)%msg(lenTotal), stat=memstat)
        if (indentCount > 0) then
          ! insert leading white spaces
          alog%LOG_ENTRY(alog%fIndex)%msg(1:indentCount) = " "
        endif
        alog%LOG_ENTRY(alog%fIndex)%msg(1+indentCount:) = &
          ESMF_UtilString2Array(trim(msg))
        alog%flushed = ESMF_FALSE

        if (associated (alog%logmsgAbort)) then
          do, i=1, size (alog%logmsgAbort)
            if (local_logmsgflag%mtype == alog%logmsgAbort(i)%mtype) then
              alog%stopprogram=.true.
              alog%fIndex = alog%fIndex + 1
              call ESMF_LogFlush(log,rc=rc2)
              call ESMF_LogClose(ESMF_LogDefault, rc=rc2)
              exit
            end if
          end do
        end if

        if (alog%fIndex == alog%maxElements .or. &
            alog%flushImmediately == ESMF_TRUE .or.  &
            local_logmsgflag == ESMF_LOGMSG_ERROR) then
                alog%fIndex = alog%fIndex + 1
                call ESMF_LogFlush(log,rc=rc2)
                alog%fIndex = 1
        else
            alog%fIndex = alog%fIndex + 1
        endif
      endif
      ! if requested, halt the program right now.
      if (alog%stopprogram) call f_ESMF_VMAbort()
      if (present(rc)) then
        rc=ESMF_SUCCESS
      endif
    else
      write (ESMF_UtilIOStderr,*) ESMF_METHOD,  &
          ": ESMF_Log not open -- cannot ESMF_LogWrite().  Log message = ", trim (msg)
      call ESMF_UtilIOUnitFlush(ESMF_UtilIOStderr, rc=rc)
      if (present (rc)) then
        rc = localrc
      end if
    endif

end subroutine ESMF_LogWrite