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

Append ensemble number to geometry filename in ensemble runs #284

Merged
merged 1 commit into from
Jul 15, 2024
Merged
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
15 changes: 14 additions & 1 deletion src/initialization/MOM_shared_initialization.F90
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module MOM_shared_initialization
use MOM_error_handler, only : MOM_mesg, MOM_error, FATAL, WARNING, is_root_pe
use MOM_error_handler, only : callTree_enter, callTree_leave, callTree_waypoint
use MOM_file_parser, only : get_param, log_param, param_file_type, log_version
use MOM_io, only : create_MOM_file, file_exists, field_size
use MOM_io, only : create_MOM_file, file_exists, field_size, get_filename_appendix
use MOM_io, only : MOM_infra_file, MOM_field
use MOM_io, only : MOM_read_data, MOM_read_vector, read_variable, stdout
use MOM_io, only : open_file_to_read, close_file_to_read, SINGLE_FILE, MULTIPLE
Expand Down Expand Up @@ -1348,13 +1348,15 @@ subroutine write_ocean_geometry_file(G, param_file, directory, US, geom_file)
! Local variables.
character(len=240) :: filepath ! The full path to the file to write
character(len=40) :: mdl = "write_ocean_geometry_file"
character(len=32) :: filename_appendix = '' ! Appendix to geom filename for ensemble runs
type(vardesc), dimension(:), allocatable :: &
vars ! Types with metadata about the variables and their staggering
type(MOM_field), dimension(:), allocatable :: &
fields ! Opaque types used by MOM_io to store variable metadata information
type(MOM_infra_file) :: IO_handle ! The I/O handle of the fileset
integer :: nFlds ! The number of variables in this file
integer :: file_threading
integer :: geom_file_len ! geometry file name length
logical :: multiple_files

call callTree_enter('write_ocean_geometry_file()')
Expand Down Expand Up @@ -1408,6 +1410,17 @@ subroutine write_ocean_geometry_file(G, param_file, directory, US, geom_file)
filepath = trim(directory) // "ocean_geometry"
endif

! Append ensemble run number to filename if it is an ensemble run
call get_filename_appendix(filename_appendix)
if (len_trim(filename_appendix) > 0) then
geom_file_len = len_trim(filepath)
if (filepath(geom_file_len-2:geom_file_len) == ".nc") then
filepath = filepath(1:geom_file_len-3) // '.' // trim(filename_appendix) // ".nc"
else
filepath = filepath // '.' // trim(filename_appendix)
endif
endif

call get_param(param_file, mdl, "PARALLEL_RESTARTFILES", multiple_files, &
"If true, the IO layout is used to group processors that write to the same "//&
"restart file or each processor writes its own (numbered) restart file. "//&
Expand Down
Loading