Skip to content

Commit

Permalink
Modern diag_manager: Add a function that determine the type of the va…
Browse files Browse the repository at this point in the history
…riable (NOAA-GFDL#1197)

* Add a function to get the type of a variable in the diag manager
  • Loading branch information
uramirez8707 authored and rem1776 committed May 1, 2024
1 parent 581d9db commit 82b1dce
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions diag_manager/diag_data.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 82b1dce

Please sign in to comment.