Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve robustness of cam open/close file register code to fix issues with history output #333

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/history/cam_hist_file.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,7 @@ subroutine config_define_file(this, restart, logname, host, model_doi_url)
end do
end do
! Determine the maximum number of dimensions
max_mdims = 0
do field_index = 1, size(this%field_list)
max_mdims = max(max_mdims, size(this%field_list(field_index)%dimensions()))
end do
Expand Down
20 changes: 13 additions & 7 deletions src/utils/cam_abortutils.F90
Original file line number Diff line number Diff line change
Expand Up @@ -80,25 +80,31 @@ subroutine cam_register_open_file(file, file_name)
end do
! If we get here, go ahead and register the file
if (associated(open_files_pool)) then
! Reuse pooled structure and point to the next pool entry
of_new => open_files_pool
open_files_pool => open_files_pool%next
allocate(of_new%file_desc, stat=ierr)
call check_allocate(ierr, subname, 'of_file%file_desc', file=__FILE__, &
line=__LINE__)
of_new%file_desc = file
of_new%file_name = file_name
allocate(open_files_pool%next)
open_files_pool%next => open_files_pool
nullify(of_new%next)
else
allocate(of_new)
allocate(of_new%file_desc)
of_new%file_desc = file
of_new%file_name = file_name
open_files_pool => of_new
end if
open_files_tail => of_new
if (.not. associated(open_files_head)) then
open_files_head => of_new
nullify(of_new%next)
end if

! Add the registered file to the tail of the open files list
if(associated(open_files_tail)) then
open_files_tail%next => of_new
open_files_tail => of_new
else
open_files_head => of_new
open_files_tail => of_new
endif
end subroutine cam_register_open_file

subroutine cam_register_close_file(file, log_shutdown_in)
Expand Down
Loading