Class | dc_histnml |
In: |
dc_histnml.f90
|
Note that Japanese and English are described in parallel.
数値モデルのヒストリデータ出力の情報を NAMELIST から読み込んで 管理する際に便利なユーティリティを提供します.
This module provides utilities for control of information from NAMELIST about history data of numerical models.
Create : | DCHSTNML 型変数の初期設定 |
Close : | DCHSTNML 型変数の終了処理 |
PutLine : | DCHSTNML 型変数に格納されている情報の印字 |
initialized : | DCHSTNML 型変数が初期設定されているか否か |
Add : | 変数情報の追加 |
Delete : | 変数情報の削除 |
ResetDefault : | デフォルト設定のみに戻す |
Inquire : | 変数情報の問い合わせ |
output_valid : | 出力の設定が有効である場合に真を返す |
output_step : | 現在の時刻が出力のタイミングの場合に真を返す |
names : | 登録されている変数名リストを返す |
———— : | ———— |
Create : | Constructor of "DCHSTNML" |
Close : | Deconstructor of "DCHSTNML" |
PutLine : | Print information of "DCHSTNML" |
initialized : | Check initialization of "DCHSTNML" |
Add : | Add information of variables |
Delete : | Delete information of variables |
ResetDefault : | Reset to default settings |
Inquire : | Inquire information of variables |
output_valid : | True is returned when a configuration of output is valid |
output_step : | True is returned when current time is output timing |
names : | Return list of registerd variable names |
※ これが出来てないとどのように使ったもんだかさっぱり分からないので,
ちゃんと書きましょう.
始めに, DCHSTNML 型の変数を定義し, Create で初期設定を行います.
DCHSTNML 型の変数の終了処理には Close を用いてください.
Derived_Types | [] | DCHSTNML, DCHSTNML_ENTRY |
Subroutine : | recursive | ||
hstnml : | type(DCHSTNML), intent(inout) | ||
name : | character(*), intent(in), optional
| ||
file : | character(*), intent(in), optional
| ||
interval_value : | real(DP), intent(in), optional
| ||
interval_unit : | character(*), intent(in), optional
| ||
precision : | character(*), intent(in), optional
| ||
average : | logical, intent(in), optional
| ||
fileprefix : | character(*), intent(in), optional
| ||
err : | logical, intent(out), optional
|
変数の出力情報を加えます.
デフォルト値を設定するには, name を与えないか, または name に空白を与えてください. デフォルト値を与える場合, file に与えられる情報は無視されます. fileprefix はデフォルト値に与える場合のみ有効です.
name に変数名が指定され, その際に file が与えられない, または空白が与えられる場合, file には "<name に与えられた文字>.nc" が指定されます.
なお, 与えられた hstnml が Create によって初期設定 されていない場合, プログラムはエラーを発生させます.
Add output information of a variable.
In order to set default values, specify blank to name or do not specify name. When default values are specified, file is ignored. fileprefix is valid only when default values are specified.
When a variable name is specified to name and file is not specified or blanks are specified to file, "<string given to name>.nc" is specified to file.
If hstnml is not initialized by "Create" yet, error is occurred.
Alias for DCHistNmlAdd
Subroutine : | |||
hstnml : | type(DCHSTNML), intent(inout) | ||
err : | logical, intent(out), optional
|
DCHSTNML 型の変数の終了処理を行います. なお, 与えられた hstnml が Create によって初期設定 されていない場合, プログラムはエラーを発生させます.
Deconstructor of "DCHSTNML". Note that if hstnml is not initialized by "Create" yet, error is occurred.
Alias for DCHistNmlClose
Subroutine : | |||
hstnml : | type(DCHSTNML), intent(inout) | ||
interval_value : | real(DP), intent(in), optional
| ||
interval_unit : | character(*), intent(in), optional
| ||
precision : | character(*), intent(in), optional
| ||
average : | logical, intent(in), optional
| ||
fileprefix : | character(*), intent(in), optional
| ||
err : | logical, intent(out), optional
|
DCHSTNML 型の変数の初期設定を行います. 他のサブルーチンを使用する前に必ずこのサブルーチンによって DCHSTNML 型の変数を初期設定してください.
interval_value, interval_unit, precision, average はデフォルト値として設定されます. fileprefix は各変数の出力ファイル名の接頭詞として 使用されます.
なお, 与えられた hstnml が既に初期設定されている場合, プログラムはエラーを発生させます.
Constructor of "DCHSTNML". Initialize hstnml by this subroutine, before other procedures are used,
interval_value, interval_unit, precision, average are set as default values. fileprefix is used as prefixes of output filenames of each variable.
Note that if hstnml is already initialized by this procedure, error is occurred.
Alias for DCHistNmlCreate
Derived Type : | |||
initialized = .false. : | logical
| ||
hstnml_list =>null() : | type(DCHSTNML_ENTRY),
pointer
|
NAMELIST から取得したヒストリデータの出力情報 を格納するための構造データ型です. まず, Create で "DCHSTNML" 型の変数を初期設定して下さい. 初期設定された "DCHSTNML" 型の変数を再度利用する際には, Close によって終了処理を行ってください.
This derived type is worked in order to store information about data output from NAMELIST. Initialize "DCHSTNML" variable by "Create" before usage. If you reuse "DCHSTNML" variable again for another application, terminate by "Close".
Subroutine : | recursive | ||
hstnml : | type(DCHSTNML), intent(inout) | ||
name : | character(*), intent(in)
| ||
err : | logical, intent(out), optional
|
変数の出力情報を削除します.
なお, 与えられた hstnml が Create によって初期設定 されていない場合, プログラムはエラーを発生させます.
Delete output information of a variable.
If hstnml is not initialized by "Create" yet, error is occurred.
Alias for DCHistNmlDelete
Subroutine : | |||
hstnml : | type(DCHSTNML), intent(in) | ||
name : | character(*), intent(in), optional
| ||
file : | character(*), intent(out), optional
| ||
interval_value : | real(DP), intent(out), optional
| ||
interval_unit : | character(*), intent(out), optional
| ||
precision : | character(*), intent(out), optional
| ||
average : | logical, intent(out), optional
| ||
fileprefix : | character(*), intent(out), optional
| ||
err : | logical, intent(out), optional
|
変数の出力情報を取得します.
デフォルト値を取得するには, name を与えないか, または name に空白を与えてください.
name に関するデータが存在しない場合, エラーを発生させます.
なお, 与えられた hstnml が Create によって初期設定 されていない場合, プログラムはエラーを発生させます.
Inquire output information of a variable.
If data correspond to name is not found, error is occurred.
If hstnml is not initialized by "Create" yet, error is occurred.
Alias for DCHistNmlInquire
Subroutine : | |||
hstnml : | type(DCHSTNML), intent(in) | ||
unit : | integer, intent(in), optional
| ||
indent : | character(*), intent(in), optional
| ||
err : | logical, intent(out), optional
|
引数 hstnml に設定されている情報を印字します. デフォルトではメッセージは標準出力に出力されます. unit に装置番号を指定することで, 出力先を変更することが可能です.
Print information of hstnml. By default messages are output to standard output. Unit number for output can be changed by unit argument.
Alias for DCHistNmlPutLine
Subroutine : | |||
hstnml : | type(DCHSTNML), intent(inout) | ||
err : | logical, intent(out), optional
|
デフォルト値を残し, 登録したデータを削除します.
なお, 与えられた hstnml が Create によって初期設定 されていない場合, プログラムはエラーを発生させます.
Stored data is deleted without default settings.
If hstnml is not initialized by "Create" yet, error is occurred.
Alias for DCHistNmlResetDefault
Function : | |
result : | logical |
hstnml : | type(DCHSTNML), intent(in) |
hstnml が初期設定されている場合には .true. が, 初期設定されていない場合には .false. が返ります.
If hstnml is initialized, .true. is returned. If hstnml is not initialized, .false. is returned.
Alias for DCHistNmlInitialized
Function : | |
result : | character(STRING) |
hstnml : | type(DCHSTNML), intent(in) |
hstnml が設定されている変数リストをカンマでつなげて 返します.
なお, 与えられた hstnml が Create によって初期設定 されていない場合, 空文字が返ります.
List of variables registered in hstnml is join with ’,’, and returned.
If hstnml is not initialized by "Create" yet, blank is returned.
Alias for DCHistNmlNames
Function : | |||
result : | logical | ||
hstnml : | type(DCHSTNML), intent(in) | ||
name : | character(*), intent(in)
| ||
time : | type(DC_DIFFTIME), intent(in)
|
time が変数 name の出力されるタイミングであれば .true. を, そうでなければ .false. を返します. hstnml が初期設定されていない場合にも .false. が返ります. name に関するデータが存在しない場合にも .false. が返ります.
なお, 与えられた hstnml が Create によって初期設定 されていない場合, プログラムはエラーを発生させます.
If time is the time that a variable name is output, .true. is returned, otherwise .false. is returned When hstnml is not initialized, .false. is returned too. When data correspond to name is not found, .false. is returned too.
If hstnml is not initialized by "Create" yet, error is occurred.
Alias for DCHistNmlOutputStep
Function : | |||
result : | logical | ||
hstnml : | type(DCHSTNML), intent(in) | ||
name : | character(*), intent(in)
|
変数 name の出力が有効であれば, .true. を, そうでなければ .false. を返します. hstnml が初期設定されていない場合にも .false. が返ります. name に関するデータが存在しない場合にも .false. が返ります.
なお, 与えられた hstnml が Create によって初期設定 されていない場合, プログラムはエラーを発生させます.
If output of a variable name is valid, .true. is returned, otherwise .false. is returned When hstnml is not initialized, .false. is returned too. When data correspond to name is not found, .false. is returned too.
If hstnml is not initialized by "Create" yet, error is occurred.
Alias for DCHistNmlOutputValid
Derived Type : | |||
name : | character(TOKEN)
| ||
file : | character(STRING)
| ||
interval_value =>null() : | real(DP), pointer
| ||
interval_unit =>null() : | character(TOKEN), pointer
| ||
precision =>null() : | character(TOKEN), pointer
| ||
average =>null() : | logical, pointer
| ||
fileprefix =>null() : | character(STRING), pointer
| ||
dummy0 : | logical
| ||
next =>null() : | type(DCHSTNML_ENTRY),
pointer
|
出力変数ごとの情報を格納するための構造体です. この構造体はモジュール内で使用されることを想定しているため, モジュール外部からは使用しないでください.
Information about individual output variable is stored in this derived type. It is expected that this derived type is used internally, so do not refer from the outside.
Subroutine : | recursive | ||
hstnml : | type(DCHSTNML), intent(inout) | ||
name : | character(*), intent(in), optional
| ||
file : | character(*), intent(in), optional
| ||
interval_value : | real(DP), intent(in), optional
| ||
interval_unit : | character(*), intent(in), optional
| ||
precision : | character(*), intent(in), optional
| ||
average : | logical, intent(in), optional
| ||
fileprefix : | character(*), intent(in), optional
| ||
err : | logical, intent(out), optional
|
変数の出力情報を加えます.
デフォルト値を設定するには, name を与えないか, または name に空白を与えてください. デフォルト値を与える場合, file に与えられる情報は無視されます. fileprefix はデフォルト値に与える場合のみ有効です.
name に変数名が指定され, その際に file が与えられない, または空白が与えられる場合, file には "<name に与えられた文字>.nc" が指定されます.
なお, 与えられた hstnml が Create によって初期設定 されていない場合, プログラムはエラーを発生させます.
Add output information of a variable.
In order to set default values, specify blank to name or do not specify name. When default values are specified, file is ignored. fileprefix is valid only when default values are specified.
When a variable name is specified to name and file is not specified or blanks are specified to file, "<string given to name>.nc" is specified to file.
If hstnml is not initialized by "Create" yet, error is occurred.
recursive subroutine DCHistNmlAdd( hstnml, name, file, interval_value, interval_unit, precision, average, fileprefix, err ) ! ! 変数の出力情報を加えます. ! ! デフォルト値を設定するには, *name* を与えないか, または ! *name* に空白を与えてください. ! デフォルト値を与える場合, *file* に与えられる情報は無視されます. ! *fileprefix* はデフォルト値に与える場合のみ有効です. ! ! *name* に変数名が指定され, その際に *file* が与えられない, ! または空白が与えられる場合, *file* には ! "<i><*name* に与えられた文字></i>.nc" が指定されます. ! ! なお, 与えられた *hstnml* が Create によって初期設定 ! されていない場合, プログラムはエラーを発生させます. ! ! Add output information of a variable. ! ! In order to set default values, specify blank to *name* or ! do not specify *name*. ! When default values are specified, *file* is ignored. ! *fileprefix* is valid only when default values are specified. ! ! When a variable name is specified to *name* and ! *file* is not specified or blanks are specified to *file*, ! "<i><string given to *name*></i>.nc" is specified to *file*. ! ! If *hstnml* is not initialized by "Create" yet, ! error is occurred. ! use dc_trace, only: BeginSub, EndSub, DbgMessage use dc_string, only: PutLine, Printf, Split, StrInclude, StoA, JoinChar use dc_present, only: present_and_not_empty, present_and_true, present_select use dc_types, only: DP, STRING, TOKEN, STDOUT use dc_date_types, only: DC_DIFFTIME use dc_date, only: Create use dc_message, only: MessageNotify use dc_error, only: StoreError, DC_NOERR, DC_ENOTINIT, DC_EARGLACK, USR_ERRNO implicit none type(DCHSTNML), intent(inout):: hstnml character(*), intent(in), optional:: name ! 変数名. ! ! 先頭の空白は無視されます. ! ! "Data1,Data2" のようにカンマで区切って複数 ! の変数を指定することも可能です. ただし, ! その際には, *file* 引数で与えられる情報は ! 無視されます. その他の情報はそれぞれの ! 変数の情報として設定されます. ! ! Variable name. ! ! Blanks at the head of the name are ignored. ! ! Multiple variables can be specified ! as "Data1,Data2" too. Delimiter is comma. ! In this case, *file* is ignored, and ! other information is set to each variable. ! character(*), intent(in), optional:: file ! ヒストリデータのファイル名. ! History data filenames real(DP), intent(in), optional:: interval_value ! ヒストリデータの出力間隔の数値. ! 負の値を与えると, 出力を抑止します. ! ! Numerical value for interval of history data output. ! Negative values suppresses output. character(*), intent(in), optional:: interval_unit ! ヒストリデータの出力間隔の単位. ! Unit for interval of history data output character(*), intent(in), optional:: precision ! ヒストリデータの精度. ! Precision of history data logical, intent(in), optional:: average ! 出力データの平均化フラグ. ! Flag for average of output data. character(*), intent(in), optional:: fileprefix ! ヒストリデータのファイル名の接頭詞. ! Prefixes of history data filenames logical, intent(out), optional:: err ! 例外処理用フラグ. ! デフォルトでは, この手続き内でエラーが ! 生じた場合, プログラムは強制終了します. ! 引数 *err* が与えられる場合, ! プログラムは強制終了せず, 代わりに ! *err* に .true. が代入されます. ! ! Exception handling flag. ! By default, when error occur in ! this procedure, the program aborts. ! If this *err* argument is given, ! .true. is substituted to *err* and ! the program does not abort. !----------------------------------- ! 作業変数 ! Work variables type(DCHSTNML_ENTRY), pointer:: hptr =>null() type(DCHSTNML_ENTRY), pointer:: hptr_last =>null() type(DC_DIFFTIME):: interval_time character(TOKEN), pointer:: varnames_array(:) =>null() integer:: i, vnmax integer:: stat character(STRING):: cause_c character(*), parameter:: subname = 'DCHistNmlAdd' continue call BeginSub( subname, fmt = '@name=%a @file=%a @interval_value=%f @interval_unit=%a @precision=%a @average=%y @fileprefix=%a', d = (/ present_select(.true., -1.0_DP, interval_value) /), l = (/ present_and_true(average) /), ca = StoA( present_select(.true., '<no>', name), present_select(.true., '<no>', file), present_select(.true., '<no>', interval_unit), present_select(.true., '<no>', precision), present_select(.true., '<no>', fileprefix) ) ) stat = DC_NOERR cause_c = '' !----------------------------------------------------------------- ! 初期設定のチェック ! Check initialization !----------------------------------------------------------------- if ( .not. hstnml % initialized ) then stat = DC_ENOTINIT cause_c = 'DCHSTNML' goto 999 end if !----------------------------------------------------------------- ! 複数の変数を設定する場合 ! Configure multiple variables !----------------------------------------------------------------- if ( present_and_not_empty(name) ) then if ( index(name, ',') > 0 ) then call DbgMessage( 'multiple entries (%c) will be created', c1 = trim(name) ) if ( present(file) ) call DbgMessage( 'argument @file=%c is ignored', c1 = trim(file) ) call Split( str = name, sep = ',', carray = varnames_array ) ! (out) vnmax = size( varnames_array ) do i = 1, vnmax call Add( hstnml = hstnml, name = varnames_array(i), interval_value = interval_value, interval_unit = interval_unit, precision = precision, average = average, err = err ) ! (out) if ( present_and_true( err ) ) then deallocate( varnames_array ) stat = USR_ERRNO goto 999 end if end do deallocate( varnames_array ) goto 999 end if end if !----------------------------------------------------------------- ! *hstnml* へ情報を追加. ! Add information to *hstnml* !----------------------------------------------------------------- if ( .not. present_and_not_empty(name) ) then if ( present(interval_value) ) hstnml % hstnml_list % interval_value = interval_value if ( present(interval_unit) ) hstnml % hstnml_list % interval_unit = interval_unit if ( present(precision) ) hstnml % hstnml_list % precision = precision if ( present(average) ) hstnml % hstnml_list % average = average if ( present(fileprefix) ) hstnml % hstnml_list % fileprefix = fileprefix hptr => hstnml % hstnml_list else hptr => hstnml % hstnml_list call ListSearch( hstnml_list = hptr, name = name ) ! (in) if ( .not. associated(hptr) ) then call DbgMessage( 'new entry (%c) is created', c1 = trim( adjustl( name ) ) ) hptr_last => hstnml % hstnml_list call ListLast( hstnml_list = hptr_last ) ! (inout) allocate( hptr ) nullify( hptr % next ) hptr % interval_value => hstnml % hstnml_list % interval_value hptr % interval_unit => hstnml % hstnml_list % interval_unit hptr % precision => hstnml % hstnml_list % precision hptr % average => hstnml % hstnml_list % average hptr % fileprefix => hstnml % hstnml_list % fileprefix hptr_last % next => hptr else call DbgMessage( 'entry (%c) is overwritten', c1 = trim( adjustl( name ) ) ) end if hptr % name = adjustl( name ) if ( present_and_not_empty(file) ) then hptr % file = file nullify( hptr % fileprefix ) allocate( hptr % fileprefix ) hptr % fileprefix = '' else hptr % file = trim(name) // '.nc' end if if ( present(interval_value) ) then nullify( hptr % interval_value ) allocate( hptr % interval_value ) hptr % interval_value = interval_value end if if ( present(interval_unit) ) then nullify( hptr % interval_unit ) allocate( hptr % interval_unit ) hptr % interval_unit = interval_unit end if if ( present(precision) ) then nullify( hptr % precision ) allocate( hptr % precision ) hptr % precision = precision end if if ( present(average) ) then nullify( hptr % average ) allocate( hptr % average ) hptr % average = average end if end if !--------------------------------------------------------------- ! 時間の単位のチェック ! Check unit of time !--------------------------------------------------------------- call Create( diff = interval_time, value = hptr % interval_value, unit = hptr % interval_unit, err = err ) ! (out) if ( present_and_true( err ) ) then call Delete( hstnml = hstnml, name = name ) ! (in) stat = USR_ERRNO goto 999 end if nullify( hptr ) !----------------------------------------------------------------- ! 終了処理, 例外処理 ! Termination and Exception handling !----------------------------------------------------------------- 999 continue call StoreError( stat, subname, err, cause_c ) call EndSub( subname ) end subroutine DCHistNmlAdd
Subroutine : | |||
hstnml : | type(DCHSTNML), intent(inout) | ||
err : | logical, intent(out), optional
|
DCHSTNML 型の変数の終了処理を行います. なお, 与えられた hstnml が Create によって初期設定 されていない場合, プログラムはエラーを発生させます.
Deconstructor of "DCHSTNML". Note that if hstnml is not initialized by "Create" yet, error is occurred.
subroutine DCHistNmlClose( hstnml, err ) ! ! DCHSTNML 型の変数の終了処理を行います. ! なお, 与えられた *hstnml* が Create によって初期設定 ! されていない場合, プログラムはエラーを発生させます. ! ! Deconstructor of "DCHSTNML". ! Note that if *hstnml* is not initialized by "Create" yet, ! error is occurred. ! use dc_trace, only: BeginSub, EndSub, DbgMessage use dc_string, only: PutLine, Printf, Split, StrInclude, StoA, JoinChar use dc_types, only: DP, STRING, TOKEN, STDOUT use dc_error, only: StoreError, DC_NOERR, DC_ENOTINIT implicit none type(DCHSTNML), intent(inout):: hstnml logical, intent(out), optional:: err ! 例外処理用フラグ. ! デフォルトでは, この手続き内でエラーが ! 生じた場合, プログラムは強制終了します. ! 引数 *err* が与えられる場合, ! プログラムは強制終了せず, 代わりに ! *err* に .true. が代入されます. ! ! Exception handling flag. ! By default, when error occur in ! this procedure, the program aborts. ! If this *err* argument is given, ! .true. is substituted to *err* and ! the program does not abort. !----------------------------------- ! 作業変数 ! Work variables type(DCHSTNML_ENTRY), pointer:: hptr =>null() type(DCHSTNML_ENTRY), pointer:: hptr_prev =>null() integer:: stat character(STRING):: cause_c character(*), parameter:: subname = 'DCHistNmlClose' continue call BeginSub( subname ) stat = DC_NOERR cause_c = '' !----------------------------------------------------------------- ! 初期設定のチェック ! Check initialization !----------------------------------------------------------------- if ( .not. hstnml % initialized ) then stat = DC_ENOTINIT cause_c = 'DCHSTNML' goto 999 end if !----------------------------------------------------------------- ! "DCHSTNML" の設定の消去 ! Clear the settings for "DCHSTNML" !----------------------------------------------------------------- do hptr => hstnml % hstnml_list call ListLast( hstnml_list = hptr, previous = hptr_prev ) ! (out) call DbgMessage( 'remove entry (%c)', c1 = trim(hptr % name) ) if ( trim( hptr % name ) == '' ) exit deallocate( hptr ) nullify( hptr_prev % next ) end do deallocate( hstnml % hstnml_list ) !----------------------------------------------------------------- ! 終了処理, 例外処理 ! Termination and Exception handling !----------------------------------------------------------------- hstnml % initialized = .false. 999 continue call StoreError( stat, subname, err, cause_c ) call EndSub( subname ) end subroutine DCHistNmlClose
Subroutine : | |||
hstnml : | type(DCHSTNML), intent(inout) | ||
interval_value : | real(DP), intent(in), optional
| ||
interval_unit : | character(*), intent(in), optional
| ||
precision : | character(*), intent(in), optional
| ||
average : | logical, intent(in), optional
| ||
fileprefix : | character(*), intent(in), optional
| ||
err : | logical, intent(out), optional
|
DCHSTNML 型の変数の初期設定を行います. 他のサブルーチンを使用する前に必ずこのサブルーチンによって DCHSTNML 型の変数を初期設定してください.
interval_value, interval_unit, precision, average はデフォルト値として設定されます. fileprefix は各変数の出力ファイル名の接頭詞として 使用されます.
なお, 与えられた hstnml が既に初期設定されている場合, プログラムはエラーを発生させます.
Constructor of "DCHSTNML". Initialize hstnml by this subroutine, before other procedures are used,
interval_value, interval_unit, precision, average are set as default values. fileprefix is used as prefixes of output filenames of each variable.
Note that if hstnml is already initialized by this procedure, error is occurred.
subroutine DCHistNmlCreate( hstnml, interval_value, interval_unit, precision, average, fileprefix, err ) ! ! DCHSTNML 型の変数の初期設定を行います. ! 他のサブルーチンを使用する前に必ずこのサブルーチンによって ! DCHSTNML 型の変数を初期設定してください. ! ! *interval_value*, ! *interval_unit*, ! *precision*, ! *average* ! はデフォルト値として設定されます. ! *fileprefix* は各変数の出力ファイル名の接頭詞として ! 使用されます. ! ! なお, 与えられた *hstnml* が既に初期設定されている場合, ! プログラムはエラーを発生させます. ! ! Constructor of "DCHSTNML". ! Initialize *hstnml* by this subroutine, ! before other procedures are used, ! ! *interval_value*, ! *interval_unit*, ! *precision*, ! *average* ! are set as default values. ! *fileprefix* is used as prefixes of output filenames of ! each variable. ! ! Note that if *hstnml* is already initialized ! by this procedure, error is occurred. ! use dc_trace, only: BeginSub, EndSub use dc_string, only: PutLine, Printf, Split, StrInclude, StoA, JoinChar use dc_types, only: DP, STRING, TOKEN, STDOUT use dc_present, only: present_and_not_empty, present_and_true, present_select use dc_message, only: MessageNotify use dc_error, only: StoreError, DC_NOERR, DC_EALREADYINIT, DC_EARGLACK, DC_ENEGATIVE, DC_ENOFILEREAD, USR_ERRNO use dc_date_types, only: DC_DIFFTIME use dc_date, only: Create implicit none type(DCHSTNML), intent(inout):: hstnml real(DP), intent(in), optional:: interval_value ! ヒストリデータの出力間隔の数値. ! 負の値を与えると, 出力を抑止します. ! ! Numerical value for interval of history data output. ! Negative values suppresses output. character(*), intent(in), optional:: interval_unit ! ヒストリデータの出力間隔の単位. ! Unit for interval of history data output character(*), intent(in), optional:: precision ! ヒストリデータの精度. ! Precision of history data logical, intent(in), optional:: average ! 出力データの平均化フラグ. ! Flag for average of output data. character(*), intent(in), optional:: fileprefix ! ヒストリデータのファイル名の接頭詞. ! Prefixes of history data filenames logical, intent(out), optional:: err ! 例外処理用フラグ. ! デフォルトでは, この手続き内でエラーが ! 生じた場合, プログラムは強制終了します. ! 引数 *err* が与えられる場合, ! プログラムは強制終了せず, 代わりに ! *err* に .true. が代入されます. ! ! Exception handling flag. ! By default, when error occur in ! this procedure, the program aborts. ! If this *err* argument is given, ! .true. is substituted to *err* and ! the program does not abort. !----------------------------------- ! 作業変数 ! Work variables type(DC_DIFFTIME):: interval_time integer:: stat character(STRING):: cause_c character(*), parameter:: subname = 'DCHistNmlCreate' continue call BeginSub( subname, fmt = '@interval_value=%f @interval_unit=%c @precision=%c @average=%y @fileprefix=%c', d = (/ present_select(.true., -1.0_DP, interval_value) /), c1 = trim( present_select(.true., '<no>', interval_unit) ), c2 = trim( present_select(.true., '<no>', precision) ), l = (/ present_and_true(average) /), c3 = trim( present_select(.true., '<no>', fileprefix) ), version = version ) stat = DC_NOERR cause_c = '' !----------------------------------------------------------------- ! 初期設定のチェック ! Check initialization !----------------------------------------------------------------- if ( hstnml % initialized ) then stat = DC_EALREADYINIT cause_c = 'DCHSTNML' goto 999 end if !----------------------------------------------------------------- ! 割付 ! Allocate !----------------------------------------------------------------- allocate( hstnml % hstnml_list ) nullify( hstnml % hstnml_list % next ) !----------------------------------------------------------------- ! デフォルト値の設定 ! Configure default values !----------------------------------------------------------------- hstnml % hstnml_list % name = '' hstnml % hstnml_list % file = '' allocate( hstnml % hstnml_list % interval_value ) allocate( hstnml % hstnml_list % interval_unit ) allocate( hstnml % hstnml_list % precision ) allocate( hstnml % hstnml_list % average ) allocate( hstnml % hstnml_list % fileprefix ) hstnml % hstnml_list % interval_value = -1.0_DP hstnml % hstnml_list % interval_unit = 'sec' hstnml % hstnml_list % precision = 'float' hstnml % hstnml_list % average = .false. hstnml % hstnml_list % fileprefix = '' if ( present(interval_value) ) hstnml % hstnml_list % interval_value = interval_value if ( present(interval_unit) ) hstnml % hstnml_list % interval_unit = interval_unit if ( present(precision) ) hstnml % hstnml_list % precision = precision if ( present(average) ) hstnml % hstnml_list % average = average if ( present(fileprefix) ) hstnml % hstnml_list % fileprefix = fileprefix !----------------------------------------------------------------- ! 時間の単位のチェック ! Check unit of time !----------------------------------------------------------------- call Create( diff = interval_time, value = hstnml % hstnml_list % interval_value, unit = hstnml % hstnml_list % interval_unit, err = err ) ! (out) if ( present_and_true( err ) ) then stat = USR_ERRNO goto 999 end if !----------------------------------------------------------------- ! 終了処理, 例外処理 ! Termination and Exception handling !----------------------------------------------------------------- hstnml % initialized = .true. 999 continue call StoreError( stat, subname, err, cause_c ) call EndSub( subname ) end subroutine DCHistNmlCreate
Subroutine : | recursive | ||
hstnml : | type(DCHSTNML), intent(inout) | ||
name : | character(*), intent(in)
| ||
err : | logical, intent(out), optional
|
変数の出力情報を削除します.
なお, 与えられた hstnml が Create によって初期設定 されていない場合, プログラムはエラーを発生させます.
Delete output information of a variable.
If hstnml is not initialized by "Create" yet, error is occurred.
recursive subroutine DCHistNmlDelete( hstnml, name, err ) ! ! 変数の出力情報を削除します. ! ! なお, 与えられた *hstnml* が Create によって初期設定 ! されていない場合, プログラムはエラーを発生させます. ! ! Delete output information of a variable. ! ! If *hstnml* is not initialized by "Create" yet, ! error is occurred. ! use dc_trace, only: BeginSub, EndSub, DbgMessage use dc_string, only: PutLine, Printf, Split, StrInclude, StoA, JoinChar use dc_present, only: present_and_not_empty, present_and_true use dc_types, only: DP, STRING, TOKEN, STDOUT use dc_error, only: StoreError, DC_NOERR, DC_ENOTINIT, DC_EARGLACK, USR_ERRNO implicit none type(DCHSTNML), intent(inout):: hstnml character(*), intent(in):: name ! 変数名. ! ! 先頭の空白は無視されます. ! ! "Data1,Data2" のようにカンマで区切って複数 ! の変数を指定することが可能です. ! ! Variable name. ! ! Blanks at the head of the name are ignored. ! ! Multiple variables can be specified ! as "Data1,Data2". Delimiter is comma. ! logical, intent(out), optional:: err ! 例外処理用フラグ. ! デフォルトでは, この手続き内でエラーが ! 生じた場合, プログラムは強制終了します. ! 引数 *err* が与えられる場合, ! プログラムは強制終了せず, 代わりに ! *err* に .true. が代入されます. ! ! Exception handling flag. ! By default, when error occur in ! this procedure, the program aborts. ! If this *err* argument is given, ! .true. is substituted to *err* and ! the program does not abort. !----------------------------------- ! 作業変数 ! Work variables type(DCHSTNML_ENTRY), pointer:: hptr =>null() type(DCHSTNML_ENTRY), pointer:: hptr_prev =>null() type(DCHSTNML_ENTRY), pointer:: hptr_next =>null() character(TOKEN), pointer:: varnames_array(:) =>null() integer:: i, vnmax integer:: stat character(STRING):: cause_c character(*), parameter:: subname = 'DCHistNmlDelete' continue call BeginSub( subname, fmt = '@name=%c', c1 = trim( name ) ) stat = DC_NOERR cause_c = '' !----------------------------------------------------------------- ! 初期設定のチェック ! Check initialization !----------------------------------------------------------------- if ( .not. hstnml % initialized ) then stat = DC_ENOTINIT cause_c = 'DCHSTNML' goto 999 end if !----------------------------------------------------------------- ! 複数の変数を削除する場合 ! Delete multiple variables !----------------------------------------------------------------- if ( present_and_not_empty(name) ) then if ( index(name, ',') > 0 ) then call DbgMessage( 'multiple entries (%c) will be deleted', c1 = trim(name) ) call Split( str = name, sep = ',', carray = varnames_array ) ! (out) vnmax = size( varnames_array ) do i = 1, vnmax call Delete( hstnml = hstnml, name = varnames_array(i), err = err ) ! (out) if ( present_and_true( err ) ) then deallocate( varnames_array ) stat = USR_ERRNO goto 999 end if end do deallocate( varnames_array ) goto 999 end if end if !----------------------------------------------------------------- ! *hstnml* の情報を削除. ! Delete information in *hstnml* !----------------------------------------------------------------- hptr => hstnml % hstnml_list call ListSearch( hstnml_list = hptr, name = name, previous = hptr_prev, next = hptr_next ) ! (out) if ( .not. associated( hptr ) ) goto 999 if ( ( trim(hptr % name) /= '' ) .and. associated( hptr_prev ) ) then call DbgMessage( 'entry (%c) is deleted', c1 = trim( adjustl( name ) ) ) hptr_prev % next => hptr_next deallocate( hptr ) end if !----------------------------------------------------------------- ! 終了処理, 例外処理 ! Termination and Exception handling !----------------------------------------------------------------- 999 continue call StoreError( stat, subname, err, cause_c ) call EndSub( subname ) end subroutine DCHistNmlDelete
Function : | |
result : | logical |
hstnml : | type(DCHSTNML), intent(in) |
hstnml が初期設定されている場合には .true. が, 初期設定されていない場合には .false. が返ります.
If hstnml is initialized, .true. is returned. If hstnml is not initialized, .false. is returned.
logical function DCHistNmlInitialized( hstnml ) result(result) ! ! *hstnml* が初期設定されている場合には .true. が, ! 初期設定されていない場合には .false. が返ります. ! ! If *hstnml* is initialized, .true. is returned. ! If *hstnml* is not initialized, .false. is returned. ! implicit none type(DCHSTNML), intent(in):: hstnml continue result = hstnml % initialized end function DCHistNmlInitialized
Subroutine : | |||
hstnml : | type(DCHSTNML), intent(in) | ||
name : | character(*), intent(in), optional
| ||
file : | character(*), intent(out), optional
| ||
interval_value : | real(DP), intent(out), optional
| ||
interval_unit : | character(*), intent(out), optional
| ||
precision : | character(*), intent(out), optional
| ||
average : | logical, intent(out), optional
| ||
fileprefix : | character(*), intent(out), optional
| ||
err : | logical, intent(out), optional
|
変数の出力情報を取得します.
デフォルト値を取得するには, name を与えないか, または name に空白を与えてください.
name に関するデータが存在しない場合, エラーを発生させます.
なお, 与えられた hstnml が Create によって初期設定 されていない場合, プログラムはエラーを発生させます.
Inquire output information of a variable.
If data correspond to name is not found, error is occurred.
If hstnml is not initialized by "Create" yet, error is occurred.
subroutine DCHistNmlInquire( hstnml, name, file, interval_value, interval_unit, precision, average, fileprefix, err ) ! ! 変数の出力情報を取得します. ! ! デフォルト値を取得するには, *name* を与えないか, または ! *name* に空白を与えてください. ! ! *name* に関するデータが存在しない場合, エラーを発生させます. ! ! なお, 与えられた *hstnml* が Create によって初期設定 ! されていない場合, プログラムはエラーを発生させます. ! ! Inquire output information of a variable. ! ! If data correspond to *name* is not found, ! error is occurred. ! ! If *hstnml* is not initialized by "Create" yet, ! error is occurred. ! use dc_trace, only: BeginSub, EndSub use dc_string, only: PutLine, Printf, Split, StrInclude, StoA, JoinChar use dc_present, only: present_and_not_empty, present_and_true use dc_types, only: DP, STRING, TOKEN, STDOUT use dc_error, only: StoreError, DC_NOERR, DC_ENOTINIT, DC_EARGLACK, DC_ENOENTRY implicit none type(DCHSTNML), intent(in):: hstnml character(*), intent(in), optional:: name ! 変数名. ! 先頭の空白は無視されます. ! ! Variable name. ! Blanks at the head of the name are ignored. character(*), intent(out), optional:: file ! ヒストリデータのファイル名. ! History data filenames real(DP), intent(out), optional:: interval_value ! ヒストリデータの出力間隔の数値. ! 負の値を与えると, 出力を抑止します. ! ! Numerical value for interval of history data output. ! Negative values suppresses output. character(*), intent(out), optional:: interval_unit ! ヒストリデータの出力間隔の単位. ! Unit for interval of history data output character(*), intent(out), optional:: precision ! ヒストリデータの精度. ! Precision of history data logical, intent(out), optional:: average ! 出力データの平均化フラグ. ! Flag for average of output data. character(*), intent(out), optional:: fileprefix ! ヒストリデータのファイル名の接頭詞. ! Prefixes of history data filenames logical, intent(out), optional:: err ! 例外処理用フラグ. ! デフォルトでは, この手続き内でエラーが ! 生じた場合, プログラムは強制終了します. ! 引数 *err* が与えられる場合, ! プログラムは強制終了せず, 代わりに ! *err* に .true. が代入されます. ! ! Exception handling flag. ! By default, when error occur in ! this procedure, the program aborts. ! If this *err* argument is given, ! .true. is substituted to *err* and ! the program does not abort. !----------------------------------- ! 作業変数 ! Work variables type(DCHSTNML_ENTRY), pointer:: hptr =>null() integer:: stat character(STRING):: cause_c character(*), parameter:: subname = 'DCHistNmlInquire' continue call BeginSub( subname ) stat = DC_NOERR cause_c = '' !----------------------------------------------------------------- ! 初期設定のチェック ! Check initialization !----------------------------------------------------------------- if ( .not. hstnml % initialized ) then stat = DC_ENOTINIT cause_c = 'DCHSTNML' goto 999 end if !----------------------------------------------------------------- ! *hstnml* へ情報を追加. ! Inquire information to *hstnml* !----------------------------------------------------------------- hptr => hstnml % hstnml_list call ListSearch( hstnml_list = hptr, name = name ) ! (in) if ( .not. associated( hptr ) ) then stat = DC_ENOENTRY cause_c = adjustl( name ) goto 999 end if if ( hptr % name == '' ) then if ( present(file) ) file = '' else if ( present(file) ) file = trim( hptr % fileprefix ) // hptr % file end if if ( present(interval_value) ) interval_value = hptr % interval_value if ( present(interval_unit) ) interval_unit = hptr % interval_unit if ( present(precision) ) precision = hptr % precision if ( present(average) ) average = hptr % average if ( present(fileprefix) ) fileprefix = hptr % fileprefix nullify( hptr ) !----------------------------------------------------------------- ! 終了処理, 例外処理 ! Termination and Exception handling !----------------------------------------------------------------- 999 continue call StoreError( stat, subname, err, cause_c ) call EndSub( subname ) end subroutine DCHistNmlInquire
Subroutine : | |||
hstnml_list : | type(DCHSTNML_ENTRY),
pointer
| ||
previous : | type(DCHSTNML_ENTRY), pointer,
optional
| ||
err : | logical, intent(out), optional
|
リスト構造である hstnml_list (DCHSTNML_ENTRY 型) を受け取り, 最後のエントリに再結合して返します. hstnml_list が始めから空の場合には空状態を返します.
previous が与えられる場合, 当該エントリの一つ前の エントリに結合します.
hstnml_list (type "DCHSTNML_ENTRY") that is a list structure is recieved, and hstnml_list is reassociated to last entry, and returned. If hstnml_list is null from the beginning, null is returned.
If previous is given, an entry previous to the above entry is associated.
subroutine DCHistNmlListLast( hstnml_list, previous, err ) ! ! リスト構造である *hstnml_list* (DCHSTNML_ENTRY 型) を受け取り, ! 最後のエントリに再結合して返します. ! *hstnml_list* が始めから空の場合には空状態を返します. ! ! *previous* が与えられる場合, 当該エントリの一つ前の ! エントリに結合します. ! ! *hstnml_list* (type "DCHSTNML_ENTRY") that is a list structure ! is recieved, and *hstnml_list* is reassociated to ! last entry, and returned. ! If *hstnml_list* is null from the beginning, null is returned. ! ! If *previous* is given, an entry previous to the above entry ! is associated. ! use dc_trace, only: BeginSub, EndSub use dc_error, only: StoreError, DC_NOERR implicit none type(DCHSTNML_ENTRY), pointer:: hstnml_list ! (inout) type(DCHSTNML_ENTRY), pointer, optional:: previous ! (out) logical, intent(out), optional:: err ! 例外処理用フラグ. ! デフォルトでは, この手続き内でエラーが ! 生じた場合, プログラムは強制終了します. ! 引数 *err* が与えられる場合, ! プログラムは強制終了せず, 代わりに ! *err* に .true. が代入されます. ! ! Exception handling flag. ! By default, when error occur in ! this procedure, the program aborts. ! If this *err* argument is given, ! .true. is substituted to *err* and ! the program does not abort. !----------------------------------- ! 作業変数 ! Work variables integer:: stat character(STRING):: cause_c character(*), parameter:: subname = 'DCHistNmlListLast' continue call BeginSub( subname ) stat = DC_NOERR cause_c = '' if ( present( previous ) ) nullify( previous ) !----------------------------------------------------------------- ! 空状態の場合は何もしないで返す ! If null, return without change !----------------------------------------------------------------- if ( .not. associated( hstnml_list ) ) goto 999 !----------------------------------------------------------------- ! 最後のエントリの *next* に結合して返す ! "*next*" in last entry is associated, and returned !----------------------------------------------------------------- do while ( associated( hstnml_list % next ) ) if ( present( previous ) ) previous => hstnml_list call ListNext( hstnml_list = hstnml_list ) ! (inout) end do !----------------------------------------------------------------- ! 終了処理, 例外処理 ! Termination and Exception handling !----------------------------------------------------------------- 999 continue call StoreError( stat, subname, err, cause_c ) call EndSub( subname ) end subroutine DCHistNmlListLast
Subroutine : | |||
hstnml_list : | type(DCHSTNML_ENTRY),
pointer
| ||
err : | logical, intent(out), optional
|
リスト構造である hstnml_list (DCHSTNML_ENTRY 型) を受け取り, 次のエントリを hstnml_list に再結合して返します. 次のエントリが無い場合, hstnml_list の最後のエントリの next (空状態) に接続して返します. hstnml_list が始めから空の場合には空状態を返します.
hstnml_list (type "DCHSTNML_ENTRY") that is a list structure is recieved, and hstnml_list is reassociated to next entry, and is returned. If next entry is not found, hstnml_list is associated to next in last entry (null), and returned. If hstnml_list is null from the beginning, null is returned.
subroutine DCHistNmlListNext( hstnml_list, err ) ! ! リスト構造である *hstnml_list* (DCHSTNML_ENTRY 型) を受け取り, ! 次のエントリを *hstnml_list* に再結合して返します. ! 次のエントリが無い場合, *hstnml_list* の最後のエントリの ! *next* (空状態) に接続して返します. ! *hstnml_list* が始めから空の場合には空状態を返します. ! ! *hstnml_list* (type "DCHSTNML_ENTRY") that is a list structure ! is recieved, and *hstnml_list* is reassociated to next entry, and ! is returned. ! If next entry is not found, *hstnml_list* is associated to ! *next* in last entry (null), and returned. ! If *hstnml_list* is null from the beginning, null is returned. ! use dc_trace, only: BeginSub, EndSub use dc_error, only: StoreError, DC_NOERR implicit none type(DCHSTNML_ENTRY), pointer:: hstnml_list ! (inout) logical, intent(out), optional:: err ! 例外処理用フラグ. ! デフォルトでは, この手続き内でエラーが ! 生じた場合, プログラムは強制終了します. ! 引数 *err* が与えられる場合, ! プログラムは強制終了せず, 代わりに ! *err* に .true. が代入されます. ! ! Exception handling flag. ! By default, when error occur in ! this procedure, the program aborts. ! If this *err* argument is given, ! .true. is substituted to *err* and ! the program does not abort. !----------------------------------- ! 作業変数 ! Work variables integer:: stat character(STRING):: cause_c character(*), parameter:: subname = 'DCHistNmlListNext' continue call BeginSub( subname ) stat = DC_NOERR cause_c = '' !----------------------------------------------------------------- ! 空状態の場合は何もしないで返す ! If null, return without change !----------------------------------------------------------------- if ( .not. associated( hstnml_list ) ) goto 999 !----------------------------------------------------------------- ! 次のエントリに結合して返す ! Next entry is associated, and returned !----------------------------------------------------------------- hstnml_list => hstnml_list % next !----------------------------------------------------------------- ! 終了処理, 例外処理 ! Termination and Exception handling !----------------------------------------------------------------- 999 continue call StoreError( stat, subname, err, cause_c ) call EndSub( subname ) end subroutine DCHistNmlListNext
Subroutine : | |||
hstnml_list : | type(DCHSTNML_ENTRY),
pointer
| ||
name : | character(*), intent(in)
| ||
previous : | type(DCHSTNML_ENTRY), pointer,
optional
| ||
next : | type(DCHSTNML_ENTRY), pointer,
optional
| ||
err : | logical, intent(out), optional
|
リスト構造である hstnml_list (DCHSTNML_ENTRY 型) を受け取り, 引数 name と同じ値を持つエントリに再結合して返します. 見つからない場合は空状態を返します. hstnml_list が始めから空の場合には空状態を返します.
previous が与えられる場合, 当該エントリの一つ前の エントリに結合します. 前のエントリが無い場合には 空状態を返します.
next が与えられる場合, 当該エントリの一つ後ろの エントリに結合します. 後ろのエントリが無い場合には 空状態を返します.
hstnml_list (type "DCHSTNML_ENTRY") that is a list structure is recieved, and hstnml_list is reassociated to the entry that has a value that is same as argument name, and returned. If the entry is not found, null is returned. If hstnml_list is null from the beginning, null is returned.
If previous is given, an entry previous to the above entry is associated. If previous entries are not found, null is returned.
If next is given, an entry next to the above entry is associated. If next entries are not found, null is returned.
subroutine DCHistNmlListSearch( hstnml_list, name, previous, next, err ) ! ! リスト構造である *hstnml_list* (DCHSTNML_ENTRY 型) を受け取り, ! 引数 *name* と同じ値を持つエントリに再結合して返します. ! 見つからない場合は空状態を返します. ! *hstnml_list* が始めから空の場合には空状態を返します. ! ! *previous* が与えられる場合, 当該エントリの一つ前の ! エントリに結合します. 前のエントリが無い場合には ! 空状態を返します. ! ! *next* が与えられる場合, 当該エントリの一つ後ろの ! エントリに結合します. 後ろのエントリが無い場合には ! 空状態を返します. ! ! *hstnml_list* (type "DCHSTNML_ENTRY") that is a list structure ! is recieved, and *hstnml_list* is reassociated to ! the entry that has a value that is same as argument *name*, ! and returned. ! If the entry is not found, null is returned. ! If *hstnml_list* is null from the beginning, null is returned. ! ! If *previous* is given, an entry previous to the above entry ! is associated. If previous entries are not found, ! null is returned. ! ! If *next* is given, an entry next to the above entry ! is associated. If next entries are not found, ! null is returned. ! use dc_trace, only: BeginSub, EndSub use dc_error, only: StoreError, DC_NOERR implicit none type(DCHSTNML_ENTRY), pointer:: hstnml_list ! (inout) character(*), intent(in):: name ! 変数名. ! 先頭の空白は無視されます. ! ! Variable name. ! Blanks at the head of the name are ignored. type(DCHSTNML_ENTRY), pointer, optional:: previous ! (out) type(DCHSTNML_ENTRY), pointer, optional:: next ! (out) logical, intent(out), optional:: err ! 例外処理用フラグ. ! デフォルトでは, この手続き内でエラーが ! 生じた場合, プログラムは強制終了します. ! 引数 *err* が与えられる場合, ! プログラムは強制終了せず, 代わりに ! *err* に .true. が代入されます. ! ! Exception handling flag. ! By default, when error occur in ! this procedure, the program aborts. ! If this *err* argument is given, ! .true. is substituted to *err* and ! the program does not abort. !----------------------------------- ! 作業変数 ! Work variables integer:: stat character(STRING):: cause_c character(*), parameter:: subname = 'DCHistNmlListSearch' continue call BeginSub( subname ) stat = DC_NOERR cause_c = '' !----------------------------------------------------------------- ! 空状態の場合は何もしないで返す ! If null, return without change !----------------------------------------------------------------- if ( .not. associated( hstnml_list ) ) goto 999 !----------------------------------------------------------------- ! 引数 *name* と同じ *name* を持つエントリを探査 ! The entry that has *name* that is same as argument *name* is searched !----------------------------------------------------------------- if ( present( previous ) ) nullify( previous ) if ( present( next ) ) nullify( next ) if ( trim( adjustl( hstnml_list % name ) ) == trim( adjustl( name ) ) ) then if ( present( next ) ) then next => hstnml_list % next end if goto 999 end if do while ( associated( hstnml_list ) ) if ( present( previous ) ) previous => hstnml_list call ListNext( hstnml_list = hstnml_list ) ! (inout) if ( .not. associated( hstnml_list ) ) goto 999 if ( trim( adjustl( hstnml_list % name ) ) == trim( adjustl( name ) ) ) then if ( present( next ) ) then next => hstnml_list % next end if goto 999 end if end do !----------------------------------------------------------------- ! 終了処理, 例外処理 ! Termination and Exception handling !----------------------------------------------------------------- 999 continue call StoreError( stat, subname, err, cause_c ) call EndSub( subname ) end subroutine DCHistNmlListSearch
Function : | |
result : | character(STRING) |
hstnml : | type(DCHSTNML), intent(in) |
hstnml が設定されている変数リストをカンマでつなげて 返します.
なお, 与えられた hstnml が Create によって初期設定 されていない場合, 空文字が返ります.
List of variables registered in hstnml is join with ’,’, and returned.
If hstnml is not initialized by "Create" yet, blank is returned.
character(STRING) function DCHistNmlNames( hstnml ) result(result) ! ! *hstnml* が設定されている変数リストをカンマでつなげて ! 返します. ! ! なお, 与えられた *hstnml* が Create によって初期設定 ! されていない場合, 空文字が返ります. ! ! List of variables registered in *hstnml* is join with ',', ! and returned. ! ! If *hstnml* is not initialized by "Create" yet, ! blank is returned. ! use dc_string, only: PutLine, Printf, Split, StrInclude, StoA, JoinChar use dc_types, only: DP, STRING, TOKEN, STDOUT implicit none type(DCHSTNML), intent(in):: hstnml !----------------------------------- ! 作業変数 ! Work variables type(DCHSTNML_ENTRY), pointer:: hptr =>null() logical:: first !!$ character(*), parameter:: subname = 'DCHistNmlNames' continue result = '' first = .true. !----------------------------------------------------------------- ! 初期設定のチェック ! Check initialization !----------------------------------------------------------------- if ( .not. hstnml % initialized ) goto 999 !----------------------------------------------------------------- ! 情報の取り出し ! Fetch information !----------------------------------------------------------------- hptr => hstnml % hstnml_list do while ( associated( hptr % next ) ) call ListNext( hstnml_list = hptr ) ! (inout) if ( first ) then result = adjustl( hptr % name ) first = .false. else result = trim( result ) // ',' // adjustl( hptr % name ) end if end do !----------------------------------------------------------------- ! 終了処理, 例外処理 ! Termination and Exception handling !----------------------------------------------------------------- 999 continue nullify( hptr ) end function DCHistNmlNames
Function : | |||
result : | logical | ||
hstnml : | type(DCHSTNML), intent(in) | ||
name : | character(*), intent(in)
| ||
time : | type(DC_DIFFTIME), intent(in)
|
time が変数 name の出力されるタイミングであれば .true. を, そうでなければ .false. を返します. hstnml が初期設定されていない場合にも .false. が返ります. name に関するデータが存在しない場合にも .false. が返ります.
なお, 与えられた hstnml が Create によって初期設定 されていない場合, プログラムはエラーを発生させます.
If time is the time that a variable name is output, .true. is returned, otherwise .false. is returned When hstnml is not initialized, .false. is returned too. When data correspond to name is not found, .false. is returned too.
If hstnml is not initialized by "Create" yet, error is occurred.
logical function DCHistNmlOutputStep( hstnml, name, time ) result(result) ! ! *time* が変数 *name* の出力されるタイミングであれば ! .true. を, そうでなければ .false. を返します. ! *hstnml* が初期設定されていない場合にも .false. が返ります. ! *name* に関するデータが存在しない場合にも .false. が返ります. ! ! なお, 与えられた *hstnml* が Create によって初期設定 ! されていない場合, プログラムはエラーを発生させます. ! ! If *time* is the time that a variable *name* is output, ! .true. is returned, otherwise .false. is returned ! When *hstnml* is not initialized, .false. is returned too. ! When data correspond to *name* is not found, .false. is returned too. ! ! If *hstnml* is not initialized by "Create" yet, ! error is occurred. ! use dc_string, only: PutLine, Printf, Split, StrInclude, StoA, JoinChar use dc_present, only: present_and_not_empty, present_and_true use dc_date_types, only: DC_DIFFTIME use dc_date, only: Create, mod, operator(==), toChar use dc_types, only: DP, STRING, TOKEN, STDOUT implicit none type(DCHSTNML), intent(in):: hstnml character(*), intent(in):: name ! 変数名. ! 先頭の空白は無視されます. ! ! Variable name. ! Blanks at the head of the name are ignored. type(DC_DIFFTIME), intent(in):: time ! 現在時刻. Current time !----------------------------------- ! 作業変数 ! Work variables type(DCHSTNML_ENTRY), pointer:: hptr =>null() type(DC_DIFFTIME):: interval_time !!$ character(*), parameter:: subname = 'DCHistNmlOutputStep' continue result = .false. !----------------------------------------------------------------- ! 初期設定のチェック ! Check initialization !----------------------------------------------------------------- if ( .not. hstnml % initialized ) goto 999 !----------------------------------------------------------------- ! 情報格納変数への結合 ! Associate a variable storing information !----------------------------------------------------------------- hptr => hstnml % hstnml_list call ListSearch( hstnml_list = hptr, name = name ) ! (in) if ( .not. associated( hptr ) ) goto 999 !----------------------------------------------------------------- ! 時刻のチェック ! Check time !----------------------------------------------------------------- if ( .not. hptr % interval_value > 0.0_DP ) goto 999 call Create( diff = interval_time, value = hptr % interval_value, unit = hptr % interval_unit ) ! (in) if ( mod( time, interval_time ) == 0 ) then result = .true. end if !----------------------------------------------------------------- ! 終了処理, 例外処理 ! Termination and Exception handling !----------------------------------------------------------------- 999 continue nullify( hptr ) end function DCHistNmlOutputStep
Function : | |||
result : | logical | ||
hstnml : | type(DCHSTNML), intent(in) | ||
name : | character(*), intent(in)
|
変数 name の出力が有効であれば, .true. を, そうでなければ .false. を返します. hstnml が初期設定されていない場合にも .false. が返ります. name に関するデータが存在しない場合にも .false. が返ります.
なお, 与えられた hstnml が Create によって初期設定 されていない場合, プログラムはエラーを発生させます.
If output of a variable name is valid, .true. is returned, otherwise .false. is returned When hstnml is not initialized, .false. is returned too. When data correspond to name is not found, .false. is returned too.
If hstnml is not initialized by "Create" yet, error is occurred.
logical function DCHistNmlOutputValid( hstnml, name ) result(result) ! ! 変数 *name* の出力が有効であれば, ! .true. を, そうでなければ .false. を返します. ! *hstnml* が初期設定されていない場合にも .false. が返ります. ! *name* に関するデータが存在しない場合にも .false. が返ります. ! ! なお, 与えられた *hstnml* が Create によって初期設定 ! されていない場合, プログラムはエラーを発生させます. ! ! If output of a variable *name* is valid, ! .true. is returned, otherwise .false. is returned ! When *hstnml* is not initialized, .false. is returned too. ! When data correspond to *name* is not found, .false. is returned too. ! ! If *hstnml* is not initialized by "Create" yet, ! error is occurred. ! use dc_string, only: PutLine, Printf, Split, StrInclude, StoA, JoinChar use dc_present, only: present_and_not_empty, present_and_true use dc_date_types, only: DC_DIFFTIME use dc_types, only: DP, STRING, TOKEN, STDOUT implicit none type(DCHSTNML), intent(in):: hstnml character(*), intent(in):: name ! 変数名. ! 先頭の空白は無視されます. ! ! Variable name. ! Blanks at the head of the name are ignored. !----------------------------------- ! 作業変数 ! Work variables type(DCHSTNML_ENTRY), pointer:: hptr =>null() !!$ character(*), parameter:: subname = 'DCHistNmlOutputValid' continue result = .false. !----------------------------------------------------------------- ! 初期設定のチェック ! Check initialization !----------------------------------------------------------------- if ( .not. hstnml % initialized ) goto 999 !----------------------------------------------------------------- ! 情報格納変数への結合 ! Associate a variable storing information !----------------------------------------------------------------- hptr => hstnml % hstnml_list call ListSearch( hstnml_list = hptr, name = name ) ! (in) if ( .not. associated( hptr ) ) goto 999 !----------------------------------------------------------------- ! 出力の有効性のチェック ! Check validity of output !----------------------------------------------------------------- if ( hptr % interval_value > 0.0_DP ) then result = .true. goto 999 end if !----------------------------------------------------------------- ! 終了処理, 例外処理 ! Termination and Exception handling !----------------------------------------------------------------- 999 continue nullify( hptr ) end function DCHistNmlOutputValid
Subroutine : | |||
hstnml : | type(DCHSTNML), intent(in) | ||
unit : | integer, intent(in), optional
| ||
indent : | character(*), intent(in), optional
| ||
err : | logical, intent(out), optional
|
引数 hstnml に設定されている情報を印字します. デフォルトではメッセージは標準出力に出力されます. unit に装置番号を指定することで, 出力先を変更することが可能です.
Print information of hstnml. By default messages are output to standard output. Unit number for output can be changed by unit argument.
subroutine DCHistNmlPutLine( hstnml, unit, indent, err ) ! ! 引数 *hstnml* に設定されている情報を印字します. ! デフォルトではメッセージは標準出力に出力されます. ! *unit* に装置番号を指定することで, 出力先を変更することが可能です. ! ! Print information of *hstnml*. ! By default messages are output to standard output. ! Unit number for output can be changed by *unit* argument. ! use dc_trace, only: BeginSub, EndSub use dc_string, only: PutLine, Printf, Split, StrInclude, StoA, JoinChar use dc_types, only: DP, STRING, TOKEN, STDOUT use dc_error, only: StoreError, DC_NOERR, DC_ENOTINIT implicit none type(DCHSTNML), intent(in):: hstnml integer, intent(in), optional:: unit ! 出力先の装置番号. ! デフォルトの出力先は標準出力. ! ! Unit number for output. ! Default value is standard output. character(*), intent(in), optional:: indent ! 表示されるメッセージの字下げ. ! ! Indent of displayed messages. logical, intent(out), optional:: err ! 例外処理用フラグ. ! デフォルトでは, この手続き内でエラーが ! 生じた場合, プログラムは強制終了します. ! 引数 *err* が与えられる場合, ! プログラムは強制終了せず, 代わりに ! *err* に .true. が代入されます. ! ! Exception handling flag. ! By default, when error occur in ! this procedure, the program aborts. ! If this *err* argument is given, ! .true. is substituted to *err* and ! the program does not abort. !----------------------------------- ! 作業変数 ! Work variables type(DCHSTNML_ENTRY), pointer:: hptr =>null() integer:: stat character(STRING):: cause_c integer:: out_unit integer:: indent_len character(STRING):: indent_str character(*), parameter:: subname = 'DCHistNmlPutLine' continue call BeginSub( subname ) stat = DC_NOERR cause_c = '' !----------------------------------------------------------------- ! 初期設定のチェック ! Check initialization !----------------------------------------------------------------- if ( present(unit) ) then out_unit = unit else out_unit = STDOUT end if indent_len = 0 indent_str = '' if ( present(indent) ) then if ( len(indent) /= 0 ) then indent_len = len(indent) indent_str(1:indent_len) = indent end if end if !----------------------------------------------------------------- ! "DCHSTNML" の設定の印字 ! Print the settings for "DCHSTNML" !----------------------------------------------------------------- if ( hstnml % initialized ) then call Printf( out_unit, indent_str(1:indent_len) // '#<DCHSTNML:: @initialized=%y', l = (/hstnml % initialized/) ) hptr => hstnml % hstnml_list do while ( associated( hptr ) ) call Printf( out_unit, indent_str(1:indent_len) // ' #<DCHSTNML_ENTRY:: @name=%c @file=%c', c1 = trim(hptr % name), c2 = trim(hptr % file) ) call Printf( out_unit, indent_str(1:indent_len) // ' @interval_value=%f @interval_unit=%c', d = (/hptr % interval_value/), c1 = trim(hptr % interval_unit) ) call Printf( out_unit, indent_str(1:indent_len) // ' @precision=%c @average=%y', c1 = trim(hptr % precision), l = (/ hptr % average /) ) call Printf( out_unit, indent_str(1:indent_len) // ' @fileprefix=%c', c1 = trim(hptr % fileprefix) ) call ListNext( hstnml_list = hptr ) ! (inout) end do call Printf( out_unit, indent_str(1:indent_len) // ' >' ) call Printf( out_unit, indent_str(1:indent_len) // '>' ) else call Printf( out_unit, indent_str(1:indent_len) // '#<DCHSTNML:: @initialized=%y>', l = (/hstnml % initialized/) ) end if !----------------------------------------------------------------- ! 終了処理, 例外処理 ! Termination and Exception handling !----------------------------------------------------------------- 999 continue call StoreError( stat, subname, err, cause_c ) call EndSub( subname ) end subroutine DCHistNmlPutLine
Subroutine : | |||
hstnml : | type(DCHSTNML), intent(inout) | ||
err : | logical, intent(out), optional
|
デフォルト値を残し, 登録したデータを削除します.
なお, 与えられた hstnml が Create によって初期設定 されていない場合, プログラムはエラーを発生させます.
Stored data is deleted without default settings.
If hstnml is not initialized by "Create" yet, error is occurred.
subroutine DCHistNmlResetDefault( hstnml, err ) ! ! デフォルト値を残し, 登録したデータを削除します. ! ! なお, 与えられた *hstnml* が Create によって初期設定 ! されていない場合, プログラムはエラーを発生させます. ! ! Stored data is deleted without default settings. ! ! If *hstnml* is not initialized by "Create" yet, ! error is occurred. ! use dc_trace, only: BeginSub, EndSub use dc_string, only: PutLine, Printf, Split, StrInclude, StoA, JoinChar use dc_types, only: DP, STRING, TOKEN, STDOUT use dc_error, only: StoreError, DC_NOERR, DC_ENOTINIT implicit none type(DCHSTNML), intent(inout):: hstnml logical, intent(out), optional:: err ! 例外処理用フラグ. ! デフォルトでは, この手続き内でエラーが ! 生じた場合, プログラムは強制終了します. ! 引数 *err* が与えられる場合, ! プログラムは強制終了せず, 代わりに ! *err* に .true. が代入されます. ! ! Exception handling flag. ! By default, when error occur in ! this procedure, the program aborts. ! If this *err* argument is given, ! .true. is substituted to *err* and ! the program does not abort. !----------------------------------- ! 作業変数 ! Work variables character(STRING):: varnames character(TOKEN), pointer:: varnames_array(:) =>null() integer:: i, vnmax integer:: stat character(STRING):: cause_c character(*), parameter:: subname = 'DCHistNmlResetDefault' continue call BeginSub( subname ) stat = DC_NOERR cause_c = '' !----------------------------------------------------------------- ! 初期設定のチェック ! Check initialization !----------------------------------------------------------------- if ( .not. hstnml % initialized ) then stat = DC_ENOTINIT cause_c = 'DCHSTNML' goto 999 end if !----------------------------------------------------------------- ! 変数名リストの取得 ! Get varnames list !----------------------------------------------------------------- varnames = names( hstnml ) call Split( str = varnames, sep = ',', carray = varnames_array ) ! (out) vnmax = size( varnames_array ) do i = 1, vnmax call Delete( hstnml = hstnml, name = varnames_array(i) ) ! (in) end do !----------------------------------------------------------------- ! 終了処理, 例外処理 ! Termination and Exception handling !----------------------------------------------------------------- 999 continue call StoreError( stat, subname, err, cause_c ) call EndSub( subname ) end subroutine DCHistNmlResetDefault
Subroutine : | |||
hstnml_list : | type(DCHSTNML_ENTRY),
pointer
| ||
previous : | type(DCHSTNML_ENTRY), pointer,
optional
| ||
err : | logical, intent(out), optional
|
リスト構造である hstnml_list (DCHSTNML_ENTRY 型) を受け取り, 最後のエントリに再結合して返します. hstnml_list が始めから空の場合には空状態を返します.
previous が与えられる場合, 当該エントリの一つ前の エントリに結合します.
hstnml_list (type "DCHSTNML_ENTRY") that is a list structure is recieved, and hstnml_list is reassociated to last entry, and returned. If hstnml_list is null from the beginning, null is returned.
If previous is given, an entry previous to the above entry is associated.
Alias for DCHistNmlListLast
Subroutine : | |||
hstnml_list : | type(DCHSTNML_ENTRY),
pointer
| ||
err : | logical, intent(out), optional
|
リスト構造である hstnml_list (DCHSTNML_ENTRY 型) を受け取り, 次のエントリを hstnml_list に再結合して返します. 次のエントリが無い場合, hstnml_list の最後のエントリの next (空状態) に接続して返します. hstnml_list が始めから空の場合には空状態を返します.
hstnml_list (type "DCHSTNML_ENTRY") that is a list structure is recieved, and hstnml_list is reassociated to next entry, and is returned. If next entry is not found, hstnml_list is associated to next in last entry (null), and returned. If hstnml_list is null from the beginning, null is returned.
Alias for DCHistNmlListNext
Subroutine : | |||
hstnml_list : | type(DCHSTNML_ENTRY),
pointer
| ||
name : | character(*), intent(in)
| ||
previous : | type(DCHSTNML_ENTRY), pointer,
optional
| ||
next : | type(DCHSTNML_ENTRY), pointer,
optional
| ||
err : | logical, intent(out), optional
|
リスト構造である hstnml_list (DCHSTNML_ENTRY 型) を受け取り, 引数 name と同じ値を持つエントリに再結合して返します. 見つからない場合は空状態を返します. hstnml_list が始めから空の場合には空状態を返します.
previous が与えられる場合, 当該エントリの一つ前の エントリに結合します. 前のエントリが無い場合には 空状態を返します.
next が与えられる場合, 当該エントリの一つ後ろの エントリに結合します. 後ろのエントリが無い場合には 空状態を返します.
hstnml_list (type "DCHSTNML_ENTRY") that is a list structure is recieved, and hstnml_list is reassociated to the entry that has a value that is same as argument name, and returned. If the entry is not found, null is returned. If hstnml_list is null from the beginning, null is returned.
If previous is given, an entry previous to the above entry is associated. If previous entries are not found, null is returned.
If next is given, an entry next to the above entry is associated. If next entries are not found, null is returned.
Alias for DCHistNmlListSearch
Constant : | |
version = ’$Name: gt4f90io-20080210 $’ // ’$Id: dc_histnml.f90,v 1.8 2007/12/16 13:46:24 morikawa Exp $’ : | character(*), parameter |