| Class | gt4_history_nmlinfo |
| In: |
gt4_history_nmlinfo.f90
|
Note that Japanese and English are described in parallel.
比較的大規模な数値モデルにおいて, データ出力の情報管理を 支援するためのモジュールです. 個別のモジュールがそれぞれ独立にデータ出力を行うことと, NAMELIST を用いて出力ファイルや出力間隔などを変更すること 想定して設計されています. ただし, このモジュール自体の主目的は情報の管理であり, 実際のデータ出力には gt4_history モジュールを 使用することに注意してください.
This module supports information management of data output in a comparatively large-scale numerical model. This module is designed expecting that individual modules perform data output independently, and output filename or output interval is changed from NAMELIST. Note that the purpose of this module is information management, therefore actual data output is performed by "gt4_history" module.
| HstNmlInfoCreate : | GTHST_NMLINFO 型変数の初期設定 |
| HstNmlInfoClose : | GTHST_NMLINFO 型変数の終了処理 |
| HstNmlInfoPutLine : | GTHST_NMLINFO 型変数に格納されている情報の印字 |
| HstNmlInfoInitialized : | GTHST_NMLINFO 型変数が初期設定されているか否か |
| HstNmlInfoDefineMode : | 定義モードの場合に真を返す |
| HstNmlInfoEndDefine : | 変数情報定義モードから出力モードへ変更 |
| HstNmlInfoAdd : | 変数情報の追加 |
| HstNmlInfoDelete : | 変数情報の削除 |
| HstNmlInfoResetDefault : | デフォルト設定のみに戻す |
| HstNmlInfoInquire : | 変数情報の問い合わせ |
| HstNmlInfoAssocGtHist : | 変数に応じた gt4_history#GT_HISTORY 型変数を返す |
| HstNmlInfoOutputStepDisable : | output_step が常に .false. を返すよう設定する |
| HstNmlInfoOutputStep : | 出力の設定が有効である場合に真を返す |
| HstNmlInfoOutputValid : | 現在の時刻が出力のタイミングの場合に真を返す |
| HstNmlInfoNames : | 登録されている変数名リストを返す |
| HstNmlInfoAllVarIniCheck : | 初期設定されていない変数名のチェック |
| HstNmlInfoSetValidName : | 変数名の有効性を設定 |
| HstNmlInfoAllNameValid : | 無効な変数名のチェック |
| ———— : | ———— |
| HstNmlInfoCreate : | Constructor of "GTHST_NMLINFO" |
| HstNmlInfoClose : | Deconstructor of "GTHST_NMLINFO" |
| HstNmlInfoPutLine : | Print information of "GTHST_NMLINFO" |
| HstNmlInfoInitialized : | Check initialization of "GTHST_NMLINFO" |
| HstNmlInfoDefineMode : | True is returned if current state is define mode |
| HstNmlInfoEndDefine : | Change define mode about information of variables to output mode |
| HstNmlInfoAdd : | Add information of variables |
| HstNmlInfoDelete : | Delete information of variables |
| HstNmlInfoResetDefault : | Reset to default settings |
| HstNmlInfoInquire : | Inquire information of variables |
| HstNmlInfoAssocGtHist : | "gt4_history#GT_HISTORY" correspond to variable is returned |
| HstNmlInfoOutputStepDisable : | Configure that "output_step" returns .false. already |
| HstNmlInfoOutputStep : | True is returned when a configuration of output is valid |
| HstNmlInfoOutputValid : | True is returned when current time is output timing |
| HstNmlInfoNames : | Return list of registerd variable identifiers |
| HstNmlInfoAllVarIniCheck : | Check uninitialized variable names |
| HstNmlInfoSetValidName : | Set validation to variable names |
| HstNmlInfoAllNameValid : | Check invalid variable names |
このモジュールは以下のような手順で用いてください.
このモジュールを使用したサンプル Fortran プログラム 作成スクリプトが www.gfd-dennou.org/library/dcpam/dcpam4/dcpam4_current/script/f90/dcmodel_f90sample_maker.rb から入手できます. Ruby で記述されており, 実行することで サンプルとなる Fortran プログラムが作成されます. 下記の解説のみでは実際の利用法やご利益が分かりにくいため, サンプル Fortran プログラムを実際に見てみることをオススメします.
それぞれの変数に関して, 出力設定が有効かどうかについては, HstNmlInfoOutputValid で知ることが可能です.
また, 時間積分中に gt4_history#HistoryPut を使用する際 に, 現在時刻が出力タイミングかどうかについては, HstNmlInfoOutputStep で知ることが可能です.
Use this module as follows.
Sample Fortran programs generator (Ruby script) is available from www.gfd-dennou.org/library/dcpam/dcpam4/dcpam4_current/script/f90/dcmodel_f90sample_maker.rb . Sample Fortran programs are created by executing this script. Because neither actual usage nor the profit are understood easily only from the following explanations, It is recommended to see sample Fortran programs actually.
It can know whether the output setting is effective for each variable with "output_valid".
Moreover, it can know time now to be whether output timing when "gt4_history#HistoryPut" is used while integrating time with "output_step".
| Derived Type : |
NAMELIST から取得したヒストリデータの出力情報 を格納するための構造データ型です. まず, HstNmlInfoCreate で "GTHST_NMLINFO" 型の変数を初期設定して下さい. 初期設定された "GTHST_NMLINFO" 型の変数を再度利用する際には, HstNmlInfoClose によって終了処理を行ってください.
This derived type is worked in order to store information about data output from NAMELIST. Initialize "GTHST_NMLINFO" variable by "HstNmlInfoCreate" before usage. If you reuse "GTHST_NMLINFO" variable again for another application, terminate by "HstNmlInfoClose".
| Subroutine : | recursive | ||
| gthstnml : | type(GTHST_NMLINFO), intent(inout) | ||
| name : | character(*), intent(in), optional
| ||
| file : | character(*), intent(in), optional
| ||
| interval_value : | real, 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" が指定されます.
なお, 与えられた gthstnml が HstNmlInfoCreate によって初期設定 されていない場合, プログラムはエラーを発生させます.
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 identifier 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 gthstnml is not initialized by "HstNmlInfoCreate" yet, error is occurred.
recursive subroutine HstNmlInfoAdd( gthstnml, name, file, interval_value, interval_unit, precision, average, fileprefix, err )
!
! 変数の出力情報を加えます.
!
! デフォルト値を設定するには, *name* を与えないか, または
! *name* に空白を与えてください.
! デフォルト値を与える場合, *file* に与えられる情報は無視されます.
! *fileprefix* はデフォルト値に与える場合のみ有効です.
!
! *name* に変数名が指定され, その際に *file* が与えられない,
! または空白が与えられる場合, *file* には
! "<i><*name* に与えられた文字></i>.nc" が指定されます.
!
! なお, 与えられた *gthstnml* が HstNmlInfoCreate によって初期設定
! されていない場合, プログラムはエラーを発生させます.
!
! 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 identifier 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 *gthstnml* is not initialized by "HstNmlInfoCreate" 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: DCDiffTimeCreate
use dc_message, only: MessageNotify
use dc_error, only: StoreError, DC_NOERR, DC_ENOTINIT, DC_EARGLACK, USR_ERRNO, HST_ENOTINDEFINE
implicit none
type(GTHST_NMLINFO), intent(inout):: gthstnml
character(*), intent(in), optional:: name
! 変数名.
!
! 先頭の空白は無視されます.
!
! "Data1,Data2" のようにカンマで区切って複数
! の変数を指定することも可能です.
!
!
! Variable identifier.
!
! Blanks at the head of the name are ignored.
!
! Multiple variables can be specified
! as "Data1,Data2" too. Delimiter is comma.
!
!
character(*), intent(in), optional:: file
! ヒストリデータのファイル名.
! History data filenames
real, 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(GTHST_NMLINFO_ENTRY), pointer:: hptr =>null()
type(GTHST_NMLINFO_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 = 'HstNmlInfoAdd'
continue
call BeginSub( subname, fmt = '@name=%a @file=%a @interval_value=%r @interval_unit=%a @precision=%a @average=%y @fileprefix=%a', r = (/ present_select(.true., -1.0, 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. gthstnml % initialized ) then
stat = DC_ENOTINIT
cause_c = 'GTHST_NMLINFO'
goto 999
end if
if ( .not. gthstnml % define_mode ) then
stat = HST_ENOTINDEFINE
cause_c = 'Add'
goto 999
end if
!-----------------------------------------------------------------
! 複数の変数を設定する場合
! Configure multiple variables
!-----------------------------------------------------------------
if ( present_and_not_empty(name) ) then
if ( index(name, name_delimiter) > 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 = name_delimiter, carray = varnames_array ) ! (out)
vnmax = size( varnames_array )
do i = 1, vnmax
call HstNmlInfoAdd( gthstnml = gthstnml, name = varnames_array(i), file = file, 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
!-----------------------------------------------------------------
! *gthstnml* へ情報を追加.
! Add information to *gthstnml*
!-----------------------------------------------------------------
if ( .not. present_and_not_empty(name) ) then
if ( present(interval_value) ) gthstnml % gthstnml_list % interval_value = interval_value
if ( present(interval_unit) ) gthstnml % gthstnml_list % interval_unit = interval_unit
if ( present(precision) ) gthstnml % gthstnml_list % precision = precision
if ( present(average) ) gthstnml % gthstnml_list % average = average
if ( present(fileprefix) ) gthstnml % gthstnml_list % fileprefix = fileprefix
hptr => gthstnml % gthstnml_list
else
hptr => gthstnml % gthstnml_list
call ListSearch( gthstnml_list = hptr, name = name ) ! (in)
if ( .not. associated(hptr) ) then
call DbgMessage( 'new entry (%c) is created', c1 = trim( adjustl( name ) ) )
hptr_last => gthstnml % gthstnml_list
call ListLast( gthstnml_list = hptr_last ) ! (inout)
allocate( hptr )
nullify( hptr % next )
hptr % interval_value => gthstnml % gthstnml_list % interval_value
hptr % interval_unit => gthstnml % gthstnml_list % interval_unit
hptr % precision => gthstnml % gthstnml_list % precision
hptr % average => gthstnml % gthstnml_list % average
hptr % fileprefix => gthstnml % gthstnml_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( adjustl(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 DCDiffTimeCreate( diff = interval_time, value = real( hptr % interval_value, DP ), unit = hptr % interval_unit, err = err ) ! (out)
if ( present_and_true( err ) ) then
call HstNmlInfoDelete( gthstnml = gthstnml, 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 HstNmlInfoAdd
| Subroutine : | |||
| gthstnml : | type(GTHST_NMLINFO), intent(in) | ||
| invalid : | logical, intent(out)
| ||
| names : | character(*), intent(out)
| ||
| err : | logical, intent(out), optional
|
無効な変数名のチェック
HstNmlInfoSetValidName によって, 有効性を設定されていない変数が ある場合, invalid に .true. を返し, names には無効な 変数名をカンマで区切った文字列を返します.
なお, 与えられた gthstnml が HstNmlInfoCreate によって初期設定 されていない場合, プログラムはエラーを発生させます.
Check invalid variable names
If variable names that are not set validation by "HstNmlInfoSetValidName" are exist, .true. is set to invalid, and invalid variable names are joined with comma, and set to names.
If gthstnml is not initialized by "HstNmlInfoCreate" yet, error is occurred.
subroutine HstNmlInfoAllNameValid( gthstnml, invalid, names, err )
!
! 無効な変数名のチェック
!
! HstNmlInfoSetValidName によって, 有効性を設定されていない変数が
! ある場合,
! *invalid* に .true. を返し, *names* には無効な
! 変数名をカンマで区切った文字列を返します.
!
! なお, 与えられた *gthstnml* が HstNmlInfoCreate によって初期設定
! されていない場合, プログラムはエラーを発生させます.
!
! Check invalid variable names
!
! If variable names that are not set validation by
! "HstNmlInfoSetValidName" are exist,
! .true. is set to *invalid*, and invalid variable names
! are joined with comma, and set to *names*.
!
! If *gthstnml* is not initialized by "HstNmlInfoCreate" 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
use gt4_history, only: HistoryInitialized
implicit none
type(GTHST_NMLINFO), intent(in):: gthstnml
logical, intent(out):: invalid
! 無効な変数名が存在する
! 場合には .true. を返す.
!
! If invalid variable names are exist,
! .true. is returned.
!
character(*), intent(out):: names
! 無効な変数名のリスト.
!
! List of invalid variable names.
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(GTHST_NMLINFO_ENTRY), pointer:: hptr =>null()
integer:: stat
character(STRING):: cause_c
character(*), parameter:: subname = 'HstNmlInfoAllNameValid'
continue
call BeginSub( subname )
stat = DC_NOERR
cause_c = ''
names = ''
invalid = .false.
!-----------------------------------------------------------------
! 初期設定のチェック
! Check initialization
!-----------------------------------------------------------------
if ( .not. gthstnml % initialized ) then
stat = DC_ENOTINIT
cause_c = 'GTHST_NMLINFO'
goto 999
end if
!-----------------------------------------------------------------
! *gthstnml* 内から, *name* に関する情報を探査.
! Search information correspond to *name* in *gthstnml*
!-----------------------------------------------------------------
hptr => gthstnml % gthstnml_list
do while ( associated( hptr % next ) )
call ListNext( gthstnml_list = hptr ) ! (inout)
if ( hptr % name_invalid ) then
invalid = .true.
if ( trim(names) /= '' ) names = trim(names) // name_delimiter
names = trim(names) // adjustl( hptr % name )
end if
end do
!-----------------------------------------------------------------
! 終了処理, 例外処理
! Termination and Exception handling
!-----------------------------------------------------------------
999 continue
call StoreError( stat, subname, err, cause_c )
call EndSub( subname, fmt = '@invalid=%y @names=%c', l = (/ invalid /), c1 = trim(names) )
end subroutine HstNmlInfoAllNameValid
| Subroutine : | |||
| gthstnml : | type(GTHST_NMLINFO), intent(in) | ||
| invalid : | logical, intent(out)
| ||
| names : | character(*), intent(out)
| ||
| err : | logical, intent(out), optional
|
初期設定されていない変数名のチェック
初期設定されていない変数名がある場合, invalid に .true. を返し, names には初期設定されていない 変数名をカンマで区切った文字列を返します.
なお, 与えられた gthstnml が HstNmlInfoCreate によって初期設定 されていない場合, プログラムはエラーを発生させます.
Check uninitialized variable names
If uninitialized variable names are exist, .true. is set to invalid, and uninitialized variable names are joined with comma, and set to names.
If gthstnml is not initialized by "HstNmlInfoCreate" yet, error is occurred.
subroutine HstNmlInfoAllVarIniCheck( gthstnml, invalid, names, err )
!
! 初期設定されていない変数名のチェック
!
! 初期設定されていない変数名がある場合,
! *invalid* に .true. を返し, *names* には初期設定されていない
! 変数名をカンマで区切った文字列を返します.
!
! なお, 与えられた *gthstnml* が HstNmlInfoCreate によって初期設定
! されていない場合, プログラムはエラーを発生させます.
!
! Check uninitialized variable names
!
! If uninitialized variable names are exist,
! .true. is set to *invalid*, and uninitialized variable names
! are joined with comma, and set to *names*.
!
! If *gthstnml* is not initialized by "HstNmlInfoCreate" 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
use gt4_history, only: HistoryInitialized
implicit none
type(GTHST_NMLINFO), intent(in):: gthstnml
logical, intent(out):: invalid
! 初期設定されていない変数名が存在する
! 場合には .true. を返す.
!
! If uninitialized variable names are exist,
! .true. is returned.
!
character(*), intent(out):: names
! 初期設定されていない変数名のリスト.
!
! List of uninitialized variable names.
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(GTHST_NMLINFO_ENTRY), pointer:: hptr =>null()
integer:: stat
character(STRING):: cause_c
character(*), parameter:: subname = 'HstNmlInfoAllVarIniCheck'
continue
call BeginSub( subname )
stat = DC_NOERR
cause_c = ''
names = ''
invalid = .false.
!-----------------------------------------------------------------
! 初期設定のチェック
! Check initialization
!-----------------------------------------------------------------
if ( .not. gthstnml % initialized ) then
stat = DC_ENOTINIT
cause_c = 'GTHST_NMLINFO'
goto 999
end if
!-----------------------------------------------------------------
! *gthstnml* 内から, *name* に関する情報を探査.
! Search information correspond to *name* in *gthstnml*
!-----------------------------------------------------------------
hptr => gthstnml % gthstnml_list
do while ( associated( hptr % next ) )
call ListNext( gthstnml_list = hptr ) ! (inout)
if ( .not. HistoryInitialized( hptr % history ) ) then
invalid = .true.
if ( trim(names) /= '' ) names = trim(names) // name_delimiter
names = trim(names) // adjustl( hptr % name )
end if
end do
!-----------------------------------------------------------------
! 終了処理, 例外処理
! Termination and Exception handling
!-----------------------------------------------------------------
999 continue
call StoreError( stat, subname, err, cause_c )
call EndSub( subname, fmt = '@invalid=%y @names=%c', l = (/ invalid /), c1 = trim(names) )
end subroutine HstNmlInfoAllVarIniCheck
| Subroutine : | |||
| gthstnml : | type(GTHST_NMLINFO), intent(in) | ||
| name : | character(*), intent(in)
| ||
| history : | type(GT_HISTORY), pointer
| ||
| err : | logical, intent(out), optional
|
与えられた gt4_history#GT_HISTORY 型のポインタ history に対し, gthstnml 内の name に関する gt4_history#GT_HISTORY 型変数を 結合します. 空状態の history を与えてください.
HstNmlInfoEndDefine で定義モードから出力モードに 移行した後に呼び出してください. HstNmlInfoEndDefine を呼ぶ前にこのサブルーチンを使用すると, プログラムはエラーを発生させます.
name に関する情報が見当たらない場合, プログラムはエラーを発生させます. name が空文字の場合にも, プログラムはエラーを発生させます.
なお, 与えられた gthstnml が HstNmlInfoCreate によって初期設定 されていない場合にも, プログラムはエラーを発生させます.
This subroutine associates given "gt4_history#GT_HISTORY" pointer history to "gt4_history#GT_HISTORY" correspond to name in gthstnml. Give null history.
Use after state is changed from define mode to output mode by "HstNmlInfoEndDefine". If this subroutine is used before "HstNmlInfoEndDefine" is used, error is occurred.
When data correspond to name is not found, error is occurred. When name is blank, error is occurred too.
If gthstnml is not initialized by "HstNmlInfoCreate" yet, error is occurred.
subroutine HstNmlInfoAssocGtHist( gthstnml, name, history, err )
!
! 与えられた gt4_history#GT_HISTORY 型のポインタ *history* に対し,
! *gthstnml* 内の *name* に関する gt4_history#GT_HISTORY 型変数を
! 結合します.
! 空状態の *history* を与えてください.
!
! HstNmlInfoEndDefine で定義モードから出力モードに
! 移行した後に呼び出してください.
! HstNmlInfoEndDefine を呼ぶ前にこのサブルーチンを使用すると,
! プログラムはエラーを発生させます.
!
! *name* に関する情報が見当たらない場合,
! プログラムはエラーを発生させます.
! *name* が空文字の場合にも,
! プログラムはエラーを発生させます.
!
! なお, 与えられた *gthstnml* が HstNmlInfoCreate によって初期設定
! されていない場合にも, プログラムはエラーを発生させます.
!
! This subroutine associates given "gt4_history#GT_HISTORY"
! pointer *history* to
! "gt4_history#GT_HISTORY" correspond to *name* in *gthstnml*.
! Give null *history*.
!
! Use after state is changed from define mode to
! output mode by "HstNmlInfoEndDefine".
! If this subroutine is used before
! "HstNmlInfoEndDefine" is used, error is occurred.
!
! When data correspond to *name* is not found,
! error is occurred.
! When *name* is blank,
! error is occurred too.
!
! If *gthstnml* is not initialized by "HstNmlInfoCreate" 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, DC_ENOENTRY, HST_EBADNAME, HST_EINDEFINE
implicit none
type(GTHST_NMLINFO), intent(in):: gthstnml
character(*), intent(in):: name
! 変数名.
! 先頭の空白は無視されます.
!
! Variable identifier.
! Blanks at the head of the name are ignored.
type(GT_HISTORY), pointer:: history
! (out)
!
! gt4_history モジュール用構造体.
! Derived type for "gt4_history" module
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(GTHST_NMLINFO_ENTRY), pointer:: hptr =>null()
integer:: stat
character(STRING):: cause_c
character(*), parameter:: subname = 'HstNmlInfoAssocGtHist'
continue
call BeginSub( subname )
stat = DC_NOERR
cause_c = ''
!-----------------------------------------------------------------
! 初期設定のチェック
! Check initialization
!-----------------------------------------------------------------
if ( .not. gthstnml % initialized ) then
stat = DC_ENOTINIT
cause_c = 'GTHST_NMLINFO'
goto 999
end if
if ( trim( name ) == '' ) then
stat = HST_EBADNAME
cause_c = ''
goto 999
end if
if ( gthstnml % define_mode ) then
stat = HST_EINDEFINE
cause_c = 'AssocGtHist'
goto 999
end if
!-----------------------------------------------------------------
! *gthstnml* 内から, *name* に関する history を探査.
! Search "history" correspond to *name* in *gthstnml*
!-----------------------------------------------------------------
hptr => gthstnml % gthstnml_list
call ListSearch( gthstnml_list = hptr, name = name ) ! (in)
if ( .not. associated( hptr ) ) then
stat = DC_ENOENTRY
cause_c = adjustl( name )
goto 999
end if
nullify( history )
history => hptr % history
nullify( hptr )
!-----------------------------------------------------------------
! 終了処理, 例外処理
! Termination and Exception handling
!-----------------------------------------------------------------
999 continue
call StoreError( stat, subname, err, cause_c )
call EndSub( subname )
end subroutine HstNmlInfoAssocGtHist
| Subroutine : | |||
| gthstnml : | type(GTHST_NMLINFO), intent(inout) | ||
| err : | logical, intent(out), optional
|
GTHST_NMLINFO 型の変数の終了処理を行います.
このサブルーチンを使用する前に, gthstnml に格納されている gt4_history#GT_HISTORY 型の全ての変数に対して, gt4_history#HistoryClose を用いて終了処理を行ってください. 終了処理されていないものがある場合, プログラムはエラーを発生させます.
なお, 与えられた gthstnml が HstNmlInfoCreate によって初期設定 されていない場合, プログラムはエラーを発生させます.
Deconstructor of "GTHST_NMLINFO".
Terminate all "gt4_history#GT_HISTORY" variables in gthstnml by "gt4_history#HistoryClose" before this subroutine is used. If unterminated variables remain, error is occurred.
Note that if gthstnml is not initialized by "HstNmlInfoCreate" yet, error is occurred.
subroutine HstNmlInfoClose( gthstnml, err )
!
! GTHST_NMLINFO 型の変数の終了処理を行います.
!
! このサブルーチンを使用する前に, *gthstnml* に格納されている
! gt4_history#GT_HISTORY 型の全ての変数に対して,
! gt4_history#HistoryClose を用いて終了処理を行ってください.
! 終了処理されていないものがある場合,
! プログラムはエラーを発生させます.
!
! なお, 与えられた *gthstnml* が HstNmlInfoCreate によって初期設定
! されていない場合, プログラムはエラーを発生させます.
!
! Deconstructor of "GTHST_NMLINFO".
!
! Terminate all "gt4_history#GT_HISTORY" variables in *gthstnml*
! by "gt4_history#HistoryClose" before this subroutine is used.
! If unterminated variables remain,
! error is occurred.
!
! Note that if *gthstnml* is not initialized by "HstNmlInfoCreate" 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, HST_ENOTTERMGTHIST
use gt4_history, only: HistoryInitialized
implicit none
type(GTHST_NMLINFO), intent(inout):: gthstnml
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(GTHST_NMLINFO_ENTRY), pointer:: hptr =>null()
type(GTHST_NMLINFO_ENTRY), pointer:: hptr_prev =>null()
integer:: stat
character(STRING):: cause_c
character(*), parameter:: subname = 'HstNmlInfoClose'
continue
call BeginSub( subname )
stat = DC_NOERR
cause_c = ''
!-----------------------------------------------------------------
! 初期設定のチェック
! Check initialization
!-----------------------------------------------------------------
if ( .not. gthstnml % initialized ) then
stat = DC_ENOTINIT
cause_c = 'GTHST_NMLINFO'
goto 999
end if
!-----------------------------------------------------------------
! "GTHST_NMLINFO" の設定の消去
! Clear the settings for "GTHST_NMLINFO"
!-----------------------------------------------------------------
do
hptr => gthstnml % gthstnml_list
call ListLast( gthstnml_list = hptr, previous = hptr_prev ) ! (out)
call DbgMessage( 'remove entry (%c)', c1 = trim(hptr % name) )
if ( trim( hptr % name ) == '' ) exit
if ( .not. gthstnml % define_mode ) then
if ( HistoryInitialized( hptr % history ) ) then
stat = HST_ENOTTERMGTHIST
cause_c = hptr % name
goto 999
end if
end if
deallocate( hptr )
nullify( hptr_prev % next )
end do
deallocate( gthstnml % gthstnml_list )
!-----------------------------------------------------------------
! 終了処理, 例外処理
! Termination and Exception handling
!-----------------------------------------------------------------
gthstnml % initialized = .false.
gthstnml % define_mode = .true.
999 continue
nullify( hptr )
call StoreError( stat, subname, err, cause_c )
call EndSub( subname )
end subroutine HstNmlInfoClose
| Subroutine : | |||
| gthstnml : | type(GTHST_NMLINFO), intent(inout) | ||
| interval_value : | real, 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
|
GTHST_NMLINFO 型の変数の初期設定を行います. 他のサブルーチンを使用する前に必ずこのサブルーチンによって GTHST_NMLINFO 型の変数を初期設定してください.
interval_value, interval_unit, precision, average はデフォルト値として設定されます. fileprefix は各変数の出力ファイル名の接頭詞として 使用されます.
なお, 与えられた gthstnml が既に初期設定されている場合, プログラムはエラーを発生させます.
Constructor of "GTHST_NMLINFO". Initialize gthstnml 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 gthstnml is already initialized by this procedure, error is occurred.
subroutine HstNmlInfoCreate( gthstnml, interval_value, interval_unit, precision, average, fileprefix, err )
!
! GTHST_NMLINFO 型の変数の初期設定を行います.
! 他のサブルーチンを使用する前に必ずこのサブルーチンによって
! GTHST_NMLINFO 型の変数を初期設定してください.
!
! *interval_value*,
! *interval_unit*,
! *precision*,
! *average*
! はデフォルト値として設定されます.
! *fileprefix* は各変数の出力ファイル名の接頭詞として
! 使用されます.
!
! なお, 与えられた *gthstnml* が既に初期設定されている場合,
! プログラムはエラーを発生させます.
!
! Constructor of "GTHST_NMLINFO".
! Initialize *gthstnml* 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 *gthstnml* 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: DCDiffTimeCreate
implicit none
type(GTHST_NMLINFO), intent(inout):: gthstnml
real, 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 = 'HstNmlInfoCreate'
continue
call BeginSub( subname, fmt = '@interval_value=%r @interval_unit=%c @precision=%c @average=%y @fileprefix=%c', r = (/ present_select(.true., -1.0, 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 ( gthstnml % initialized ) then
stat = DC_EALREADYINIT
cause_c = 'GTHST_NMLINFO'
goto 999
end if
!-----------------------------------------------------------------
! 割付
! Allocate
!-----------------------------------------------------------------
allocate( gthstnml % gthstnml_list )
nullify( gthstnml % gthstnml_list % next )
!-----------------------------------------------------------------
! デフォルト値の設定
! Configure default values
!-----------------------------------------------------------------
gthstnml % gthstnml_list % name = ''
gthstnml % gthstnml_list % file = ''
allocate( gthstnml % gthstnml_list % interval_value )
allocate( gthstnml % gthstnml_list % interval_unit )
allocate( gthstnml % gthstnml_list % precision )
allocate( gthstnml % gthstnml_list % average )
allocate( gthstnml % gthstnml_list % fileprefix )
gthstnml % gthstnml_list % interval_value = -1.0
gthstnml % gthstnml_list % interval_unit = 'sec'
gthstnml % gthstnml_list % precision = 'float'
gthstnml % gthstnml_list % average = .false.
gthstnml % gthstnml_list % fileprefix = ''
if ( present(interval_value) ) gthstnml % gthstnml_list % interval_value = interval_value
if ( present(interval_unit) ) gthstnml % gthstnml_list % interval_unit = interval_unit
if ( present(precision) ) gthstnml % gthstnml_list % precision = precision
if ( present(average) ) gthstnml % gthstnml_list % average = average
if ( present(fileprefix) ) gthstnml % gthstnml_list % fileprefix = fileprefix
!-----------------------------------------------------------------
! 時間の単位のチェック
! Check unit of time
!-----------------------------------------------------------------
call DCDiffTimeCreate( diff = interval_time, value = real( gthstnml % gthstnml_list % interval_value, DP ), unit = gthstnml % gthstnml_list % interval_unit, err = err ) ! (out)
if ( present_and_true( err ) ) then
stat = USR_ERRNO
goto 999
end if
!-----------------------------------------------------------------
! 終了処理, 例外処理
! Termination and Exception handling
!-----------------------------------------------------------------
gthstnml % initialized = .true.
gthstnml % define_mode = .true.
999 continue
call StoreError( stat, subname, err, cause_c )
call EndSub( subname )
end subroutine HstNmlInfoCreate
| Function : | |
| result : | logical |
| gthstnml : | type(GTHST_NMLINFO), intent(in) |
gthstnml が定義モードであれば .true. が, 定義モードでなければ .false. が返ります.
If gthstnml is define mode, .true. is returned. If gthstnml is not define mode, .false. is returned.
logical function HstNmlInfoDefineMode( gthstnml ) result(result)
!
! *gthstnml* が定義モードであれば .true. が,
! 定義モードでなければ .false. が返ります.
!
! If *gthstnml* is define mode, .true. is returned.
! If *gthstnml* is not define mode, .false. is returned.
!
implicit none
type(GTHST_NMLINFO), intent(in):: gthstnml
continue
result = gthstnml % define_mode
end function HstNmlInfoDefineMode
| Subroutine : | recursive | ||
| gthstnml : | type(GTHST_NMLINFO), intent(inout) | ||
| name : | character(*), intent(in)
| ||
| err : | logical, intent(out), optional
|
変数の出力情報を削除します.
なお, 与えられた gthstnml が HstNmlInfoCreate によって初期設定 されていない場合, プログラムはエラーを発生させます.
Delete output information of a variable.
If gthstnml is not initialized by "HstNmlInfoCreate" yet, error is occurred.
recursive subroutine HstNmlInfoDelete( gthstnml, name, err )
!
! 変数の出力情報を削除します.
!
! なお, 与えられた *gthstnml* が HstNmlInfoCreate によって初期設定
! されていない場合, プログラムはエラーを発生させます.
!
! Delete output information of a variable.
!
! If *gthstnml* is not initialized by "HstNmlInfoCreate" 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, HST_ENOTINDEFINE
implicit none
type(GTHST_NMLINFO), intent(inout):: gthstnml
character(*), intent(in):: name
! 変数名.
!
! 先頭の空白は無視されます.
!
! "Data1,Data2" のようにカンマで区切って複数
! の変数を指定することが可能です.
!
! Variable identifier.
!
! 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(GTHST_NMLINFO_ENTRY), pointer:: hptr =>null()
type(GTHST_NMLINFO_ENTRY), pointer:: hptr_prev =>null()
type(GTHST_NMLINFO_ENTRY), pointer:: hptr_next =>null()
character(TOKEN), pointer:: varnames_array(:) =>null()
integer:: i, vnmax
integer:: stat
character(STRING):: cause_c
character(*), parameter:: subname = 'HstNmlInfoDelete'
continue
call BeginSub( subname, fmt = '@name=%c', c1 = trim( name ) )
stat = DC_NOERR
cause_c = ''
!-----------------------------------------------------------------
! 初期設定のチェック
! Check initialization
!-----------------------------------------------------------------
if ( .not. gthstnml % initialized ) then
stat = DC_ENOTINIT
cause_c = 'GTHST_NMLINFO'
goto 999
end if
if ( .not. gthstnml % define_mode ) then
stat = HST_ENOTINDEFINE
cause_c = 'Delete'
goto 999
end if
!-----------------------------------------------------------------
! 複数の変数を削除する場合
! Delete multiple variables
!-----------------------------------------------------------------
if ( present_and_not_empty(name) ) then
if ( index(name, name_delimiter) > 0 ) then
call DbgMessage( 'multiple entries (%c) will be deleted', c1 = trim(name) )
call Split( str = name, sep = name_delimiter, carray = varnames_array ) ! (out)
vnmax = size( varnames_array )
do i = 1, vnmax
call HstNmlInfoDelete( gthstnml = gthstnml, 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
!-----------------------------------------------------------------
! *gthstnml* の情報を削除.
! Delete information in *gthstnml*
!-----------------------------------------------------------------
hptr => gthstnml % gthstnml_list
call ListSearch( gthstnml_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 HstNmlInfoDelete
| Subroutine : | |||
| gthstnml : | type(GTHST_NMLINFO), intent(inout) | ||
| err : | logical, intent(out), optional
|
定義モードから出力モードに移行し, gthstnml に設定した情報を確定します. HstNmlInfoAssocGTHist サブルーチンを呼び出す前に, 必ずこのサブルーチンを呼び出してください. このサブルーチンを呼んだ後に HstNmlInfoAdd, HstNmlInfoDelete, HstNmlInfoResetDefault を呼ぶとプログラムはエラーを発生させます.
なお, 与えられた gthstnml が HstNmlInfoCreate によって初期設定 されていない場合にも, プログラムはエラーを発生させます.
Change from define mode to output mode, and determine information configured in gthstnml. Use this subroutine before "HstNmlInfoAssocGTHist" is used. If "HstNmlInfoAdd", "HstNmlInfoDelete", "HstNmlInfoResetDefault" are used after this subroutine is used, error is occurred.
If gthstnml is not initialized by "HstNmlInfoCreate" yet, error is occurred.
subroutine HstNmlInfoEndDefine( gthstnml, err )
!
! 定義モードから出力モードに移行し,
! *gthstnml* に設定した情報を確定します.
! HstNmlInfoAssocGTHist サブルーチンを呼び出す前に,
! 必ずこのサブルーチンを呼び出してください.
! このサブルーチンを呼んだ後に
! HstNmlInfoAdd, HstNmlInfoDelete, HstNmlInfoResetDefault
! を呼ぶとプログラムはエラーを発生させます.
!
! なお, 与えられた *gthstnml* が HstNmlInfoCreate によって初期設定
! されていない場合にも, プログラムはエラーを発生させます.
!
! Change from define mode to output mode,
! and determine information configured in *gthstnml*.
! Use this subroutine before "HstNmlInfoAssocGTHist" is used.
! If "HstNmlInfoAdd", "HstNmlInfoDelete", "HstNmlInfoResetDefault"
! are used after
! this subroutine is used, error is occurred.
!
! If *gthstnml* is not initialized by "HstNmlInfoCreate" 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_hash, only: HASH, DCHashPut, DCHashGet, DCHashRewind, DCHashNext, DCHashNumber
use dc_error, only: StoreError, DC_NOERR, DC_ENOTINIT, HST_ENOTINDEFINE, HST_EINTFILE
use dc_message, only: MessageNotify
implicit none
type(GTHST_NMLINFO), intent(inout):: gthstnml
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.
!-----------------------------------
! ファイルの重複をチェックするための変数
! Variables for checking duplication of files
type(HASH):: opened_files
character(STRING):: opname, opfile
logical:: end
!-----------------------------------
! 作業変数
! Work variables
character(STRING):: fullfilename
type(GTHST_NMLINFO_ENTRY), pointer:: hptr =>null()
type(GTHST_NMLINFO_ENTRY), pointer:: hptr_prev =>null()
integer:: stat
character(STRING):: cause_c
character(*), parameter:: subname = 'HstNmlInfoEndDefine'
continue
call BeginSub( subname )
stat = DC_NOERR
cause_c = ''
!-----------------------------------------------------------------
! 初期設定のチェック
! Check initialization
!-----------------------------------------------------------------
if ( .not. gthstnml % initialized ) then
stat = DC_ENOTINIT
cause_c = 'GTHST_NMLINFO'
goto 999
end if
if ( .not. gthstnml % define_mode ) then
stat = HST_ENOTINDEFINE
cause_c = 'EndDefine'
goto 999
end if
!-----------------------------------------------------------------
! gt4_history#GT_HISTORY 変数の割付
! Allocate "gt4_history#GT_HISTORY" variables
!-----------------------------------------------------------------
hptr => gthstnml % gthstnml_list
allocate( hptr % history )
WholeLoop : do while ( associated( hptr % next ) )
call ListNext( gthstnml_list = hptr ) ! (inout)
if ( trim(hptr % name) == '' .or. trim(hptr % file) == '' ) cycle WholeLoop
fullfilename = trim( hptr % fileprefix ) // hptr % file
!---------------------------------------------------------------
! 以前に同一ファイル名の gt4_history#GT_HISTORY 変数がある場合, そちらに結合
! If "gt4_history#GT_HISTORY" that has same filename exist already, associate to it
!---------------------------------------------------------------
nullify( hptr_prev )
call DCHashRewind(opened_files) ! (inout)
SearchLoop : do
call DCHashNext( opened_files, opname, opfile, end ) ! (out)
if ( end ) exit SearchLoop
if ( trim(opfile) /= trim(fullfilename) ) cycle SearchLoop
hptr_prev => gthstnml % gthstnml_list
call ListSearch( gthstnml_list = hptr_prev, name = opname ) ! (in)
if ( .not. associated( hptr_prev ) ) cycle SearchLoop
!
! interval_value, interval_unit の同一性をチェック
! Check consistency of "interval_value", "interval_unit"
!
if ( hptr % interval_value /= hptr_prev % interval_value ) then
call MessageNotify( 'W', subname, '@interval_value=%r (var=%a) and @interval_value=%r (var=%a) are applied to a file "%a"', r = (/hptr % interval_value, hptr_prev % interval_value/), ca = StoA(hptr % name, hptr_prev % name, fullfilename) )
stat = HST_EINTFILE
cause_c = fullfilename
goto 999
elseif ( hptr % interval_unit /= hptr_prev % interval_unit ) then
call MessageNotify( 'W', subname, '@interval_unit=%a (var=%a) and @interval_unit=%a (var=%a) are applied to a file "%a"', ca = StoA(hptr % interval_unit, hptr % name, hptr_prev % interval_unit, hptr_prev % name, fullfilename) )
stat = HST_EINTFILE
cause_c = fullfilename
goto 999
end if
hptr % history => hptr_prev % history
exit SearchLoop
end do SearchLoop
!---------------------------------------------------------------
! 新規に割付
! Allocate newly
!---------------------------------------------------------------
if ( .not. associated( hptr % history ) ) then
allocate( hptr % history )
end if
!---------------------------------------------------------------
! 割り付けられた名前とファイル名を登録
! Regist allocated name and filename
!---------------------------------------------------------------
call DCHashPut( opened_files, hptr % name, fullfilename ) ! (in)
end do WholeLoop
nullify( hptr )
nullify( hptr_prev )
!-----------------------------------------------------------------
! 終了処理, 例外処理
! Termination and Exception handling
!-----------------------------------------------------------------
gthstnml % define_mode = .false.
999 continue
call StoreError( stat, subname, err, cause_c )
call EndSub( subname )
end subroutine HstNmlInfoEndDefine
| Function : | |
| result : | logical |
| gthstnml : | type(GTHST_NMLINFO), intent(in) |
gthstnml が初期設定されている場合には .true. が, 初期設定されていない場合には .false. が返ります.
If gthstnml is initialized, .true. is returned. If gthstnml is not initialized, .false. is returned.
logical function HstNmlInfoInitialized( gthstnml ) result(result)
!
! *gthstnml* が初期設定されている場合には .true. が,
! 初期設定されていない場合には .false. が返ります.
!
! If *gthstnml* is initialized, .true. is returned.
! If *gthstnml* is not initialized, .false. is returned.
!
implicit none
type(GTHST_NMLINFO), intent(in):: gthstnml
continue
result = gthstnml % initialized
end function HstNmlInfoInitialized
| Subroutine : | |||
| gthstnml : | type(GTHST_NMLINFO), intent(in) | ||
| name : | character(*), intent(in), optional
| ||
| file : | character(*), intent(out), optional
| ||
| interval_value : | real, 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 に関するデータが存在しない場合, エラーを発生させます.
なお, 与えられた gthstnml が HstNmlInfoCreate によって初期設定 されていない場合, プログラムはエラーを発生させます.
Inquire output information of a variable.
If data correspond to name is not found, error is occurred.
If gthstnml is not initialized by "HstNmlInfoCreate" yet, error is occurred.
subroutine HstNmlInfoInquire( gthstnml, name, file, interval_value, interval_unit, precision, average, fileprefix, err )
!
! 変数の出力情報を取得します.
!
! デフォルト値を取得するには, *name* を与えないか, または
! *name* に空白を与えてください.
!
! *name* に関するデータが存在しない場合, エラーを発生させます.
!
! なお, 与えられた *gthstnml* が HstNmlInfoCreate によって初期設定
! されていない場合, プログラムはエラーを発生させます.
!
! Inquire output information of a variable.
!
! If data correspond to *name* is not found,
! error is occurred.
!
! If *gthstnml* is not initialized by "HstNmlInfoCreate" 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(GTHST_NMLINFO), intent(in):: gthstnml
character(*), intent(in), optional:: name
! 変数名.
! 先頭の空白は無視されます.
!
! Variable identifier.
! Blanks at the head of the name are ignored.
character(*), intent(out), optional:: file
! ヒストリデータのファイル名.
! History data filenames
real, 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(GTHST_NMLINFO_ENTRY), pointer:: hptr =>null()
character(STRING):: name_work
integer:: stat
character(STRING):: cause_c
character(*), parameter:: subname = 'HstNmlInfoInquire'
continue
call BeginSub( subname )
stat = DC_NOERR
cause_c = ''
!-----------------------------------------------------------------
! 初期設定のチェック
! Check initialization
!-----------------------------------------------------------------
if ( .not. gthstnml % initialized ) then
stat = DC_ENOTINIT
cause_c = 'GTHST_NMLINFO'
goto 999
end if
!-----------------------------------------------------------------
! *gthstnml* 内から, *name* に関する情報を探査.
! Search information correspond to *name* in *gthstnml*
!-----------------------------------------------------------------
if ( present(name) ) then
name_work = name
else
name_work = ''
end if
hptr => gthstnml % gthstnml_list
call ListSearch( gthstnml_list = hptr, name = name_work ) ! (in)
if ( .not. associated( hptr ) ) then
stat = DC_ENOENTRY
cause_c = adjustl( name_work )
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 HstNmlInfoInquire
| Function : | |
| result : | character(STRING) |
| gthstnml : | type(GTHST_NMLINFO), intent(in) |
gthstnml が設定されている変数リストをカンマでつなげて 返します.
なお, 与えられた gthstnml が HstNmlInfoCreate によって初期設定 されていない場合, 空文字が返ります.
List of variables registered in gthstnml is join with camma, and returned.
If gthstnml is not initialized by "HstNmlInfoCreate" yet, blank is returned.
character(STRING) function HstNmlInfoNames( gthstnml ) result(result)
!
! *gthstnml* が設定されている変数リストをカンマでつなげて
! 返します.
!
! なお, 与えられた *gthstnml* が HstNmlInfoCreate によって初期設定
! されていない場合, 空文字が返ります.
!
! List of variables registered in *gthstnml* is join with camma,
! and returned.
!
! If *gthstnml* is not initialized by "HstNmlInfoCreate" 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(GTHST_NMLINFO), intent(in):: gthstnml
!-----------------------------------
! 作業変数
! Work variables
type(GTHST_NMLINFO_ENTRY), pointer:: hptr =>null()
logical:: first
!!$ character(*), parameter:: subname = 'HstNmlInfoNames'
continue
result = ''
first = .true.
!-----------------------------------------------------------------
! 初期設定のチェック
! Check initialization
!-----------------------------------------------------------------
if ( .not. gthstnml % initialized ) goto 999
!-----------------------------------------------------------------
! 情報の取り出し
! Fetch information
!-----------------------------------------------------------------
hptr => gthstnml % gthstnml_list
do while ( associated( hptr % next ) )
call ListNext( gthstnml_list = hptr ) ! (inout)
if ( first ) then
result = adjustl( hptr % name )
first = .false.
else
result = trim( result ) // name_delimiter // adjustl( hptr % name )
end if
end do
!-----------------------------------------------------------------
! 終了処理, 例外処理
! Termination and Exception handling
!-----------------------------------------------------------------
999 continue
nullify( hptr )
end function HstNmlInfoNames
| Function : | |||
| result : | logical | ||
| gthstnml : | type(GTHST_NMLINFO), intent(in) | ||
| name : | character(*), intent(in)
| ||
| time : | type(DC_DIFFTIME), intent(in)
|
time が変数 name の出力されるタイミングであれば .true. を, そうでなければ .false. を返します. gthstnml が初期設定されていない場合にも .false. が返ります. name に関するデータが存在しない場合にも .false. が返ります.
なお, 与えられた gthstnml が HstNmlInfoCreate によって初期設定 されていない場合, プログラムはエラーを発生させます.
If time is the time that a variable name is output, .true. is returned, otherwise .false. is returned When gthstnml is not initialized, .false. is returned too. When data correspond to name is not found, .false. is returned too.
If gthstnml is not initialized by "HstNmlInfoCreate" yet, error is occurred.
logical function HstNmlInfoOutputStep( gthstnml, name, time ) result(result)
!
! *time* が変数 *name* の出力されるタイミングであれば
! .true. を, そうでなければ .false. を返します.
! *gthstnml* が初期設定されていない場合にも .false. が返ります.
! *name* に関するデータが存在しない場合にも .false. が返ります.
!
! なお, 与えられた *gthstnml* が HstNmlInfoCreate によって初期設定
! されていない場合, プログラムはエラーを発生させます.
!
! If *time* is the time that a variable *name* is output,
! .true. is returned, otherwise .false. is returned
! When *gthstnml* is not initialized, .false. is returned too.
! When data correspond to *name* is not found, .false. is returned too.
!
! If *gthstnml* is not initialized by "HstNmlInfoCreate" 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: DCDiffTimeCreate, mod, operator(==), toChar
use dc_types, only: DP, STRING, TOKEN, STDOUT
implicit none
type(GTHST_NMLINFO), intent(in):: gthstnml
character(*), intent(in):: name
! 変数名.
! 先頭の空白は無視されます.
!
! Variable identifier.
! Blanks at the head of the name are ignored.
type(DC_DIFFTIME), intent(in):: time
! 現在時刻. Current time
!-----------------------------------
! 作業変数
! Work variables
type(GTHST_NMLINFO_ENTRY), pointer:: hptr =>null()
type(DC_DIFFTIME):: interval_time
!!$ character(*), parameter:: subname = 'HstNmlInfoOutputStep'
continue
result = .false.
!-----------------------------------------------------------------
! 初期設定のチェック
! Check initialization
!-----------------------------------------------------------------
if ( .not. gthstnml % initialized ) goto 999
!-----------------------------------------------------------------
! 情報格納変数への結合
! Associate a variable storing information
!-----------------------------------------------------------------
hptr => gthstnml % gthstnml_list
call ListSearch( gthstnml_list = hptr, name = name ) ! (in)
if ( .not. associated( hptr ) ) goto 999
if ( hptr % output_step_disable ) goto 999
!-----------------------------------------------------------------
! 時刻のチェック
! Check time
!-----------------------------------------------------------------
if ( .not. hptr % interval_value > 0.0 ) goto 999
call DCDiffTimeCreate( diff = interval_time, value = real( hptr % interval_value, DP ), 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 HstNmlInfoOutputStep
| Subroutine : | |||
| gthstnml : | type(GTHST_NMLINFO), intent(in) | ||
| name : | character(*), intent(in)
| ||
| err : | logical, intent(out), optional
|
このサブルーチンを使用すると, name に関して, 以降は HstNmlInfoOutputStep が常に .false. を返すようになります.
データ出力間隔を出力の初期設定から変更し, データを出力するたびに時刻を明示的に指定する場合に利用することを 想定しています.
HstNmlInfoEndDefine で定義モードから出力モードに 移行した後に呼び出してください. HstNmlInfoEndDefine を呼ぶ前にこのサブルーチンを使用すると, プログラムはエラーを発生させます.
name に関する情報が見当たらない場合, プログラムはエラーを発生させます. name が空文字の場合にも, プログラムはエラーを発生させます.
なお, 与えられた gthstnml が HstNmlInfoCreate によって初期設定 されていない場合にも, プログラムはエラーを発生させます.
After this subroutine is used, "HstNmlInfoOutputStep" returns .false. already corresponding to the name.
This subroutine expected to use when interval of data output is changed from initialization of output, and time is specified explicitly whenever data is output.
Use after state is changed from define mode to output mode by "HstNmlInfoEndDefine". If this subroutine is used before "HstNmlInfoEndDefine" is used, error is occurred.
When data correspond to name is not found, error is occurred. When name is blank, error is occurred too.
If gthstnml is not initialized by "HstNmlInfoCreate" yet, error is occurred.
subroutine HstNmlInfoOutputStepDisable( gthstnml, name, err )
!
! このサブルーチンを使用すると, *name* に関して,
! 以降は HstNmlInfoOutputStep が常に .false. を返すようになります.
!
! データ出力間隔を出力の初期設定から変更し,
! データを出力するたびに時刻を明示的に指定する場合に利用することを
! 想定しています.
!
! HstNmlInfoEndDefine で定義モードから出力モードに
! 移行した後に呼び出してください.
! HstNmlInfoEndDefine を呼ぶ前にこのサブルーチンを使用すると,
! プログラムはエラーを発生させます.
!
! *name* に関する情報が見当たらない場合,
! プログラムはエラーを発生させます.
! *name* が空文字の場合にも,
! プログラムはエラーを発生させます.
!
! なお, 与えられた *gthstnml* が HstNmlInfoCreate によって初期設定
! されていない場合にも, プログラムはエラーを発生させます.
!
! After this subroutine is used,
! "HstNmlInfoOutputStep" returns .false. already
! corresponding to the *name*.
!
! This subroutine expected to use when
! interval of data output is changed from initialization of output,
! and time is specified explicitly whenever data is output.
!
! Use after state is changed from define mode to
! output mode by "HstNmlInfoEndDefine".
! If this subroutine is used before
! "HstNmlInfoEndDefine" is used, error is occurred.
!
! When data correspond to *name* is not found, error is occurred.
! When *name* is blank, error is occurred too.
!
! If *gthstnml* is not initialized by "HstNmlInfoCreate" 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, DC_ENOENTRY, HST_EBADNAME, HST_EINDEFINE
implicit none
type(GTHST_NMLINFO), intent(in):: gthstnml
character(*), intent(in):: name
! 変数名.
! 先頭の空白は無視されます.
!
! Variable identifier.
! Blanks at the head of the name are ignored.
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(GTHST_NMLINFO_ENTRY), pointer:: hptr =>null()
integer:: stat
character(STRING):: cause_c
character(*), parameter:: subname = 'HstNmlInfoOutputStepDisable'
continue
call BeginSub( subname )
stat = DC_NOERR
cause_c = ''
!-----------------------------------------------------------------
! 初期設定のチェック
! Check initialization
!-----------------------------------------------------------------
if ( .not. gthstnml % initialized ) then
stat = DC_ENOTINIT
cause_c = 'GTHST_NMLINFO'
goto 999
end if
if ( trim( name ) == '' ) then
stat = HST_EBADNAME
cause_c = ''
goto 999
end if
if ( gthstnml % define_mode ) then
stat = HST_EINDEFINE
cause_c = 'OutputStepDisable'
goto 999
end if
!-----------------------------------------------------------------
! *gthstnml* 内から, *name* に関する history を探査.
! Search "history" correspond to *name* in *gthstnml*
!-----------------------------------------------------------------
hptr => gthstnml % gthstnml_list
call ListSearch( gthstnml_list = hptr, name = name ) ! (in)
if ( .not. associated( hptr ) ) then
stat = DC_ENOENTRY
cause_c = adjustl( name )
goto 999
end if
hptr % output_step_disable = .true.
nullify( hptr )
!-----------------------------------------------------------------
! 終了処理, 例外処理
! Termination and Exception handling
!-----------------------------------------------------------------
999 continue
call StoreError( stat, subname, err, cause_c )
call EndSub( subname )
end subroutine HstNmlInfoOutputStepDisable
| Function : | |||
| result : | logical | ||
| gthstnml : | type(GTHST_NMLINFO), intent(in) | ||
| name : | character(*), intent(in)
|
変数 name の出力が有効であれば, .true. を, そうでなければ .false. を返します. 出力が有効であるかどうかは, 出力間隔 interval_value の 正負によって判定されます. 正の場合が有効, 負の場合が無効です. gthstnml が初期設定されていない場合にも .false. が返ります. name に関するデータが存在しない場合にも .false. が返ります.
なお, 与えられた gthstnml が HstNmlInfoCreate によって初期設定 されていない場合, プログラムはエラーを発生させます.
If output of a variable name is valid, .true. is returned, otherwise .false. is returned. Whether output is valid or not is judged with positive or negative of interval_value. Positive is valid, and negative is invalid. When gthstnml is not initialized, .false. is returned too. When data correspond to name is not found, .false. is returned too.
If gthstnml is not initialized by "HstNmlInfoCreate" yet, error is occurred.
logical function HstNmlInfoOutputValid( gthstnml, name ) result(result)
!
! 変数 *name* の出力が有効であれば,
! .true. を, そうでなければ .false. を返します.
! 出力が有効であるかどうかは, 出力間隔 *interval_value* の
! 正負によって判定されます. 正の場合が有効, 負の場合が無効です.
! *gthstnml* が初期設定されていない場合にも .false. が返ります.
! *name* に関するデータが存在しない場合にも .false. が返ります.
!
! なお, 与えられた *gthstnml* が HstNmlInfoCreate によって初期設定
! されていない場合, プログラムはエラーを発生させます.
!
! If output of a variable *name* is valid,
! .true. is returned, otherwise .false. is returned.
! Whether output is valid or not is judged with positive or negative
! of *interval_value*. Positive is valid, and negative is invalid.
! When *gthstnml* is not initialized, .false. is returned too.
! When data correspond to *name* is not found, .false. is returned too.
!
! If *gthstnml* is not initialized by "HstNmlInfoCreate" 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(GTHST_NMLINFO), intent(in):: gthstnml
character(*), intent(in):: name
! 変数名.
! 先頭の空白は無視されます.
!
! Variable identifier.
! Blanks at the head of the name are ignored.
!-----------------------------------
! 作業変数
! Work variables
type(GTHST_NMLINFO_ENTRY), pointer:: hptr =>null()
!!$ character(*), parameter:: subname = 'HstNmlInfoOutputValid'
continue
result = .false.
!-----------------------------------------------------------------
! 初期設定のチェック
! Check initialization
!-----------------------------------------------------------------
if ( .not. gthstnml % initialized ) goto 999
!-----------------------------------------------------------------
! 情報格納変数への結合
! Associate a variable storing information
!-----------------------------------------------------------------
hptr => gthstnml % gthstnml_list
call ListSearch( gthstnml_list = hptr, name = name ) ! (in)
if ( .not. associated( hptr ) ) goto 999
!-----------------------------------------------------------------
! 出力の有効性のチェック
! Check validity of output
!-----------------------------------------------------------------
if ( hptr % interval_value > 0.0 ) then
result = .true.
goto 999
end if
!-----------------------------------------------------------------
! 終了処理, 例外処理
! Termination and Exception handling
!-----------------------------------------------------------------
999 continue
nullify( hptr )
end function HstNmlInfoOutputValid
| Subroutine : | |||
| gthstnml : | type(GTHST_NMLINFO), intent(in) | ||
| unit : | integer, intent(in), optional
| ||
| indent : | character(*), intent(in), optional
| ||
| err : | logical, intent(out), optional
|
引数 gthstnml に設定されている情報を印字します. デフォルトではメッセージは標準出力に出力されます. unit に装置番号を指定することで, 出力先を変更することが可能です.
Print information of gthstnml. By default messages are output to standard output. Unit number for output can be changed by unit argument.
subroutine HstNmlInfoPutLine( gthstnml, unit, indent, err )
!
! 引数 *gthstnml* に設定されている情報を印字します.
! デフォルトではメッセージは標準出力に出力されます.
! *unit* に装置番号を指定することで, 出力先を変更することが可能です.
!
! Print information of *gthstnml*.
! 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
use gt4_history, only: HistoryPutLine
implicit none
type(GTHST_NMLINFO), intent(in):: gthstnml
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(GTHST_NMLINFO_ENTRY), pointer:: hptr =>null()
integer:: stat
character(STRING):: cause_c
integer:: out_unit
integer:: indent_len
character(STRING):: indent_str
character(*), parameter:: subname = 'HstNmlInfoPutLine'
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
!-----------------------------------------------------------------
! "GTHST_NMLINFO" の設定の印字
! Print the settings for "GTHST_NMLINFO"
!-----------------------------------------------------------------
if ( gthstnml % initialized ) then
call Printf( out_unit, indent_str(1:indent_len) // '#<GTHST_NMLINFO:: @initialized=%y define_mode=%y', l = (/gthstnml % initialized, gthstnml % define_mode/) )
hptr => gthstnml % gthstnml_list
do while ( associated( hptr ) )
call Printf( out_unit, indent_str(1:indent_len) // ' #<GTHST_NMLINFO_ENTRY:: @name=%c @file=%c', c1 = trim(hptr % name), c2 = trim(hptr % file) )
call Printf( out_unit, indent_str(1:indent_len) // ' @interval_value=%r @interval_unit=%c', r = (/hptr % interval_value/), c1 = trim(hptr % interval_unit) )
call Printf( out_unit, indent_str(1:indent_len) // ' @output_step_disable=%y', l = (/hptr % output_step_disable/) )
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) )
if ( .not. gthstnml % define_mode ) then
call Printf( out_unit, indent_str(1:indent_len) // ' @history=' )
call HistoryPutLine( hptr % history, unit = out_unit, indent = indent_str(1:indent_len) // ' ' )
end if
call ListNext( gthstnml_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) // '#<GTHST_NMLINFO:: @initialized=%y>', l = (/gthstnml % initialized/) )
end if
!-----------------------------------------------------------------
! 終了処理, 例外処理
! Termination and Exception handling
!-----------------------------------------------------------------
999 continue
call StoreError( stat, subname, err, cause_c )
call EndSub( subname )
end subroutine HstNmlInfoPutLine
| Subroutine : | |||
| gthstnml : | type(GTHST_NMLINFO), intent(inout) | ||
| err : | logical, intent(out), optional
|
デフォルト値を残し, 登録したデータを削除します.
なお, 与えられた gthstnml が HstNmlInfoCreate によって初期設定 されていない場合, プログラムはエラーを発生させます.
Stored data is deleted without default settings.
If gthstnml is not initialized by "HstNmlInfoCreate" yet, error is occurred.
subroutine HstNmlInfoResetDefault( gthstnml, err )
!
! デフォルト値を残し, 登録したデータを削除します.
!
! なお, 与えられた *gthstnml* が HstNmlInfoCreate によって初期設定
! されていない場合, プログラムはエラーを発生させます.
!
! Stored data is deleted without default settings.
!
! If *gthstnml* is not initialized by "HstNmlInfoCreate" 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, HST_ENOTINDEFINE
implicit none
type(GTHST_NMLINFO), intent(inout):: gthstnml
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 = 'HstNmlInfoResetDefault'
continue
call BeginSub( subname )
stat = DC_NOERR
cause_c = ''
!-----------------------------------------------------------------
! 初期設定のチェック
! Check initialization
!-----------------------------------------------------------------
if ( .not. gthstnml % initialized ) then
stat = DC_ENOTINIT
cause_c = 'GTHST_NMLINFO'
goto 999
end if
if ( .not. gthstnml % define_mode ) then
stat = HST_ENOTINDEFINE
cause_c = 'ResetDefault'
goto 999
end if
!-----------------------------------------------------------------
! 変数名リストの取得
! Get varnames list
!-----------------------------------------------------------------
varnames = HstNmlInfoNames( gthstnml )
call Split( str = varnames, sep = name_delimiter, carray = varnames_array ) ! (out)
vnmax = size( varnames_array )
do i = 1, vnmax
call HstNmlInfoDelete( gthstnml = gthstnml, name = varnames_array(i) ) ! (in)
end do
deallocate( varnames_array )
!-----------------------------------------------------------------
! 終了処理, 例外処理
! Termination and Exception handling
!-----------------------------------------------------------------
999 continue
call StoreError( stat, subname, err, cause_c )
call EndSub( subname )
end subroutine HstNmlInfoResetDefault
| Subroutine : | |||
| gthstnml : | type(GTHST_NMLINFO), intent(in) | ||
| name : | character(*), intent(in)
| ||
| err : | logical, intent(out), optional
|
変数名の有効性を設定.
無効な変数名を検知するため, このサブルーチンで 有効な変数に対しては明示的に設定を行います.
なお, 与えられた gthstnml が HstNmlInfoCreate によって初期設定 されていない場合, プログラムはエラーを発生させます.
Set validation to variable names.
For detection of invalid variable names, Set validation to variable names explicitly by this subroutine.
If gthstnml is not initialized by "HstNmlInfoCreate" yet, error is occurred.
subroutine HstNmlInfoSetValidName( gthstnml, name, err )
!
! 変数名の有効性を設定.
!
! 無効な変数名を検知するため, このサブルーチンで
! 有効な変数に対しては明示的に設定を行います.
!
! なお, 与えられた *gthstnml* が HstNmlInfoCreate によって初期設定
! されていない場合, プログラムはエラーを発生させます.
!
! Set validation to variable names.
!
! For detection of invalid variable names,
! Set validation to variable names explicitly by this
! subroutine.
!
! If *gthstnml* is not initialized by "HstNmlInfoCreate" 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
use gt4_history, only: HistoryInitialized
implicit none
type(GTHST_NMLINFO), intent(in):: gthstnml
character(*), intent(in):: name
! 有効であることを設定する変数名.
!
! "Data1,Data2" のようにカンマで区切って複数
! の変数を指定することも可能です.
!
! A variable name that is set validation.
!
! Multiple variables can be specified
! as "Data1,Data2" too. 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(GTHST_NMLINFO_ENTRY), pointer:: hptr =>null()
character(TOKEN), pointer:: varnames_array(:) =>null()
integer:: i, vnmax
integer:: stat
character(STRING):: cause_c
character(*), parameter:: subname = 'HstNmlInfoSetValidName'
continue
call BeginSub( subname, fmt = '@name=%c', c1 = trim(name) )
stat = DC_NOERR
cause_c = ''
!-----------------------------------------------------------------
! 初期設定のチェック
! Check initialization
!-----------------------------------------------------------------
if ( .not. gthstnml % initialized ) then
stat = DC_ENOTINIT
cause_c = 'GTHST_NMLINFO'
goto 999
end if
!-----------------------------------------------------------------
! 複数の変数名の取り扱い
! Handle multiple variables
!-----------------------------------------------------------------
call Split( str = name, sep = name_delimiter, carray = varnames_array ) ! (out)
vnmax = size( varnames_array )
!-----------------------------------------------------------------
! *gthstnml* 内から, *name* に関する情報を探査.
! Search information correspond to *name* in *gthstnml*
!-----------------------------------------------------------------
do i = 1, vnmax
hptr => gthstnml % gthstnml_list
call ListSearch( gthstnml_list = hptr, name = varnames_array(i) ) ! (in)
if ( associated( hptr ) ) then
hptr % name_invalid = .false.
end if
end do
!-----------------------------------------------------------------
! 終了処理, 例外処理
! Termination and Exception handling
!-----------------------------------------------------------------
999 continue
call StoreError( stat, subname, err, cause_c )
call EndSub( subname )
end subroutine HstNmlInfoSetValidName