Skip to content

Commit

Permalink
add number of diurnal sample and power level to the yaml (NOAA-GFDL#977)
Browse files Browse the repository at this point in the history
* Adds variables to hold the number of diurnal samples and the power value
  • Loading branch information
uramirez8707 authored and rem1776 committed May 1, 2024
1 parent 51a2707 commit 0093bef
Showing 1 changed file with 41 additions and 3 deletions.
44 changes: 41 additions & 3 deletions diag_manager/fms_diag_yaml.F90
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ module fms_diag_yaml_mod
character (len=:), private, allocatable :: var_outname !< Name of the variable as written to the file
character (len=:), private, allocatable :: var_longname !< Overwrites the long name of the variable
character (len=:), private, allocatable :: var_units !< Overwrites the units
integer , private :: n_diurnal !< Number of diurnal samples
!! 0 if var_reduction is not "diurnalXX"
integer , private :: pow_value !< The power value
!! 0 if pow_value is not "powXX"

!< Need to use `MAX_STR_LEN` because not all filenames/global attributes are the same length
character (len=MAX_STR_LEN), dimension (:, :), private, allocatable :: var_attributes !< Attributes to overwrite or
Expand All @@ -172,6 +176,8 @@ module fms_diag_yaml_mod
procedure :: get_var_longname
procedure :: get_var_units
procedure :: get_var_attributes
procedure :: get_n_diurnal
procedure :: get_pow_value
procedure :: is_var_attributes

procedure :: has_var_fname
Expand All @@ -183,6 +189,8 @@ module fms_diag_yaml_mod
procedure :: has_var_longname
procedure :: has_var_units
procedure :: has_var_attributes
procedure :: has_n_diurnal
procedure :: has_pow_value

end type diagYamlFilesVar_type

Expand Down Expand Up @@ -674,8 +682,9 @@ subroutine check_field_kind(field)
end subroutine check_field_kind

!> @brief This checks if the reduction of a diag field is valid and crashes if it isn't
!! If the reduction method is diurnalXX or powXX, it gets the number of diurnal sample and the power value
subroutine check_field_reduction(field)
type(diagYamlFilesVar_type), intent(in) :: field !< diagYamlFilesVar_type obj to read the contents into
type(diagYamlFilesVar_type), intent(inout) :: field !< diagYamlFilesVar_type obj to read the contents into

integer :: n_diurnal !< number of diurnal samples
integer :: pow_value !< The power value
Expand Down Expand Up @@ -707,6 +716,9 @@ subroutine check_field_reduction(field)
&Check your entry for file:"//trim(field%var_varname)//" in file "//trim(field%var_fname))
end select
endif

field%n_diurnal = n_diurnal
field%pow_value = pow_value
end subroutine check_field_reduction

!> @brief This checks if a time unit is valid
Expand Down Expand Up @@ -918,6 +930,22 @@ pure function get_var_attributes(diag_var_obj) &
character (len=MAX_STR_LEN), allocatable :: res (:,:) !< What is returned
res = diag_var_obj%var_attributes
end function get_var_attributes
!> @brief Inquiry for diag_yaml_files_var_obj%n_diurnal
!! @return the number of diurnal samples of a diag_yaml_files_var_obj
pure function get_n_diurnal(diag_var_obj) &
result (res)
class (diagYamlFilesVar_type), intent(in) :: diag_var_obj !< The object being inquiried
integer :: res !< What is returned
res = diag_var_obj%n_diurnal
end function get_n_diurnal
!> @brief Inquiry for diag_yaml_files_var_obj%pow_value
!! @return the pow_value of a diag_yaml_files_var_obj
pure function get_pow_value(diag_var_obj) &
result (res)
class (diagYamlFilesVar_type), intent(in) :: diag_var_obj !< The object being inquiried
integer :: res !< What is returned
res = diag_var_obj%pow_value
end function get_pow_value
!> @brief Inquiry for whether var_attributes is allocated
!! @return Flag indicating if var_attributes is allocated
function is_var_attributes(diag_var_obj) &
Expand Down Expand Up @@ -1091,8 +1119,18 @@ pure logical function has_var_attributes (obj)
class(diagYamlFilesVar_type), intent(in) :: obj !< diagYamlvar_type object to initialize
has_var_attributes = allocated(obj%var_attributes)
end function has_var_attributes


!> @brief Checks if obj%n_diurnal is set
!! @return true if obj%n_diurnal is set
pure logical function has_n_diurnal(obj)
class(diagYamlFilesVar_type), intent(in) :: obj !< diagYamlvar_type object to inquire
has_n_diurnal = (obj%n_diurnal .ne. 0)
end function has_n_diurnal
!> @brief Checks if obj%pow_value is set
!! @return true if obj%pow_value is set
pure logical function has_pow_value(obj)
class(diagYamlFilesVar_type), intent(in) :: obj !< diagYamlvar_type object to inquire
has_pow_value = (obj%pow_value .ne. 0)
end function has_pow_value

!> @brief Checks if obj%diag_title is allocated
!! @return true if obj%diag_title is allocated
Expand Down

0 comments on commit 0093bef

Please sign in to comment.