diff --git a/sources/helpers.F90 b/sources/helpers.F90 index 88c0b37..30feaf3 100644 --- a/sources/helpers.F90 +++ b/sources/helpers.F90 @@ -49,11 +49,13 @@ module helpers module procedure print_message_msg end interface + logical :: noflush = .true. + private public :: print_welcome, print_section, print_parameter, print_message public :: uppercase, lowercase - public :: flush_and_sync + public :: enable_flush_and_sync, disable_flush_and_sync, flush_and_sync !- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! @@ -551,10 +553,53 @@ module helpers ! !=============================================================================== ! +! subroutine ENABLE_FLUSH_AND_SYNC: +! -------------------------------- +! +! This function enables flushing and synchronization of I/O buffers. +! +!=============================================================================== +! + subroutine enable_flush_and_sync() + + implicit none + +!------------------------------------------------------------------------------- +! + noflush = .false. + +!------------------------------------------------------------------------------- +! + end subroutine enable_flush_and_sync +! +!=============================================================================== +! +! subroutine DISABLE_FLUSH_AND_SYNC: +! --------------------------------- +! +! This function disables flushing and synchronization of I/O buffers. +! +!=============================================================================== +! + subroutine disable_flush_and_sync() + + implicit none + +!------------------------------------------------------------------------------- +! + noflush = .true. + +!------------------------------------------------------------------------------- +! + end subroutine disable_flush_and_sync +! +!=============================================================================== +! ! subroutine FLUSH_AND_SYNC: ! ------------------------- ! -! Function flushes and fsyncs the I/O buffers. +! This function performs a flush of the I/O buffers and ensures that all +! changes are synchronized to the storage device using fsync. ! ! Arguments: ! @@ -584,6 +629,8 @@ module helpers !------------------------------------------------------------------------------- ! + if (noflush) return + call flush(iounit) #ifdef __GFORTRAN__ diff --git a/sources/statistics.F90 b/sources/statistics.F90 index c1f273f..a2ceef7 100644 --- a/sources/statistics.F90 +++ b/sources/statistics.F90 @@ -104,6 +104,7 @@ module statistics use equations , only : pvars, nf use evolution , only : error_control use forcing , only : forcing_enabled + use helpers , only : enable_flush_and_sync, disable_flush_and_sync use mpitools , only : master #ifdef MPI use mpitools , only : nprocs @@ -124,6 +125,15 @@ module statistics ! status = 0 + stmp = "off" + call get_parameter("enable_io_flush", stmp) + select case(trim(stmp)) + case ("on", "ON", "t", "T", "y", "Y", "true", "TRUE", "yes", "YES") + call enable_flush_and_sync + case default + call disable_flush_and_sync + end select + stmp = "on" call get_parameter("enable_conservation", stmp) select case(trim(stmp))