Skip to content

Commit

Permalink
Modern diag manager: check if field is registered (NOAA-GFDL#1151)
Browse files Browse the repository at this point in the history
* add a subroutine to check if a field in the file object was registered and uses it to skip fields that were not registered
  • Loading branch information
uramirez8707 authored Mar 29, 2023
1 parent 030c1d7 commit cd26058
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions diag_manager/fms_diag_file_object.F90
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ module fms_diag_file_object_mod

contains
procedure, public :: add_field_and_yaml_id
procedure, public :: is_field_registered
procedure, public :: init_diurnal_axis
procedure, public :: has_file_metadata_from_model
procedure, public :: has_fileobj
Expand Down Expand Up @@ -256,6 +257,15 @@ logical function fms_diag_files_object_init (files_array)
endif
end function fms_diag_files_object_init

!< @brief Determine if the field corresponding to the field_id was registered to the file
!! @return .True. if the field was registed to the file
pure logical function is_field_registered(this, field_id)
class(fmsDiagFile_type), intent(in) :: this !< The file object
integer, intent(in) :: field_id !< Id of the field to check

is_field_registered = this%field_registered(field_id)
end function is_field_registered

!> \brief Adds a field and yaml ID to the file
subroutine add_field_and_yaml_id (this, new_field_id, yaml_id)
class(fmsDiagFile_type), intent(inout) :: this !< The file object
Expand Down
3 changes: 3 additions & 0 deletions diag_manager/fms_diag_object.F90
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,9 @@ subroutine fms_diag_send_complete(this, time_step)
allocate (file_field_ids(size(diag_file%FMS_diag_file%get_field_ids() )))
file_field_ids = diag_file%FMS_diag_file%get_field_ids()
field_loop: do ifield = 1, size(file_field_ids)
! If the field is not registered go away
if (.not. diag_file%FMS_diag_file%is_field_registered(ifield)) cycle

diag_field => this%FMS_diag_fields(file_field_ids(ifield))
!> Check if math needs to be done
! math = diag_field%get_math_needs_to_be_done()
Expand Down

0 comments on commit cd26058

Please sign in to comment.