gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
gtool_history_nmlinfo_generic.f90
Go to the documentation of this file.
1!> @file gtool_history_nmlinfo_generic.f90
2!>
3!> @author Yasuhiro MORIKAWA
4!> @copyright Copyright (C) GFD Dennou Club, 2007-2026. All rights reserved. <br/>
5!> License is BSD-2-Clause. See [COPYRIGHT](@ref COPYRIGHT) in detail
6!>
7!> @en
8!> @brief Interface of procedures provided from gtool_history_nmlinfo
9!> @enden
10!>
11!> @ja
12!> @brief gtool_history_nmlinfo より提供される手続の引用仕様宣言
13!> @endja
14
16 !>
17 !> @en
18 !> @brief Interface of procedures provided from gtool_history_nmlinfo
19 !>
20 !> See gtool_history_nmlinfo for brief of this module.
21 !>
22 !> ### Procedures List
23 !>
24 !> - HstNmlInfoCreate : Constructor of gtool_history_nmlinfo_types::GTHST_NMLINFO
25 !> - HstNmlInfoClose : Destructor of gtool_history_nmlinfo_types::GTHST_NMLINFO
26 !> - HstNmlInfoPutLine : Print information of gtool_history_nmlinfo_types::GTHST_NMLINFO
27 !> - HstNmlInfoInitialized : Check initialization of gtool_history_nmlinfo_types::GTHST_NMLINFO
28 !> - HstNmlInfoDefineMode : True is returned if current state is define mode
29 !> - HstNmlInfoEndDefine : Transit define mode about information of variables to output mode
30 !> - HstNmlInfoReDefine : Transit output mode to define mode about information of variables
31 !> - HstNmlInfoAdd : Add information of variables
32 !> - HstNmlInfoDelete : Delete information of variables
33 !> - HstNmlInfoResetDefault : Reset to default settings
34 !> - HstNmlInfoInquire : Inquire information of variables
35 !> - HstNmlInfoAssocGtHist : gtool_history_types::GT_HISTORY correspond to variable is returned
36 !> - HstNmlInfoOutputStepDisable : Configure that output_step returns .false. already
37 !> - HstNmlInfoOutputStep : True is returned when a configuration of output is valid
38 !> - HstNmlInfoOutputValid : True is returned when current time is output timing
39 !> - HstNmlInfoNames : Return list of registered variable identifiers (function)
40 !> - HstNmlInfoGetNames : Return list of registered variable identifiers (subroutine)
41 !> - HstNmlInfoAllVarIniCheck : Check uninitialized variable names
42 !> - HstNmlInfoSetValidName : Set validation to variable names
43 !> - HstNmlInfoAllNameValid : Check invalid variable names
44 !> @enden
45 !>
46 !> @ja
47 !> @brief gtool_history_nmlinfo より提供される手続の引用仕様宣言
48 !>
49 !> モジュールの概要については, gtool_history_nmlinfo
50 !> を参照ください.
51 !>
52 !> ### 手続リスト
53 !>
54 !> - HstNmlInfoCreate : gtool_history_nmlinfo_types::GTHST_NMLINFO 型変数の初期設定
55 !> - HstNmlInfoClose : gtool_history_nmlinfo_types::GTHST_NMLINFO 型変数の終了処理
56 !> - HstNmlInfoPutLine : gtool_history_nmlinfo_types::GTHST_NMLINFO 型変数に格納されている情報の印字
57 !> - HstNmlInfoInitialized : gtool_history_nmlinfo_types::GTHST_NMLINFO 型変数が初期設定されているか否か
58 !> - HstNmlInfoDefineMode : 定義モードの場合に真を返す
59 !> - HstNmlInfoEndDefine : 変数情報定義モードから出力モードへ変更
60 !> - HstNmlInfoReDefine : 出力モードから変数情報定義モードへ変更
61 !> - HstNmlInfoAdd : 変数情報の追加
62 !> - HstNmlInfoDelete : 変数情報の削除
63 !> - HstNmlInfoResetDefault : デフォルト設定のみに戻す
64 !> - HstNmlInfoInquire : 変数情報の問い合わせ
65 !> - HstNmlInfoAssocGtHist : 変数に応じた gtool_history_types::GT_HISTORY 型変数を返す
66 !> - HstNmlInfoOutputStepDisable : output_step が常に .false. を返すよう設定する
67 !> - HstNmlInfoOutputStep : 出力の設定が有効である場合に真を返す
68 !> - HstNmlInfoOutputValid : 現在の時刻が出力のタイミングの場合に真を返す
69 !> - HstNmlInfoNames : 登録されている変数名リストを返す (関数)
70 !> - HstNmlInfoGetNames : 登録されている変数名リストを返す (サブルーチン)
71 !> - HstNmlInfoAllVarIniCheck : 初期設定されていない変数名のチェック
72 !> - HstNmlInfoSetValidName : 変数名の有効性を設定
73 !> - HstNmlInfoAllNameValid : 無効な変数名のチェック
74 !> @endja
75 !>
76 !>
77 !> @en
78 !> ### Usage
79 !>
80 !> Use this module as follows.
81 !>
82 !> Sample Fortran programs generator (Ruby script) is available from
83 !> http://www.gfd-dennou.org/library/dcpam/dcpam4/dcpam4_current/script/f90/dcmodel_f90sample_maker.rb .
84 !> Sample Fortran programs are created by executing this script.
85 !> It is recommended to see sample Fortran programs actually.
86 !>
87 !> 0. Declare gtool_history_nmlinfo_types::GTHST_NMLINFO variable in the module.
88 !>
89 !> 1. Initialize gtool_history_nmlinfo_types::GTHST_NMLINFO variable by HstNmlInfoCreate.
90 !> On this occasion, configure default
91 !> interval_value, interval_unit,
92 !> precision, time_average, fileprefix (prefix of output file).
93 !>
94 !> 2. Register by using HstNmlInfoAdd when there are variables that
95 !> the program outputs by default.
96 !> Variable identifier is given to name. Do not specify same name
97 !> for different variables because name is used as a key to
98 !> identify the variable. The output file name is given to file.
99 !> A suitable file name is set when not giving it.
100 !>
101 !> 3. Register information of output variables obtained from NAMELIST
102 !> by using HstNmlInfoAdd. When registered name is registered again,
103 !> the setting concerning the name has been overwritten.
104 !>
105 !> 4. Shift from the define mode to output mode by using HstNmlInfoEndDefine
106 !> when registration is completed.
107 !>
108 !> 5. Pass HstNmlInfoAssocGtHist variable identifier name and
109 !> history of gtool_history_types::GT_HISTORY pointer when
110 !> setting output and data output is performed with
111 !> gtool_history_generic::HistoryCreate, gtool_history_generic::HistoryAddVariable,
112 !> gtool_history_generic::HistoryPut, etc.
113 !> history is associated to gtool_history_types::GT_HISTORY correspond
114 !> to name stored in gtool_history_nmlinfo_types::GTHST_NMLINFO variable.
115 !> Necessary output interval and precision for
116 !> gtool_history_generic::HistoryCreate can be obtained by using
117 !> HstNmlInfoInquire.
118 !> Please put history into a null state by NULLIFY after use.
119 !> (Information of output is lost when DEALLOCATE is used,
120 !> so do not use it).
121 !>
122 !> It can know whether the output setting is effective
123 !> for each variable with HstNmlInfoOutputValid.
124 !>
125 !> Moreover, it can know whether current time is output timing
126 !> when gtool_history_generic::HistoryPut is used
127 !> while integrating time with HstNmlInfoOutputStep.
128 !>
129 !> 6. Acquire history of gtool_history_types::GT_HISTORY type as well as
130 !> the above-mentioned procedure, and terminate that by
131 !> gtool_history_generic::HistoryClose when the output of the file ends.
132 !>
133 !> 7. Finally, the termination of the variable of gtool_history_nmlinfo_types::GTHST_NMLINFO
134 !> type is done by HstNmlInfoClose.
135 !> @enden
136 !>
137 !> @ja
138 !> ### 使用方法
139 !>
140 !> このモジュールは以下のような手順で用いてください.
141 !>
142 !> このモジュールを使用したサンプル Fortran プログラム作成スクリプトが
143 !> http://www.gfd-dennou.org/library/dcpam/dcpam4/dcpam4_current/script/f90/dcmodel_f90sample_maker.rb
144 !> から入手できます. Ruby で記述されており, 実行することで
145 !> サンプルとなる Fortran プログラムが作成されます.
146 !> 下記の解説のみでは実際の利用法やご利益が分かりにくいため,
147 !> サンプル Fortran プログラムを実際に見てみることをオススメします.
148 !>
149 !> 0. モジュール内で, gtool_history_nmlinfo_types::GTHST_NMLINFO 型の変数を定義しておきます.
150 !>
151 !> 1. HstNmlInfoCreate を用いて, gtool_history_nmlinfo_types::GTHST_NMLINFO 型の変数の初期設定を行います.
152 !> この際にデフォルトの出力間隔 interval_value,
153 !> interval_unit, 精度 precision, 時間の平均化 time_average,
154 !> 出力ファイル名接頭詞 fileprefix を設定します.
155 !>
156 !> 2. プログラムがデフォルトで出力する変数がある場合, HstNmlInfoAdd を
157 !> 使用して登録してください.
158 !> name には変数名を与えます. name は変数を識別するためのキーと
159 !> して利用するため, 異なる変数に対して同じ name を指定しないでください.
160 !> file には出力ファイル名を与えます. 与えない場合,
161 !> 適当なファイル名が設定されます.
162 !> その他の情報は上記と同様です.
163 !>
164 !> 3. NAMELIST から得られた出力変数の情報を,
165 !> HstNmlInfoAdd を使用して登録してください.
166 !> HstNmlInfoAdd で既に登録済みの name を再度登録することで,
167 !> 設定が上書きされます.
168 !>
169 !> 4. 登録が完了したら, HstNmlInfoEndDefine を用いて,
170 !> 定義モードから出力モードへ移行してください.
171 !>
172 !> 5. gtool_history_generic::HistoryCreate, gtool_history_generic::HistoryAddVariable,
173 !> gtool_history_generic::HistoryPut 等で出力設定およびデータ出力を行う際には,
174 !> HstNmlInfoAssocGtHist に対し, 変数名 name と
175 !> gtool_history_types::GT_HISTORY 型のポインタ history を渡してください.
176 !> gtool_history_nmlinfo_types::GTHST_NMLINFO 型の変数に登録されている
177 !> name に関する gtool_history_types::GT_HISTORY 型変数に結合された
178 !> history が返ります. この history
179 !> を上記 gtool_history のサブルーチン群の引数 history に渡して
180 !> 出力設定およびデータ出力を行ってください.
181 !> gtool_history_generic::HistoryCreate に必要な
182 !> 出力間隔や精度は HstNmlInfoInquire を用いて得ることができます.
183 !> 使用後は, NULLIFY によって history を空状態にしてください.
184 !> (DEALLOCATE を使用すると出力に関する情報が失われるため,
185 !> 使用しないでください).
186 !>
187 !> それぞれの変数に関して, 出力設定が有効かどうかについては,
188 !> HstNmlInfoOutputValid で知ることが可能です.
189 !>
190 !> また, 時間積分中に gtool_history_generic::HistoryPut を使用する際
191 !> に, 現在時刻が出力タイミングかどうかについては,
192 !> HstNmlInfoOutputStep で知ることが可能です.
193 !>
194 !> 6. ファイルの出力が終了したら, 上記の手順と同様に
195 !> gtool_history_types::GT_HISTORY 型の history を取得し,
196 !> gtool_history_generic::HistoryClose によって終了処理を行ってください.
197 !>
198 !> 7. 最後に, HstNmlInfoClose によって, gtool_history_nmlinfo_types::GTHST_NMLINFO 型の変数の
199 !> 終了処理を行います.
200 !> @endja
201 !>
202
203 implicit none
204 private
210 public:: hstnmlinfoinquire
211 public:: hstnmlinfoassocgthist
213 public:: hstnmlinfooutputstep
214 public:: hstnmlinfooutputvalid
219
220 !-----------------------------------------------------------------
221 ! 公開手続
222 ! Public procedures
223 !-----------------------------------------------------------------
224
226 subroutine hstnmlinfocreate( gthstnml, &
227 & interval_value, &
228 & interval_unit, &
229 & precision, &
230 & time_average, average, &
231 & fileprefix, &
232 & origin_value, origin_unit, &
233 & terminus_value, terminus_unit, &
234 & slice_start, slice_end, slice_stride, &
235 & space_average, &
236 & newfile_intvalue, newfile_intunit, &
237 & err )
239 use dc_types, only: dp
240 type(gthst_nmlinfo), intent(inout):: gthstnml
241 real(DP), intent(in), optional:: interval_value
242 character(*), intent(in), optional:: interval_unit
243 character(*), intent(in), optional:: precision
244 logical, intent(in), optional:: time_average
245 logical, intent(in), optional:: average
246 character(*), intent(in), optional:: fileprefix
247 real(DP), intent(in), optional:: origin_value
248 character(*), intent(in), optional:: origin_unit
249 real(DP), intent(in), optional:: terminus_value
250 character(*), intent(in), optional:: terminus_unit
251 integer, intent(in), optional:: slice_start(:)
252 integer, intent(in), optional:: slice_end(:)
253 integer, intent(in), optional:: slice_stride(:)
254 logical, intent(in), optional:: space_average(:)
255 integer, intent(in), optional:: newfile_intvalue
256 character(*), intent(in), optional:: newfile_intunit
257 logical, intent(out), optional:: err
258 end subroutine hstnmlinfocreate
259 end interface
260
262 subroutine hstnmlinfoclose( gthstnml, err )
264 type(gthst_nmlinfo), intent(inout):: gthstnml
265 logical, intent(out), optional:: err
266 end subroutine hstnmlinfoclose
267 end interface
268
270 subroutine hstnmlinfoputline( gthstnml, unit, indent, err )
272 type(gthst_nmlinfo), intent(in):: gthstnml
273 integer, intent(in), optional:: unit
274 character(*), intent(in), optional:: indent
275 logical, intent(out), optional:: err
276 end subroutine hstnmlinfoputline
277 end interface
278
280 logical function hstnmlinfoinitialized( gthstnml ) result(result)
282 type(gthst_nmlinfo), intent(in):: gthstnml
283 end function hstnmlinfoinitialized
284 end interface
285
287 logical function hstnmlinfodefinemode( gthstnml ) result(result)
289 type(gthst_nmlinfo), intent(in):: gthstnml
290 end function hstnmlinfodefinemode
291 end interface
292
294 subroutine hstnmlinfoenddefine( gthstnml, err )
296 type(gthst_nmlinfo), intent(inout):: gthstnml
297 logical, intent(out), optional:: err
298 end subroutine hstnmlinfoenddefine
299 end interface
300
302 subroutine hstnmlinforedefine( gthstnml, err )
304 type(gthst_nmlinfo), intent(inout):: gthstnml
305 logical, intent(out), optional:: err
306 end subroutine hstnmlinforedefine
307 end interface
308
310 recursive subroutine hstnmlinfoadd( gthstnml, &
311 & name, file, &
312 & interval_value, interval_unit, &
313 & precision, &
314 & time_average, average, &
315 & fileprefix, &
316 & origin_value, origin_unit, &
317 & terminus_value, terminus_unit, &
318 & slice_start, slice_end, slice_stride, &
319 & space_average, &
320 & newfile_intvalue, newfile_intunit, &
321 & err )
323 use dc_types, only: dp
324 type(gthst_nmlinfo), intent(inout):: gthstnml
325 character(*), intent(in), optional:: name
326 character(*), intent(in), optional:: file
327 real(dp), intent(in), optional:: interval_value
328 character(*), intent(in), optional:: interval_unit
329 character(*), intent(in), optional:: precision
330 logical, intent(in), optional:: time_average
331 logical, intent(in), optional:: average
332 character(*), intent(in), optional:: fileprefix
333 real(dp), intent(in), optional:: origin_value
334 character(*), intent(in), optional:: origin_unit
335 real(dp), intent(in), optional:: terminus_value
336 character(*), intent(in), optional:: terminus_unit
337 integer, intent(in), optional:: slice_start(:)
338 integer, intent(in), optional:: slice_end(:)
339 integer, intent(in), optional:: slice_stride(:)
340 logical, intent(in), optional:: space_average(:)
341 integer, intent(in), optional:: newfile_intvalue
342 character(*), intent(in), optional:: newfile_intunit
343 logical, intent(out), optional:: err
344 end subroutine hstnmlinfoadd
345 end interface
346
348 recursive subroutine hstnmlinfodelete( gthstnml, name, err )
350 type(gthst_nmlinfo), intent(inout):: gthstnml
351 character(*), intent(in):: name
352 logical, intent(out), optional:: err
353 end subroutine hstnmlinfodelete
354 end interface
355
357 subroutine hstnmlinforesetdefault( gthstnml, err )
359 type(gthst_nmlinfo), intent(inout):: gthstnml
360 logical, intent(out), optional:: err
361 end subroutine hstnmlinforesetdefault
362 end interface
363
365 subroutine hstnmlinfoinquire( gthstnml, &
366 & name, &
367 & file, &
368 & interval_value, &
369 & interval_unit, &
370 & precision, &
371 & time_average, average, &
372 & fileprefix, &
373 & origin_value, origin_unit, &
374 & terminus_value, terminus_unit, &
375 & slice_start, slice_end, slice_stride, &
376 & space_average, &
377 & newfile_intvalue, newfile_intunit, &
378 & err )
380 use dc_types, only: dp
381 type(gthst_nmlinfo), intent(in):: gthstnml
382 character(*), intent(in), optional:: name
383 character(*), intent(out), optional:: file
384 real(DP), intent(out), optional:: interval_value
385 character(*), intent(out), optional:: interval_unit
386 character(*), intent(out), optional:: precision
387 logical, intent(out), optional:: time_average
388 logical, intent(out), optional:: average
389 character(*), intent(out), optional:: fileprefix
390 real(DP), intent(out), optional:: origin_value
391 character(*), intent(out), optional:: origin_unit
392 real(DP), intent(out), optional:: terminus_value
393 character(*), intent(out), optional:: terminus_unit
394 integer, intent(out), optional:: slice_start(:)
395 integer, intent(out), optional:: slice_end(:)
396 integer, intent(out), optional:: slice_stride(:)
397 logical, intent(out), optional:: space_average(:)
398 integer, intent(out), optional:: newfile_intvalue
399 character(*), intent(out), optional:: newfile_intunit
400 logical, intent(out), optional:: err
401 end subroutine hstnmlinfoinquire
402 end interface
403
405 subroutine hstnmlinfoassocgthist( gthstnml, &
406 & name, history, err )
408 use gtool_history, only: gt_history
409 type(gthst_nmlinfo), intent(in):: gthstnml
410 character(*), intent(in):: name
411 type(gt_history), pointer:: history
412 logical, intent(out), optional:: err
413 end subroutine hstnmlinfoassocgthist
414 end interface
415
417 subroutine hstnmlinfooutputstepdisable( gthstnml, &
418 & name, err )
420 type(gthst_nmlinfo), intent(in):: gthstnml
421 character(*), intent(in):: name
422 logical, intent(out), optional:: err
423 end subroutine hstnmlinfooutputstepdisable
424 end interface
425
427 logical function hstnmlinfooutputstep( gthstnml, &
428 & name, time ) result(result)
430 use gtool_history, only: gt_history
431 use dc_date_types, only: dc_difftime
432 type(gthst_nmlinfo), intent(in):: gthstnml
433 character(*), intent(in):: name
434 type(dc_difftime), intent(in):: time
435 end function hstnmlinfooutputstep
436 end interface
437
439 logical function hstnmlinfooutputvalid( gthstnml, &
440 & name ) result(result)
442 type(gthst_nmlinfo), intent(in):: gthstnml
443 character(*), intent(in):: name
444 end function hstnmlinfooutputvalid
445 end interface
446
448 function hstnmlinfonames( gthstnml ) result(result)
450 use dc_types, only: string
451 character(STRING):: result
452 type(gthst_nmlinfo), intent(in):: gthstnml
453 end function hstnmlinfonames
454 end interface
455
457 subroutine hstnmlinfogetnames( gthstnml, varnames_ary, err )
459 use dc_types, only: token
460 type(gthst_nmlinfo), intent(in):: gthstnml
461 character(TOKEN), pointer:: varnames_ary(:)
462 logical, intent(out), optional:: err
463 end subroutine hstnmlinfogetnames
464 end interface
465
467 subroutine hstnmlinfoallvarinicheck( gthstnml, &
468 & invalid, &
469 & names, &
470 & err )
472 type(gthst_nmlinfo), intent(in):: gthstnml
473 logical, intent(out):: invalid
474 character(*), intent(out):: names
475 logical, intent(out), optional:: err
476 end subroutine hstnmlinfoallvarinicheck
477 end interface
478
480 subroutine hstnmlinfosetvalidname( gthstnml, &
481 & name, &
482 & err )
484 type(gthst_nmlinfo), intent(in):: gthstnml
485 character(*), intent(in):: name
486 logical, intent(out), optional:: err
487 end subroutine hstnmlinfosetvalidname
488 end interface
489
491 subroutine hstnmlinfoallnamevalid( gthstnml, &
492 & invalid, &
493 & names, &
494 & err )
496 type(gthst_nmlinfo), intent(in):: gthstnml
497 logical, intent(out):: invalid
498 character(*), intent(out):: names
499 logical, intent(out), optional:: err
500 end subroutine hstnmlinfoallnamevalid
501 end interface
502
Derived types and parameters for date and time.
Provides kind type parameter values.
Definition dc_types.f90:55
integer, parameter, public token
Character length for word, token
Definition dc_types.f90:128
integer, parameter, public string
Character length for string
Definition dc_types.f90:137
integer, parameter, public dp
Double Precision Real number
Definition dc_types.f90:92