From 9ca359cdb1677a2a46d341c3e9c1c05018e67ee5 Mon Sep 17 00:00:00 2001 From: Dom Heinzeller Date: Wed, 23 Aug 2017 11:39:30 +0200 Subject: [PATCH 1/2] Cleanup work in framework/mpas_stream_manager.F after switching to new MPAS logging module --- src/framework/mpas_stream_manager.F | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/framework/mpas_stream_manager.F b/src/framework/mpas_stream_manager.F index c00d71564327..2b6c1e6651d1 100644 --- a/src/framework/mpas_stream_manager.F +++ b/src/framework/mpas_stream_manager.F @@ -197,6 +197,7 @@ subroutine MPAS_stream_mgr_finalize(manager, ierr)!{{{ threadNum = mpas_threading_get_thread_num() + ! DH* note that this is written to fort.1 if STREAM_DEBUG_WRITE is enabled (log file already closed?) STREAM_DEBUG_WRITE('-- Called MPAS_stream_mgr_finalize()') if (present(ierr)) ierr = MPAS_STREAM_MGR_NOERR @@ -207,6 +208,7 @@ subroutine MPAS_stream_mgr_finalize(manager, ierr)!{{{ ! stream_cursor => manager % streams % head do while (associated(stream_cursor)) + ! DH* note that this is written to fort.1 if STREAM_DEBUG_WRITE is enabled (log file already closed?) STREAM_DEBUG_WRITE(' -- deleting stream '//trim(stream_cursor % name)) call MPAS_stream_mgr_destroy_stream(manager, stream_cursor % name, ierr=err_local) stream_cursor => manager % streams % head @@ -438,6 +440,7 @@ subroutine MPAS_stream_mgr_destroy_stream(manager, streamID, ierr)!{{{ threadNum = mpas_threading_get_thread_num() + ! DH* note that this is written to fort.1 if STREAM_DEBUG_WRITE is enabled (log file already closed?) STREAM_DEBUG_WRITE('-- Called MPAS_stream_mgr_destroy_stream()') if (present(ierr)) ierr = MPAS_STREAM_MGR_NOERR @@ -1470,7 +1473,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 @@ -1743,7 +1745,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 @@ -1807,7 +1809,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 @@ -1917,7 +1919,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 @@ -2994,7 +2996,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. @@ -3079,7 +3081,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 @@ -5910,7 +5911,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 From a5f893110495a762c184511301cb268d9209edab Mon Sep 17 00:00:00 2001 From: Dom Heinzeller Date: Wed, 6 Sep 2017 09:25:28 +0200 Subject: [PATCH 2/2] Moved finalization of infrastructure (streams) etc before closing the log files. Removed comments stating that certain log messages are printed to fort.1, since this is no longer the case. --- src/driver/mpas_subdriver.F | 13 +++++++------ src/framework/mpas_stream_manager.F | 3 --- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/driver/mpas_subdriver.F b/src/driver/mpas_subdriver.F index 1538be4d2d04..90217ad80d1c 100644 --- a/src/driver/mpas_subdriver.F +++ b/src/driver/mpas_subdriver.F @@ -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) diff --git a/src/framework/mpas_stream_manager.F b/src/framework/mpas_stream_manager.F index 2b6c1e6651d1..32a721002a2f 100644 --- a/src/framework/mpas_stream_manager.F +++ b/src/framework/mpas_stream_manager.F @@ -197,7 +197,6 @@ subroutine MPAS_stream_mgr_finalize(manager, ierr)!{{{ threadNum = mpas_threading_get_thread_num() - ! DH* note that this is written to fort.1 if STREAM_DEBUG_WRITE is enabled (log file already closed?) STREAM_DEBUG_WRITE('-- Called MPAS_stream_mgr_finalize()') if (present(ierr)) ierr = MPAS_STREAM_MGR_NOERR @@ -208,7 +207,6 @@ subroutine MPAS_stream_mgr_finalize(manager, ierr)!{{{ ! stream_cursor => manager % streams % head do while (associated(stream_cursor)) - ! DH* note that this is written to fort.1 if STREAM_DEBUG_WRITE is enabled (log file already closed?) STREAM_DEBUG_WRITE(' -- deleting stream '//trim(stream_cursor % name)) call MPAS_stream_mgr_destroy_stream(manager, stream_cursor % name, ierr=err_local) stream_cursor => manager % streams % head @@ -440,7 +438,6 @@ subroutine MPAS_stream_mgr_destroy_stream(manager, streamID, ierr)!{{{ threadNum = mpas_threading_get_thread_num() - ! DH* note that this is written to fort.1 if STREAM_DEBUG_WRITE is enabled (log file already closed?) STREAM_DEBUG_WRITE('-- Called MPAS_stream_mgr_destroy_stream()') if (present(ierr)) ierr = MPAS_STREAM_MGR_NOERR