Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modern diag_manager: Add a function that determine the type of the variable #1197

Merged
merged 3 commits into from
Apr 21, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions diag_manager/diag_data.F90
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,30 @@ subroutine fms_add_attribute(this, att_name, att_value)
this%att_value = 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) &
thomas-robinson marked this conversation as resolved.
Show resolved Hide resolved
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
END MODULE diag_data_mod
!> @}
! close documentation grouping