ESMF_LogInitialize Subroutine

public subroutine ESMF_LogInitialize(filename, logappendflag, logkindflag, rc)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: filename
logical, intent(in), optional :: logappendflag
type(ESMF_LogKind_Flag), intent(in), optional :: logkindflag
integer, intent(out), optional :: rc

Calls

proc~~esmf_loginitialize~~CallsGraph proc~esmf_loginitialize ESMF_LogInitialize c_esmc_vmgetenv c_esmc_vmgetenv proc~esmf_loginitialize->c_esmc_vmgetenv interface~esmf_logopen ESMF_LogOpen proc~esmf_loginitialize->interface~esmf_logopen proc~esmf_logfounderror ESMF_LogFoundError proc~esmf_loginitialize->proc~esmf_logfounderror proc~esmf_logset ESMF_LogSet proc~esmf_loginitialize->proc~esmf_logset proc~esmf_logseterror ESMF_LogSetError proc~esmf_loginitialize->proc~esmf_logseterror interface~esmf_logopen->interface~esmf_logopen proc~esmf_logopendefault ESMF_LogOpenDefault interface~esmf_logopen->proc~esmf_logopendefault esmf_breakpoint esmf_breakpoint proc~esmf_logfounderror->esmf_breakpoint proc~esmf_logrc2msg ESMF_LogRc2Msg proc~esmf_logfounderror->proc~esmf_logrc2msg proc~esmf_logwrite ESMF_LogWrite proc~esmf_logfounderror->proc~esmf_logwrite c_esmc_logset c_esmc_logset proc~esmf_logset->c_esmc_logset c_esmc_logsettrace c_esmc_logsettrace proc~esmf_logset->c_esmc_logsettrace proc~esmf_logentrycopy ESMF_LogEntryCopy proc~esmf_logset->proc~esmf_logentrycopy proc~esmf_logflush ESMF_LogFlush proc~esmf_logset->proc~esmf_logflush proc~esmf_logset->proc~esmf_logwrite proc~esmf_utiliounitflush ESMF_UtilIOUnitFlush proc~esmf_logset->proc~esmf_utiliounitflush proc~esmf_logseterror->esmf_breakpoint proc~esmf_logseterror->proc~esmf_logrc2msg proc~esmf_logseterror->proc~esmf_logwrite proc~esmf_logflush->proc~esmf_utiliounitflush proc~esmf_utilarray2string ESMF_UtilArray2String proc~esmf_logflush->proc~esmf_utilarray2string proc~esmf_logopendefault->interface~esmf_logopen proc~esmf_logopendefault->proc~esmf_logrc2msg proc~esmf_logopendefault->proc~esmf_utiliounitflush c_esmc_loggeterrormsg c_esmc_loggeterrormsg proc~esmf_logrc2msg->c_esmc_loggeterrormsg proc~esmf_logwrite->proc~esmf_logflush proc~esmf_logwrite->proc~esmf_utiliounitflush 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_logopenfile ESMF_LogOpenFile proc~esmf_logwrite->proc~esmf_logopenfile proc~esmf_utilstring2array ESMF_UtilString2Array proc~esmf_logwrite->proc~esmf_utilstring2array proc~esmf_logclose->proc~esmf_logflush proc~esmf_logopenfile->proc~esmf_utiliounitflush proc~esmf_utiliounitget ESMF_UtilIOUnitGet proc~esmf_logopenfile->proc~esmf_utiliounitget

Called by

proc~~esmf_loginitialize~~CalledByGraph proc~esmf_loginitialize ESMF_LogInitialize proc~esmf_frameworkinternalinit ESMF_FrameworkInternalInit proc~esmf_frameworkinternalinit->proc~esmf_loginitialize proc~esmf_initialize ESMF_Initialize proc~esmf_initialize->proc~esmf_frameworkinternalinit proc~f_esmf_frameworkinitialize f_esmf_frameworkinitialize proc~f_esmf_frameworkinitialize->proc~esmf_frameworkinternalinit

Source Code

      subroutine ESMF_LogInitialize(filename, logappendflag, logkindflag, rc)
