Close open units on exit to flush the buffer

This commit is contained in:
Lorenzo Figini 2021-12-22 23:45:30 +01:00 committed by Michele Guerini Rocco
parent b379a20192
commit d3a87e1044
Signed by: rnhmjoj
GPG Key ID: BFBAF4C975F76450
2 changed files with 19 additions and 1 deletions

View File

@ -1,7 +1,7 @@
program main
use const_and_precisions, only : wp_, one, zero
use logger, only : INFO, ERROR, set_log_level, log_message
use units, only : set_active_units
use units, only : set_active_units, close_units
use gray_cli, only : cli_options, parse_cli_options
use gray_core, only : gray_main
use gray_params, only : gray_parameters, gray_data, gray_results, &
@ -143,6 +143,7 @@ program main
call deinit_profiles(data%profiles)
call deinit_misc
deallocate(results%dpdv, results%jcd)
call close_units
contains

View File

@ -40,6 +40,23 @@ contains
end subroutine set_active_units
subroutine close_units
! Close all the active units to flush the buffer.
implicit none
integer :: i
if (allocated(active_units)) then
do i = 1, size(active_units)
close(active_units(i))
end do
deallocate(active_units)
end if
end subroutine close_units
function unit_active(unit) result(on)
! Checks whether the given `unit` is active