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

+Enhanced support for novel axes in MOM_io #1369

Merged
merged 1 commit into from
Apr 12, 2021
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
11 changes: 10 additions & 1 deletion config_src/infra/FMS1/MOM_io_infra.F90
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ module MOM_io_infra

!> Write metadata about a variable or axis to a file and store it for later reuse
interface write_metadata
module procedure write_metadata_axis, write_metadata_field
module procedure write_metadata_axis, write_metadata_field, write_metadata_global
end interface write_metadata

!> Close a file (or fileset). If the file handle does not point to an open file,
Expand Down Expand Up @@ -793,4 +793,13 @@ subroutine write_metadata_field(IO_handle, field, axes, name, units, longname, &

end subroutine write_metadata_field

!> Write a global text attribute to a file.
subroutine write_metadata_global(IO_handle, name, attribute)
type(file_type), intent(in) :: IO_handle !< Handle for a file that is open for writing
character(len=*), intent(in) :: name !< The name in the file of this global attribute
character(len=*), intent(in) :: attribute !< The value of this attribute

call mpp_write_meta(IO_handle%unit, name, cval=attribute)
end subroutine write_metadata_global

end module MOM_io_infra
20 changes: 17 additions & 3 deletions config_src/infra/FMS2/MOM_io_infra.F90
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module MOM_io_infra
use fms2_io_mod, only : FmsNetcdfDomainFile_t, FmsNetcdfFile_t, fms2_read_data => read_data
use fms2_io_mod, only : get_unlimited_dimension_name, get_num_dimensions, get_num_variables
use fms2_io_mod, only : get_variable_names, variable_exists, get_variable_size, get_variable_units
use fms2_io_mod, only : register_field, write_data, register_variable_attribute
use fms2_io_mod, only : register_field, write_data, register_variable_attribute, register_global_attribute
use fms2_io_mod, only : variable_att_exists, get_variable_attribute, get_variable_num_dimensions
use fms2_io_mod, only : get_variable_dimension_names, is_dimension_registered, get_dimension_size
use fms2_io_mod, only : is_dimension_unlimited, register_axis, unlimited
Expand Down Expand Up @@ -90,7 +90,7 @@ module MOM_io_infra

!> Write metadata about a variable or axis to a file and store it for later reuse
interface write_metadata
module procedure write_metadata_axis, write_metadata_field
module procedure write_metadata_axis, write_metadata_field, write_metadata_global
end interface write_metadata

!> Close a file (or fileset). If the file handle does not point to an open file,
Expand Down Expand Up @@ -1779,7 +1779,7 @@ subroutine write_metadata_axis(IO_handle, axis, name, units, longname, cartesian
endif

axis%name = trim(name)
if (present(data) .and. allocated(axis%ax_data)) call MOM_error(FATAL, &
if (present(data) .and. allocated(axis%ax_data)) call MOM_error(FATAL, &
"Data is already allocated in a call to write_metadata_axis for axis "//&
trim(name)//" in file "//trim(IO_handle%filename))

Expand Down Expand Up @@ -1920,4 +1920,18 @@ subroutine write_metadata_field(IO_handle, field, axes, name, units, longname, &

end subroutine write_metadata_field

!> Write a global text attribute to a file.
subroutine write_metadata_global(IO_handle, name, attribute)
type(file_type), intent(in) :: IO_handle !< Handle for a file that is open for writing
character(len=*), intent(in) :: name !< The name in the file of this global attribute
character(len=*), intent(in) :: attribute !< The value of this attribute

if (IO_handle%FMS2_file) then
call register_global_attribute(IO_handle%fileobj, name, attribute, len_trim(attribute))
else
call mpp_write_meta(IO_handle%unit, name, cval=attribute)
endif

end subroutine write_metadata_global

end module MOM_io_infra
Loading