@@ -36,103 +36,175 @@ module penf_b_size
36
36
endinterface
37
37
38
38
contains
39
- elemental function bit_size_R16P (i ) result(bits)
40
- ! < Compute the number of bits of a real variable.
41
- real (R16P), intent (in ) :: i ! < Real variable whose number of bits must be computed.
42
- integer (I2P) :: bits ! < Number of bits of r.
43
- integer (I1P) :: mold(1 ) ! < "Molding" dummy variable for bits counting.
44
-
45
- bits = size (transfer (i, mold), dim= 1 , kind= I2P) * 8_I2P
46
- end function bit_size_R16P
47
-
48
- elemental function bit_size_R8P (i ) result(bits)
49
- ! < Compute the number of bits of a real variable.
50
- real (R8 P), intent (in ) :: i ! < Real variable whose number of bits must be computed.
51
- integer (I1P) :: bits ! < Number of bits of r.
52
- integer (I1P) :: mold(1 ) ! < "Molding" dummy variable for bits counting.
53
-
54
- bits = size (transfer (i, mold), dim= 1 , kind= I1P) * 8_I1P
55
- end function bit_size_R8P
56
-
57
- elemental function bit_size_R4P (i ) result(bits)
58
- ! < Compute the number of bits of a real variable.
59
- real (R4 P), intent (in ) :: i ! < Real variable whose number of bits must be computed.
60
- integer (I1P) :: bits ! < Number of bits of r.
61
- integer (I1P) :: mold(1 ) ! < "Molding" dummy variable for bits counting.
62
-
63
- bits = size (transfer (i, mold), dim= 1 , kind= I1P) * 8_I1P
64
- end function bit_size_R4P
65
-
66
- elemental function bit_size_chr (i ) result(bits)
67
- ! < Compute the number of bits of a character variable.
68
- character (* ), intent (IN ) :: i ! < Character variable whose number of bits must be computed.
69
- integer (I4P) :: bits ! < Number of bits of c.
70
- integer (I1P) :: mold(1 ) ! < "Molding" dummy variable for bits counting.
71
-
72
- bits = size (transfer (i, mold), dim= 1 , kind= I4P) * 8_I4P
73
- end function bit_size_chr
74
-
75
- elemental function byte_size_I8P (i ) result(bytes)
76
- ! < Compute the number of bytes of an integer variable.
77
- integer (I8P), intent (in ) :: i ! < Integer variable whose number of bytes must be computed.
78
- integer (I1P) :: bytes ! < Number of bytes of i.
79
-
80
- bytes = bit_size (i)/ 8_I1P
81
- end function byte_size_I8P
82
-
83
- elemental function byte_size_I4P (i ) result(bytes)
84
- ! < Compute the number of bytes of an integer variable.
85
- integer (I4P), intent (in ) :: i ! < Integer variable whose number of bytes must be computed.
86
- integer (I1P) :: bytes ! < Number of bytes of i.
87
-
88
- bytes = bit_size (i)/ 8_I1P
89
- end function byte_size_I4P
90
-
91
- elemental function byte_size_I2P (i ) result(bytes)
92
- ! < Compute the number of bytes of an integer variable.
93
- integer (I2P), intent (in ) :: i ! < Integer variable whose number of bytes must be computed.
94
- integer (I1P) :: bytes ! < Number of bytes of i.
95
-
96
- bytes = bit_size (i)/ 8_I1P
97
- end function byte_size_I2P
98
-
99
- elemental function byte_size_I1P (i ) result(bytes)
100
- ! < Compute the number of bytes of an integer variable.
101
- integer (I1P), intent (in ) :: i ! < Integer variable whose number of bytes must be computed.
102
- integer (I1P) :: bytes ! < Number of bytes of i.
103
-
104
- bytes = bit_size (i)/ 8_I1P
105
- end function byte_size_I1P
106
-
107
- elemental function byte_size_R16P (i ) result(bytes)
108
- ! < Compute the number of bytes of a real variable.
109
- real (R16P), intent (in ) :: i ! < Real variable whose number of bytes must be computed.
110
- integer (I1P) :: bytes ! < Number of bytes of r.
111
-
112
- bytes = bit_size (i)/ 8_I1P
113
- end function byte_size_R16P
114
-
115
- elemental function byte_size_R8P (i ) result(bytes)
116
- ! < Compute the number of bytes of a real variable.
117
- real (R8 P), intent (in ) :: i ! < Real variable whose number of bytes must be computed.
118
- integer (I1P) :: bytes ! < Number of bytes of r.
119
-
120
- bytes = bit_size (i)/ 8_I1P
121
- end function byte_size_R8P
122
-
123
- elemental function byte_size_R4P (i ) result(bytes)
124
- ! < Compute the number of bytes of a real variable.
125
- real (R4 P), intent (in ) :: i ! < Real variable whose number of bytes must be computed.
126
- integer (I1P) :: bytes ! < Number of bytes of r.
127
-
128
- bytes = bit_size (i)/ 8_I1P
129
- end function byte_size_R4P
130
-
131
- elemental function byte_size_chr (i ) result(bytes)
132
- ! < Compute the number of bytes of a character variable.
133
- character (* ), intent (in ) :: i ! < Character variable whose number of bytes must be computed.
134
- integer (I4P) :: bytes ! < Number of bytes of c.
135
-
136
- bytes = bit_size (i)/ 8_I4P
137
- end function byte_size_chr
39
+ elemental function bit_size_R16P (i ) result(bits)
40
+ ! < Compute the number of bits of a real variable.
41
+ ! <
42
+ ! <```fortran
43
+ ! < use penf
44
+ ! < print FI2P, bit_size(1._R16P)
45
+ ! <```
46
+ ! => 128 <<<
47
+ real (R16P), intent (in ) :: i ! < Real variable whose number of bits must be computed.
48
+ integer (I2P) :: bits ! < Number of bits of r.
49
+ integer (I1P) :: mold(1 ) ! < "Molding" dummy variable for bits counting.
50
+
51
+ bits = size (transfer (i, mold), dim= 1 , kind= I2P) * 8_I2P
52
+ end function bit_size_R16P
53
+
54
+ elemental function bit_size_R8P (i ) result(bits)
55
+ ! < Compute the number of bits of a real variable.
56
+ ! <
57
+ ! <```fortran
58
+ ! < use penf
59
+ ! < print FI1P, bit_size(1._R8P)
60
+ ! <```
61
+ ! => 64 <<<
62
+ real (R8 P), intent (in ) :: i ! < Real variable whose number of bits must be computed.
63
+ integer (I1P) :: bits ! < Number of bits of r.
64
+ integer (I1P) :: mold(1 ) ! < "Molding" dummy variable for bits counting.
65
+
66
+ bits = size (transfer (i, mold), dim= 1 , kind= I1P) * 8_I1P
67
+ end function bit_size_R8P
68
+
69
+ elemental function bit_size_R4P (i ) result(bits)
70
+ ! < Compute the number of bits of a real variable.
71
+ ! <
72
+ ! <```fortran
73
+ ! < use penf
74
+ ! < print FI1P, bit_size(1._R4P)
75
+ ! <```
76
+ ! => 32 <<<
77
+ real (R4 P), intent (in ) :: i ! < Real variable whose number of bits must be computed.
78
+ integer (I1P) :: bits ! < Number of bits of r.
79
+ integer (I1P) :: mold(1 ) ! < "Molding" dummy variable for bits counting.
80
+
81
+ bits = size (transfer (i, mold), dim= 1 , kind= I1P) * 8_I1P
82
+ end function bit_size_R4P
83
+
84
+ elemental function bit_size_chr (i ) result(bits)
85
+ ! < Compute the number of bits of a character variable.
86
+ ! <
87
+ ! <```fortran
88
+ ! < use penf
89
+ ! < print FI4P, bit_size('ab')
90
+ ! <```
91
+ ! => 16 <<<
92
+ character (* ), intent (IN ) :: i ! < Character variable whose number of bits must be computed.
93
+ integer (I4P) :: bits ! < Number of bits of c.
94
+ integer (I1P) :: mold(1 ) ! < "Molding" dummy variable for bits counting.
95
+
96
+ bits = size (transfer (i, mold), dim= 1 , kind= I4P) * 8_I4P
97
+ end function bit_size_chr
98
+
99
+ elemental function byte_size_R16P (i ) result(bytes)
100
+ ! < Compute the number of bytes of a real variable.
101
+ ! <
102
+ ! <```fortran
103
+ ! < use penf
104
+ ! < print FI1P, byte_size(1._R16P)
105
+ ! <```
106
+ ! => 16 <<<
107
+ real (R16P), intent (in ) :: i ! < Real variable whose number of bytes must be computed.
108
+ integer (I1P) :: bytes ! < Number of bytes of r.
109
+
110
+ bytes = bit_size (i) / 8_I1P
111
+ end function byte_size_R16P
112
+
113
+ elemental function byte_size_R8P (i ) result(bytes)
114
+ ! < Compute the number of bytes of a real variable.
115
+ ! <
116
+ ! <```fortran
117
+ ! < use penf
118
+ ! < print FI1P, byte_size(1._R8P)
119
+ ! <```
120
+ ! => 8 <<<
121
+ real (R8 P), intent (in ) :: i ! < Real variable whose number of bytes must be computed.
122
+ integer (I1P) :: bytes ! < Number of bytes of r.
123
+
124
+ bytes = bit_size (i) / 8_I1P
125
+ end function byte_size_R8P
126
+
127
+ elemental function byte_size_R4P (i ) result(bytes)
128
+ ! < Compute the number of bytes of a real variable.
129
+ ! <
130
+ ! <```fortran
131
+ ! < use penf
132
+ ! < print FI1P, byte_size(1._R4P)
133
+ ! <```
134
+ ! => 4 <<<
135
+ real (R4 P), intent (in ) :: i ! < Real variable whose number of bytes must be computed.
136
+ integer (I1P) :: bytes ! < Number of bytes of r.
137
+
138
+ bytes = bit_size (i) / 8_I1P
139
+ end function byte_size_R4P
140
+
141
+ elemental function byte_size_chr (i ) result(bytes)
142
+ ! < Compute the number of bytes of a character variable.
143
+ ! <
144
+ ! <```fortran
145
+ ! < use penf
146
+ ! < print FI1P, byte_size('ab')
147
+ ! <```
148
+ ! => 2 <<<
149
+ character (* ), intent (in ) :: i ! < Character variable whose number of bytes must be computed.
150
+ integer (I4P) :: bytes ! < Number of bytes of c.
151
+
152
+ bytes = bit_size (i) / 8_I4P
153
+ end function byte_size_chr
154
+
155
+ elemental function byte_size_I8P (i ) result(bytes)
156
+ ! < Compute the number of bytes of an integer variable.
157
+ ! <
158
+ ! <```fortran
159
+ ! < use penf
160
+ ! < print FI1P, byte_size(1_I8P)
161
+ ! <```
162
+ ! => 8 <<<
163
+ integer (I8P), intent (in ) :: i ! < Integer variable whose number of bytes must be computed.
164
+ integer (I1P) :: bytes ! < Number of bytes of i.
165
+
166
+ bytes = bit_size (i) / 8_I1P
167
+ end function byte_size_I8P
168
+
169
+ elemental function byte_size_I4P (i ) result(bytes)
170
+ ! < Compute the number of bytes of an integer variable.
171
+ ! <
172
+ ! <```fortran
173
+ ! < use penf
174
+ ! < print FI1P, byte_size(1_I4P)
175
+ ! <```
176
+ ! => 4 <<<
177
+ integer (I4P), intent (in ) :: i ! < Integer variable whose number of bytes must be computed.
178
+ integer (I1P) :: bytes ! < Number of bytes of i.
179
+
180
+ bytes = bit_size (i) / 8_I1P
181
+ end function byte_size_I4P
182
+
183
+ elemental function byte_size_I2P (i ) result(bytes)
184
+ ! < Compute the number of bytes of an integer variable.
185
+ ! <
186
+ ! <```fortran
187
+ ! < use penf
188
+ ! < print FI1P, byte_size(1_I2P)
189
+ ! <```
190
+ ! => 2 <<<
191
+ integer (I2P), intent (in ) :: i ! < Integer variable whose number of bytes must be computed.
192
+ integer (I1P) :: bytes ! < Number of bytes of i.
193
+
194
+ bytes = bit_size (i) / 8_I1P
195
+ end function byte_size_I2P
196
+
197
+ elemental function byte_size_I1P (i ) result(bytes)
198
+ ! < Compute the number of bytes of an integer variable.
199
+ ! <
200
+ ! <```fortran
201
+ ! < use penf
202
+ ! < print FI1P, byte_size(1_I1P)
203
+ ! <```
204
+ ! => 1 <<<
205
+ integer (I1P), intent (in ) :: i ! < Integer variable whose number of bytes must be computed.
206
+ integer (I1P) :: bytes ! < Number of bytes of i.
207
+
208
+ bytes = bit_size (i) / 8_I1P
209
+ end function byte_size_I1P
138
210
endmodule penf_b_size
0 commit comments