| Class | gt4_historyauto |
| In: |
gt4_historyauto.f90
|
Note that Japanese and English are described in parallel.
gt4_historyauto モジュールは gt4_history モジュールの応用版であり, 出力変数が 10 を超えるような大規模な数値モデルを想定した, データ出力のための簡便なインターフェースを 提供します. このモジュールは以下のような特徴を持ちます.
"gt4_historyauto" module is an application of "gt4_history" module, and provides data output easy-to-use interfaces for large numerical models that output 10 or more variables. This module has following features.
| HistoryAutoCreate : | 初期化 |
| HistoryAutoAddVariable : | 変数追加 |
| HistoryAutoPut : | データ出力 |
| HistoryAutoProgress : | 時刻進行 |
| HistoryAutoClose : | 終了処理 |
| HistoryAutoPutAxis : | 座標データ追加 |
| HistoryAutoAddWeight : | 座標重み追加 |
| HistoryAutoAddAttr : | 属性追加 |
| ——————— : | ——————— |
| HistoryAutoCreate : | Initialization |
| HistoryAutoAddVariable : | Addition of variables |
| HistoryAutoPut : | Output of data |
| HistoryAutoProgress : | Progression of time |
| HistoryAutoClose : | Termination |
| HistoryAutoPutAxis : | Addition of data of axes |
| HistoryAutoAddWeight : | Addition of weights of axes |
| HistoryAutoAddAttr : | Addition of attributes |
| Subroutine : | |||
| varname : | character(*), intent(in)
| ||
| attrname : | character(*), intent(in)
| ||
| value : | character(*), intent(in)
|
座標変数および座標重み変数に属性を付加します. このサブルーチンを用いる前に, HistoryAutoCreate による初期設定が 必要です.
Add attributes axes or weights of axes. Initialization by "HistoryAutoCreate" is needed before use of this subroutine.
subroutine HistoryAutoAddAttrChar0( varname, attrname, value )
!
!
! 座標変数および座標重み変数に属性を付加します.
! このサブルーチンを用いる前に, HistoryAutoCreate による初期設定が
! 必要です.
!
! * 座標変数については, HistoryAutoCreate の "dims" に与えられた
! もののみ指定可能です.
!
! * 座標重み変数については, HistoryAutoAddWeight で与えられた
! もののみ指定可能です.
!
! * *HistoryAutoAddAttr* は複数のサブルーチンの総称名です. *value*
! にはいくつかの型を与えることが可能です.
! 下記のサブルーチンを参照ください.
!
! Add attributes axes or weights of axes.
! Initialization by "HistoryAutoCreate" is needed
! before use of this subroutine.
!
! * About axes, "dims" specified by "HistoryAutoCreate" can be
! specified.
!
! * About weights of axes, "dims" specified by "HistoryAutoAddWeight"
! can be specified.
!
! * "HistoryAutoAddAttr" is a generic name of multiple subroutines.
! Then some data type can be specified to "value".
!
!
use dc_trace, only: BeginSub, EndSub
use dc_error, only: StoreError, DC_NOERR, HST_ENOAXISNAME, DC_ENOTINIT
use dc_string, only: toChar
use gt4_history, only: HistoryAxisAddAttr, HistoryAxisInquire, HistoryVarinfoAddAttr, HistoryVarinfoInquire
implicit none
character(*), intent(in):: varname
! 変数の名前.
!
! ここで指定するものは,
! HistoryAutoCreate の *dims* ,
! または HistoryAutoAddWeight の
! *varname* で既に指定されてい
! なければなりません.
!
! Name of a variable.
!
! This must be specified with *dims*
! in HistoryAutoCreate, or
! *varname* in "HistoryAutoAddWeight".
!
character(*), intent(in):: attrname
! 属性の名前.
! Name of an attribute.
character(*), intent(in):: value
! 属性の値.
! Value of an attribute.
character(STRING):: name
integer:: stat, i
character(STRING):: cause_c
character(*), parameter:: subname = "HistoryAutoAddAttrChar0"
continue
call BeginSub(subname, 'varname=<%c> attrname=<%c>, value=<%c>', c1=trim(varname), c2=trim(attrname), c3=trim(value))
stat = DC_NOERR
cause_c = ""
! 初期設定チェック
! Check initialization
!
if ( .not. initialized ) then
stat = DC_ENOTINIT
cause_c = 'gt4_historyauto'
goto 999
end if
do i = 1, numdims
call HistoryAxisInquire( axis = gthst_axes(i), name = name ) ! (out)
if ( trim(varname) == trim(name) ) then
call HistoryAxisAddAttr( axis = gthst_axes(i), attrname = attrname, value = value ) ! (in)
goto 999
end if
end do
do i = 1, numwgts
call HistoryVarinfoInquire( varinfo = gthst_weights(i), name = name ) ! (out)
if ( trim(varname) == trim(name) ) then
call HistoryVarinfoAddAttr( varinfo = gthst_weights(i), attrname = attrname, value = value ) ! (in)
goto 999
end if
end do
stat = HST_ENOAXISNAME
cause_c = varname
999 continue
call StoreError(stat, subname, cause_c = cause_c)
call EndSub(subname)
end subroutine HistoryAutoAddAttrChar0
| Subroutine : | |
| varname : | character(*), intent(in) |
| attrname : | character(*), intent(in) |
| value : | integer, intent(in) |
subroutine HistoryAutoAddAttrInt0( varname, attrname, value )
!
!
use dc_trace, only: BeginSub, EndSub
use dc_error, only: StoreError, DC_NOERR, HST_ENOAXISNAME, DC_ENOTINIT
use dc_string, only: toChar
use gt4_history, only: HistoryAxisAddAttr, HistoryAxisInquire, HistoryVarinfoAddAttr, HistoryVarinfoInquire
implicit none
character(*), intent(in):: varname
character(*), intent(in):: attrname
integer, intent(in):: value
character(STRING):: name
integer:: stat, i
character(STRING):: cause_c
character(*), parameter:: subname = "HistoryAutoAddAttrInt0"
continue
call BeginSub(subname, 'varname=<%c> attrname=<%c>, value=<%c>', c1=trim(varname), c2=trim(attrname), c3=trim(toChar(value)))
stat = DC_NOERR
cause_c = ""
! 初期設定チェック
! Check initialization
!
if ( .not. initialized ) then
stat = DC_ENOTINIT
cause_c = 'gt4_historyauto'
goto 999
end if
do i = 1, numdims
call HistoryAxisInquire( axis = gthst_axes(i), name = name ) ! (out)
if ( trim(varname) == trim(name) ) then
call HistoryAxisAddAttr( axis = gthst_axes(i), attrname = attrname, value = value ) ! (in)
goto 999
end if
end do
do i = 1, numwgts
call HistoryVarinfoInquire( varinfo = gthst_weights(i), name = name ) ! (out)
if ( trim(varname) == trim(name) ) then
call HistoryVarinfoAddAttr( varinfo = gthst_weights(i), attrname = attrname, value = value ) ! (in)
goto 999
end if
end do
stat = HST_ENOAXISNAME
cause_c = varname
999 continue
call StoreError(stat, subname, cause_c = cause_c)
call EndSub(subname)
end subroutine HistoryAutoAddAttrInt0
| Subroutine : | |
| varname : | character(*), intent(in) |
| attrname : | character(*), intent(in) |
| value : | logical, intent(in) |
subroutine HistoryAutoAddAttrLogical0( varname, attrname, value )
!
!
use dc_trace, only: BeginSub, EndSub
use dc_error, only: StoreError, DC_NOERR, HST_ENOAXISNAME, DC_ENOTINIT
use dc_string, only: toChar
use gt4_history, only: HistoryAxisAddAttr, HistoryAxisInquire, HistoryVarinfoAddAttr, HistoryVarinfoInquire
implicit none
character(*), intent(in):: varname
character(*), intent(in):: attrname
logical, intent(in):: value
character(STRING):: name
integer:: stat, i
character(STRING):: cause_c
character(*), parameter:: subname = "HistoryAutoAddAttrLogical0"
continue
call BeginSub(subname, 'varname=<%c> attrname=<%c>, value=<%c>', c1=trim(varname), c2=trim(attrname), c3=trim(toChar(value)))
stat = DC_NOERR
cause_c = ""
! 初期設定チェック
! Check initialization
!
if ( .not. initialized ) then
stat = DC_ENOTINIT
cause_c = 'gt4_historyauto'
goto 999
end if
do i = 1, numdims
call HistoryAxisInquire( axis = gthst_axes(i), name = name ) ! (out)
if ( trim(varname) == trim(name) ) then
call HistoryAxisAddAttr( axis = gthst_axes(i), attrname = attrname, value = value ) ! (in)
goto 999
end if
end do
do i = 1, numwgts
call HistoryVarinfoInquire( varinfo = gthst_weights(i), name = name ) ! (out)
if ( trim(varname) == trim(name) ) then
call HistoryVarinfoAddAttr( varinfo = gthst_weights(i), attrname = attrname, value = value ) ! (in)
goto 999
end if
end do
stat = HST_ENOAXISNAME
cause_c = varname
999 continue
call StoreError(stat, subname, cause_c = cause_c)
call EndSub(subname)
end subroutine HistoryAutoAddAttrLogical0
| Subroutine : | |
| varname : | character(*), intent(in) |
| attrname : | character(*), intent(in) |
| value : | real(DP), intent(in) |
subroutine HistoryAutoAddAttrDouble0( varname, attrname, value )
!
!
use dc_trace, only: BeginSub, EndSub
use dc_error, only: StoreError, DC_NOERR, HST_ENOAXISNAME, DC_ENOTINIT
use dc_string, only: toChar
use gt4_history, only: HistoryAxisAddAttr, HistoryAxisInquire, HistoryVarinfoAddAttr, HistoryVarinfoInquire
implicit none
character(*), intent(in):: varname
character(*), intent(in):: attrname
real(DP), intent(in):: value
character(STRING):: name
integer:: stat, i
character(STRING):: cause_c
character(*), parameter:: subname = "HistoryAutoAddAttrDouble0"
continue
call BeginSub(subname, 'varname=<%c> attrname=<%c>, value=<%c>', c1=trim(varname), c2=trim(attrname), c3=trim(toChar(value)))
stat = DC_NOERR
cause_c = ""
! 初期設定チェック
! Check initialization
!
if ( .not. initialized ) then
stat = DC_ENOTINIT
cause_c = 'gt4_historyauto'
goto 999
end if
do i = 1, numdims
call HistoryAxisInquire( axis = gthst_axes(i), name = name ) ! (out)
if ( trim(varname) == trim(name) ) then
call HistoryAxisAddAttr( axis = gthst_axes(i), attrname = attrname, value = value ) ! (in)
goto 999
end if
end do
do i = 1, numwgts
call HistoryVarinfoInquire( varinfo = gthst_weights(i), name = name ) ! (out)
if ( trim(varname) == trim(name) ) then
call HistoryVarinfoAddAttr( varinfo = gthst_weights(i), attrname = attrname, value = value ) ! (in)
goto 999
end if
end do
stat = HST_ENOAXISNAME
cause_c = varname
999 continue
call StoreError(stat, subname, cause_c = cause_c)
call EndSub(subname)
end subroutine HistoryAutoAddAttrDouble0
| Subroutine : | |
| varname : | character(*), intent(in) |
| attrname : | character(*), intent(in) |
| value : | real, intent(in) |
subroutine HistoryAutoAddAttrReal0( varname, attrname, value )
!
!
use dc_trace, only: BeginSub, EndSub
use dc_error, only: StoreError, DC_NOERR, HST_ENOAXISNAME, DC_ENOTINIT
use dc_string, only: toChar
use gt4_history, only: HistoryAxisAddAttr, HistoryAxisInquire, HistoryVarinfoAddAttr, HistoryVarinfoInquire
implicit none
character(*), intent(in):: varname
character(*), intent(in):: attrname
real, intent(in):: value
character(STRING):: name
integer:: stat, i
character(STRING):: cause_c
character(*), parameter:: subname = "HistoryAutoAddAttrReal0"
continue
call BeginSub(subname, 'varname=<%c> attrname=<%c>, value=<%c>', c1=trim(varname), c2=trim(attrname), c3=trim(toChar(value)))
stat = DC_NOERR
cause_c = ""
! 初期設定チェック
! Check initialization
!
if ( .not. initialized ) then
stat = DC_ENOTINIT
cause_c = 'gt4_historyauto'
goto 999
end if
do i = 1, numdims
call HistoryAxisInquire( axis = gthst_axes(i), name = name ) ! (out)
if ( trim(varname) == trim(name) ) then
call HistoryAxisAddAttr( axis = gthst_axes(i), attrname = attrname, value = value ) ! (in)
goto 999
end if
end do
do i = 1, numwgts
call HistoryVarinfoInquire( varinfo = gthst_weights(i), name = name ) ! (out)
if ( trim(varname) == trim(name) ) then
call HistoryVarinfoAddAttr( varinfo = gthst_weights(i), attrname = attrname, value = value ) ! (in)
goto 999
end if
end do
stat = HST_ENOAXISNAME
cause_c = varname
999 continue
call StoreError(stat, subname, cause_c = cause_c)
call EndSub(subname)
end subroutine HistoryAutoAddAttrReal0
| Subroutine : | |
| varname : | character(*), intent(in) |
| attrname : | character(*), intent(in) |
| value(:) : | integer, intent(in) |
subroutine HistoryAutoAddAttrInt1( varname, attrname, value )
!
!
use dc_trace, only: BeginSub, EndSub
use dc_error, only: StoreError, DC_NOERR, HST_ENOAXISNAME, DC_ENOTINIT
use dc_string, only: toChar
use gt4_history, only: HistoryAxisAddAttr, HistoryAxisInquire, HistoryVarinfoAddAttr, HistoryVarinfoInquire
implicit none
character(*), intent(in):: varname
character(*), intent(in):: attrname
integer, intent(in):: value(:)
character(STRING):: name
integer:: stat, i
character(STRING):: cause_c
character(*), parameter:: subname = "HistoryAutoAddAttrInt1"
continue
call BeginSub(subname, 'varname=<%c> attrname=<%c>, value=<%c>', c1=trim(varname), c2=trim(attrname), c3=trim(toChar(value)))
stat = DC_NOERR
cause_c = ""
! 初期設定チェック
! Check initialization
!
if ( .not. initialized ) then
stat = DC_ENOTINIT
cause_c = 'gt4_historyauto'
goto 999
end if
do i = 1, numdims
call HistoryAxisInquire( axis = gthst_axes(i), name = name ) ! (out)
if ( trim(varname) == trim(name) ) then
call HistoryAxisAddAttr( axis = gthst_axes(i), attrname = attrname, value = value ) ! (in)
goto 999
end if
end do
do i = 1, numwgts
call HistoryVarinfoInquire( varinfo = gthst_weights(i), name = name ) ! (out)
if ( trim(varname) == trim(name) ) then
call HistoryVarinfoAddAttr( varinfo = gthst_weights(i), attrname = attrname, value = value ) ! (in)
goto 999
end if
end do
stat = HST_ENOAXISNAME
cause_c = varname
999 continue
call StoreError(stat, subname, cause_c = cause_c)
call EndSub(subname)
end subroutine HistoryAutoAddAttrInt1
| Subroutine : | |
| varname : | character(*), intent(in) |
| attrname : | character(*), intent(in) |
| value(:) : | real(DP), intent(in) |
subroutine HistoryAutoAddAttrDouble1( varname, attrname, value )
!
!
use dc_trace, only: BeginSub, EndSub
use dc_error, only: StoreError, DC_NOERR, HST_ENOAXISNAME, DC_ENOTINIT
use dc_string, only: toChar
use gt4_history, only: HistoryAxisAddAttr, HistoryAxisInquire, HistoryVarinfoAddAttr, HistoryVarinfoInquire
implicit none
character(*), intent(in):: varname
character(*), intent(in):: attrname
real(DP), intent(in):: value(:)
character(STRING):: name
integer:: stat, i
character(STRING):: cause_c
character(*), parameter:: subname = "HistoryAutoAddAttrDouble1"
continue
call BeginSub(subname, 'varname=<%c> attrname=<%c>, value=<%c>', c1=trim(varname), c2=trim(attrname), c3=trim(toChar(value)))
stat = DC_NOERR
cause_c = ""
! 初期設定チェック
! Check initialization
!
if ( .not. initialized ) then
stat = DC_ENOTINIT
cause_c = 'gt4_historyauto'
goto 999
end if
do i = 1, numdims
call HistoryAxisInquire( axis = gthst_axes(i), name = name ) ! (out)
if ( trim(varname) == trim(name) ) then
call HistoryAxisAddAttr( axis = gthst_axes(i), attrname = attrname, value = value ) ! (in)
goto 999
end if
end do
do i = 1, numwgts
call HistoryVarinfoInquire( varinfo = gthst_weights(i), name = name ) ! (out)
if ( trim(varname) == trim(name) ) then
call HistoryVarinfoAddAttr( varinfo = gthst_weights(i), attrname = attrname, value = value ) ! (in)
goto 999
end if
end do
stat = HST_ENOAXISNAME
cause_c = varname
999 continue
call StoreError(stat, subname, cause_c = cause_c)
call EndSub(subname)
end subroutine HistoryAutoAddAttrDouble1
| Subroutine : | |
| varname : | character(*), intent(in) |
| attrname : | character(*), intent(in) |
| value(:) : | real, intent(in) |
subroutine HistoryAutoAddAttrReal1( varname, attrname, value )
!
!
use dc_trace, only: BeginSub, EndSub
use dc_error, only: StoreError, DC_NOERR, HST_ENOAXISNAME, DC_ENOTINIT
use dc_string, only: toChar
use gt4_history, only: HistoryAxisAddAttr, HistoryAxisInquire, HistoryVarinfoAddAttr, HistoryVarinfoInquire
implicit none
character(*), intent(in):: varname
character(*), intent(in):: attrname
real, intent(in):: value(:)
character(STRING):: name
integer:: stat, i
character(STRING):: cause_c
character(*), parameter:: subname = "HistoryAutoAddAttrReal1"
continue
call BeginSub(subname, 'varname=<%c> attrname=<%c>, value=<%c>', c1=trim(varname), c2=trim(attrname), c3=trim(toChar(value)))
stat = DC_NOERR
cause_c = ""
! 初期設定チェック
! Check initialization
!
if ( .not. initialized ) then
stat = DC_ENOTINIT
cause_c = 'gt4_historyauto'
goto 999
end if
do i = 1, numdims
call HistoryAxisInquire( axis = gthst_axes(i), name = name ) ! (out)
if ( trim(varname) == trim(name) ) then
call HistoryAxisAddAttr( axis = gthst_axes(i), attrname = attrname, value = value ) ! (in)
goto 999
end if
end do
do i = 1, numwgts
call HistoryVarinfoInquire( varinfo = gthst_weights(i), name = name ) ! (out)
if ( trim(varname) == trim(name) ) then
call HistoryVarinfoAddAttr( varinfo = gthst_weights(i), attrname = attrname, value = value ) ! (in)
goto 999
end if
end do
stat = HST_ENOAXISNAME
cause_c = varname
999 continue
call StoreError(stat, subname, cause_c = cause_c)
call EndSub(subname)
end subroutine HistoryAutoAddAttrReal1
| Subroutine : | |||
| varname : | character(*), intent(in)
| ||
| dims(:) : | character(*), intent(in)
| ||
| longname : | character(*), intent(in)
| ||
| units : | character(*), intent(in)
| ||
| xtype : | character(*), intent(in), optional
| ||
| time_units : | character(*), intent(in), optional
| ||
| time_average : | logical, intent(in), optional
| ||
| file : | character(*), intent(in), optional
| ||
| origin : | real, intent(in), optional
| ||
| terminus : | real, intent(in), optional
| ||
| interval : | real, intent(in), optional
| ||
| slice_start(:) : | integer, intent(in), optional
| ||
| slice_end(:) : | integer, intent(in), optional
| ||
| slice_stride(:) : | integer, intent(in), optional
| ||
| space_average(:) : | logical, intent(in), optional
| ||
| newfile_interval : | integer, intent(in), optional
|
ヒストリデータ出力するための変数登録を行います.
HistoryAutoProgress を呼ぶ前にこのサブルーチンを使用してください.
Register variables for history data output
Use this subroutine before "HistoryAutoProgress" is called.
subroutine HistoryAutoAddVariable1( varname, dims, longname, units, xtype, time_units, time_average, file, origin, terminus, interval, slice_start, slice_end, slice_stride, space_average, newfile_interval )
!
! ヒストリデータ出力するための変数登録を行います.
!
! HistoryAutoProgress を呼ぶ前にこのサブルーチンを使用してください.
!
! Register variables for history data output
!
! Use this subroutine before "HistoryAutoProgress" is called.
!
! モジュール引用 ; USE statements
!
use dc_trace, only: BeginSub, EndSub
use dc_error, only: StoreError, DC_NOERR, HST_EVARINUSE, HST_EALREADYPROGRESS, DC_ENOTINIT, HST_EMAXDIMSDEPENDED, HST_EINDIVISIBLE
use dc_message, only: MessageNotify
use dc_string, only: StrInclude, JoinChar, toChar
use dc_date, only: DCDiffTimeCreate, operator(/), mod, EvalSec, operator(-), EvalbyUnit
use netcdf_f77, only: NF_EMAXVARS
use gt4_history, only: HistoryVarinfoCreate, HistoryVarinfoInquire, HistoryAxisInquire
use gt4_history_nmlinfo, only: HstNmlInfoSetValidName, HstNmlInfoDefineMode, HstNmlInfoReDefine, HstNmlInfoEndDefine, HstNmlInfoAdd, HstNmlInfoInquire, HstNmlInfoOutputValid, HstNmlInfoAssocGtHist
! 宣言文 ; Declaration statements
!
implicit none
character(*), intent(in):: varname
! 変数名. Variable name
character(*), intent(in):: dims(:)
! 変数が依存する次元の名前.
! 時間の次元は配列の最後に指定すること.
!
! Names of dependency dimensions of a variable.
! Dimension of time must be specified
! to last of an array.
character(*), intent(in):: longname
! 変数の記述的名称.
!
! Descriptive name of a variable
character(*), intent(in):: units
! 変数の単位.
!
! Units of a variable
character(*), intent(in), optional:: xtype
!
! 変数のデータ型
!
! デフォルトは float (単精度実数型) であ
! る. 有効なのは, double (倍精度実数型),
! int (整数型) である. 指定しない 場合や,
! 無効な型を指定した場合には, float (単
! 精度実数型) となる.
!
! Data types of dimensions specified
! with "dims".
!
! Default value is "float" (single precision).
! Other valid values are
! "double" (double precision),
! "int" (integer).
! If no value or invalid value is specified,
! "float" is applied.
!
character(*), intent(in), optional:: time_units
! 時刻次元の単位.
! Units of time dimension.
logical, intent(in), optional:: time_average
!
! 出力データを時間平均する場合には
! .true. を与えます. デフォルトは
! .false. です.
!
! If output data is averaged, specify
! ".true.". Default is ".false.".
!
character(*), intent(in), optional:: file
! 出力ファイル名.
! Output file name.
real, intent(in), optional:: origin
! 出力開始時刻.
!
! 省略した場合, 自動的に current_time の値が
! 設定されます.
!
! Start time of output.
!
! If this argument is omitted,
! a value of "current_time" is specified
! automatically.
!
real, intent(in), optional:: terminus
! 出力終了時刻.
!
! 省略した場合, 数値モデルの実行が終了するまで
! 出力を行います.
!
! End time of output.
!
! If this argument is omitted,
! output is continued until a numerical model
! is finished.
!
real, intent(in), optional:: interval
! 出力時間間隔.
!
! 省略した場合,
! 自動的に delta_time の値が設定されます.
!
! Interval of output time.
!
! If this argument is omitted,
! a value of "delta_time" is specified
! automatically.
!
integer, intent(in), optional:: slice_start(:)
! 空間方向の開始点.
!
! 省略した場合, 座標データの開始点が設定されます.
!
! Start points of spaces.
!
! If this argument is omitted,
! start points of dimensions are set.
!
integer, intent(in), optional:: slice_end(:)
! 空間方向の終了点.
!
! 省略した場合, 座標データの終了点が設定されます.
!
! End points of spaces.
!
! If this argument is omitted,
! End points of dimensions are set.
!
integer, intent(in), optional:: slice_stride(:)
! 空間方向の刻み幅.
!
! 省略した場合, 1 が設定されます.
!
! Strides of spaces
!
! If this argument is omitted,
! 1 is set.
!
logical, intent(in), optional:: space_average(:)
! 平均化のフラグ.
!
! .true. が指定される座標に対して平均化を
! 行います.
! 省略した場合, .false. が設定されます.
!
! Flag of average.
!
! Axes specified .true. are averaged.
! If this argument is omitted,
! .false. is set.
!
integer, intent(in), optional:: newfile_interval
! ファイル分割時間間隔.
!
! 省略した場合,
! 時間方向へのファイル分割を行いません.
!
! Interval of time of separation of a file.
!
! If this argument is omitted,
! a files is not separated in time direction.
!
! 作業変数
! Work variables
!
character(TOKEN):: interval_unit_work
! ヒストリデータの出力間隔の単位.
! Unit for interval of history data output
character(TOKEN):: origin_unit_work
! 出力開始時刻の単位.
! Unit of start time of output.
character(TOKEN):: terminus_unit_work
! 出力終了時刻の単位.
! Unit of end time of output.
character(TOKEN):: newfile_intunit_work
! ファイル分割時間間隔の単位.
! Unit of interval of time of separation of a file.
real:: interval_value
! ヒストリデータの出力間隔の数値.
! Numerical value for interval of history data output
real:: origin_value
! ヒストリデータの出力開始時刻の数値.
! Numerical value for start time of history data output
real:: terminus_value
! 出力終了時刻の数値.
! Numerical value for end time of output.
integer:: newfile_intvalue
! ファイル分割時間間隔.
! Interval of time of separation of a file.
type(DC_DIFFTIME):: interval_difftime, origin_difftime, terminus_difftime, newfileint_difftime
character(TOKEN):: time_name
! 時刻次元の名称.
! Name of time dimension
character(STRING), allocatable:: dims_work(:)
! 変数が依存する次元の名前.
! Names of dependency dimensions of a variable.
character(TOKEN):: precision
! ヒストリデータの精度.
! Precision of history data
logical:: time_average_work
! 出力データの時間平均フラグ.
! Flag for time average of output data
logical:: space_average_work(1:numdims-1)
integer:: slice_start_work(1:numdims-1)
! 空間方向の開始点.
! Start points of spaces.
integer:: slice_end_work(1:numdims-1)
! 空間方向の終了点.
! End points of spaces.
integer:: slice_stride_work(1:numdims-1)
! 空間方向の刻み幅.
! Strides of spaces
logical:: define_mode, varname_not_found
integer:: cause_i, stat, i, j, k, cnt, cnt2, dim_size
character(TOKEN), pointer:: dims_noavr(:) =>null(), dims_avr(:) =>null()
character(STRING):: longname_avrmsg
character(STRING):: name, cause_c
character(*), parameter:: subname = "HistoryAutoAddVariable1"
continue
call BeginSub(subname, 'varname=%c', c1 = trim(varname), version = version)
stat = DC_NOERR
cause_c = ""
cause_i = 0
! 初期設定チェック
! Check initialization
!
if ( .not. initialized ) then
stat = DC_ENOTINIT
cause_c = 'gt4_historyauto'
goto 999
end if
! 既に HistoryAutoProgress が呼ばれていたらエラー
! Error is occurred if "HistoryAutoProgress" is called already
!
if ( once_progressed ) then
call MessageNotify( 'W', subname, '"HistoryAutoAddVariable" (varname = %c) must be called before "HistoryAutoProgress"', c1 = trim(varname) )
stat = HST_EALREADYPROGRESS
cause_c = 'HistoryAutoProgress'
goto 999
end if
! 重複のチェック
! Check duplication
!
do i = 1, numvars
call HistoryVarinfoInquire( varinfo = gthst_vars(i), name = name ) ! (out)
if ( trim(varname) == trim(name) ) then
stat = HST_EVARINUSE
cause_c = varname
goto 999
end if
end do
! 変数の数の限界チェック
! Check limit of number of variables
!
if ( numvars + 1 > NF_MAX_VARS ) then
stat = NF_EMAXVARS
goto 999
end if
! 時刻の次元に関する修正
! Correction for time dimension
!
call HistoryAxisInquire( axis = gthst_axes(numdims), name = time_name ) ! (out)
if ( size(dims) > 0 ) then
if ( StrInclude( dims, time_name ) ) then
if ( trim( dims(size(dims)) ) == trim( time_name ) ) then
allocate( dims_work(size(dims)) )
dims_work = dims
else
allocate( dims_work(size(dims)) )
cnt = 1
do i = 1, size(dims)
if ( trim( dims(i) ) /= trim( time_name ) ) then
dims_work( cnt ) = dims( i )
cnt = cnt + 1
end if
end do
dims_work(size(dims)) = time_name
call MessageNotify( 'W', subname, 'last entity of "dims=<%c>" must be time dimension (varname=<%c>). ' // ' "dims" are resequenced forcibly => <%c>', c1 = trim( JoinChar(dims, ',') ), c2 = trim( varname ), c3 = trim( JoinChar(dims_work, ',') ) )
end if
else
allocate( dims_work(size(dims)+1) )
dims_work(1:size(dims)) = dims
dims_work(size(dims)+1) = time_name
call MessageNotify( 'W', subname, 'time dimension is not found in "dims=<%c>" (varname=<%c>). ' // ' time dimensin "%c" is appended to "dims" forcibly.', c1 = trim( JoinChar(dims, ',') ), c2 = trim( varname ), c3 = trim( time_name ) )
end if
else
allocate( dims_work(1) )
dims_work(1) = time_name
call MessageNotify( 'W', subname, 'time dimension is not found (varname=<%c>). ' // ' time dimensin "%c" is appended to "dims" forcibly.', c1 = trim( varname ), c2 = trim( time_name ) )
end if
! 依存する次元の数の限界チェック
! Check limit of number of depended dimensions
!
if ( size( dims_work ) - 1 > MAX_DIMS_DEPENDED_BY_VAR ) then
call MessageNotify( 'W', subname, 'number of dimensions' // ' on which one variable depends must not be greater than %d (varname=<%c>, dims=<%c>). ', i = (/ 7 + 1 /), c1 = trim( varname ), c2 = trim( JoinChar(dims_work, ',') ) )
stat = HST_EMAXDIMSDEPENDED
cause_i = size( dims_work )
cause_c = varname
end if
! 全ての変数を出力する際には, ここで登録
! Register here if all variables are output
!
if ( all_output_save ) then
call HstNmlInfoInquire( gthstnml = gthstnml, name = varname, err = varname_not_found ) ! (out) optional
if ( varname_not_found ) then
define_mode = HstNmlInfoDefineMode( gthstnml )
if ( .not. define_mode ) call HstNmlInfoReDefine( gthstnml ) ! (inout)
call HstNmlInfoInquire( gthstnml = gthstnml, interval_unit = interval_unit_work, origin_unit = origin_unit_work , terminus_unit = terminus_unit_work, newfile_intunit = newfile_intunit_work ) ! (out) optional
! 時刻の単位を設定
! Configure unit of time
!
if ( present( interval ) ) then
interval_unit_work = time_unit_bycreate
if ( present(time_units) ) interval_unit_work = time_units
end if
if ( present( origin ) ) then
origin_unit_work = time_unit_bycreate
if ( present(time_units) ) origin_unit_work = time_units
end if
if ( present( terminus ) ) then
terminus_unit_work = time_unit_bycreate
if ( present(time_units) ) terminus_unit_work = time_units
end if
if ( present( newfile_interval ) ) then
newfile_intunit_work = time_unit_bycreate
if ( present(time_units) ) newfile_intunit_work = time_units
end if
call HstNmlInfoAdd( gthstnml = gthstnml, name = varname, file = file, precision = xtype, interval_value = interval, interval_unit = interval_unit_work, origin_value = origin, origin_unit = origin_unit_work, terminus_value = terminus, terminus_unit = terminus_unit_work, slice_start = slice_start, slice_end = slice_end, slice_stride = slice_stride, time_average = time_average, space_average = space_average, newfile_intvalue = newfile_interval, newfile_intunit = newfile_intunit_work ) ! (in) optional
if ( .not. define_mode ) call HstNmlInfoEndDefine( gthstnml ) ! (inout)
end if
end if
! 平均化に伴う次元の縮退を反映した変数情報の作り直し
! Remake information of variables that reflects reduction of dimensions
! correspond to average
!
call HstNmlInfoInquire( gthstnml = gthstnml, name = varname, precision = precision, time_average = time_average_work, space_average = space_average_work, slice_start = slice_start_work, slice_end = slice_end_work, slice_stride = slice_stride_work, err = varname_not_found ) ! (out) optional
if ( varname_not_found ) then
call HstNmlInfoInquire( gthstnml = gthstnml, name = '', precision = precision, time_average = time_average_work, space_average = space_average_work, slice_start = slice_start_work, slice_end = slice_end_work, slice_stride = slice_stride_work ) ! (out)
end if
if ( .not. associated( space_avr_vars(numvars + 1) % avr ) ) allocate( space_avr_vars(numvars + 1) % avr( size( dims_work ) - 1 ) )
space_avr_vars(numvars + 1) % avr = .false.
do i = 1, size( dims_work ) - 1
do j = 1, numdims - 1
call HistoryAxisInquire( axis = gthst_axes(j), name = name ) ! (out)
if ( trim(dims_work(i)) == trim(name) ) then
space_avr_vars(numvars + 1) % avr( i ) = space_average_work( j )
exit
end if
end do
end do
allocate( dims_noavr ( size(dims_work) - count(space_avr_vars(numvars + 1) % avr) ) )
if ( count(space_avr_vars(numvars + 1) % avr) < 1 ) then
dims_noavr = dims_work
longname_avrmsg = ''
else
allocate( dims_avr( count(space_avr_vars(numvars + 1) % avr) ) )
cnt = 1
cnt2 = 1
do i = 1, size( dims_work ) - 1
if ( .not. space_avr_vars(numvars + 1) % avr(i) ) then
dims_noavr( cnt ) = dims_work( i )
cnt = cnt + 1
else
dims_avr( cnt2 ) = dims_work( i )
cnt2 = cnt2 + 1
end if
end do
dims_noavr( cnt ) = dims_work( size ( dims_work ) )
longname_avrmsg = ' averaged in ' // trim( JoinChar( dims_avr, ',' ) ) // '-direction'
deallocate( dims_avr )
end if
! HistoryPut の際のデータの切り出し情報作成
! Create information of slices of data for "HistoryPut"
!
if ( .not. associated( slice_vars(numvars + 1) % st ) ) allocate( slice_vars(numvars + 1) % st( NF_MAX_DIMS ) )
if ( .not. associated( slice_vars(numvars + 1) % ed ) ) allocate( slice_vars(numvars + 1) % ed( NF_MAX_DIMS ) )
if ( .not. associated( slice_vars(numvars + 1) % sd ) ) allocate( slice_vars(numvars + 1) % sd( NF_MAX_DIMS ) )
slice_vars(numvars + 1) % st = 1
slice_vars(numvars + 1) % ed = 1
slice_vars(numvars + 1) % sd = 1
if ( size(dims_work) > 1 ) then
slice_subscript_search: do i = 1, size( dims_work ) - 1
do j = 1, numdims - 1
call HistoryAxisInquire( axis = gthst_axes(j), name = name, size = dim_size ) ! (out)
if ( slice_end_work(j) < 1 ) slice_end_work(j) = dim_size
if ( trim(dims_work(i)) == trim(name) ) then
slice_vars(numvars + 1) % st( i ) = slice_start_work( j )
slice_vars(numvars + 1) % ed( i ) = slice_end_work( j )
slice_vars(numvars + 1) % sd( i ) = slice_stride_work( j )
cycle slice_subscript_search
end if
end do
end do slice_subscript_search
end if
! HistoryPut の際の座標重み情報作成
! Create information of axes weight for "HistoryPut"
!
if ( .not. associated( weight_vars(numvars + 1) % wgt1 ) ) allocate( weight_vars(numvars + 1) % wgt1( 1 ) )
weight_vars(numvars + 1) % wgt1 = 1.0_DP
if ( size(dims_work) >= 1 ) then
do j = 1, numdims - 1
call HistoryAxisInquire( axis = gthst_axes(j), name = name, size = dim_size ) ! (out)
if ( trim(dims_work(1)) == trim(name) ) then
deallocate( weight_vars(numvars + 1) % wgt1 )
allocate( weight_vars(numvars + 1) % wgt1( dim_size ) )
weight_vars(numvars + 1) % wgt1 = 1.0_DP
do k = 1, numwgts
call HistoryVarinfoInquire( varinfo = gthst_weights(k), name = name ) ! (out)
if ( trim(dims_work(1)) // wgtsuf == trim(name) ) then
weight_vars(numvars + 1) % wgt1 = data_weights( k ) % a_axis
exit
end if
end do
exit
end if
end do
end if
if ( .not. associated( weight_vars(numvars + 1) % wgt2 ) ) allocate( weight_vars(numvars + 1) % wgt2( 1 ) )
weight_vars(numvars + 1) % wgt2 = 1.0_DP
if ( size(dims_work) >= 2 ) then
do j = 1, numdims - 1
call HistoryAxisInquire( axis = gthst_axes(j), name = name, size = dim_size ) ! (out)
if ( trim(dims_work(2)) == trim(name) ) then
deallocate( weight_vars(numvars + 1) % wgt2 )
allocate( weight_vars(numvars + 1) % wgt2( dim_size ) )
weight_vars(numvars + 1) % wgt2 = 1.0_DP
do k = 1, numwgts
call HistoryVarinfoInquire( varinfo = gthst_weights(k), name = name ) ! (out)
if ( trim(dims_work(2)) // wgtsuf == trim(name) ) then
weight_vars(numvars + 1) % wgt2 = data_weights( k ) % a_axis
exit
end if
end do
exit
end if
end do
end if
if ( .not. associated( weight_vars(numvars + 1) % wgt3 ) ) allocate( weight_vars(numvars + 1) % wgt3( 1 ) )
weight_vars(numvars + 1) % wgt3 = 1.0_DP
if ( size(dims_work) >= 3 ) then
do j = 1, numdims - 1
call HistoryAxisInquire( axis = gthst_axes(j), name = name, size = dim_size ) ! (out)
if ( trim(dims_work(3)) == trim(name) ) then
deallocate( weight_vars(numvars + 1) % wgt3 )
allocate( weight_vars(numvars + 1) % wgt3( dim_size ) )
weight_vars(numvars + 1) % wgt3 = 1.0_DP
do k = 1, numwgts
call HistoryVarinfoInquire( varinfo = gthst_weights(k), name = name ) ! (out)
if ( trim(dims_work(3)) // wgtsuf == trim(name) ) then
weight_vars(numvars + 1) % wgt3 = data_weights( k ) % a_axis
exit
end if
end do
exit
end if
end do
end if
if ( .not. associated( weight_vars(numvars + 1) % wgt4 ) ) allocate( weight_vars(numvars + 1) % wgt4( 1 ) )
weight_vars(numvars + 1) % wgt4 = 1.0_DP
if ( size(dims_work) >= 4 ) then
do j = 1, numdims - 1
call HistoryAxisInquire( axis = gthst_axes(j), name = name, size = dim_size ) ! (out)
if ( trim(dims_work(4)) == trim(name) ) then
deallocate( weight_vars(numvars + 1) % wgt4 )
allocate( weight_vars(numvars + 1) % wgt4( dim_size ) )
weight_vars(numvars + 1) % wgt4 = 1.0_DP
do k = 1, numwgts
call HistoryVarinfoInquire( varinfo = gthst_weights(k), name = name ) ! (out)
if ( trim(dims_work(4)) // wgtsuf == trim(name) ) then
weight_vars(numvars + 1) % wgt4 = data_weights( k ) % a_axis
exit
end if
end do
exit
end if
end do
end if
if ( .not. associated( weight_vars(numvars + 1) % wgt5 ) ) allocate( weight_vars(numvars + 1) % wgt5( 1 ) )
weight_vars(numvars + 1) % wgt5 = 1.0_DP
if ( size(dims_work) >= 5 ) then
do j = 1, numdims - 1
call HistoryAxisInquire( axis = gthst_axes(j), name = name, size = dim_size ) ! (out)
if ( trim(dims_work(5)) == trim(name) ) then
deallocate( weight_vars(numvars + 1) % wgt5 )
allocate( weight_vars(numvars + 1) % wgt5( dim_size ) )
weight_vars(numvars + 1) % wgt5 = 1.0_DP
do k = 1, numwgts
call HistoryVarinfoInquire( varinfo = gthst_weights(k), name = name ) ! (out)
if ( trim(dims_work(5)) // wgtsuf == trim(name) ) then
weight_vars(numvars + 1) % wgt5 = data_weights( k ) % a_axis
exit
end if
end do
exit
end if
end do
end if
if ( .not. associated( weight_vars(numvars + 1) % wgt6 ) ) allocate( weight_vars(numvars + 1) % wgt6( 1 ) )
weight_vars(numvars + 1) % wgt6 = 1.0_DP
if ( size(dims_work) >= 6 ) then
do j = 1, numdims - 1
call HistoryAxisInquire( axis = gthst_axes(j), name = name, size = dim_size ) ! (out)
if ( trim(dims_work(6)) == trim(name) ) then
deallocate( weight_vars(numvars + 1) % wgt6 )
allocate( weight_vars(numvars + 1) % wgt6( dim_size ) )
weight_vars(numvars + 1) % wgt6 = 1.0_DP
do k = 1, numwgts
call HistoryVarinfoInquire( varinfo = gthst_weights(k), name = name ) ! (out)
if ( trim(dims_work(6)) // wgtsuf == trim(name) ) then
weight_vars(numvars + 1) % wgt6 = data_weights( k ) % a_axis
exit
end if
end do
exit
end if
end do
end if
if ( .not. associated( weight_vars(numvars + 1) % wgt7 ) ) allocate( weight_vars(numvars + 1) % wgt7( 1 ) )
weight_vars(numvars + 1) % wgt7 = 1.0_DP
if ( size(dims_work) >= 7 ) then
do j = 1, numdims - 1
call HistoryAxisInquire( axis = gthst_axes(j), name = name, size = dim_size ) ! (out)
if ( trim(dims_work(7)) == trim(name) ) then
deallocate( weight_vars(numvars + 1) % wgt7 )
allocate( weight_vars(numvars + 1) % wgt7( dim_size ) )
weight_vars(numvars + 1) % wgt7 = 1.0_DP
do k = 1, numwgts
call HistoryVarinfoInquire( varinfo = gthst_weights(k), name = name ) ! (out)
if ( trim(dims_work(7)) // wgtsuf == trim(name) ) then
weight_vars(numvars + 1) % wgt7 = data_weights( k ) % a_axis
exit
end if
end do
exit
end if
end do
end if
! 変数名の有効性を設定
! Set validation of the variable name
!
call HstNmlInfoSetValidName( gthstnml = gthstnml, name = varname ) ! (in)
! 変数情報の登録
! Register information of variable
!
call HistoryVarinfoCreate( varinfo = gthst_vars(numvars + 1), name = varname, dims = dims_noavr, longname = trim(longname) // longname_avrmsg , units = units, xtype = precision, time_average = time_average_work ) ! (in) optional
varname_vars(numvars + 1) = varname
tavr_vars(numvars + 1) = time_average_work
deallocate( dims_noavr )
deallocate( dims_work )
! 出力の有効かどうかを確認する
! Confirm whether the output is effective
!
output_valid_vars(numvars + 1) = HstNmlInfoOutputValid( gthstnml, varname )
! 各ステップ数を算出する.
! Calculate number of each step
!
if ( output_valid_vars(numvars + 1) ) then
call HstNmlInfoInquire( gthstnml = gthstnml, name = varname, interval_value = interval_value, interval_unit = interval_unit_work, origin_value = origin_value, origin_unit = origin_unit_work, terminus_value = terminus_value, terminus_unit = terminus_unit_work, newfile_intvalue = newfile_intvalue, newfile_intunit = newfile_intunit_work ) ! (out)
! 出力間隔ステップ数を算出する.
! Calculate number of step of interval of output
!
call DCDiffTimeCreate( interval_difftime, interval_value, interval_unit_work ) ! (in)
deltime_value_vars(numvars + 1) = EvalbyUnit( delta_difftime, interval_unit_work )
intstep_vars(numvars + 1) = nint( interval_difftime / delta_difftime )
if ( EvalSec( mod(interval_difftime, delta_difftime) ) > max_remainder_range ) then
call MessageNotify( 'W', subname, 'interval=<%r [%c]> can not be divided by deltime=<%f [s]>', r = (/ interval_value /), d = (/ EvalSec(delta_difftime) /), c1 = trim(interval_unit_work) )
stat = HST_EINDIVISIBLE
cause_c = 'interval=' // trim(toChar(interval_value)) // ' [' // trim(interval_unit_work) // ']'
goto 999
end if
! ファイルを作成するステップ数を算出する.
! Calculate number of step of interval of output
!
if ( origin_value > 0.0 ) then
call DCDiffTimeCreate( origin_difftime, origin_value, origin_unit_work ) ! (in)
origin_value_vars(numvars + 1) = EvalbyUnit( origin_difftime, interval_unit_work )
originstep_vars(numvars + 1) = nint( ( origin_difftime - start_difftime ) / delta_difftime )
if ( EvalSec( mod( ( origin_difftime - start_difftime ), delta_difftime ) ) > max_remainder_range ) then
call MessageNotify( 'W', subname, 'origin=<%r [%c]> - start=<%d [%c]> can not be divided by deltime=<%f [s]>', r = (/ origin_value /), d = (/ EvalbyUnit(start_difftime, origin_unit_work), EvalSec(delta_difftime) /), c1 = trim(origin_unit_work), c2 = trim(origin_unit_work) )
stat = HST_EINDIVISIBLE
cause_c = 'origin=' // trim(toChar(origin_value)) // ' [' // trim(origin_unit_work) // ']'
goto 999
end if
end if
! ファイルをクローズするステップ数を算出する.
! Calculate number of step of closure of file
!
if ( terminus_value > 0.0 ) then
call DCDiffTimeCreate( terminus_difftime, terminus_value, terminus_unit_work ) ! (in)
terminusstep_vars(numvars + 1) = nint( ( terminus_difftime - start_difftime ) / delta_difftime ) + 1
if ( EvalSec( mod( ( terminus_difftime - start_difftime ), delta_difftime ) ) > max_remainder_range ) then
call MessageNotify( 'W', subname, 'terminus=<%r [%c]> - start=<%d [%c]> can not be divided by deltime=<%f [s]>', r = (/ terminus_value /), d = (/ EvalbyUnit(start_difftime, terminus_unit_work), EvalSec(delta_difftime) /), c1 = trim(terminus_unit_work), c2 = trim(terminus_unit_work) )
stat = HST_EINDIVISIBLE
cause_c = 'terminus=' // trim(toChar(terminus_value)) // ' [' // trim(terminus_unit_work) // ']'
goto 999
end if
end if
! ファイルを新規に作り直すステップ数の算出
! Calculate number of step of remake of file
if ( newfile_intvalue > 0.0 ) then
call DCDiffTimeCreate( newfileint_difftime, real( newfile_intvalue ), newfile_intunit_work ) ! (in)
newfile_intstep_vars(numvars + 1) = nint( ( newfileint_difftime ) / delta_difftime )
if ( EvalSec( mod( newfileint_difftime, delta_difftime ) ) > max_remainder_range ) then
call MessageNotify( 'W', subname, 'newfile_interval=<%d [%c]> can not be divided by deltime=<%f [s]>', i = (/ newfile_intvalue /), d = (/ EvalSec(delta_difftime) /), c1 = trim(newfile_intunit_work) )
stat = HST_EINDIVISIBLE
cause_c = 'newfile_interval=' // trim(toChar(newfile_intvalue)) // ' [' // trim(newfile_intunit_work) // ']'
goto 999
end if
if ( EvalSec( mod( newfileint_difftime, interval_difftime ) ) > max_remainder_range ) then
call MessageNotify( 'W', subname, 'newfile_interval=<%d [%c]> can not be divided by interval=<%r [%c]>', i = (/ newfile_intvalue /), r = (/ interval_value /), c1 = trim(newfile_intunit_work), c2 = trim(interval_unit_work) )
stat = HST_EINDIVISIBLE
cause_c = 'newfile_interval=' // trim(toChar(newfile_intvalue)) // ' [' // trim(newfile_intunit_work) // ']'
goto 999
end if
if ( .not. newfile_intstep_vars(numvars + 1) > intstep_vars(numvars + 1) ) then
call MessageNotify( 'W', subname, 'newfile_interval=<%d [%c]> must be greater than interval=<%r [%c]>', i = (/ newfile_intvalue /), r = (/ interval_value /), c1 = trim(newfile_intunit_work), c2 = trim(interval_unit_work) )
stat = HST_EINDIVISIBLE
cause_c = 'newfile_interval=' // trim(toChar(newfile_intvalue)) // ' [' // trim(newfile_intunit_work) // ']'
goto 999
end if
end if
end if
! GT_HISTORY 変数の取得
! Get "GT_HISTORY" variable
!
if ( output_valid_vars(numvars + 1) ) then
define_mode = HstNmlInfoDefineMode( gthstnml )
if ( define_mode ) call HstNmlInfoEndDefine( gthstnml ) ! (inout)
call HstNmlInfoAssocGtHist( gthstnml = gthstnml, name = varname, history = gthst_history_vars(numvars + 1) % gthist ) ! (out)
if ( define_mode ) call HstNmlInfoReDefine( gthstnml ) ! (inout)
end if
! 登録変数の数を更新
! Update number of registered variables
!
numvars = numvars + 1
999 continue
call StoreError(stat, subname, cause_c = cause_c, cause_i = cause_i)
call EndSub(subname, 'stat=%d', i = (/stat/) )
end subroutine HistoryAutoAddVariable1
| Subroutine : | |||
| dim : | character(*), intent(in)
| ||
| weight(:) : | integer, intent(in)
| ||
| units : | character(*), intent(in), optional
| ||
| xtype : | character(*), intent(in), optional
|
座標の重みデータを設定します.
Set weights of axes.
subroutine HistoryAutoAddWeightInt( dim, weight, units, xtype )
!
! 座標の重みデータを設定します.
!
! Set weights of axes.
!
use dc_trace, only: BeginSub, EndSub
use dc_error, only: StoreError, DC_NOERR, GT_EARGSIZEMISMATCH, HST_ENOAXISNAME, DC_ENOTINIT
use gt4_history, only: HistoryAxisInquire, HistoryAxisAddAttr, HistoryVarinfoCreate
implicit none
character(*), intent(in):: dim
! 座標重みを設定する座標の名称.
!
! ただし, ここで指定するもの
! は, HistoryAutoCreate の *dims*
! 既に指定されていなければなりません.
!
! Name of axis to which "weight" are set.
!
! Note that this value must be set
! as "dims" of "HistoryAutoCreate".
!
integer, intent(in):: weight(:)
! 座標重みデータ.
!
! データ型は整数, 単精度実数型,
! 倍精度実数型のどれでもかまいません.
! ただし, ファイルへ出力される際には,
! xtype もしくは座標データの型へと
! 変換されます.
!
! Weight of axis.
!
! Integer, single or double precision are
! acceptable as data type.
! Note that when this is output to a file,
! data type is converted into "xtype" or
! type of the axis.
!
character(*), intent(in), optional:: units
! 座標重みの単位.
! 省略した場合には, 座標の単位が
! 使用されます.
!
! Units of axis weight.
! If this argument is omitted,
! unit of the dimension is used.
!
character(*), intent(in), optional:: xtype
! 座標重みのデータ型.
! 省略した場合には, 座標のデータ型が
! 使用されます.
!
! Data type of weight of the dimension.
! If this argument is omitted,
! data type of the dimension is used.
!
character(STRING):: name, longname
character(TOKEN):: dim_units, dim_xtype
integer:: dim_size
integer:: stat, i
character(STRING):: cause_c
character(*), parameter:: subname = "HistoryAutoAddWeightInt"
continue
call BeginSub(subname, 'dim=<%c>', c1=trim(dim) )
stat = DC_NOERR
cause_c = ""
! 初期設定チェック
! Check initialization
!
if ( .not. initialized ) then
stat = DC_ENOTINIT
cause_c = 'gt4_historyauto'
goto 999
end if
do i = 1, numdims
call HistoryAxisInquire( axis = gthst_axes(i), name = name, size = dim_size, longname = longname, units = dim_units, xtype = dim_xtype ) ! (out)
if ( trim(dim) == trim(name) ) then
if ( dim_size /= size(weight) ) then
stat = GT_EARGSIZEMISMATCH
cause_c = 'weight'
end if
if ( present(units) ) dim_units = units
if ( present(xtype) ) dim_xtype = xtype
call HistoryVarinfoCreate( varinfo = gthst_weights(numwgts + 1), name = trim(dim) // wgtsuf, dims = (/ dim /), longname = 'weight for integration or average in ' // trim(longname), units = dim_units, xtype = dim_xtype ) ! (in)
call HistoryAxisAddAttr( axis = gthst_axes(i), attrname = 'gt_calc_weight', value = trim(dim) // wgtsuf ) ! (in)
allocate( data_weights(numwgts + 1) % a_axis( dim_size ) )
data_weights(numwgts + 1) % a_axis = weight
numwgts = numwgts + 1
goto 999
end if
end do
stat = HST_ENOAXISNAME
cause_c = dim
999 continue
call StoreError(stat, subname, cause_c = cause_c)
call EndSub(subname)
end subroutine HistoryAutoAddWeightInt
| Subroutine : | |||
| dim : | character(*), intent(in)
| ||
| weight(:) : | real(DP), intent(in)
| ||
| units : | character(*), intent(in), optional
| ||
| xtype : | character(*), intent(in), optional
|
座標の重みデータを設定します.
Set weights of axes.
subroutine HistoryAutoAddWeightDouble( dim, weight, units, xtype )
!
! 座標の重みデータを設定します.
!
! Set weights of axes.
!
use dc_trace, only: BeginSub, EndSub
use dc_error, only: StoreError, DC_NOERR, GT_EARGSIZEMISMATCH, HST_ENOAXISNAME, DC_ENOTINIT
use gt4_history, only: HistoryAxisInquire, HistoryAxisAddAttr, HistoryVarinfoCreate
implicit none
character(*), intent(in):: dim
! 座標重みを設定する座標の名称.
!
! ただし, ここで指定するもの
! は, HistoryAutoCreate の *dims*
! 既に指定されていなければなりません.
!
! Name of axis to which "weight" are set.
!
! Note that this value must be set
! as "dims" of "HistoryAutoCreate".
!
real(DP), intent(in):: weight(:)
! 座標重みデータ.
!
! データ型は整数, 単精度実数型,
! 倍精度実数型のどれでもかまいません.
! ただし, ファイルへ出力される際には,
! xtype もしくは座標データの型へと
! 変換されます.
!
! Weight of axis.
!
! Integer, single or double precision are
! acceptable as data type.
! Note that when this is output to a file,
! data type is converted into "xtype" or
! type of the axis.
!
character(*), intent(in), optional:: units
! 座標重みの単位.
! 省略した場合には, 座標の単位が
! 使用されます.
!
! Units of axis weight.
! If this argument is omitted,
! unit of the dimension is used.
!
character(*), intent(in), optional:: xtype
! 座標重みのデータ型.
! 省略した場合には, 座標のデータ型が
! 使用されます.
!
! Data type of weight of the dimension.
! If this argument is omitted,
! data type of the dimension is used.
!
character(STRING):: name, longname
character(TOKEN):: dim_units, dim_xtype
integer:: dim_size
integer:: stat, i
character(STRING):: cause_c
character(*), parameter:: subname = "HistoryAutoAddWeightDouble"
continue
call BeginSub(subname, 'dim=<%c>', c1=trim(dim) )
stat = DC_NOERR
cause_c = ""
! 初期設定チェック
! Check initialization
!
if ( .not. initialized ) then
stat = DC_ENOTINIT
cause_c = 'gt4_historyauto'
goto 999
end if
do i = 1, numdims
call HistoryAxisInquire( axis = gthst_axes(i), name = name, size = dim_size, longname = longname, units = dim_units, xtype = dim_xtype ) ! (out)
if ( trim(dim) == trim(name) ) then
if ( dim_size /= size(weight) ) then
stat = GT_EARGSIZEMISMATCH
cause_c = 'weight'
end if
if ( present(units) ) dim_units = units
if ( present(xtype) ) dim_xtype = xtype
call HistoryVarinfoCreate( varinfo = gthst_weights(numwgts + 1), name = trim(dim) // wgtsuf, dims = (/ dim /), longname = 'weight for integration or average in ' // trim(longname), units = dim_units, xtype = dim_xtype ) ! (in)
call HistoryAxisAddAttr( axis = gthst_axes(i), attrname = 'gt_calc_weight', value = trim(dim) // wgtsuf ) ! (in)
allocate( data_weights(numwgts + 1) % a_axis( dim_size ) )
data_weights(numwgts + 1) % a_axis = weight
numwgts = numwgts + 1
goto 999
end if
end do
stat = HST_ENOAXISNAME
cause_c = dim
999 continue
call StoreError(stat, subname, cause_c = cause_c)
call EndSub(subname)
end subroutine HistoryAutoAddWeightDouble
| Subroutine : | |||
| dim : | character(*), intent(in)
| ||
| weight(:) : | real, intent(in)
| ||
| units : | character(*), intent(in), optional
| ||
| xtype : | character(*), intent(in), optional
|
座標の重みデータを設定します.
Set weights of axes.
subroutine HistoryAutoAddWeightReal( dim, weight, units, xtype )
!
! 座標の重みデータを設定します.
!
! Set weights of axes.
!
use dc_trace, only: BeginSub, EndSub
use dc_error, only: StoreError, DC_NOERR, GT_EARGSIZEMISMATCH, HST_ENOAXISNAME, DC_ENOTINIT
use gt4_history, only: HistoryAxisInquire, HistoryAxisAddAttr, HistoryVarinfoCreate
implicit none
character(*), intent(in):: dim
! 座標重みを設定する座標の名称.
!
! ただし, ここで指定するもの
! は, HistoryAutoCreate の *dims*
! 既に指定されていなければなりません.
!
! Name of axis to which "weight" are set.
!
! Note that this value must be set
! as "dims" of "HistoryAutoCreate".
!
real, intent(in):: weight(:)
! 座標重みデータ.
!
! データ型は整数, 単精度実数型,
! 倍精度実数型のどれでもかまいません.
! ただし, ファイルへ出力される際には,
! xtype もしくは座標データの型へと
! 変換されます.
!
! Weight of axis.
!
! Integer, single or double precision are
! acceptable as data type.
! Note that when this is output to a file,
! data type is converted into "xtype" or
! type of the axis.
!
character(*), intent(in), optional:: units
! 座標重みの単位.
! 省略した場合には, 座標の単位が
! 使用されます.
!
! Units of axis weight.
! If this argument is omitted,
! unit of the dimension is used.
!
character(*), intent(in), optional:: xtype
! 座標重みのデータ型.
! 省略した場合には, 座標のデータ型が
! 使用されます.
!
! Data type of weight of the dimension.
! If this argument is omitted,
! data type of the dimension is used.
!
character(STRING):: name, longname
character(TOKEN):: dim_units, dim_xtype
integer:: dim_size
integer:: stat, i
character(STRING):: cause_c
character(*), parameter:: subname = "HistoryAutoAddWeightReal"
continue
call BeginSub(subname, 'dim=<%c>', c1=trim(dim) )
stat = DC_NOERR
cause_c = ""
! 初期設定チェック
! Check initialization
!
if ( .not. initialized ) then
stat = DC_ENOTINIT
cause_c = 'gt4_historyauto'
goto 999
end if
do i = 1, numdims
call HistoryAxisInquire( axis = gthst_axes(i), name = name, size = dim_size, longname = longname, units = dim_units, xtype = dim_xtype ) ! (out)
if ( trim(dim) == trim(name) ) then
if ( dim_size /= size(weight) ) then
stat = GT_EARGSIZEMISMATCH
cause_c = 'weight'
end if
if ( present(units) ) dim_units = units
if ( present(xtype) ) dim_xtype = xtype
call HistoryVarinfoCreate( varinfo = gthst_weights(numwgts + 1), name = trim(dim) // wgtsuf, dims = (/ dim /), longname = 'weight for integration or average in ' // trim(longname), units = dim_units, xtype = dim_xtype ) ! (in)
call HistoryAxisAddAttr( axis = gthst_axes(i), attrname = 'gt_calc_weight', value = trim(dim) // wgtsuf ) ! (in)
allocate( data_weights(numwgts + 1) % a_axis( dim_size ) )
data_weights(numwgts + 1) % a_axis = weight
numwgts = numwgts + 1
goto 999
end if
end do
stat = HST_ENOAXISNAME
cause_c = dim
999 continue
call StoreError(stat, subname, cause_c = cause_c)
call EndSub(subname)
end subroutine HistoryAutoAddWeightReal
| Subroutine : |
HistoryAutoCreate で始まったデータ出力の終了処理を行います. プログラムを終了する前に必ずこのサブルーチンを呼んでください.
Terminates data output with "HistoryAutoCreate". Call this subroutine certainly before a progrem is finished.
subroutine HistoryAutoClose1
!
! HistoryAutoCreate で始まったデータ出力の終了処理を行います.
! プログラムを終了する前に必ずこのサブルーチンを呼んでください.
!
! Terminates data output with "HistoryAutoCreate".
! Call this subroutine certainly before a progrem is finished.
!
use dc_trace, only: BeginSub, EndSub
use dc_string, only: PutLine, Printf, Split, StrInclude, StoA, JoinChar
use dc_error, only: StoreError, DC_NOERR, DC_ENOTINIT
use gt4_history_nmlinfo, only: HstNmlInfoClose, HstNmlInfoGetNames, HstNmlInfoAssocGtHist, HstNmlInfoPutLine
use gt4_history, only: GT_HISTORY, HistoryClose, HistoryInitialized, HistoryAxisClear, HistoryVarinfoClear
! ヒストリファイルへのデータ出力設定
! Configure the settings for history data output
!
character(STRING):: name = ''
! 変数名. Variable identifier
character(TOKEN), pointer:: varnames_array(:) =>null()
! 変数名リスト配列.
! List of variables (array)
integer:: i, vnmax
type(GT_HISTORY), pointer:: gthist =>null()
! gt4_history モジュール用構造体.
! Derived type for "gt4_history" module
! 作業変数
! Work variables
!
integer:: stat
character(STRING):: cause_c
character(*), parameter:: subname = 'HistoryAutoClose1'
continue
call BeginSub( subname )
stat = DC_NOERR
cause_c = ''
! 初期設定チェック
! Check initialization
!
if ( .not. initialized ) then
stat = DC_ENOTINIT
cause_c = 'gt4_historyauto'
goto 999
end if
! ヒストリファイルへのデータ出力の終了処理
! Terminate the settings for history data output
!
call HstNmlInfoGetNames( gthstnml, varnames_array ) ! (out)
vnmax = size( varnames_array )
do i = 1, vnmax
name = varnames_array(i)
if ( trim( name ) == '' ) exit
nullify( gthist )
call HstNmlInfoAssocGtHist( gthstnml = gthstnml, name = name, history = gthist ) ! (out)
if ( HistoryInitialized( gthist ) ) then
call HistoryClose( history = gthist ) ! (inout)
end if
end do
! ヒストリファイルへのデータ出力設定の割付解除
! Deallocate the settings for history data output
!
call HstNmlInfoClose( gthstnml ) ! (inout)
! 座標軸情報のクリア
! Create axes information
!
do i = 1, numdims
call HistoryAxisClear( gthst_axes(i) )
deallocate( data_axes(i) % a_axis )
end do
numdims = 0
! 座標重み情報のクリア
! Create axes weights information
!
do i = 1, numwgts
call HistoryVarinfoClear( gthst_weights(i) )
deallocate( data_weights(i) % a_axis )
end do
numwgts = 0
! 変数情報のクリア
! Create variables information
!
do i = 1, numvars
call HistoryVarinfoClear( gthst_vars(i) )
if ( associated( slice_vars(i) % st ) ) deallocate( slice_vars(i) % st )
if ( associated( slice_vars(i) % ed ) ) deallocate( slice_vars(i) % ed )
if ( associated( slice_vars(i) % sd ) ) deallocate( slice_vars(i) % sd )
if ( associated( weight_vars(i) % wgt1 ) ) deallocate( weight_vars(i) % wgt1 )
if ( associated( weight_vars(i) % wgt2 ) ) deallocate( weight_vars(i) % wgt2 )
if ( associated( weight_vars(i) % wgt3 ) ) deallocate( weight_vars(i) % wgt3 )
if ( associated( weight_vars(i) % wgt4 ) ) deallocate( weight_vars(i) % wgt4 )
if ( associated( weight_vars(i) % wgt5 ) ) deallocate( weight_vars(i) % wgt5 )
if ( associated( weight_vars(i) % wgt6 ) ) deallocate( weight_vars(i) % wgt6 )
if ( associated( weight_vars(i) % wgt7 ) ) deallocate( weight_vars(i) % wgt7 )
if ( associated( space_avr_vars(i) % avr ) ) deallocate( space_avr_vars(i) % avr )
varname_vars(i) = ''
output_valid_vars(i) = .false.
output_timing_vars(i) = .false.
intstep_vars(i) = 1
originstep_vars(i) = 0
terminusstep_vars(i) = -1
newfile_intstep_vars(i) = -1
tavr_vars(i) = .false.
deltime_value_vars(i) = 1.0
origin_value_vars(i) = 0.0
end do
numvars = 0
! 時刻データのクリア
! Clear time data
!
Nstep = 0
! 終了処理, 例外処理
! Termination and Exception handling
!
initialized = .false.
once_progressed = .false.
all_output_save = .false.
999 continue
call StoreError( stat, subname, cause_c = cause_c )
call EndSub( subname )
end subroutine HistoryAutoClose1
| Subroutine : | |||
| title : | character(*), intent(in)
| ||
| source : | character(*), intent(in)
| ||
| institution : | character(*), intent(in)
| ||
| dims(:) : | character(*), intent(in)
| ||
| dimsizes(:) : | integer, intent(in)
| ||
| longnames(:) : | character(*), intent(in)
| ||
| units(:) : | character(*), intent(in)
| ||
| xtypes(:) : | character(*), intent(in), optional
| ||
| conventions : | character(*), intent(in), optional
| ||
| gt_version : | character(*), intent(in), optional
| ||
| all_output : | logical, intent(in), optional
| ||
| file_prefix : | character(*), intent(in), optional
| ||
| namelist_filename : | character(*), intent(in), optional
| ||
| current_time : | real, intent(in), optional
| ||
| delta_time : | real, intent(in), optional
| ||
| interval : | real, intent(in), optional
| ||
| origin : | real, intent(in), optional
| ||
| terminus : | real, intent(in), optional
| ||
| slice_start(:) : | integer, intent(in), optional
| ||
| slice_end(:) : | integer, intent(in), optional
| ||
| slice_stride(:) : | integer, intent(in), optional
| ||
| space_average(:) : | logical, intent(in), optional
| ||
| time_average : | logical, intent(in), optional
| ||
| newfile_interval : | integer, intent(in), optional
| ||
| rank : | character(*), intent(in), optional
|
複数のヒストリデータ出力を行うための初期化を行います.
この HistoryAutoCreate には, モデル内で出力する 変数が依存する座標や座標重みなどを全てを設定してください.
all_output に .true. を与えた場合や, namelist_filename を与えない (空文字を与える) 場合には, HistoryAutoAddVariable で登録される全ての変数が出力されます. 一方で namelist_filename に NAMELIST ファイル名を与える場合には, その NAMELIST ファイルから出力のオンオフや, 出力ファイル名, 出力間隔などを変更可能です. 変更可能な項目に関しては NAMELIST#gt4_historyauto_nml を参照して下さい.
interval, origin, terminus, slice_start, slice_end, slice_stride, space_average, time_average, newfile_interval などの設定はデフォルト値として使用されます. これらの設定値は HistoryAutoAddVariable および NAMELIST#gt4_historyauto_nml で上書きされます. (優先度が高いのは NAMELIST#gt4_historyauto_nml , HistoryAutoAddVariable の引数, HistoryAutoCreate の引数 の順です).
Initialization for multiple history data output
Set all axes and their weights depended by variables output from numerical models to this "HistoryAutoCreate".
All variables registered by "HistoryAutoAddVariable" are output if .true. is given to "all_output" or "namelist_filename" is not given (or blanks are given) On the other hand, if a filename of NAMELIST file is given to "namelist_filename", on/off of output, output filename and output interval, etc. can be changed from the NAMELIST file. For available items, see "NAMELIST#gt4_historyauto_nml".
Settings about "interval", "origin", "terminus", "slice_start", "slice_end", "slice_stride", "space_average", "time_average", "newfile_interval" etc. are used as default values. Their set values are overwritten by "HistoryAutoAddVariable" or "NAMELIST#gt4_historyauto_nml". ("NAMELIST#gt4_historyauto_nml" is high priority, arguments of "HistoryAutoAddVariable" are medium, arguments of "HistoryAutoCreate" are low).
This procedure input/output NAMELIST#gt4_historyauto_nml .
subroutine HistoryAutoCreate1( title, source, institution, dims, dimsizes, longnames, units, xtypes, conventions, gt_version, all_output, file_prefix, namelist_filename, current_time, delta_time, interval, origin, terminus, slice_start, slice_end, slice_stride, space_average, time_average, newfile_interval, rank )
!
! 複数のヒストリデータ出力を行うための初期化を行います.
!
! この HistoryAutoCreate には, モデル内で出力する
! 変数が依存する座標や座標重みなどを全てを設定してください.
!
! all_output に .true. を与えた場合や,
! namelist_filename を与えない (空文字を与える) 場合には,
! HistoryAutoAddVariable で登録される全ての変数が出力されます.
! 一方で namelist_filename に NAMELIST ファイル名を与える場合には,
! その NAMELIST ファイルから出力のオンオフや,
! 出力ファイル名, 出力間隔などを変更可能です.
! 変更可能な項目に関しては NAMELIST#gt4_historyauto_nml
! を参照して下さい.
!
! interval, origin, terminus, slice_start, slice_end, slice_stride,
! space_average, time_average, newfile_interval
! などの設定はデフォルト値として使用されます.
! これらの設定値は HistoryAutoAddVariable および
! NAMELIST#gt4_historyauto_nml で上書きされます.
! (優先度が高いのは NAMELIST#gt4_historyauto_nml ,
! HistoryAutoAddVariable の引数,
! HistoryAutoCreate の引数 の順です).
!
!
! Initialization for multiple history data output
!
! Set all axes and their weights depended by variables
! output from numerical models to this "HistoryAutoCreate".
!
! All variables registered by "HistoryAutoAddVariable"
! are output if .true. is given to "all_output" or
! "namelist_filename" is not given (or blanks are given)
! On the other hand, if a filename of NAMELIST file is
! given to "namelist_filename", on/off of output,
! output filename and output interval, etc. can be changed
! from the NAMELIST file.
! For available items, see "NAMELIST#gt4_historyauto_nml".
!
! Settings about
! "interval", "origin", "terminus", "slice_start", "slice_end", "slice_stride",
! "space_average", "time_average", "newfile_interval"
! etc. are used as default values.
! Their set values are overwritten by
! "HistoryAutoAddVariable" or
! "NAMELIST#gt4_historyauto_nml".
! ("NAMELIST#gt4_historyauto_nml" is high priority,
! arguments of "HistoryAutoAddVariable" are medium,
! arguments of "HistoryAutoCreate" are low).
!
use dc_trace, only: BeginSub, EndSub
use dc_error, only: StoreError, DC_NOERR, DC_EALREADYINIT, GT_EARGSIZEMISMATCH, HST_ENOTIMEDIM, DC_ENEGATIVE
use netcdf_f77, only: NF_EMAXDIMS
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_date, only: DCDiffTimeCreate, EvalbyUnit
use dc_message, only: MessageNotify
use dc_iounit, only: FileOpen
use gt4_history, only: HistoryAxisCreate
use gt4_history_nmlinfo, only: HstNmlInfoCreate, HstNmlInfoAdd, HstNmlInfoEndDefine, HstNmlInfoPutLine, HstNmlInfoAllNameValid, HstNmlInfoInquire
implicit none
character(*), intent(in):: title
! データ全体の表題.
! Title of entire data
character(*), intent(in):: source
! データを作成する際の手段.
! Source of data file
character(*), intent(in):: institution
! ファイルを最終的に変更した組織/個人.
! Institution or person that changes files for the last time
character(*), intent(in):: dims(:)
! 次元の名前.
!
! 配列の大きさに制限はありません.
! 個々の次元の文字数は dc_types#TOKEN まで.
! 配列内の文字数は
! 全て同じでなければなりません.
! 足りない文字分は空白で
! 補ってください.
!
! Names of dimensions.
!
! Length of array is unlimited.
! Limits of numbers of characters of each
! dimensions are "dc_types#TOKEN".
! Numbers of characters in this array
! must be same.
! Make up a deficit with blanks.
!
integer, intent(in):: dimsizes (:)
! dims で指定したそれぞれの次元大きさ.
!
! 配列の大きさは dims の大きさと等しい
! 必要があります. '0' (数字のゼロ) を指定
! するとその次元は 無制限次元 (unlimited
! dimension) となります. (gt4_history
! では時間の次元に対して無制限次元を
! 用いることを想定しています). ただし,
! 1 つの NetCDF ファイル (バージョン 3)
! は最大で 1 つの無制限次元しか持てないので,
! 2 ヶ所以上に '0' を指定しないでください.
! その場合, 正しく gtool4 データが出力されません.
!
! Lengths of dimensions specified with "dims".
!
! Length of this array must be same as
! length of "dim". If '0' (zero) is
! specified, the dimension is treated as
! unlimited dimension.
! (In "gt4_history", unlimited dimension is