Skip to content

Commit

Permalink
Fix to prevent time from being written multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
uramirez8707 committed Feb 14, 2024
1 parent 7a3b1af commit efee97d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion diag_manager/fms_diag_file_object.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1374,8 +1374,9 @@ logical function writing_on_this_pe(this)
end function

!> \brief Write out the time data to the file
subroutine write_time_data(this)
subroutine write_time_data(this, is_the_end)
class(fmsDiagFileContainer_type), intent(in), target :: this !< The file object
logical, optional, intent(in) :: is_the_end !< True if it is the end of the run

real :: dif !< The time as a real number
class(fmsDiagFile_type), pointer :: diag_file !< Diag_file object to open
Expand All @@ -1389,6 +1390,11 @@ subroutine write_time_data(this)
diag_file => this%FMS_diag_file
fms2io_fileobj => diag_file%fms2io_fileobj

if (present(is_the_end)) then
! If at the end of the run, do not do anything for the static files
if (is_the_end .and. diag_file%is_static) return
endif

if (diag_file%time_ops) then
middle_time = (diag_file%last_output+diag_file%next_output)/2
dif = get_date_dif(middle_time, get_base_time(), diag_file%get_file_timeunit())
Expand Down
1 change: 1 addition & 0 deletions diag_manager/fms_diag_object.F90
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ subroutine fms_diag_do_io(this, end_time)
call diag_file%increase_unlim_dimension_level()
if (diag_file%is_time_to_close_file(model_time)) call diag_file%close_diag_file()
else if (force_write) then
call diag_file%write_time_data(is_the_end = .true.)
call diag_file%close_diag_file()
endif
enddo
Expand Down

0 comments on commit efee97d

Please sign in to comment.