Skip to content

Commit

Permalink
Merge branch 'framework/cleanup-logging-stream-manager' into develop
Browse files Browse the repository at this point in the history
This merge shifts the closing of the log files to behind the finalization of
the stream manager to avoid having stream manager debug messages being written
to fort.1. This merge also fixes compilation errors when MPAS_STREAM_DEBUG is
enabled that were introduced with the use of the logging module.

* framework/cleanup-logging-stream-manager:
  Moved finalization of infrastructure (streams) etc before closing the log files.
  Cleanup work in framework/mpas_stream_manager.F after switching to new MPAS logging module
  • Loading branch information
mgduda committed Sep 11, 2017
2 parents 504c282 + a5f8931 commit 960a648
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
13 changes: 7 additions & 6 deletions src/driver/mpas_subdriver.F
Original file line number Diff line number Diff line change
Expand Up @@ -366,18 +366,19 @@ subroutine mpas_finalize()
call mpas_timer_write()
call mpas_timer_finalize(domain_ptr)

!
! Finalize infrastructure
!
call MPAS_stream_mgr_finalize(domain_ptr % streamManager)

! Print out log stats and close log file
! (do this after timer stats are printed)
! (Do this after timer stats are printed and stream mgr finalized,
! but before framework is finalized because domain is destroyed there.)
call mpas_log_finalize(iErr)
if ( iErr /= 0 ) then
call mpas_dmpar_global_abort('ERROR: Log finalize failed for core ' // trim(domain_ptr % core % coreName))
end if

!
! Finalize infrastructure
!
call MPAS_stream_mgr_finalize(domain_ptr % streamManager)

call mpas_framework_finalize(domain_ptr % dminfo, domain_ptr)

deallocate(corelist % domainlist)
Expand Down
11 changes: 4 additions & 7 deletions src/framework/mpas_stream_manager.F
Original file line number Diff line number Diff line change
Expand Up @@ -1470,7 +1470,6 @@ logical function MPAS_stream_mgr_ringing_alarms(manager, streamID, direction, ie
end if
end if
if ( threadNum == 0 ) then
if (local_direction == MPAS_STREAM_INPUT .or. local_direction == MPAS_STREAM_INPUT_OUTPUT) then
if (associated(stream)) then
Expand Down Expand Up @@ -1743,7 +1742,7 @@ end subroutine MPAS_stream_mgr_set_property_logical !}}}
!-----------------------------------------------------------------------
! routine MPAS_stream_mgr_get_property_int
!
!> \brief Sets a property of a stream in an MPAS stream manager.
!> \brief Gets a property of a stream in an MPAS stream manager.
!> \author Michael Duda, Doug Jacobsen
!> \date 13 June 2014
!> \details
Expand Down Expand Up @@ -1807,7 +1806,7 @@ end subroutine MPAS_stream_mgr_get_property_int !}}}
!-----------------------------------------------------------------------
! routine MPAS_stream_mgr_get_property_char
!
!> \brief Sets a property of a stream in an MPAS stream manager.
!> \brief Gets a property of a stream in an MPAS stream manager.
!> \author Michael Duda, Doug Jacobsen
!> \date 13 June 2014
!> \details
Expand Down Expand Up @@ -1917,7 +1916,7 @@ end subroutine MPAS_stream_mgr_get_property_char !}}}
!-----------------------------------------------------------------------
! routine MPAS_stream_mgr_get_property_logical
!
!> \brief Sets a property of a stream in an MPAS stream manager.
!> \brief Gets a property of a stream in an MPAS stream manager.
!> \author Michael Duda, Doug Jacobsen
!> \date 13 June 2014
!> \details
Expand Down Expand Up @@ -2994,7 +2993,7 @@ subroutine write_stream(manager, stream, blockID, timeLevel, mgLevel, forceWrite
! Look for exact record (in the case of overwriting)
! This also gets the number of records in the file.
stream % nRecords = MPAS_seekStream(stream % stream, now_string, MPAS_STREAM_EXACT_TIME, actualWhen, maxRecords, local_ierr)
STREAM_DEBUG_WRITE(' -- Seeked record is: $i with current records equal to $i and an error of $i' COMMA intArgs=(/stream % nRecords COMMA maxRecords, local_ierr/))
STREAM_DEBUG_WRITE(' -- Seeked record is: $i with current records equal to $i and an error of $i' COMMA intArgs=(/stream % nRecords COMMA maxRecords COMMA local_ierr/))
if ( stream % nRecords == 0 ) then
! If we didn't find an exact time, set record to point to the end of the file.
Expand Down Expand Up @@ -3079,7 +3078,6 @@ subroutine write_stream(manager, stream, blockID, timeLevel, mgLevel, forceWrite
! Look for exact record (in the case of overwriting)
! This also gets the number of records in the file.
stream % nRecords = MPAS_seekStream(stream % stream, now_string, MPAS_STREAM_EXACT_TIME, actualWhen, maxRecords, local_ierr)
STREAM_DEBUG_WRITE(' -- Seeked record is: ' COMMA stream % nRecords COMMA ' with current records equal to ' COMMA maxRecords COMMA ' and an error of ' COMMA local_ierr)
STREAM_DEBUG_WRITE(' -- Seeked record is: $i with current records equal to $i and an error of $i' COMMA intArgs=(/stream % nRecords COMMA maxRecords COMMA local_ierr/))
if ( stream % nRecords == 0 ) then
Expand Down Expand Up @@ -5914,7 +5912,6 @@ subroutine stream_mgr_add_pkg_c(manager_c, streamID_c, package_c, ierr_c) bind(c

type (MPAS_streamManager_type), pointer :: manager
character(len=StrKIND) :: streamID, package
integer :: idirection
integer :: ierr


Expand Down

0 comments on commit 960a648

Please sign in to comment.