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