FMS 2025.01.02-dev
Flexible Modeling System
Loading...
Searching...
No Matches
get_data_type_string.inc
1!***********************************************************************
2!* GNU Lesser General Public License
3!*
4!* This file is part of the GFDL Flexible Modeling System (FMS).
5!*
6!* FMS is free software: you can redistribute it and/or modify it under
7!* the terms of the GNU Lesser General Public License as published by
8!* the Free Software Foundation, either version 3 of the License, or (at
9!* your option) any later version.
10!*
11!* FMS is distributed in the hope that it will be useful, but WITHOUT
12!* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13!* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14!* for more details.
15!*
16!* You should have received a copy of the GNU Lesser General Public
17!* License along with FMS. If not, see <http://www.gnu.org/licenses/>.
18!***********************************************************************
19!> @file
20!> @brief Routines to return a given arguments data type as a string.
21!! Provides multiple dimensions for @ref get_data_type_string interface.
22
23!> @addtogroup fms_io_utils_mod
24!> @{
25
26!> @brief Return a string describing the input data's type.
27subroutine get_data_type_string_0d(sdata, type_string)
28
29 class(*), intent(in) :: sdata !> Data.
30 character(len=*), intent(inout) :: type_string !> Data type.
31
32 select type(sdata)
33 type is (integer(kind=i4_kind))
34 call string_copy(type_string, "int")
35 type is (integer(kind=i8_kind))
36 call string_copy(type_string, "i8_kind")
37 type is (real(kind=r4_kind))
38 call string_copy(type_string, "float")
39 type is (real(kind=r8_kind))
40 call string_copy(type_string, "double")
41 type is (character(len=*))
42 call string_copy(type_string, "char")
43 class default
44 call error("unsupported type.")
45 end select
46end subroutine get_data_type_string_0d
47
48
49
50!> @brief Return a string describing the input data's type.
51subroutine get_data_type_string_1d(sdata, type_string)
52
53 class(*), dimension(:), intent(in) :: sdata !> Data.
54 character(len=*), intent(inout) :: type_string !> Data type.
55
56 select type(sdata)
57 type is (integer(kind=i4_kind))
58 call string_copy(type_string, "int")
59 type is (integer(kind=i8_kind))
60 call string_copy(type_string, "i8_kind")
61 type is (real(kind=r4_kind))
62 call string_copy(type_string, "float")
63 type is (real(kind=r8_kind))
64 call string_copy(type_string, "double")
65 type is (character(len=*))
66 call string_copy(type_string, "char")
67 class default
68 call error("unsupported type.")
69 end select
70end subroutine get_data_type_string_1d
71
72
73
74!> @brief Return a string describing the input data's type.
75subroutine get_data_type_string_2d(sdata, type_string)
76
77 class(*), dimension(:,:), intent(in) :: sdata !> Data.
78 character(len=*), intent(inout) :: type_string !> Data type.
79
80 select type(sdata)
81 type is (integer(kind=i4_kind))
82 call string_copy(type_string, "int")
83 type is (integer(kind=i8_kind))
84 call string_copy(type_string, "i8_kind")
85 type is (real(kind=r4_kind))
86 call string_copy(type_string, "float")
87 type is (real(kind=r8_kind))
88 call string_copy(type_string, "double")
89 type is (character(len=*))
90 call string_copy(type_string, "char")
91 class default
92 call error("unsupported type.")
93 end select
94end subroutine get_data_type_string_2d
95
96
97
98!> @brief Return a string describing the input data's type.
99subroutine get_data_type_string_3d(sdata, type_string)
100
101 class(*), dimension(:,:,:), intent(in) :: sdata !> Data.
102 character(len=*), intent(inout) :: type_string !> Data type.
103
104 select type(sdata)
105 type is (integer(kind=i4_kind))
106 call string_copy(type_string, "int")
107 type is (integer(kind=i8_kind))
108 call string_copy(type_string, "i8_kind")
109 type is (real(kind=r4_kind))
110 call string_copy(type_string, "float")
111 type is (real(kind=r8_kind))
112 call string_copy(type_string, "double")
113 type is (character(len=*))
114 call string_copy(type_string, "char")
115 class default
116 call error("unsupported type.")
117 end select
118end subroutine get_data_type_string_3d
119
120
121
122!> @brief Return a string describing the input data's type.
123subroutine get_data_type_string_4d(sdata, type_string)
124
125 class(*), dimension(:,:,:,:), intent(in) :: sdata !> Data.
126 character(len=*), intent(inout) :: type_string !> Data type.
127
128 select type(sdata)
129 type is (integer(kind=i4_kind))
130 call string_copy(type_string, "int")
131 type is (integer(kind=i8_kind))
132 call string_copy(type_string, "i8_kind")
133 type is (real(kind=r4_kind))
134 call string_copy(type_string, "float")
135 type is (real(kind=r8_kind))
136 call string_copy(type_string, "double")
137 type is (character(len=*))
138 call string_copy(type_string, "char")
139 class default
140 call error("unsupported type.")
141 end select
142end subroutine get_data_type_string_4d
143
144
145
146!> @brief Return a string describing the input data's type.
147subroutine get_data_type_string_5d(sdata, type_string)
148
149 class(*), dimension(:,:,:,:,:), intent(in) :: sdata !> Data.
150 character(len=*), intent(inout) :: type_string !> Data type.
151
152 select type(sdata)
153 type is (integer(kind=i4_kind))
154 call string_copy(type_string, "int")
155 type is (integer(kind=i8_kind))
156 call string_copy(type_string, "i8_kind")
157 type is (real(kind=r4_kind))
158 call string_copy(type_string, "float")
159 type is (real(kind=r8_kind))
160 call string_copy(type_string, "double")
161 type is (character(len=*))
162 call string_copy(type_string, "char")
163 class default
164 call error("unsupported type.")
165 end select
166end subroutine get_data_type_string_5d
167!> @}
subroutine get_data_type_string_4d(sdata, type_string)
Return a string describing the input data's type.
subroutine get_data_type_string_5d(sdata, type_string)
Return a string describing the input data's type.
subroutine get_data_type_string_1d(sdata, type_string)
Return a string describing the input data's type.
subroutine get_data_type_string_0d(sdata, type_string)
Return a string describing the input data's type.
subroutine get_data_type_string_3d(sdata, type_string)
Return a string describing the input data's type.
subroutine get_data_type_string_2d(sdata, type_string)
Return a string describing the input data's type.