Skip to content

Commit

Permalink
Protect extra logging durign Finalize() with macro. Small formatting
Browse files Browse the repository at this point in the history
fixes.
  • Loading branch information
theurich committed Oct 11, 2023
1 parent 190f8cf commit 4413abc
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/Superstructure/ESMFMod/src/ESMF_Init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ subroutine ESMF_Initialize(keywordEnforcer, configFilenameFromArgNum, &
! \item\apiStatusCompatibleVersion{5.2.0r}
! \item\apiStatusModifiedSinceVersion{5.2.0r}
! \begin{description}
! \item[7.0.0] Added argument {\tt logAppendFlag} to allow specifying that the existing
! log files will be overwritten.
! \item[7.0.0] Added argument {\tt logAppendFlag} to allow specifying that the
! existing log files will be overwritten.
! \item[8.2.0] Added argument {\tt globalResourceControl} to support ESMF-aware
! threading and resource control on the global VM level.\newline
! Added argument {\tt config} to return default handle to the
Expand All @@ -151,8 +151,8 @@ subroutine ESMF_Initialize(keywordEnforcer, configFilenameFromArgNum, &
! configurations.\newline
! Added argument {\tt configFilenameFromArgNum} to support config
! file specification via the command line.
! \item[8.6.0] Added {\tt defaultDefaultCalKind} argument to allow specifiation of
! a default for {\tt defaultCalKind}.
! \item[8.6.0] Added {\tt defaultDefaultCalKind} argument to allow specifiation
! of a default for {\tt defaultCalKind}.
! \end{description}
! \end{itemize}
!
Expand Down Expand Up @@ -1629,11 +1629,13 @@ subroutine ESMF_Finalize(keywordEnforcer, endflag, rc)
endif
endif

#ifdef LOG_FINALIZE
call ESMF_LogWrite("Done closing ESMF_Trace", &
ESMF_LOGMSG_INFO, rc=localrc)
if (localrc /= ESMF_SUCCESS) then
write (ESMF_UtilIOStderr,*) ESMF_METHOD, ": Error writing into the default log"
endif
#endif

! Close the Config file
! TODO: write this routine and remove the status= line
Expand All @@ -1653,11 +1655,13 @@ subroutine ESMF_Finalize(keywordEnforcer, endflag, rc)
": Error finalizing the time manager calendars"
endif

#ifdef LOG_FINALIZE
call ESMF_LogWrite("Done finalizing ESMF_Calendar", &
ESMF_LOGMSG_INFO, rc=localrc)
if (localrc /= ESMF_SUCCESS) then
write (ESMF_UtilIOStderr,*) ESMF_METHOD, ": Error writing into the default log"
endif
#endif

! Flush log to avoid lost messages
call ESMF_LogFlush (rc=localrc)
Expand All @@ -1667,11 +1671,13 @@ subroutine ESMF_Finalize(keywordEnforcer, endflag, rc)
": Error flushing log file: ", errmsg(:errmsg_l)
end if

#ifdef LOG_FINALIZE
call ESMF_LogWrite("Done flushing ESMF_Log", &
ESMF_LOGMSG_INFO, rc=localrc)
if (localrc /= ESMF_SUCCESS) then
write (ESMF_UtilIOStderr,*) ESMF_METHOD, ": Error writing into the default log"
endif
#endif

if (abortFlag) then
! Abort the VM
Expand All @@ -1693,11 +1699,13 @@ subroutine ESMF_Finalize(keywordEnforcer, endflag, rc)
endif
endif

#ifdef LOG_FINALIZE
call ESMF_LogWrite("Done finalizing ESMF_VM", &
ESMF_LOGMSG_INFO, rc=localrc)
if (localrc /= ESMF_SUCCESS) then
write (ESMF_UtilIOStderr,*) ESMF_METHOD, ": Error writing into the default log"
endif
#endif

! Shut down the log file
call ESMF_LogFinalize(localrc)
Expand Down

0 comments on commit 4413abc

Please sign in to comment.