From 82b1dcef5e82d99d338273a902d916223fa91b10 Mon Sep 17 00:00:00 2001 From: uramirez8707 <49168881+uramirez8707@users.noreply.github.com> Date: Fri, 21 Apr 2023 12:05:15 -0400 Subject: [PATCH] Modern diag_manager: Add a function that determine the type of the variable (#1197) * Add a function to get the type of a variable in the diag manager --- diag_manager/diag_data.F90 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/diag_manager/diag_data.F90 b/diag_manager/diag_data.F90 index ddf56604f..bdbbdc448 100644 --- a/diag_manager/diag_data.F90 +++ b/diag_manager/diag_data.F90 @@ -584,6 +584,30 @@ subroutine fms_add_attribute(this, att_name, att_value) end select end subroutine fms_add_attribute + !> @brief gets the type of a variable + !> @return the type of the variable (r4,r8,i4,i8,string) + function get_var_type(var) & + result(var_type) + class(*), intent(in) :: var !< Variable to get the type for + integer :: var_type !< The variable's type + + select type(var) + type is (real(r4_kind)) + var_type = r4 + type is (real(r8_kind)) + var_type = r8 + type is (integer(i4_kind)) + var_type = i4 + type is (integer(i8_kind)) + var_type = i8 + type is (character(len=*)) + var_type = string + class default + call mpp_error(FATAL, "get_var_type:: The variable does not have a supported type. "& + &"The supported types are r4, r8, i4, i8 and string.") + end select + end function get_var_type + !> @brief Writes out the attributes from an fmsDiagAttribute_type subroutine write_metadata(this, fileobj, var_name, cell_methods) class(fmsDiagAttribute_type), intent(inout) :: this !< Diag attribute type