From 0093bef99e24af9a93483efd4bc7ec475dcb26fb Mon Sep 17 00:00:00 2001 From: uramirez8707 <49168881+uramirez8707@users.noreply.github.com> Date: Mon, 16 May 2022 13:34:47 -0400 Subject: [PATCH] add number of diurnal sample and power level to the yaml (#977) * Adds variables to hold the number of diurnal samples and the power value --- diag_manager/fms_diag_yaml.F90 | 44 +++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/diag_manager/fms_diag_yaml.F90 b/diag_manager/fms_diag_yaml.F90 index 11072f3ad..1a6cd9f39 100644 --- a/diag_manager/fms_diag_yaml.F90 +++ b/diag_manager/fms_diag_yaml.F90 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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) & @@ -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