Skip to content

Commit

Permalink
move the crash to the register call
Browse files Browse the repository at this point in the history
  • Loading branch information
uramirez8707 committed May 7, 2024
1 parent e48213d commit 9073a22
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 26 deletions.
15 changes: 11 additions & 4 deletions diag_manager/fms_diag_file_object.F90
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,17 @@ subroutine set_file_time_ops(this, VarYaml, is_static)
endif
else
var_reduct = VarYaml%get_var_reduction()
select case (var_reduct)
case (time_average, time_rms, time_max, time_min, time_sum, time_diurnal, time_power)
this%time_ops = .true.
end select
if (this%num_registered_fields .eq. 1) then
select case (var_reduct)
case (time_average, time_rms, time_max, time_min, time_sum, time_diurnal, time_power)
this%time_ops = .true.
end select
else
if (var_reduct .ne. time_none .and. .not. is_static) &
call mpp_error(FATAL, "The file: "//this%get_file_fname()//&
" has variables that are time averaged and instantaneous")
endif

endif

end subroutine set_file_time_ops
Expand Down
24 changes: 2 additions & 22 deletions diag_manager/fms_diag_yaml.F90
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,7 @@ subroutine diag_yaml_object_init(diag_subset_output)
diag_yaml%diag_fields(var_count)%var_axes_names = ""
diag_yaml%diag_fields(var_count)%var_file_is_subregional = diag_yaml%diag_files(file_count)%has_file_sub_region()

call fill_in_diag_fields(diag_yaml_id, var_ids(j), diag_yaml%diag_fields(var_count), allow_averages, &
j .eq. 1, is_instantaneous)
call fill_in_diag_fields(diag_yaml_id, var_ids(j), diag_yaml%diag_fields(var_count), allow_averages)

!> Save the variable name in the diag_file type
diag_yaml%diag_files(file_count)%file_varlist(file_var_count) = diag_yaml%diag_fields(var_count)%var_varname
Expand Down Expand Up @@ -608,16 +607,11 @@ subroutine fill_in_diag_files(diag_yaml_id, diag_file_id, yaml_fileobj)

!> @brief Fills in a diagYamlFilesVar_type with the contents of a variable block in
!! diag_table.yaml
subroutine fill_in_diag_fields(diag_file_id, var_id, field, allow_averages, first_variable_in_file, &
is_instantaneous)
subroutine fill_in_diag_fields(diag_file_id, var_id, field, allow_averages)
integer, intent(in) :: diag_file_id !< Id of the file block in the yaml file
integer, intent(in) :: var_id !< Id of the variable block in the yaml file
type(diagYamlFilesVar_type), intent(inout) :: field !< diagYamlFilesVar_type obj to read the contents into
logical, intent(in) :: allow_averages !< .True. if averages are allowed for this file
logical, intent(in) :: first_variable_in_file !< .True. if this is the first variable
!! in the file
logical, intent(inout) :: is_instantaneous !< .True. if the file is instantaneous, so averaged
!! fields are not allowed

integer :: natt !< Number of attributes in variable
integer :: var_att_id(1) !< Id of the variable attribute block
Expand All @@ -638,20 +632,6 @@ subroutine fill_in_diag_fields(diag_file_id, var_id, field, allow_averages, firs
"Check your diag_table.yaml for the field:"//trim(field%var_varname))
endif

!! This is to prevent mixing instantaneous and averaged fields in the same file
if (first_variable_in_file) then
if (field%var_reduction .eq. time_none) then
is_instantaneous = .true.
else
is_instantaneous = .false.
endif
else
if ((is_instantaneous .and. field%var_reduction .ne. time_none) &
.or. (.not. is_instantaneous .and. field%var_reduction .eq. time_none)) &
call mpp_error(FATAL, "The file "//field%var_fname//" is mixing instantaneous and non-instantaneous "//&
"fields which is not allowed as it will cause the times in your file to be wrong.")
endif

call diag_get_value_from_key(diag_file_id, var_id, "module", field%var_module)
deallocate(buffer)
call diag_get_value_from_key(diag_file_id, var_id, "kind", buffer)
Expand Down

0 comments on commit 9073a22

Please sign in to comment.