gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
historyputline.f90
Go to the documentation of this file.
1
14
41 subroutine historyputline( history, unit, indent, err )
42 !
46 use gtdata_generic, only: gtputline => putline
47 use dc_trace, only: beginsub, endsub
48 use dc_string, only: printf, joinchar, strputline => putline
49 use dc_types, only: string, token, stdout, dp
50 use dc_error, only: storeerror, dc_noerr
51 implicit none
52 type(gt_history), intent(in), target, optional:: history
53 integer, intent(in), optional:: unit
54 ! 出力先の装置番号.
55 ! デフォルトの出力先は標準出力.
56 !
57 ! Unit number for output.
58 ! Default value is standard output.
59 character(*), intent(in), optional:: indent
60 ! 表示されるメッセージの字下げ.
61 !
62 ! Indent of displayed messages.
63 logical, intent(out), optional:: err
64 ! 例外処理用フラグ.
65 ! デフォルトでは, この手続き内でエラーが
66 ! 生じた場合, プログラムは強制終了します.
67 ! 引数 *err* が与えられる場合,
68 ! プログラムは強制終了せず, 代わりに
69 ! *err* に .true. が代入されます.
70 !
71 ! Exception handling flag.
72 ! By default, when error occur in
73 ! this procedure, the program aborts.
74 ! If this *err* argument is given,
75 ! .true. is substituted to *err* and
76 ! the program does not abort.
77
78 !-----------------------------------
79 ! 作業変数
80 ! Work variables
81 type(gt_history), pointer:: hst =>null()
82 integer:: i, max
83 integer:: stat
84 character(STRING):: cause_c
85 integer:: out_unit
86 integer:: indent_len
87 character(STRING):: indent_str
88
89 character(STRING):: file, title, source, institution
90 character(STRING):: conventions, gt_version
91 character(TOKEN), pointer:: dims(:) =>null()
92 integer, pointer:: dimsizes(:) =>null()
93 character(STRING), pointer:: longnames(:) =>null()
94 character(TOKEN), pointer:: units(:) =>null()
95 character(TOKEN), pointer:: xtypes(:) =>null()
96
97 real(DP):: origin, interval, newest, oldest
98 character(*), parameter:: subname = 'HistoryPutLine'
99 continue
100 call beginsub( subname )
101 stat = dc_noerr
102 cause_c = ''
103
104 !-----------------------------------------------------------------
105 ! 出力先装置番号と字下げの設定
106 ! Configure output unit number and indents
107 !-----------------------------------------------------------------
108 if ( present(unit) ) then
109 out_unit = unit
110 else
111 out_unit = stdout
112 end if
113
114 indent_len = 0
115 indent_str = ''
116 if ( present(indent) ) then
117 if ( len(indent) /= 0 ) then
118 indent_len = len(indent)
119 indent_str(1:indent_len) = indent
120 end if
121 end if
122
123 if (present(history)) then
124 hst => history
125 else
126 hst => default
127 endif
128
129 !-----------------------------------------------------------------
130 ! "GT_HISTORY" の設定の印字
131 ! Print the settings for "GT_HISTORY"
132 !-----------------------------------------------------------------
133 if ( hst % initialized ) then
134 call printf( out_unit, &
135 & indent_str(1:indent_len) // &
136 & '#<GT_HISTORY:: @initialized=%y', &
137 & l = (/hst % initialized/) )
138
139 call historyinquire( history = hst, & ! (in)
140 & err = err, & ! (out)
141 & file = file, title = title, & ! (out)
142 & source = source, institution = institution, & ! (out)
143 & dims = dims, dimsizes = dimsizes, & ! (out)
144 & longnames = longnames, & ! (out)
145 & units = units, xtypes = xtypes, & ! (out)
146 & conventions = conventions, & ! (out)
147 & gt_version = gt_version ) ! (out)
148
149 call printf( out_unit, &
150 & indent_str(1:indent_len) // &
151 & ' @file=%c @title=%c', &
152 & c1 = trim(file), c2 = trim(title) )
153
154 call printf( out_unit, &
155 & indent_str(1:indent_len) // &
156 & ' @source=%c @institution=%c', &
157 & c1 = trim(source), c2 = trim(institution) )
158
159 max = size( dims )
160 call printf( out_unit, &
161 & indent_str(1:indent_len) // &
162 & ' @dims=%c @dimsizes=%*d', &
163 & c1 = trim( joinchar(dims, ',') ), &
164 & i = dimsizes, n = (/max/) )
165 deallocate( dims, dimsizes )
166
167 call printf( out_unit, &
168 & indent_str(1:indent_len) // &
169 & ' @longnames=%c', &
170 & c1 = trim( joinchar(longnames, ',') ) )
171 deallocate( longnames )
172
173 call printf( out_unit, &
174 & indent_str(1:indent_len) // &
175 & ' @units=%c @xtypes=%c', &
176 & c1 = trim( joinchar(units, ',') ), &
177 & c2 = trim( joinchar(xtypes, ',') ) )
178 deallocate( units, xtypes )
179
180 call printf( out_unit, &
181 & indent_str(1:indent_len) // &
182 & ' @conventions=%c @gt_version=%c', &
183 & c1 = trim(conventions), c2 = trim(gt_version) )
184
185 call printf( out_unit, &
186 & indent_str(1:indent_len) // &
187 & ' @unlimited_index=%d', &
188 & i = (/hst % unlimited_index/) )
189
190 max = size( hst % dim_value_written )
191 call printf( out_unit, &
192 & indent_str(1:indent_len) // &
193 & ' @dim_value_written=%*y', &
194 & l = hst % dim_value_written, n = (/max/) )
195
196 origin = real(hst % origin, kind=kind(origin))
197 interval = real(hst % interval, kind=kind(interval))
198 newest = real(hst % newest, kind=kind(newest))
199 oldest = real(hst % oldest, kind=kind(oldest))
200
201!!$ origin = EvalByUnit( hst % origin, '', hst % unlimited_units_symbol )
202!!$ interval = EvalByUnit( hst % interval, '', hst % unlimited_units_symbol )
203!!$ newest = EvalByUnit( hst % newest, '', hst % unlimited_units_symbol )
204!!$ oldest = EvalByUnit( hst % oldest, '', hst % unlimited_units_symbol )
205
206 call printf( out_unit, &
207 & indent_str(1:indent_len) // &
208 & ' @origin=%r @interval=%r @newest=%r @oldest=%r', &
209 & d = (/origin, interval, newest, oldest/) )
210
211 if ( associated( hst % growable_indices ) ) then
212 max = size( hst % growable_indices )
213 call printf( out_unit, &
214 & indent_str(1:indent_len) // &
215 & ' @growable_indices=%*d', &
216 & i = hst % growable_indices, n = (/max/) )
217 else
218 call printf( out_unit, &
219 & indent_str(1:indent_len) // &
220 & ' @growable_indices=<null>' )
221 end if
222
223 if ( associated( hst % count ) ) then
224 max = size( hst % count )
225 call printf( out_unit, &
226 & indent_str(1:indent_len) // &
227 & ' @count=%*d', &
228 & i = hst % count, n = (/max/) )
229 else
230 call printf( out_unit, &
231 & indent_str(1:indent_len) // &
232 & ' @count=<null>' )
233 end if
234
235 if ( associated( hst % dimvars ) ) then
236 call printf( out_unit, &
237 & indent_str(1:indent_len) // &
238 & ' @dimvars=' )
239 max = size( hst % dimvars )
240 do i = 1, max
241 call gtputline( hst % dimvars(i), out_unit, &
242 & indent_str(1:indent_len) // ' ', err )
243 end do
244 else
245 call printf( out_unit, &
246 & indent_str(1:indent_len) // &
247 & ' @dimvars=<null>' )
248 end if
249
250 if ( associated( hst % vars ) ) then
251 call printf( out_unit, &
252 & indent_str(1:indent_len) // &
253 & ' @vars=' )
254 max = size( hst % vars )
255 do i = 1, max
256 call gtputline( hst % vars(i), out_unit, &
257 & indent_str(1:indent_len) // ' ', err )
258 end do
259 else
260 call printf( out_unit, &
261 & indent_str(1:indent_len) // &
262 & ' @vars=<null>' )
263 end if
264
265 if ( associated( hst % var_avr_count ) ) then
266 max = size( hst % var_avr_count )
267 call printf( out_unit, &
268 & indent_str(1:indent_len) // &
269 & ' @var_avr_count=%*d', &
270 & i = hst % var_avr_count, n = (/max/) )
271 else
272 call printf( out_unit, &
273 & indent_str(1:indent_len) // &
274 & ' @var_avr_count=<null>' )
275 end if
276
277 if ( associated( hst % var_avr_firstput ) ) then
278 max = size( hst % var_avr_firstput )
279 call printf( out_unit, &
280 & indent_str(1:indent_len) // &
281 & ' @var_avr_firstput=%*b', &
282 & l = hst % var_avr_firstput, n = (/max/) )
283 else
284 call printf( out_unit, &
285 & indent_str(1:indent_len) // &
286 & ' @var_avr_firstput=<null>' )
287 end if
288
289 if ( associated( hst % var_avr_coefsum ) ) then
290 max = size( hst % var_avr_coefsum )
291 call printf( out_unit, &
292 & indent_str(1:indent_len) // &
293 & ' @var_avr_coefsum=%*f', &
294 & d = hst % var_avr_coefsum, n = (/max/) )
295 else
296 call printf( out_unit, &
297 & indent_str(1:indent_len) // &
298 & ' @var_avr_coefsum=<null>' )
299 end if
300
301 call printf( out_unit, &
302 & indent_str(1:indent_len) // &
303 & ' @time_bnds=%*f, @time_bnds_output_count=%d', &
304 & i = (/hst % time_bnds_output_count/), &
305 & d = hst % time_bnds, &
306 & n = (/ size(hst % time_bnds) /) )
307
308 if ( associated( hst % var_avr_data ) ) then
309 call printf( out_unit, &
310 & indent_str(1:indent_len) // &
311 & ' @var_avr_data=' )
312 max = size( hst % var_avr_data )
313 do i = 1, max
314 call printf( out_unit, &
315 & indent_str(1:indent_len) // &
316 & ' #<GT_HISTORY_AVRDATA:: @length=%d', &
317 & i = (/hst % var_avr_data(i) % length/) )
318 call strputline( hst % var_avr_data(i) % a_DataAvr, unit = out_unit, &
319 & lbounds = lbound(hst % var_avr_data(i) % a_DataAvr), &
320 & ubounds = ubound(hst % var_avr_data(i) % a_DataAvr), &
321 & indent = indent_str(1:indent_len) // &
322 & ' @a_DataAvr=' )
323 end do
324 else
325 call printf( out_unit, &
326 & indent_str(1:indent_len) // &
327 & ' @var_avr_data=<null>' )
328 end if
329
330 call printf( out_unit, &
331 & indent_str(1:indent_len) // &
332 & '>' )
333 else
334 call printf( out_unit, &
335 & indent_str(1:indent_len) // &
336 & '#<GT_HISTORY:: @initialized=%y>', &
337 & l = (/hst % initialized/) )
338 end if
339
340 !-----------------------------------------------------------------
341 ! 終了処理, 例外処理
342 ! Termination and Exception handling
343 !-----------------------------------------------------------------
344 call storeerror( stat, subname, err, cause_c )
345 call endsub( subname )
346 end subroutine historyputline
subroutine historyputline(history, unit, indent, err)
Error handling module.
Definition dc_error.f90:454
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition dc_error.f90:891
integer, parameter, public dc_noerr
Error storage variables
Definition dc_error.f90:468
Handling character types.
Definition dc_string.f90:83
character(string) function, public joinchar(carray, expr)
Debug tracing module.
Definition dc_trace.f90:150
subroutine, public beginsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca, version)
Definition dc_trace.f90:457
subroutine, public endsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca)
Definition dc_trace.f90:580
Provides kind type parameter values.
Definition dc_types.f90:55
integer, parameter, public stdout
Unit number for Standard OUTPUT
Definition dc_types.f90:117
integer, parameter, public token
Character length for word, token
Definition dc_types.f90:128
integer, parameter, public dp
Double Precision Real number
Definition dc_types.f90:92
integer, parameter, public string
Character length for string
Definition dc_types.f90:137
type(gt_history), target, save, public default