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

+Add get_netcdf_filename for a get_field_nc error #582

Merged
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
6 changes: 4 additions & 2 deletions src/framework/MOM_io_file.F90
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module MOM_io_file
use MOM_netcdf, only : write_netcdf_attribute
use MOM_netcdf, only : get_netcdf_size
use MOM_netcdf, only : get_netcdf_fields
use MOM_netcdf, only : get_netcdf_filename
use MOM_netcdf, only : read_netcdf_field

use MOM_error_handler, only : MOM_error, FATAL
Expand Down Expand Up @@ -1757,8 +1758,9 @@ subroutine get_field_nc(handle, label, values, rescale)
! NOTE: Data on face and vertex points is not yet supported. This is a
! temporary check to detect such cases, but may be removed in the future.
if (.not. (compute_domain .or. data_domain)) &
call MOM_error(FATAL, 'get_field_nc: Only compute and data domains ' // &
'are currently supported.')
call MOM_error(FATAL, 'get_field_nc trying to read '//trim(label)//' from '//&
trim(get_netcdf_filename(handle%handle_nc))//&
': Only compute and data domains are currently supported.')

field_nc = handle%fields%get(label)

Expand Down
9 changes: 9 additions & 0 deletions src/framework/MOM_netcdf.F90
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ module MOM_netcdf
public :: write_netcdf_attribute
public :: get_netcdf_size
public :: get_netcdf_fields
public :: get_netcdf_filename
public :: read_netcdf_field


Expand Down Expand Up @@ -722,6 +723,14 @@ subroutine get_netcdf_fields(handle, axes, fields)
fields(:) = vars(:nfields)
end subroutine get_netcdf_fields

!> Return the name of a file from a netCDF handle
function get_netcdf_filename(handle)
type(netcdf_file_type), intent(in) :: handle !< A netCDF file handle
character(len=:), allocatable :: get_netcdf_filename !< The name of the file that this handle refers to.

get_netcdf_filename = handle%filename

end function

!> Read the values of a field from a netCDF file
subroutine read_netcdf_field(handle, field, values, bounds)
Expand Down
Loading