HELPERS: Add functions to enable/disable I/O flush and sync.
This change introduces the logical flag 'noflush' to control the flushing and synchronization of I/O buffers. Subsequently, subroutines 'enable_flush_and_sync' and 'disable_flush_and_sync' were added to enable and disable the flushing and synchronization, respectively. The 'flush_and_sync' subroutine was modified to respect the noflush flag. Additionally, this change updates 'statistics.F90' to read the 'enable_io_flush' parameter and call the appropriate subroutine ('enable_flush_and_sync' or 'disable_flush_and_sync') based on its value. Signed-off-by: Grzegorz Kowal <grzegorz@amuncode.org>
This commit is contained in:
parent
94ecb53bc4
commit
29f1e94e9c
@ -49,11 +49,13 @@ module helpers
|
|||||||
module procedure print_message_msg
|
module procedure print_message_msg
|
||||||
end interface
|
end interface
|
||||||
|
|
||||||
|
logical :: noflush = .true.
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
public :: print_welcome, print_section, print_parameter, print_message
|
public :: print_welcome, print_section, print_parameter, print_message
|
||||||
public :: uppercase, lowercase
|
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:
|
! 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:
|
! Arguments:
|
||||||
!
|
!
|
||||||
@ -584,6 +629,8 @@ module helpers
|
|||||||
|
|
||||||
!-------------------------------------------------------------------------------
|
!-------------------------------------------------------------------------------
|
||||||
!
|
!
|
||||||
|
if (noflush) return
|
||||||
|
|
||||||
call flush(iounit)
|
call flush(iounit)
|
||||||
|
|
||||||
#ifdef __GFORTRAN__
|
#ifdef __GFORTRAN__
|
||||||
|
@ -104,6 +104,7 @@ module statistics
|
|||||||
use equations , only : pvars, nf
|
use equations , only : pvars, nf
|
||||||
use evolution , only : error_control
|
use evolution , only : error_control
|
||||||
use forcing , only : forcing_enabled
|
use forcing , only : forcing_enabled
|
||||||
|
use helpers , only : enable_flush_and_sync, disable_flush_and_sync
|
||||||
use mpitools , only : master
|
use mpitools , only : master
|
||||||
#ifdef MPI
|
#ifdef MPI
|
||||||
use mpitools , only : nprocs
|
use mpitools , only : nprocs
|
||||||
@ -124,6 +125,15 @@ module statistics
|
|||||||
!
|
!
|
||||||
status = 0
|
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"
|
stmp = "on"
|
||||||
call get_parameter("enable_conservation", stmp)
|
call get_parameter("enable_conservation", stmp)
|
||||||
select case(trim(stmp))
|
select case(trim(stmp))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user