!
! !ARGUMENTS:
      character(len=*),        intent(in)           :: filename
      logical,                 intent(in), optional :: logappendflag
      type(ESMF_LogKind_Flag), intent(in), optional :: logkindflag
      integer,                 intent(out),optional :: rc

! !DESCRIPTION:
!      This routine initializes the global default {\tt ESMF\_Log}.
!      The default {\tt ESMF\_Log} is assigned the {\tt filename} and
!      is associated with an open Fortran unit number.
!
!      The arguments are:
!      \begin{description}
!
!      \item [filename]
!            Name of file.  Maximum length 58 characters to allow for
!            the PET number to be added and keep the total file name
!            length under 64 characters.
!     \item [{[logappendflag]}]
!           If the log file already exists, a value of {\tt .false.}
!           will set the file position to the beginning of the file.  A value
!           of [\tt .true.} sets the position to the end of the file.
!           If not specified, defaults to {\tt .true.}.
!      \item [{[logkindflag]}]
!            Specifies {\tt ESMF\_LOGKIND\_SINGLE}, {\tt ESMF\_LOGKIND\_MULTI} or
!            {\tt ESMF\_LOGKIND\_NONE}.
!      \item [{[rc]}]
!            Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
!      \end{description}
!
!EOPI

    integer                        :: localrc
    integer                        :: msgAbortCnt
    type(ESMF_LogMsg_Flag)         :: msgAbortLst(6)
    character(ESMF_MAXSTR)         :: envRtAbort
    integer                        :: idxRtAbort

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

    call ESMF_LogOpen(ESMF_LogDefault, filename,  &
      appendflag=logappendflag, logkindflag=logkindflag, rc=localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return

    call c_ESMC_VMGetEnv("ESMF_RUNTIME_ABORT_LOGMSG_TYPES", envRtAbort, localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return
    msgAbortCnt = 0
    idxRtAbort = index (envRtAbort, "ESMF_LOGMSG_DEBUG")
    if (idxRtAbort > 0) then
      msgAbortCnt = msgAbortCnt + 1
      msgAbortLst(msgAbortCnt) = ESMF_LOGMSG_DEBUG
    endif
    idxRtAbort = index (envRtAbort, "ESMF_LOGMSG_ERROR")
    if (idxRtAbort > 0) then
      msgAbortCnt = msgAbortCnt + 1
      msgAbortLst(msgAbortCnt) = ESMF_LOGMSG_ERROR
    endif
    idxRtAbort = index (envRtAbort, "ESMF_LOGMSG_INFO")
    if (idxRtAbort > 0) then
      msgAbortCnt = msgAbortCnt + 1
      msgAbortLst(msgAbortCnt) = ESMF_LOGMSG_INFO
    endif
    idxRtAbort = index (envRtAbort, "ESMF_LOGMSG_JSON")
    if (idxRtAbort > 0) then
      msgAbortCnt = msgAbortCnt + 1
      msgAbortLst(msgAbortCnt) = ESMF_LOGMSG_JSON
    endif
    idxRtAbort = index (envRtAbort, "ESMF_LOGMSG_TRACE")
    if (idxRtAbort > 0) then
      msgAbortCnt = msgAbortCnt + 1
      msgAbortLst(msgAbortCnt) = ESMF_LOGMSG_TRACE
    endif
    idxRtAbort = index (envRtAbort, "ESMF_LOGMSG_WARNING")
    if (idxRtAbort > 0) then
      msgAbortCnt = msgAbortCnt + 1
      msgAbortLst(msgAbortCnt) = ESMF_LOGMSG_WARNING
    endif
    if (msgAbortCnt > 6) then
      call ESMF_LogSetError(ESMF_RC_BUFFER_SHORT, &
        msg="msgAbortLst overflow - ESMF_RUNTIME_ABORT_LOGMSG_TYPES", &
        ESMF_CONTEXT, rcToReturn=rc)
      return
    elseif (msgAbortCnt > 0) then
      call ESMF_LogSet(ESMF_LogDefault, &
        logmsgAbort=msgAbortLst(1:msgAbortCnt), rc=localrc)
      if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT, rcToReturn=rc)) return
    endif

    if (present(rc)) rc=ESMF_SUCCESS

end subroutine ESMF_LogInitialize