historyautoallvarfix.f90 File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine historyautoallvarfix
 

Function/Subroutine Documentation

◆ historyautoallvarfix()

subroutine historyautoallvarfix ( )

Definition at line 11 of file historyautoallvarfix.f90.

References dc_trace::beginsub(), dc_error::dc_enotinit, dc_error::dc_noerr, dc_types::dp, dc_trace::endsub(), gtool_historyauto_internal::flag_allvarfixed, gtool_historyauto_internal::gthst_vars, gtool_historyauto_internal::gthstnml, dc_error::hst_ebadvarname, gtool_historyauto_internal::initialized, dc_string::joinchar(), gtool_historyauto_internal::numdims, gtool_historyauto_internal::numvars, gtool_historyauto_internal::save_mpi_gather, dc_error::storeerror(), dc_types::string, gtool_historyauto_internal::sub_sname, and dc_types::token.

11  !
12  ! このサブルーチンは以下の動作を行います.
13  !
14  ! * NAMELIST から読み込んだ変数名に無効なものが存在したかどうかをチェック.
15  ! * HistoryAutoAddVariable で登録した変数名を印字.
16  !
17  ! このサブルーチンを呼んだ後に HistoryAutoAddVariable を呼ぶと
18  ! エラーを生じます.
19  !
20  ! This subroutine performs following acts.
21  !
22  ! * Check that invalid variable names are loaded from NAMELIST or not.
23  ! * Print registered variable names by "HistoryAutoAddVariable".
24  !
25  ! If "HistoryAutoAddVariable" is called after this subroutine is called,
26  ! an error is occurred.
27  !
32  use dc_trace, only: beginsub, endsub
34  use dc_message, only: messagenotify
35  use dc_date, only: operator(*), operator(+)
36  use dc_string, only: joinchar
37  use dc_types, only: dp, string, token
38 
39  implicit none
40  logical:: allvar_invalid
41  ! 無効な変数名のチェックフラグ.
42  ! Check flag of invalid variable names.
43 
44  integer, parameter:: names_limit = 100
45  character(names_limit):: names_invalid
46  ! 無効な変数名.
47  ! Invalid variable names.
48 
49  character(STRING):: name, units, longname, var_info_str
50  character(TOKEN), pointer:: dims(:) =>null()
51  integer:: msnot_rank
52  integer:: stat, i
53  character(STRING):: cause_c
54  character(*), parameter:: subname = "HistoryAutoAllVarFix"
55  continue
56  call beginsub(subname)
57  stat = dc_noerr
58  cause_c = ""
59 
60  ! 初期設定チェック
61  ! Check initialization
62  !
63  if ( .not. initialized ) then
64  stat = dc_enotinit
65  cause_c = 'gtool_historyauto'
66  goto 999
67  end if
68 
69  ! 既に確定後であれば何もせずに終了.
70  ! Nothing is done after fixed
71  !
72  if ( flag_allvarfixed ) goto 999
73 
74 
75  ! 無効な変数名のチェック (初回のみ)
76  ! Check invalid variable names (at only first time)
77  !
79  & gthstnml = gthstnml, & ! (inout)
80  & invalid = allvar_invalid, names = names_invalid ) ! (out)
81 
82  if ( len_trim(names_invalid) > (names_limit - 5) ) then
83  names_invalid = names_invalid(1:names_limit - 5) // ' ....'
84  end if
85 
86  if ( allvar_invalid ) then
87  stat = hst_ebadvarname
88  cause_c = names_invalid
89  call messagenotify( 'W', subname, &
90  & 'names "%c" from NAMELIST "gtool_historyauto_nml" are invalid.', &
91  & c1 = trim(names_invalid) )
92  goto 999
93  end if
94 
95  ! 登録された変数の印字 (初回のみ)
96  ! Print registered variables (at only first time)
97  !
98  msnot_rank = -1
99  if ( save_mpi_gather ) msnot_rank = 0
100  call messagenotify( 'M', sub_sname, '-------------------------------------------', rank_mpi = msnot_rank )
101  call messagenotify( 'M', sub_sname, '----- Registered variables for output -----', rank_mpi = msnot_rank )
102  call messagenotify( 'M', sub_sname, '-------------------------------------------', rank_mpi = msnot_rank )
103 
104  do i = 1, numvars
105  call historyvarinfoinquire( &
106  & varinfo = gthst_vars(i), & ! (in)
107  & name = name, & ! (out) optional
108  & dims = dims, & ! (out) optional
109  & longname = longname, & ! (out) optional
110  & units = units ) ! (out) optional
111 
112  var_info_str = trim( longname ) // ' [' // &
113  & trim( units ) // '] {' // &
114  & trim( joinchar( dims, ',' ) ) // '}'
115  deallocate( dims )
116 
117  call messagenotify( 'M', sub_sname, ' %c (%c)', &
118  & c1 = trim(name), c2 = trim(var_info_str), rank_mpi = msnot_rank )
119 
120  end do
121  call messagenotify( 'M', sub_sname, '-----', rank_mpi = msnot_rank )
122 
123  ! フラグの設定
124  ! Set a flag
125  !
126  if ( .not. flag_allvarfixed ) flag_allvarfixed = .true.
127 
128 999 continue
129  call storeerror(stat, subname, cause_c = cause_c)
130  call endsub(subname, 'stat=%d', i = (/stat/) )
integer, parameter, public dc_enotinit
Definition: dc_error.f90:557
integer, parameter, public token
単語やキーワードを保持する文字型変数の種別型パラメタ
Definition: dc_types.f90:109
type(gt_history_varinfo), dimension(1:max_vars), save, public gthst_vars
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition: dc_error.f90:830
integer, parameter, public dc_noerr
Definition: dc_error.f90:509
integer, parameter, public hst_ebadvarname
Definition: dc_error.f90:587
character(string) function, public joinchar(carray, expr)
Definition: dc_string.f90:861
integer, parameter, public dp
倍精度実数型変数
Definition: dc_types.f90:83
subroutine, public beginsub(name, fmt, i, r, d, L, n, c1, c2, c3, ca, version)
Definition: dc_trace.f90:351
文字型変数の操作.
Definition: dc_string.f90:24
種別型パラメタを提供します。
Definition: dc_types.f90:49
type(gthst_nmlinfo), save, public gthstnml
subroutine, public endsub(name, fmt, i, r, d, L, n, c1, c2, c3, ca)
Definition: dc_trace.f90:446
character(*), parameter, public sub_sname
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ
Definition: dc_types.f90:118
Here is the call graph for this function: