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