Skip to content

Commit

Permalink
diag_yaml update (NOAA-GFDL#901)
Browse files Browse the repository at this point in the history
* Fix issue checking if frequency is valid, fix reading the diurnal and pow reduction

* Corrects error message

* changes logic to make more sense
  • Loading branch information
uramirez8707 authored and rem1776 committed May 1, 2024
1 parent 25633da commit 3409cc4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions diag_manager/fms_diag_yaml.F90
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,8 @@ function get_total_num_vars(diag_yaml_id, diag_file_ids) &
subroutine check_file_freq(fileobj)
type(diagYamlFiles_type), intent(inout) :: fileobj !< diagYamlFiles_type obj to check

if (fileobj%file_freq < 1 ) &
call mpp_error(FATAL, "freq must be greater than 0. &
if (.not. (fileobj%file_freq >= -1) ) &
call mpp_error(FATAL, "freq must be greater than or equal to -1. &
&Check you entry for"//trim(fileobj%file_fname))
if(.not. is_valid_time_units(fileobj%file_frequnit)) &
call mpp_error(FATAL, trim(fileobj%file_frequnit)//" is not a valid file_frequnit. &
Expand Down Expand Up @@ -574,14 +574,14 @@ subroutine check_field_reduction(field)
n_diurnal = 0
pow_value = 0
ioerror = 0
if (field%var_reduction(1:7) .eq. "diurnal") then
if (index(field%var_reduction, "diurnal") .ne. 0) then
READ (UNIT=field%var_reduction(8:LEN_TRIM(field%var_reduction)), FMT=*, IOSTAT=ioerror) n_diurnal
if (ioerror .ne. 0) &
call mpp_error(FATAL, "Error getting the number of diurnal samples from "//trim(field%var_reduction))
if (n_diurnal .le. 0) &
call mpp_error(FATAL, "Diurnal samples should be greater than 0. &
& Check your entry for file:"//trim(field%var_varname)//" in file "//trim(field%var_fname))
elseif (field%var_reduction(1:3) .eq. "pow") then
elseif (index(field%var_reduction, "pow") .ne. 0) then
READ (UNIT=field%var_reduction(4:LEN_TRIM(field%var_reduction)), FMT=*, IOSTAT=ioerror) pow_value
if (ioerror .ne. 0) &
call mpp_error(FATAL, "Error getting the power value from "//trim(field%var_reduction))
Expand Down
2 changes: 1 addition & 1 deletion test_fms/diag_manager/diagTables/diag_table_yaml_26
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ diag_files:
dim1_begin: 64.0
dim3_end: 20.0
- file_name: normal2
freq: 24
freq: -1
freq_units: days
time_units: hours
unlimdim: records
Expand Down
2 changes: 1 addition & 1 deletion test_fms/diag_manager/test_diag_yaml.F90
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ subroutine compare_diag_files(res)

call compare_result("file_freq 1", res(1)%get_file_freq(), 6)
call compare_result("file_freq 2", res(2)%get_file_freq(), 24)
call compare_result("file_freq 3", res(3)%get_file_freq(), 24)
call compare_result("file_freq 3", res(3)%get_file_freq(), -1)

call compare_result("file_frequnit 1", res(1)%get_file_frequnit(), "hours")
call compare_result("file_frequnit 2", res(2)%get_file_frequnit(), "days")
Expand Down

0 comments on commit 3409cc4

Please sign in to comment.