| 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.
Alias for HistoryAutoAddAttrChar0
| Subroutine : | |
| varname : | character(*), intent(in) |
| attrname : | character(*), intent(in) |
| value : | integer, intent(in) |
Alias for HistoryAutoAddAttrInt0
| Subroutine : | |
| varname : | character(*), intent(in) |
| attrname : | character(*), intent(in) |
| value : | logical, intent(in) |
Alias for HistoryAutoAddAttrLogical0
| Subroutine : | |
| varname : | character(*), intent(in) |
| attrname : | character(*), intent(in) |
| value : | real(DP), intent(in) |
Alias for HistoryAutoAddAttrDouble0
| Subroutine : | |
| varname : | character(*), intent(in) |
| attrname : | character(*), intent(in) |
| value : | real, intent(in) |
Alias for HistoryAutoAddAttrReal0
| Subroutine : | |
| varname : | character(*), intent(in) |
| attrname : | character(*), intent(in) |
| value(:) : | integer, intent(in) |
Alias for HistoryAutoAddAttrInt1
| Subroutine : | |
| varname : | character(*), intent(in) |
| attrname : | character(*), intent(in) |
| value(:) : | real(DP), intent(in) |
Alias for HistoryAutoAddAttrDouble1
| Subroutine : | |
| varname : | character(*), intent(in) |
| attrname : | character(*), intent(in) |
| value(:) : | real, intent(in) |
Alias for 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.
Alias for HistoryAutoAddVariable1
| Subroutine : | |||
| dim : | character(*), intent(in)
| ||
| weight(:) : | integer, intent(in)
| ||
| units : | character(*), intent(in), optional
| ||
| xtype : | character(*), intent(in), optional
|
座標の重みデータを設定します.
Set weights of axes.
Alias for 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.
Alias for HistoryAutoAddWeightDouble
| Subroutine : | |||
| dim : | character(*), intent(in)
| ||
| weight(:) : | real, intent(in)
| ||
| units : | character(*), intent(in), optional
| ||
| xtype : | character(*), intent(in), optional
|
座標の重みデータを設定します.
Set weights of axes.
Alias for HistoryAutoAddWeightReal
| Subroutine : |
HistoryAutoCreate で始まったデータ出力の終了処理を行います. プログラムを終了する前に必ずこのサブルーチンを呼んでください.
Terminates data output with "HistoryAutoCreate". Call this subroutine certainly before a progrem is finished.
Alias for 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 .
Alias for HistoryAutoCreate1
| Subroutine : |
時刻を進めます.
時刻は HistoryAutoCreate の delta_time で指定された分 (省略した場合は 1.0) だけ進みます.
HistoryAutoAddVariable はサブルーチンを呼ぶ前に, 使用してください.
一度目に呼んだ際には, 以下の事を行います.
Progress time.
Time is progressed to the extent that specified with "delta_time" of "HistoryAutoCreate" (1.0 when omitting "delta_time").
Use "HistoryAutoAddVariable" before this subroutine is called.
When this subroutine called at first, following things are done.
subroutine HistoryAutoProgress
!
! 時刻を進めます.
!
! 時刻は HistoryAutoCreate の delta_time で指定された分
! (省略した場合は 1.0) だけ進みます.
!
! HistoryAutoAddVariable はサブルーチンを呼ぶ前に,
! 使用してください.
!
! 一度目に呼んだ際には, 以下の事を行います.
!
! * NAMELIST から読み込んだ値に無効なものが存在したかどうかをチェック
! * HistoryAutoAddVariable で登録した変数群を印字
!
!
! Progress time.
!
! Time is progressed to the extent that specified with
! "delta_time" of "HistoryAutoCreate" (1.0 when omitting
! "delta_time").
!
! Use "HistoryAutoAddVariable" before this subroutine is called.
!
! When this subroutine called at first, following things are done.
!
! * Check that invalid values are loaded from NAMELIST or not.
! * Print registered variables by "HistoryAutoAddVariable"
!
use dc_trace, only: BeginSub, EndSub
use dc_error, only: StoreError, DC_NOERR, HST_EBADVARNAME, DC_ENOTINIT
use dc_message, only: MessageNotify
use dc_date, only: operator(*), operator(+)
use dc_string, only: JoinChar
use gt4_history, only: HistoryVarinfoInquire
use gt4_history_nmlinfo, only: HstNmlInfoAllNameValid
implicit none
logical:: allvar_invalid
! 無効な変数名のチェックフラグ.
! Check flag of invalid variable names.
integer, parameter:: names_limit = 100
character(names_limit):: names_invalid
! 無効な変数名.
! Invalid variable names.
character(STRING):: name, units, longname, var_info_str
character(TOKEN), pointer:: dims(:) =>null()
integer:: stat, i
character(STRING):: cause_c
character(*), parameter:: subname = "HistoryAutoProgress"
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
! 無効な変数名のチェック (初回のみ)
! Check invalid variable names (at only first time)
!
if ( Nstep == 0 ) then
call HstNmlInfoAllNameValid( gthstnml = gthstnml, invalid = allvar_invalid, names = names_invalid ) ! (out)
if ( len_trim(names_invalid) > (names_limit - 5) ) then
names_invalid = names_invalid(1:names_limit - 5) // ' ....'
end if
if ( allvar_invalid ) then
stat = HST_EBADVARNAME
cause_c = names_invalid
call MessageNotify( 'W', subname, 'names "%c" from NAMELIST "gt4_historyauto_nml" are invalid.', c1 = trim(names_invalid) )
goto 999
end if
end if
! 登録された変数の印字 (初回のみ)
! Print registered variables (at only first time)
!
if ( Nstep == 0 ) then
call MessageNotify( 'M', sub_sname, '-------------------------------------------' )
call MessageNotify( 'M', sub_sname, '----- Registered variables for output -----' )
call MessageNotify( 'M', sub_sname, '-------------------------------------------' )
do i = 1, numvars
call HistoryVarinfoInquire( varinfo = gthst_vars(i), name = name, dims = dims, longname = longname, units = units ) ! (out) optional
var_info_str = trim( longname ) // ' [' // trim( units ) // '] {' // trim( JoinChar( dims, ',' ) ) // '}'
deallocate( dims )
call MessageNotify( 'M', sub_sname, ' %c (%c)', c1 = trim(name), c2 = trim(var_info_str) )
end do
call MessageNotify( 'M', sub_sname, '-----' )
end if
! 時刻を進める
! Progress time
!
Nstep = Nstep + 1
current_difftime = start_difftime + delta_difftime * Nstep
if ( .not. once_progressed ) once_progressed = .true.
! 出力タイミングのチェックとファイルの作成
! Check output timing and create files
!
call HstVarsOutputCheck
999 continue
call StoreError(stat, subname, cause_c = cause_c)
call EndSub(subname, 'stat=%d', i = (/stat/) )
end subroutine HistoryAutoProgress
| Subroutine : | |||
| varname : | character(*), intent(in)
| ||
| array(:) : | real(DP), intent(in), target
| ||
| err : | logical, intent(out), optional
|
データの出力を行います. このサブルーチンを用いる前に, "HistoryAutoCreate" による初期設定が必要です.
varname は HistoryAutoAddVariable で指定されている必要があります.
HistoryAutoPut は複数のサブルーチンの総称名です. array には 0 〜 7 次元のデータを与えることが可能です. (下記のサブルーチンを参照ください). また, 整数, 単精度実数, 倍精度実数を与えることが可能です. ただし, 0 次元のデータを与える際の引数キーワードは value を用いてください.
Output data. Initialization by "HistoryAutoCreate" is needed before use of this subroutine.
"varname" must be specified by "HistoryAutoAddVariable".
"HistoryAutoPut" is a generic name of multiple subroutines. Then 0 — 7 dimensional data can be given to "array". (See bellow subroutines). And, integer, sinble or double precision can be given. However, if 0 dimensional data is given, use "value" as a keyword argument.
Alias for HistoryAutoPutDouble1
| Subroutine : | |||
| varname : | character(*), intent(in) | ||
| array(:) : | integer, intent(in), target | ||
| err : | logical, intent(out), optional
|
Alias for HistoryAutoPutInt1
| Subroutine : | |||
| varname : | character(*), intent(in) | ||
| array(:) : | real, intent(in), target | ||
| err : | logical, intent(out), optional
|
Alias for HistoryAutoPutReal1
| Subroutine : | |||
| varname : | character(*), intent(in) | ||
| array(:,:) : | integer, intent(in), target | ||
| err : | logical, intent(out), optional
|
Alias for HistoryAutoPutInt2
| Subroutine : | |||
| varname : | character(*), intent(in) | ||
| array(:,:) : | real(DP), intent(in), target | ||
| err : | logical, intent(out), optional
|
Alias for HistoryAutoPutDouble2
| Subroutine : | |||
| varname : | character(*), intent(in) | ||
| array(:,:) : | real, intent(in), target | ||
| err : | logical, intent(out), optional
|
Alias for HistoryAutoPutReal2
| Subroutine : | |||
| varname : | character(*), intent(in) | ||
| array(:,:,:) : | integer, intent(in), target | ||
| err : | logical, intent(out), optional
|
Alias for HistoryAutoPutInt3
| Subroutine : | |||
| varname : | character(*), intent(in) | ||
| array(:,:,:) : | real(DP), intent(in), target | ||
| err : | logical, intent(out), optional
|
Alias for HistoryAutoPutDouble3
| Subroutine : | |||
| varname : | character(*), intent(in) | ||
| array(:,:,:) : | real, intent(in), target | ||
| err : | logical, intent(out), optional
|
Alias for HistoryAutoPutReal3
| Subroutine : | |||
| varname : | character(*), intent(in) | ||
| array(:,:,:,:) : | integer, intent(in), target | ||
| err : | logical, intent(out), optional
|
Alias for HistoryAutoPutInt4
| Subroutine : | |||
| varname : | character(*), intent(in) | ||
| array(:,:,:,:) : | real(DP), intent(in), target | ||
| err : | logical, intent(out), optional
|
Alias for HistoryAutoPutDouble4
| Subroutine : | |||
| varname : | character(*), intent(in) | ||
| array(:,:,:,:) : | real, intent(in), target | ||
| err : | logical, intent(out), optional
|
Alias for HistoryAutoPutReal4
| Subroutine : | |||
| varname : | character(*), intent(in) | ||
| array(:,:,:,:,:) : | integer, intent(in), target | ||
| err : | logical, intent(out), optional
|
Alias for HistoryAutoPutInt5
| Subroutine : | |||
| varname : | character(*), intent(in) | ||
| array(:,:,:,:,:) : | real(DP), intent(in), target | ||
| err : | logical, intent(out), optional
|
Alias for HistoryAutoPutDouble5
| Subroutine : | |||
| varname : | character(*), intent(in) | ||
| array(:,:,:,:,:) : | real, intent(in), target | ||
| err : | logical, intent(out), optional
|
Alias for HistoryAutoPutReal5
| Subroutine : | |||
| varname : | character(*), intent(in) | ||
| array(:,:,:,:,:,:) : | integer, intent(in), target | ||
| err : | logical, intent(out), optional
|
Alias for HistoryAutoPutInt6
| Subroutine : | |||
| varname : | character(*), intent(in) | ||
| array(:,:,:,:,:,:) : | real(DP), intent(in), target | ||
| err : | logical, intent(out), optional
|
Alias for HistoryAutoPutDouble6
| Subroutine : | |||
| varname : | character(*), intent(in) | ||
| array(:,:,:,:,:,:) : | real, intent(in), target | ||
| err : | logical, intent(out), optional
|
Alias for HistoryAutoPutReal6
| Subroutine : | |||
| varname : | character(*), intent(in) | ||
| array(:,:,:,:,:,:,:) : | integer, intent(in), target | ||
| err : | logical, intent(out), optional
|
Alias for HistoryAutoPutInt7
| Subroutine : | |||
| varname : | character(*), intent(in) | ||
| array(:,:,:,:,:,:,:) : | real(DP), intent(in), target | ||
| err : | logical, intent(out), optional
|
Alias for HistoryAutoPutDouble7
| Subroutine : | |||
| varname : | character(*), intent(in) | ||
| array(:,:,:,:,:,:,:) : | real, intent(in), target | ||
| err : | logical, intent(out), optional
|
Alias for HistoryAutoPutReal7
| Subroutine : | |||
| varname : | character(*), intent(in) | ||
| value : | integer, intent(in), target | ||
| err : | logical, intent(out), optional
|
Alias for HistoryAutoPutInt0
| Subroutine : | |||
| varname : | character(*), intent(in) | ||
| value : | real(DP), intent(in), target | ||
| err : | logical, intent(out), optional
|
Alias for HistoryAutoPutDouble0
| Subroutine : | |||
| varname : | character(*), intent(in) | ||
| value : | real, intent(in), target | ||
| err : | logical, intent(out), optional
|
Alias for HistoryAutoPutReal0
| Subroutine : | |||
| dim : | character(*), intent(in)
| ||
| array(:) : | integer, intent(in)
|
座標データを設定します.
Set data of an axis.
Alias for HistoryAutoPutAxisInt
| Subroutine : | |||
| dim : | character(*), intent(in)
| ||
| array(:) : | real(DP), intent(in)
|
座標データを設定します.
Set data of an axis.
Alias for HistoryAutoPutAxisDouble
| Subroutine : | |||
| dim : | character(*), intent(in)
| ||
| array(:) : | real, intent(in)
|
座標データを設定します.
Set data of an axis.
Alias for HistoryAutoPutAxisReal
| Derived Type : | |
| wgt1(:) =>null() : | real(DP), pointer |
| wgt2(:) =>null() : | real(DP), pointer |
| wgt3(:) =>null() : | real(DP), pointer |
| wgt4(:) =>null() : | real(DP), pointer |
| wgt5(:) =>null() : | real(DP), pointer |
| wgt6(:) =>null() : | real(DP), pointer |
| wgt7(:) =>null() : | real(DP), pointer |
座標重み情報管理用の構造型 Derived type for information of axes weight
| Subroutine : | |||
| array(:) : | real(DP), intent(in), target | ||
| space_average(1) : | logical, intent(in) | ||
| weight1(:) : | real(DP), intent(in) | ||
| array_avr(:) : | real(DP), pointer
|
space_average で .true. に指定された次元に対して, array を平均化して array_avr に返します. 平均化には重み weight1 〜 weight7 が用いられます. array_avr の配列の次元そのものは減りません. その代わり, 平均化された次元の配列のサイズは 1 になります.
subroutine AverageReduceDouble1( array, space_average, weight1, array_avr )
!
! space_average で .true. に指定された次元に対して,
! array を平均化して array_avr に返します.
! 平均化には重み weight1 〜 weight7 が用いられます.
! array_avr の配列の次元そのものは減りません. その代わり,
! 平均化された次元の配列のサイズは 1 になります.
!
implicit none
real(DP), intent(in), target:: array(:)
logical, intent(in):: space_average(1)
real(DP), intent(in):: weight1(:)
real(DP), pointer:: array_avr(:) ! (out)
real(DP), pointer:: array_avr_work(:)
real(DP), pointer:: array_avr_work1(:)
integer:: array_shape(1)
integer:: i, dim_size
real(DP):: weight_sum
continue
array_shape = shape( array )
array_avr_work => array
if ( space_average(1) ) then
dim_size = array_shape(1)
array_shape(1) = 1
allocate( array_avr_work1( array_shape(1) ) )
array_avr_work1 = 0.0_DP
weight_sum = 0.0_DP
do i = 1, dim_size
array_avr_work1(1) = array_avr_work1(1) + array_avr_work(i) * weight1(i)
weight_sum = weight_sum + weight1(i)
end do
array_avr_work1 = array_avr_work1 / weight_sum
array_avr_work => array_avr_work1
end if
allocate( array_avr( array_shape(1) ) )
array_avr = array_avr_work
nullify( array_avr_work )
if ( associated( array_avr_work1 ) ) deallocate( array_avr_work1 )
end subroutine AverageReduceDouble1
| Subroutine : | |||
| array(:,:) : | real(DP), intent(in), target | ||
| space_average(2) : | logical, intent(in) | ||
| weight1(:) : | real(DP), intent(in) | ||
| weight2(:) : | real(DP), intent(in) | ||
| array_avr(:,:) : | real(DP), pointer
|
space_average で .true. に指定された次元に対して, array を平均化して array_avr に返します. 平均化には重み weight1 〜 weight7 が用いられます. array_avr の配列の次元そのものは減りません. その代わり, 平均化された次元の配列のサイズは 1 になります.
subroutine AverageReduceDouble2( array, space_average, weight1, weight2, array_avr )
!
! space_average で .true. に指定された次元に対して,
! array を平均化して array_avr に返します.
! 平均化には重み weight1 〜 weight7 が用いられます.
! array_avr の配列の次元そのものは減りません. その代わり,
! 平均化された次元の配列のサイズは 1 になります.
!
implicit none
real(DP), intent(in), target:: array(:,:)
logical, intent(in):: space_average(2)
real(DP), intent(in):: weight1(:)
real(DP), intent(in):: weight2(:)
real(DP), pointer:: array_avr(:,:) ! (out)
real(DP), pointer:: array_avr_work(:,:)
real(DP), pointer:: array_avr_work1(:,:)
real(DP), pointer:: array_avr_work2(:,:)
integer:: array_shape(2)
integer:: i, dim_size
real(DP):: weight_sum
continue
array_shape = shape( array )
array_avr_work => array
if ( space_average(1) ) then
dim_size = array_shape(1)
array_shape(1) = 1
allocate( array_avr_work1( array_shape(1) , array_shape(2) ) )
array_avr_work1 = 0.0_DP
weight_sum = 0.0_DP
do i = 1, dim_size
array_avr_work1(1,:) = array_avr_work1(1,:) + array_avr_work(i,:) * weight1(i)
weight_sum = weight_sum + weight1(i)
end do
array_avr_work1 = array_avr_work1 / weight_sum
array_avr_work => array_avr_work1
end if
if ( space_average(2) ) then
dim_size = array_shape(2)
array_shape(2) = 1
allocate( array_avr_work2( array_shape(1) , array_shape(2) ) )
array_avr_work2 = 0.0_DP
weight_sum = 0.0_DP
do i = 1, dim_size
array_avr_work2(:,1) = array_avr_work2(:,1) + array_avr_work(:,i) * weight2(i)
weight_sum = weight_sum + weight2(i)
end do
array_avr_work2 = array_avr_work2 / weight_sum
array_avr_work => array_avr_work2
end if
allocate( array_avr( array_shape(1) , array_shape(2) ) )
array_avr = array_avr_work
nullify( array_avr_work )
if ( associated( array_avr_work1 ) ) deallocate( array_avr_work1 )
if ( associated( array_avr_work2 ) ) deallocate( array_avr_work2 )
end subroutine AverageReduceDouble2
| Subroutine : | |||
| array(:,:,:) : | real(DP), intent(in), target | ||
| space_average(3) : | logical, intent(in) | ||
| weight1(:) : | real(DP), intent(in) | ||
| weight2(:) : | real(DP), intent(in) | ||
| weight3(:) : | real(DP), intent(in) | ||
| array_avr(:,:,:) : | real(DP), pointer
|
space_average で .true. に指定された次元に対して, array を平均化して array_avr に返します. 平均化には重み weight1 〜 weight7 が用いられます. array_avr の配列の次元そのものは減りません. その代わり, 平均化された次元の配列のサイズは 1 になります.
subroutine AverageReduceDouble3( array, space_average, weight1, weight2, weight3, array_avr )
!
! space_average で .true. に指定された次元に対して,
! array を平均化して array_avr に返します.
! 平均化には重み weight1 〜 weight7 が用いられます.
! array_avr の配列の次元そのものは減りません. その代わり,
! 平均化された次元の配列のサイズは 1 になります.
!
implicit none
real(DP), intent(in), target:: array(:,:,:)
logical, intent(in):: space_average(3)
real(DP), intent(in):: weight1(:)
real(DP), intent(in):: weight2(:)
real(DP), intent(in):: weight3(:)
real(DP), pointer:: array_avr(:,:,:) ! (out)
real(DP), pointer:: array_avr_work(:,:,:)
real(DP), pointer:: array_avr_work1(:,:,:)
real(DP), pointer:: array_avr_work2(:,:,:)
real(DP), pointer:: array_avr_work3(:,:,:)
integer:: array_shape(3)
integer:: i, dim_size
real(DP):: weight_sum
continue
array_shape = shape( array )
array_avr_work => array
if ( space_average(1) ) then
dim_size = array_shape(1)
array_shape(1) = 1
allocate( array_avr_work1( array_shape(1) , array_shape(2) , array_shape(3) ) )
array_avr_work1 = 0.0_DP
weight_sum = 0.0_DP
do i = 1, dim_size
array_avr_work1(1,:,:) = array_avr_work1(1,:,:) + array_avr_work(i,:,:) * weight1(i)
weight_sum = weight_sum + weight1(i)
end do
array_avr_work1 = array_avr_work1 / weight_sum
array_avr_work => array_avr_work1
end if
if ( space_average(2) ) then
dim_size = array_shape(2)
array_shape(2) = 1
allocate( array_avr_work2( array_shape(1) , array_shape(2) , array_shape(3) ) )
array_avr_work2 = 0.0_DP
weight_sum = 0.0_DP
do i = 1, dim_size
array_avr_work2(:,1,:) = array_avr_work2(:,1,:) + array_avr_work(:,i,:) * weight2(i)
weight_sum = weight_sum + weight2(i)
end do
array_avr_work2 = array_avr_work2 / weight_sum
array_avr_work => array_avr_work2
end if
if ( space_average(3) ) then
dim_size = array_shape(3)
array_shape(3) = 1
allocate( array_avr_work3( array_shape(1) , array_shape(2) , array_shape(3) ) )
array_avr_work3 = 0.0_DP
weight_sum = 0.0_DP
do i = 1, dim_size
array_avr_work3(:,:,1) = array_avr_work3(:,:,1) + array_avr_work(:,:,i) * weight3(i)
weight_sum = weight_sum + weight3(i)
end do
array_avr_work3 = array_avr_work3 / weight_sum
array_avr_work => array_avr_work3
end if
allocate( array_avr( array_shape(1) , array_shape(2) , array_shape(3) ) )
array_avr = array_avr_work
nullify( array_avr_work )
if ( associated( array_avr_work1 ) ) deallocate( array_avr_work1 )
if ( associated( array_avr_work2 ) ) deallocate( array_avr_work2 )
if ( associated( array_avr_work3 ) ) deallocate( array_avr_work3 )
end subroutine AverageReduceDouble3
| Subroutine : | |||
| array(:,:,:,:) : | real(DP), intent(in), target | ||
| space_average(4) : | logical, intent(in) | ||
| weight1(:) : | real(DP), intent(in) | ||
| weight2(:) : | real(DP), intent(in) | ||
| weight3(:) : | real(DP), intent(in) | ||
| weight4(:) : | real(DP), intent(in) | ||
| array_avr(:,:,:,:) : | real(DP), pointer
|
space_average で .true. に指定された次元に対して, array を平均化して array_avr に返します. 平均化には重み weight1 〜 weight7 が用いられます. array_avr の配列の次元そのものは減りません. その代わり, 平均化された次元の配列のサイズは 1 になります.
subroutine AverageReduceDouble4( array, space_average, weight1, weight2, weight3, weight4, array_avr )
!
! space_average で .true. に指定された次元に対して,
! array を平均化して array_avr に返します.
! 平均化には重み weight1 〜 weight7 が用いられます.
! array_avr の配列の次元そのものは減りません. その代わり,
! 平均化された次元の配列のサイズは 1 になります.
!
implicit none
real(DP), intent(in), target:: array(:,:,:,:)
logical, intent(in):: space_average(4)
real(DP), intent(in):: weight1(:)
real(DP), intent(in):: weight2(:)
real(DP), intent(in):: weight3(:)
real(DP), intent(in):: weight4(:)
real(DP), pointer:: array_avr(:,:,:,:) ! (out)
real(DP), pointer:: array_avr_work(:,:,:,:)
real(DP), pointer:: array_avr_work1(:,:,:,:)
real(DP), pointer:: array_avr_work2(:,:,:,:)
real(DP), pointer:: array_avr_work3(:,:,:,:)
real(DP), pointer:: array_avr_work4(:,:,:,:)
integer:: array_shape(4)
integer:: i, dim_size
real(DP):: weight_sum
continue
array_shape = shape( array )
array_avr_work => array
if ( space_average(1) ) then
dim_size = array_shape(1)
array_shape(1) = 1
allocate( array_avr_work1( array_shape(1) , array_shape(2) , array_shape(3) , array_shape(4) ) )
array_avr_work1 = 0.0_DP
weight_sum = 0.0_DP
do i = 1, dim_size
array_avr_work1(1,:,:,:) = array_avr_work1(1,:,:,:) + array_avr_work(i,:,:,:) * weight1(i)
weight_sum = weight_sum + weight1(i)
end do
array_avr_work1 = array_avr_work1 / weight_sum
array_avr_work => array_avr_work1
end if
if ( space_average(2) ) then
dim_size = array_shape(2)
array_shape(2) = 1
allocate( array_avr_work2( array_shape(1) , array_shape(2) , array_shape(3) , array_shape(4) ) )
array_avr_work2 = 0.0_DP
weight_sum = 0.0_DP
do i = 1, dim_size
array_avr_work2(:,1,:,:) = array_avr_work2(:,1,:,:) + array_avr_work(:,i,:,:) * weight2(i)
weight_sum = weight_sum + weight2(i)
end do
array_avr_work2 = array_avr_work2 / weight_sum
array_avr_work => array_avr_work2
end if
if ( space_average(3) ) then
dim_size = array_shape(3)
array_shape(3) = 1
allocate( array_avr_work3( array_shape(1) , array_shape(2) , array_shape(3) , array_shape(4) ) )
array_avr_work3 = 0.0_DP
weight_sum = 0.0_DP
do i = 1, dim_size
array_avr_work3(:,:,1,:) = array_avr_work3(:,:,1,:) + array_avr_work(:,:,i,:) * weight3(i)
weight_sum = weight_sum + weight3(i)
end do
array_avr_work3 = array_avr_work3 / weight_sum
array_avr_work => array_avr_work3
end if
if ( space_average(4) ) then
dim_size = array_shape(4)
array_shape(4) = 1
allocate( array_avr_work4( array_shape(1) , array_shape(2) , array_shape(3) , array_shape(4) ) )
array_avr_work4 = 0.0_DP
weight_sum = 0.0_DP
do i = 1, dim_size
array_avr_work4(:,:,:,1) = array_avr_work4(:,:,:,1) + array_avr_work(:,:,:,i) * weight4(i)
weight_sum = weight_sum + weight4(i)
end do
array_avr_work4 = array_avr_work4 / weight_sum
array_avr_work => array_avr_work4
end if
allocate( array_avr( array_shape(1) , array_shape(2) , array_shape(3) , array_shape(4) ) )
array_avr = array_avr_work
nullify( array_avr_work )
if ( associated( array_avr_work1 ) ) deallocate( array_avr_work1 )
if ( associated( array_avr_work2 ) ) deallocate( array_avr_work2 )
if ( associated( array_avr_work3 ) ) deallocate( array_avr_work3 )
if ( associated( array_avr_work4 ) ) deallocate( array_avr_work4 )
end subroutine AverageReduceDouble4
| Subroutine : | |||
| array(:,:,:,:,:) : | real(DP), intent(in), target | ||
| space_average(5) : | logical, intent(in) | ||
| weight1(:) : | real(DP), intent(in) | ||
| weight2(:) : | real(DP), intent(in) | ||
| weight3(:) : | real(DP), intent(in) | ||
| weight4(:) : | real(DP), intent(in) | ||
| weight5(:) : | real(DP), intent(in) | ||
| array_avr(:,:,:,:,:) : | real(DP), pointer
|
space_average で .true. に指定された次元に対して, array を平均化して array_avr に返します. 平均化には重み weight1 〜 weight7 が用いられます. array_avr の配列の次元そのものは減りません. その代わり, 平均化された次元の配列のサイズは 1 になります.
subroutine AverageReduceDouble5( array, space_average, weight1, weight2, weight3, weight4, weight5, array_avr )
!
! space_average で .true. に指定された次元に対して,
! array を平均化して array_avr に返します.
! 平均化には重み weight1 〜 weight7 が用いられます.
! array_avr の配列の次元そのものは減りません. その代わり,
! 平均化された次元の配列のサイズは 1 になります.
!
implicit none
real(DP), intent(in), target:: array(:,:,:,:,:)
logical, intent(in):: space_average(5)
real(DP), intent(in):: weight1(:)
real(DP), intent(in):: weight2(:)
real(DP), intent(in):: weight3(:)
real(DP), intent(in):: weight4(:)
real(DP), intent(in):: weight5(:)
real(DP), pointer:: array_avr(:,:,:,:,:) ! (out)
real(DP), pointer:: array_avr_work(:,:,:,:,:)
real(DP), pointer:: array_avr_work1(:,:,:,:,:)
real(DP), pointer:: array_avr_work2(:,:,:,:,:)
real(DP), pointer:: array_avr_work3(:,:,:,:,:)
real(DP), pointer:: array_avr_work4(:,:,:,:,:)
real(DP), pointer:: array_avr_work5(:,:,:,:,:)
integer:: array_shape(5)
integer:: i, dim_size
real(DP):: weight_sum
continue
array_shape = shape( array )
array_avr_work => array
if ( space_average(1) ) then
dim_size = array_shape(1)
array_shape(1) = 1
allocate( array_avr_work1( array_shape(1) , array_shape(2) , array_shape(3) , array_shape(4) , array_shape(5) ) )
array_avr_work1 = 0.0_DP
weight_sum = 0.0_DP
do i = 1, dim_size
array_avr_work1(1,:,:,:,:) = array_avr_work1(1,:,:,:,:) + array_avr_work(i,:,:,:,:) * weight1(i)
weight_sum = weight_sum + weight1(i)
end do
array_avr_work1 = array_avr_work1 / weight_sum
array_avr_work => array_avr_work1
end if
if ( space_average(2) ) then
dim_size = array_shape(2)
array_shape(2) = 1
allocate( array_avr_work2( array_shape(1) , array_shape(2) , array_shape(3) , array_shape(4) , array_shape(5) ) )
array_avr_work2 = 0.0_DP
weight_sum = 0.0_DP
do i = 1, dim_size
array_avr_work2(:,1,:,:,:) = array_avr_work2(:,1,:,:,:) + array_avr_work(:,i,:,:,:) * weight2(i)
weight_sum = weight_sum + weight2(i)
end do
array_avr_work2 = array_avr_work2 / weight_sum
array_avr_work => array_avr_work2
end if
if ( space_average(3) ) then
dim_size = array_shape(3)
array_shape(3) = 1
allocate( array_avr_work3( array_shape(1) , array_shape(2) , array_shape(3) , array_shape(4) , array_shape(5) ) )
array_avr_work3 = 0.0_DP
weight_sum = 0.0_DP
do i = 1, dim_size
array_avr_work3(:,:,1,:,:) = array_avr_work3(:,:,1,:,:) + array_avr_work(:,:,i,:,:) * weight3(i)
weight_sum = weight_sum + weight3(i)
end do
array_avr_work3 = array_avr_work3 / weight_sum
array_avr_work => array_avr_work3
end if
if ( space_average(4) ) then
dim_size = array_shape(4)
array_shape(4) = 1
allocate( array_avr_work4( array_shape(1) , array_shape(2) , array_shape(3) , array_shape(4) , array_shape(5) ) )
array_avr_work4 = 0.0_DP
weight_sum = 0.0_DP
do i = 1, dim_size
array_avr_work4(:,:,:,1,:) = array_avr_work4(:,:,:,1,:) + array_avr_work(:,:,:,i,:) * weight4(i)
weight_sum = weight_sum + weight4(i)
end do
array_avr_work4 = array_avr_work4 / weight_sum
array_avr_work => array_avr_work4
end if