\hypertarget{historyaddvariable_8f90}{}\section{gtool/gtool\+\_\+history/historyaddvariable.f90 File Reference}
\label{historyaddvariable_8f90}\index{gtool/gtool\+\_\+history/historyaddvariable.\+f90@{gtool/gtool\+\_\+history/historyaddvariable.\+f90}}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
recursive subroutine \hyperlink{historyaddvariable_8f90_acf0d7af06caeec679cca4c099b53f6cd}{historyaddvariable1} (varname, dims, longname, units, xtype, time\+\_\+average, average, history, err)
\item 
subroutine \hyperlink{historyaddvariable_8f90_a59e160540a64fe551ec3ecb5a829bdf3}{historyaddvariable2} (varinfo, history, err)
\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{historyaddvariable_8f90_acf0d7af06caeec679cca4c099b53f6cd}\label{historyaddvariable_8f90_acf0d7af06caeec679cca4c099b53f6cd}} 
\index{historyaddvariable.\+f90@{historyaddvariable.\+f90}!historyaddvariable1@{historyaddvariable1}}
\index{historyaddvariable1@{historyaddvariable1}!historyaddvariable.\+f90@{historyaddvariable.\+f90}}
\subsubsection{\texorpdfstring{historyaddvariable1()}{historyaddvariable1()}}
{\footnotesize\ttfamily recursive subroutine historyaddvariable1 (\begin{DoxyParamCaption}\item[{character(len = $\ast$), intent(in)}]{varname,  }\item[{character(len = $\ast$), dimension(\+:), intent(in)}]{dims,  }\item[{character(len = $\ast$), intent(in)}]{longname,  }\item[{character(len = $\ast$), intent(in)}]{units,  }\item[{character(len = $\ast$), intent(in), optional}]{xtype,  }\item[{logical, intent(in), optional}]{time\+\_\+average,  }\item[{logical, intent(in), optional}]{average,  }\item[{type(gt\+\_\+history), intent(inout), optional, target}]{history,  }\item[{logical, intent(out), optional}]{err }\end{DoxyParamCaption})}



Definition at line 13 of file historyaddvariable.\+f90.



References dc\+\_\+trace\+::beginsub(), dc\+\_\+trace\+::dbgmessage(), dc\+\_\+error\+::dc\+\_\+enotinit, dc\+\_\+error\+::dc\+\_\+noerr, gtool\+\_\+history\+\_\+internal\+::default, dc\+\_\+types\+::dp, dc\+\_\+trace\+::endsub(), dc\+\_\+url\+::gt\+\_\+atmark, dc\+\_\+error\+::hst\+\_\+empinoaxisdata, dc\+\_\+error\+::hst\+\_\+enodependtime, dc\+\_\+string\+::joinchar(), dc\+\_\+present\+::present\+\_\+and\+\_\+true(), dc\+\_\+error\+::storeerror(), dc\+\_\+types\+::string, and dc\+\_\+types\+::token.


\begin{DoxyCode}
13     \textcolor{comment}{!}
14     \textcolor{comment}{!== 変数定義}
15     \textcolor{comment}{!}
16     \textcolor{comment}{! gtool4 データ内の変数の定義を行います。このサブルーチンを}
17     \textcolor{comment}{! 用いる前に、 HistoryCreate による初期設定が必要です。}
18     \textcolor{comment}{!}
19     \textcolor{comment}{! 既に gtool4 データが存在し、そのデータ内の変数と全く同じ}
20     \textcolor{comment}{! 構造の変数を定義したい場合は HistoryCopyVariable を利用すると便利です。}
21     \textcolor{comment}{!}
22     \textcolor{comment}{! *HistoryAddVariable* というサブルーチン名は 2 つの別々の}
23     \textcolor{comment}{! サブルーチンの総称名です。上記のサブルーチンも参照ください。}
24     \textcolor{comment}{!}
25     \textcolor{comment}{!=== 時間平均について}
26     \textcolor{comment}{!}
27     \textcolor{comment}{! gtool\_history を用いた出力では、以下の条件を満たす場合に出力データを}
28     \textcolor{comment}{! 時間方向に平均化して出力します。}
29     \textcolor{comment}{!}
30     \textcolor{comment}{! * HistoryAddVariable の引数 *time\_average* に .true. を与えている。}
31     \textcolor{comment}{! * HistoryPut に時刻を示す引数 *time* (単精度実数型)、}
32     \textcolor{comment}{!   *timed* (倍精度実数型)、*difftime* (dc\_date\_types#DC\_DIFFTIME)}
33     \textcolor{comment}{!   のいづれかを与えている。}
34     \textcolor{comment}{!}
35     \textcolor{comment}{! HistoryPut に与えられたデータは gtool\_history モジュール内部}
36     \textcolor{comment}{! にいったん保管され、HistoryCreate の引数 *interval* の間隔を}
37     \textcolor{comment}{! おいて出力が行われます。平均化は出力時から次の出力時の間の}
38     \textcolor{comment}{! データを用いて行われます。時間間隔が一定でない場合、}
39     \textcolor{comment}{! 重み付けをして出力されます。重み付けは以下のように行われます。}
40     \textcolor{comment}{!}
41     \textcolor{comment}{!   sum( <data> * <weight> ) / sum ( <weight> )}
42     \textcolor{comment}{!}
43     \textcolor{comment}{! <data>   :: *array* または *value* に与えられたデータ}
44     \textcolor{comment}{! <weight> :: 前回 HistoryPut が呼ばれた際の時刻と今回の時刻との差}
45     \textcolor{comment}{! sum      :: 前回出力が行われた時刻から *interval* 経過するまでの値の和}
46     \textcolor{comment}{!}
47     \textcolor{keywordtype}{use }\hyperlink{namespacegtool__history__types}{gtool\_history\_types}\textcolor{keywordtype}{, only}: \hyperlink{structgtool__history__types_1_1gt__history}{gt\_history}, &
48       & \hyperlink{structgtool__history__types_1_1gt__history__axis}{gt\_history\_axis}, \hyperlink{structgtool__history__types_1_1gt__history__varinfo}{gt\_history\_varinfo}, 
      \hyperlink{structgtool__history__types_1_1gt__history__attr}{gt\_history\_attr}, &
49       & \hyperlink{structgtool__history__types_1_1gt__history__avrdata}{gt\_history\_avrdata}, \hyperlink{structgtool__history__types_1_1gt__history__mpivarindex}{gt\_history\_mpivarindex}
50     \textcolor{keywordtype}{use }\hyperlink{namespacegtool__history__internal}{gtool\_history\_internal}\textcolor{keywordtype}{, only}: \hyperlink{namespacegtool__history__internal_aa7fc82d2ca1961a254be1acb599afbb1}{default}, 
      \hyperlink{interfacegtool__history__internal_1_1lookup__dimension}{lookup\_dimension}
51     \textcolor{keywordtype}{use }\hyperlink{namespacegtool__history__generic}{gtool\_history\_generic}\textcolor{keywordtype}{, only}: \hyperlink{interfacegtool__history__generic_1_1historyaddvariable}{historyaddvariable}, 
      \hyperlink{interfacegtool__history__generic_1_1historyvarinfocreate}{historyvarinfocreate}
52     \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__generic}{gtdata\_generic}\textcolor{keywordtype}{, only}: \hyperlink{interfacegtdata__generic_1_1inquire}{inquire}, \hyperlink{interfacegtdata__generic_1_1create}{create}, \hyperlink{interfacegtdata__generic_1_1slice}{slice}, 
      \hyperlink{interfacegtdata__generic_1_1put__attr}{put\_attr}, &
53       & \hyperlink{interfacegtdata__generic_1_1put}{put}, \hyperlink{interfacegtdata__generic_1_1putline}{putline}
54     \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__types}{gtdata\_types}\textcolor{keywordtype}{, only}: \hyperlink{structgtdata__types_1_1gt__variable}{gt\_variable}
55     \textcolor{keywordtype}{use }netcdf\textcolor{keywordtype}{, only}: nf90\_ebaddim
56     \textcolor{keywordtype}{use }\hyperlink{namespacedc__error}{dc\_error}\textcolor{keywordtype}{, only}: \hyperlink{namespacedc__error_a0104aee83ee5752b1a9f6152b11864a8}{storeerror}, \hyperlink{namespacedc__error_a64841a3c9e3ef7d5ddb175e5770f7dfe}{dc\_noerr}, 
      \hyperlink{namespacedc__error_a31f1081213c338a4f6a6e5acdfe4a8a8}{dc\_enotinit}, \hyperlink{namespacedc__error_a9f376cdc0f575d61de0c36b9f6ca47a9}{hst\_enodependtime}, &
57       & \hyperlink{namespacedc__error_ac9383c449e0a61a04a809199b7fe284b}{hst\_empinoaxisdata}
58     \textcolor{keywordtype}{use }\hyperlink{namespacedc__string}{dc\_string}\textcolor{keywordtype}{, only}: \hyperlink{interfacedc__string_1_1cprintf}{cprintf}, \hyperlink{namespacedc__string_a20412554f8f648165d202319119cf628}{joinchar}, \hyperlink{interfacedc__string_1_1stoa}{stoa}
59     \textcolor{keywordtype}{use }\hyperlink{namespacedc__url}{dc\_url}\textcolor{keywordtype}{, only}: \hyperlink{namespacedc__url_a3157f15c35d09732b55dfb0f4f52397d}{gt\_atmark}, \hyperlink{interfacedc__url_1_1urlresolve}{urlresolve}
60     \textcolor{keywordtype}{use }\hyperlink{namespacedc__present}{dc\_present}\textcolor{keywordtype}{, only}: \hyperlink{namespacedc__present_ab280582985ee69fda00e2a0bf09194af}{present\_and\_true}
61     \textcolor{keywordtype}{use }\hyperlink{namespacedc__types}{dc\_types}\textcolor{keywordtype}{, only}: \hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}
62     \textcolor{keywordtype}{use }\hyperlink{namespacedc__date}{dc\_date}\textcolor{keywordtype}{, only}: \hyperlink{interfacedc__date__generic_1_1dcdifftimecreate}{dcdifftimecreate}
63     \textcolor{keywordtype}{use }\hyperlink{namespacedc__date__types}{dc\_date\_types}\textcolor{keywordtype}{, only}: \hyperlink{structdc__date__types_1_1dc__difftime}{dc\_difftime}
64     \textcolor{keywordtype}{use }\hyperlink{namespacedc__message}{dc\_message}\textcolor{keywordtype}{, only}: \hyperlink{interfacedc__message_1_1messagenotify}{messagenotify}
65     \textcolor{keywordtype}{use }\hyperlink{namespacedc__trace}{dc\_trace}\textcolor{keywordtype}{, only}: \hyperlink{namespacedc__trace_aca1efe8bae50b85f74980a8c4d704dd8}{beginsub}, \hyperlink{namespacedc__trace_ae44de97565a3bdd685789c7748b37e37}{endsub}, \hyperlink{namespacedc__trace_a2a38fceb4cf9baf298d63456238c3fea}{dbgmessage}
66     \textcolor{keywordtype}{use }\hyperlink{namespacedc__types}{dc\_types}\textcolor{keywordtype}{, only}: \hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}, \hyperlink{namespacedc__types_a6d28eb015ba84292a06f4ff25165b376}{token}, \hyperlink{namespacedc__types_ac74a34430fcd3d0eb2344f19d536c086}{dp}
67     \textcolor{keywordtype}{implicit none}
68     \textcolor{keywordtype}{character(len = *)}, \textcolor{keywordtype}{intent(in)}:: varname
69                               \textcolor{comment}{! 定義する変数の名前}
70                               \textcolor{comment}{!}
71                               \textcolor{comment}{! 最大文字数は dc\_type#TOKEN}
72                               \textcolor{comment}{!}
73     \textcolor{keywordtype}{character(len = *)}, \textcolor{keywordtype}{intent(in)}:: dims(:)
74                               \textcolor{comment}{! 変数が依存する次元の名前}
75                               \textcolor{comment}{!}
76                               \textcolor{comment}{! 時間の次元は配列の最後に指定}
77                               \textcolor{comment}{! しなければならない。}
78                               \textcolor{comment}{! ここで指定するものは、}
79                               \textcolor{comment}{! HistoryCreate にて dims で指定}
80                               \textcolor{comment}{! されていなければならない。}
81                               \textcolor{comment}{!}
82                               \textcolor{comment}{! もしもスカラー変数を作成}
83                               \textcolor{comment}{! する場合には, サイズが 1 で}
84                               \textcolor{comment}{! 中身が空の文字型配列,}
85                               \textcolor{comment}{! すなわち <tt> (/''/) </tt>}
86                               \textcolor{comment}{! を与えること.}
87                               \textcolor{comment}{!}
88     \textcolor{keywordtype}{character(len = *)}, \textcolor{keywordtype}{intent(in)}:: longname
89                               \textcolor{comment}{! 変数の記述的名称}
90                               \textcolor{comment}{!}
91                               \textcolor{comment}{! 最大文字数は dc\_types#STRING}
92                               \textcolor{comment}{!}
93     \textcolor{keywordtype}{character(len = *)}, \textcolor{keywordtype}{intent(in)}:: \hyperlink{structdc__units_1_1units}{units}
94                               \textcolor{comment}{! 変数の単位}
95                               \textcolor{comment}{!}
96                               \textcolor{comment}{! 最大文字数は dc\_types#STRING}
97                               \textcolor{comment}{!}
98     \textcolor{keywordtype}{character(len = *)}, \textcolor{keywordtype}{intent(in)}, \textcolor{keywordtype}{optional}:: xtype
99                               \textcolor{comment}{! 変数のデータ型}
100                               \textcolor{comment}{!}
101                               \textcolor{comment}{! デフォルトはfloat (単精度実数型)}
102                               \textcolor{comment}{! である。 有効なのは、}
103                               \textcolor{comment}{! double (倍精度実数型)、 int}
104                               \textcolor{comment}{! (整数型)、char (文字型)である。}
105                               \textcolor{comment}{! 指定しない場合や、無効な型を指定した}
106                               \textcolor{comment}{! 場合には、 float (単精度実数型)}
107                               \textcolor{comment}{! となる。}
108                               \textcolor{comment}{!}
109     \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(in)}, \textcolor{keywordtype}{optional}:: time\_average
110                               \textcolor{comment}{! 出力データを時間平均する場合には}
111                               \textcolor{comment}{! .true. を与えます。}
112                               \textcolor{comment}{! デフォルトは .false. です。}
113                               \textcolor{comment}{!}
114                               \textcolor{comment}{! If output data is averaged in time direction,}
115                               \textcolor{comment}{! specify ".true.".}
116                               \textcolor{comment}{! Default is ".false.".}
117                               \textcolor{comment}{!}
118     \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(in)}, \textcolor{keywordtype}{optional}:: average
119                               \textcolor{comment}{! time\_average の旧版.}
120                               \textcolor{comment}{! Old version of "time\_average"}
121     \textcolor{keywordtype}{type}(\hyperlink{structgtool__history__types_1_1gt__history}{gt\_history}), \textcolor{keywordtype}{intent(inout)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{target}:: history
122                               \textcolor{comment}{! 出力ファイルの設定に関する情報を}
123                               \textcolor{comment}{! 格納した構造体}
124                               \textcolor{comment}{!}
125                               \textcolor{comment}{! ここに指定するものは、}
126                               \textcolor{comment}{! HistoryCreate によって初期設定}
127                               \textcolor{comment}{! されていなければなりません。}
128                               \textcolor{comment}{!}
129     \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(out)}, \textcolor{keywordtype}{optional}:: err
130                               \textcolor{comment}{! 例外処理用フラグ.}
131                               \textcolor{comment}{! デフォルトでは, この手続き内でエラーが}
132                               \textcolor{comment}{! 生じた場合, プログラムは強制終了します.}
133                               \textcolor{comment}{! 引数 *err* が与えられる場合,}
134                               \textcolor{comment}{! プログラムは強制終了せず, 代わりに}
135                               \textcolor{comment}{! *err* に .true. が代入されます.}
136                               \textcolor{comment}{!}
137                               \textcolor{comment}{! Exception handling flag.}
138                               \textcolor{comment}{! By default, when error occur in}
139                               \textcolor{comment}{! this procedure, the program aborts.}
140                               \textcolor{comment}{! If this *err* argument is given,}
141                               \textcolor{comment}{! .true. is substituted to *err* and}
142                               \textcolor{comment}{! the program does not abort.}
143     \textcolor{keywordtype}{type}(\hyperlink{structgtool__history__types_1_1gt__history}{gt\_history}), \textcolor{keywordtype}{pointer}:: hst =>null()
144     \textcolor{keywordtype}{type}(\hyperlink{structgtdata__types_1_1gt__variable}{gt\_variable}), \textcolor{keywordtype}{pointer}:: vwork(:) =>null(), dimvars(:) =>null()
145     \textcolor{keywordtype}{character(STRING)}:: fullname, url, cause\_c
146     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{pointer}:: count\_work(:) =>null()
147     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{pointer}:: var\_avr\_count\_work(:) =>null()
148     \textcolor{keywordtype}{integer}:: var\_avr\_length
149     \textcolor{keywordtype}{type}(\hyperlink{structgtool__history__types_1_1gt__history__avrdata}{gt\_history\_avrdata}), \textcolor{keywordtype}{pointer}:: var\_avr\_data\_work(:) =>null()
150     \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{pointer}:: var\_avr\_firstput\_work(:) =>null()
151     \textcolor{keywordtype}{real(DP)}, \textcolor{keywordtype}{pointer}:: var\_avr\_coefsum\_work(:) =>null()
152     \textcolor{keywordtype}{real(DP)}, \textcolor{keywordtype}{pointer}:: var\_avr\_baseint\_work(:) =>null()
153     \textcolor{keywordtype}{real(DP)}, \textcolor{keywordtype}{pointer}:: var\_avr\_prevtime\_work(:) =>null()
154 \textcolor{comment}{!!$    type(DC\_DIFFTIME), pointer:: var\_avr\_baseint\_work(:) =>null()}
155 \textcolor{comment}{!!$    type(DC\_DIFFTIME), pointer:: var\_avr\_prevtime\_work(:) =>null()}
156     \textcolor{keywordtype}{character(STRING)}:: time\_name, time\_xtype, time\_url
157     \textcolor{keywordtype}{type}(\hyperlink{structgtdata__types_1_1gt__variable}{gt\_variable}), \textcolor{keywordtype}{pointer}:: dimvars\_work(:) =>null()
158     \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{pointer}:: dim\_value\_written\_work(:) =>null()
159     \textcolor{keywordtype}{integer}:: dimvars\_size
160     \textcolor{keywordtype}{logical}:: nv\_exist, bnds\_exist
161     \textcolor{keywordtype}{character(STRING)}:: nv\_name\_check, bnds\_name\_check
162     \textcolor{keywordtype}{character(*)}, \textcolor{keywordtype}{parameter}:: nv\_suffix = \textcolor{stringliteral}{'\_nv'}
163     \textcolor{keywordtype}{character(*)}, \textcolor{keywordtype}{parameter}:: bnds\_suffix = \textcolor{stringliteral}{'\_bnds'}
164     \textcolor{keywordtype}{type}(\hyperlink{structgtdata__types_1_1gt__variable}{gt\_variable}), \textcolor{keywordtype}{pointer}:: timevar
165     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{pointer}:: dimord(:) =>null()
166     \textcolor{keywordtype}{integer}:: nvars, numdims, i, stat
167     \textcolor{keywordtype}{character(*)}, \textcolor{keywordtype}{parameter}:: subname = \textcolor{stringliteral}{"HistoryAddVariable1"}
168   \textcolor{keywordflow}{continue}
169     \textcolor{keyword}{call }\hyperlink{namespacedc__trace_aca1efe8bae50b85f74980a8c4d704dd8}{beginsub}(subname, \textcolor{stringliteral}{'name=<%a>, dims=<%a>, longname=<%a>, units=<%a>'}, &
170       & ca=\hyperlink{interfacedc__string_1_1stoa}{stoa}(varname, \hyperlink{namespacedc__string_a20412554f8f648165d202319119cf628}{joinchar}(dims), longname, \hyperlink{structdc__units_1_1units}{units}))
171     stat = \hyperlink{namespacedc__error_a64841a3c9e3ef7d5ddb175e5770f7dfe}{dc\_noerr}
172     cause\_c = \textcolor{stringliteral}{''}
173     \textcolor{comment}{! 操作対象決定}
174     \textcolor{comment}{!}
175     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(history)) \textcolor{keywordflow}{then}
176       hst => history
177     \textcolor{keywordflow}{else}
178       hst => \hyperlink{namespacegtool__history__internal_aa7fc82d2ca1961a254be1acb599afbb1}{default}
179 \textcolor{keywordflow}{    endif}
180     \textcolor{comment}{! 初期設定のチェック}
181     \textcolor{comment}{! Check initialization}
182     \textcolor{comment}{!}
183     \textcolor{keywordflow}{if} ( .not. hst % initialized ) \textcolor{keywordflow}{then}
184       stat = \hyperlink{namespacedc__error_a31f1081213c338a4f6a6e5acdfe4a8a8}{dc\_enotinit}
185       cause\_c = \textcolor{stringliteral}{'GT\_HISTORY'}
186       \textcolor{keywordflow}{goto} 999
187 \textcolor{keywordflow}{    end if}
188     \textcolor{comment}{! 変数表拡張}
189     \textcolor{comment}{!}
190     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(hst % vars)) \textcolor{keywordflow}{then}
191       nvars = \textcolor{keyword}{size}(hst % vars(:))
192       vwork => hst % vars
193       count\_work => hst % count
194       \textcolor{keyword}{nullify}(hst % vars, hst % count)
195       \textcolor{keyword}{allocate}(hst % vars(nvars + 1), hst % count(nvars + 1))
196       hst % vars(1:nvars) = vwork(1:nvars)
197       hst % count(1:nvars) = count\_work(1:nvars)
198       \textcolor{keyword}{deallocate}(vwork, count\_work)
199       count\_work => hst % growable\_indices
200       \textcolor{keyword}{nullify}(hst % growable\_indices)
201       \textcolor{keyword}{allocate}(hst % growable\_indices(nvars + 1))
202       hst % growable\_indices(1:nvars) = count\_work(1:nvars)
203       \textcolor{keyword}{deallocate}(count\_work)
204       \textcolor{comment}{! 平均値出力のための変数表コピー}
205       \textcolor{comment}{! Copy table of variables for average value output}
206       \textcolor{comment}{!}
207       var\_avr\_count\_work => hst % var\_avr\_count
208       \textcolor{keyword}{nullify}( hst % var\_avr\_count )
209       \textcolor{keyword}{allocate}( hst % var\_avr\_count(nvars + 1) )
210       hst % var\_avr\_count(1:nvars) = var\_avr\_count\_work(1:nvars)
211       \textcolor{keyword}{deallocate}( var\_avr\_count\_work )
212       var\_avr\_data\_work => hst % var\_avr\_data
213       \textcolor{keyword}{nullify}(hst % var\_avr\_data)
214       \textcolor{keyword}{allocate}(hst % var\_avr\_data(nvars + 1))
215       \textcolor{keywordflow}{do} i = 1, nvars
216         hst % var\_avr\_data(i) % length = var\_avr\_data\_work(i) % length
217         \textcolor{keyword}{allocate}(hst % var\_avr\_data(i) % &
218           & a\_dataavr(var\_avr\_data\_work(i) % length))
219         hst % var\_avr\_data(i) % a\_DataAvr = var\_avr\_data\_work(i) % a\_DataAvr
220         \textcolor{keyword}{deallocate}( var\_avr\_data\_work(i) % a\_DataAvr )
221 \textcolor{keywordflow}{      end do}
222       \textcolor{keyword}{deallocate}( var\_avr\_data\_work )
223       var\_avr\_firstput\_work => hst % var\_avr\_firstput
224       \textcolor{keyword}{nullify}( hst % var\_avr\_firstput )
225       \textcolor{keyword}{allocate}( hst % var\_avr\_firstput(nvars + 1) )
226       hst % var\_avr\_firstput(1:nvars) = var\_avr\_firstput\_work(1:nvars)
227       \textcolor{keyword}{deallocate}( var\_avr\_firstput\_work )
228       var\_avr\_coefsum\_work => hst % var\_avr\_coefsum
229       \textcolor{keyword}{nullify}( hst % var\_avr\_coefsum )
230       \textcolor{keyword}{allocate}( hst % var\_avr\_coefsum(nvars + 1) )
231       hst % var\_avr\_coefsum(1:nvars) = var\_avr\_coefsum\_work(1:nvars)
232       \textcolor{keyword}{deallocate}( var\_avr\_coefsum\_work )
233       var\_avr\_baseint\_work => hst % var\_avr\_baseint
234       \textcolor{keyword}{nullify}( hst % var\_avr\_baseint )
235       \textcolor{keyword}{allocate}( hst % var\_avr\_baseint(nvars + 1) )
236       hst % var\_avr\_baseint(1:nvars) = var\_avr\_baseint\_work(1:nvars)
237       \textcolor{keyword}{deallocate}( var\_avr\_baseint\_work )
238       var\_avr\_prevtime\_work => hst % var\_avr\_prevtime
239       \textcolor{keyword}{nullify}( hst % var\_avr\_prevtime )
240       \textcolor{keyword}{allocate}( hst % var\_avr\_prevtime(nvars + 1) )
241       hst % var\_avr\_prevtime(1:nvars) = var\_avr\_prevtime\_work(1:nvars)
242       \textcolor{keyword}{deallocate}( var\_avr\_prevtime\_work )
243     \textcolor{keywordflow}{else}
244       \textcolor{comment}{! トリッキーだが, ここで count だけ 2 要素確保するのは,}
245       \textcolor{comment}{! HistorySetTime による巻き戻しに備えるため.}
246       \textcolor{comment}{!}
247       \textcolor{keyword}{allocate}(hst % vars(1), hst % count(2), hst % growable\_indices(1))
248       hst % count(2) = 0
249       \textcolor{keyword}{allocate}(hst % var\_avr\_count(1), hst % var\_avr\_data(1))
250       \textcolor{keyword}{allocate}(hst % var\_avr\_firstput(1), hst % var\_avr\_coefsum(1))
251       \textcolor{keyword}{allocate}(hst % var\_avr\_baseint(1), hst % var\_avr\_prevtime(1))
252 \textcolor{keywordflow}{    endif}
253     nvars = \textcolor{keyword}{size}(hst % vars(:))
254     hst % growable\_indices(nvars) = 0
255     \textcolor{keywordflow}{if} ( nvars < 2 ) \textcolor{keywordflow}{then}
256       hst % count(nvars) = 0
257     \textcolor{keywordflow}{else}
258       hst % count(nvars) = hst % count(1)
259 \textcolor{keywordflow}{    end if}
260     \textcolor{comment}{! スカラー変数作成への対応}
261     \textcolor{comment}{!}
262     \textcolor{keywordflow}{if} (\textcolor{keyword}{size}(dims) == 1 .and. trim(dims(1)) == \textcolor{stringliteral}{''}) \textcolor{keywordflow}{then}
263       numdims = 0
264     \textcolor{keywordflow}{else}
265       numdims = \textcolor{keyword}{size}(dims)
266 \textcolor{keywordflow}{    end if}
267     \textcolor{keyword}{allocate}( dimvars(numdims) )
268     \textcolor{keyword}{allocate}( dimord(numdims) )
269     \textcolor{comment}{! 次元の ID の取得}
270     \textcolor{comment}{!}
271     \textcolor{keywordflow}{do}, i = 1, numdims
272       \textcolor{comment}{! hst 内で, 次元変数名 dim(i) に当たる次元変数の ID である}
273       \textcolor{comment}{! hst % dimvar(i) を dimvars(i) に, 添字を dimord に}
274       \textcolor{comment}{!}
275       dimvars(i) = \hyperlink{interfacegtool__history__internal_1_1lookup__dimension}{lookup\_dimension}( hst, dims(i), &   \textcolor{comment}{! (in)}
276         &                            ord = dimord(i) ) \textcolor{comment}{! (out)}
277       \textcolor{keywordflow}{if} (dimord(i) == 0) \textcolor{keywordflow}{then}
278         stat = nf90\_ebaddim
279         cause\_c = \hyperlink{interfacedc__string_1_1cprintf}{cprintf}(\textcolor{stringliteral}{'"%c" dimension is not found.'}, c1=trim(dims(i)))
280         \textcolor{keywordflow}{goto} 999
281 \textcolor{keywordflow}{      end if}
282 \textcolor{keywordflow}{    end do}
283     \textcolor{comment}{! 変数添字次元を決定}
284     \textcolor{comment}{!}
285     \textcolor{keywordflow}{do}, i = 1, numdims
286       \textcolor{comment}{! 無制限次元の添字と一致する場合に,}
287       \textcolor{comment}{! その添字を hst % growable\_indices(nvars) に}
288       \textcolor{comment}{!}
289       \textcolor{keywordflow}{if} (dimord(i) == hst % unlimited\_index) \textcolor{keywordflow}{then}
290         hst % growable\_indices(nvars) = i
291 \textcolor{keywordflow}{      endif}
292 \textcolor{keywordflow}{    enddo}
293     \textcolor{comment}{! 変数作成}
294     \textcolor{comment}{!}
295     \textcolor{keyword}{call }\hyperlink{interfacegtdata__generic_1_1inquire}{inquire}(hst % dimvars(1), url=url)
296     fullname = \hyperlink{interfacedc__url_1_1urlresolve}{urlresolve}((\hyperlink{namespacedc__url_a3157f15c35d09732b55dfb0f4f52397d}{gt\_atmark} // trim(varname)), trim(url))
297     \textcolor{keyword}{call }\hyperlink{interfacegtdata__generic_1_1create}{create}(hst % vars(nvars), trim(fullname), dimvars, xtype=xtype)
298     \textcolor{keywordflow}{if} ( \textcolor{keyword}{associated}(dimvars) ) \textcolor{keyword}{deallocate}( dimvars )
299     \textcolor{comment}{! 拡張可能次元があったらそれをサイズ 1 に拡張しておく}
300     \textcolor{comment}{!}
301     \textcolor{keywordflow}{if} (hst % growable\_indices(nvars) /= 0) \textcolor{keywordflow}{then}
302       \textcolor{keyword}{call }\hyperlink{interfacegtdata__generic_1_1slice}{slice}(hst % vars(nvars), hst % growable\_indices(nvars), &
303         & start=1, count=1, stride=1)
304 \textcolor{keywordflow}{    endif}
305     \textcolor{keyword}{call }\hyperlink{interfacegtdata__generic_1_1put__attr}{put\_attr}(hst % vars(nvars), \textcolor{stringliteral}{'long\_name'}, longname)
306     \textcolor{keyword}{call }\hyperlink{interfacegtdata__generic_1_1put__attr}{put\_attr}(hst % vars(nvars), \textcolor{stringliteral}{'units'}, \hyperlink{structdc__units_1_1units}{units})
307     \textcolor{comment}{! 平均処理に関する情報管理}
308     \textcolor{comment}{!}
309     \textcolor{keywordflow}{if} (      \hyperlink{namespacedc__present_ab280582985ee69fda00e2a0bf09194af}{present\_and\_true}( time\_average ) &
310       &  .or. \hyperlink{namespacedc__present_ab280582985ee69fda00e2a0bf09194af}{present\_and\_true}( average ) ) \textcolor{keywordflow}{then}
311       hst % var\_avr\_count(nvars) = 0
312       \textcolor{comment}{! 情報の取得}
313       \textcolor{comment}{! Get Information}
314       \textcolor{comment}{!}
315       timevar => hst % dimvars( hst % unlimited\_index )
316       \textcolor{keyword}{call }\hyperlink{interfacegtdata__generic_1_1inquire}{inquire}( &
317         & var = timevar, &                    \textcolor{comment}{! (in)}
318         & name = time\_name, url = time\_url, & \textcolor{comment}{! (out)}
319         & xtype = time\_xtype )                \textcolor{comment}{! (out)}
320       \textcolor{comment}{! 変数のデータ数の取得}
321       \textcolor{comment}{!}
322       \textcolor{keyword}{call }\hyperlink{interfacegtdata__generic_1_1inquire}{inquire}(hst % vars(nvars), \textcolor{keyword}{size} = var\_avr\_length )
323       \textcolor{comment}{! 割り付け}
324       \textcolor{comment}{!}
325       hst % var\_avr\_data(nvars) % length = var\_avr\_length
326       \textcolor{keyword}{allocate}(hst % var\_avr\_data(nvars) % a\_DataAvr(var\_avr\_length))
327       hst % var\_avr\_data(nvars) % a\_DataAvr = 0.0\_dp
328       \textcolor{comment}{! デフォルト値設定}
329       \textcolor{comment}{!}
330       hst % var\_avr\_firstput = .true.
331       hst % var\_avr\_coefsum(nvars) = 0.0\_dp
332       hst % var\_avr\_baseint(nvars) = 0.0\_dp
333 \textcolor{comment}{!!$      call DCDiffTimeCreate( &}
334 \textcolor{comment}{!!$        & hst % var\_avr\_baseint(nvars), & ! (out)}
335 \textcolor{comment}{!!$        & sec = 0.0\_DP )                   ! (in)}
336       hst % var\_avr\_prevtime(nvars) = hst % var\_avr\_baseint(nvars)
337       \textcolor{comment}{! 時間次元情報の取得}
338       \textcolor{comment}{!}
339       \textcolor{keywordflow}{if} ( hst % growable\_indices(nvars) < 1 ) \textcolor{keywordflow}{then}
340         stat = \hyperlink{namespacedc__error_a9f376cdc0f575d61de0c36b9f6ca47a9}{hst\_enodependtime}
341         cause\_c = trim(varname)
342         \textcolor{keywordflow}{goto} 999
343 \textcolor{keywordflow}{      end if}
344       \textcolor{comment}{! 時間次元への属性 "bounds" の追加}
345       \textcolor{comment}{!}
346       \textcolor{keyword}{call }\hyperlink{interfacegtdata__generic_1_1put__attr}{put\_attr}( var = timevar, &              \textcolor{comment}{! (inout)}
347         & name = \textcolor{stringliteral}{'bounds'}, &                       \textcolor{comment}{! (in)}
348         & \textcolor{keywordtype}{value} = trim(time\_name) // bnds\_suffix ) \textcolor{comment}{! (in)}
349       \textcolor{comment}{! 変数 "varname" への属性 "cell\_methods" の追加}
350       \textcolor{comment}{!}
351       \textcolor{keyword}{call }\hyperlink{interfacegtdata__generic_1_1put__attr}{put\_attr}( var = hst % vars(nvars), & \textcolor{comment}{! (inout)}
352         & name = \textcolor{stringliteral}{'cell\_methods'}, &              \textcolor{comment}{! (in)}
353         & \textcolor{keywordtype}{value} = trim(time\_name) // \textcolor{stringliteral}{': mean'} ) \textcolor{comment}{! (in)}
354       \textcolor{comment}{! "time\_nv" 次元の作成 (既に作成されていたら何もしない)}
355       \textcolor{comment}{!}
356       dimvars\_size = \textcolor{keyword}{size}( hst % dimvars )
357       nv\_exist = .false.
358       \textcolor{keywordflow}{do} i = 1, dimvars\_size
359         \textcolor{keyword}{call }\hyperlink{interfacegtdata__generic_1_1inquire}{inquire}( &
360           & var = hst % dimvars(i), & \textcolor{comment}{! (in)}
361           & name = nv\_name\_check )    \textcolor{comment}{! (out)}
362         \textcolor{keywordflow}{if} ( trim(time\_name) // trim(nv\_suffix) == trim(nv\_name\_check) ) \textcolor{keywordflow}{then}
363           nv\_exist = .true.
364           \textcolor{keywordflow}{exit}
365 \textcolor{keywordflow}{        end if}
366 \textcolor{keywordflow}{      end do}
367       \textcolor{keywordflow}{if} ( .not. nv\_exist ) \textcolor{keywordflow}{then}
368         dimvars\_work => hst % dimvars
369         dim\_value\_written\_work => hst % dim\_value\_written
370         \textcolor{keyword}{nullify}(hst % dimvars, hst % dim\_value\_written)
371         \textcolor{keyword}{allocate}(hst % dimvars(dimvars\_size + 1))
372         \textcolor{keyword}{allocate}(hst % dim\_value\_written(dimvars\_size + 1))
373         hst % dimvars(1:dimvars\_size) = dimvars\_work(1:dimvars\_size)
374         hst % dim\_value\_written(1:dimvars\_size) = dim\_value\_written\_work(1:dimvars\_size)
375         \textcolor{keyword}{deallocate}(dimvars\_work)
376         \textcolor{keyword}{deallocate}(dim\_value\_written\_work)
377         \textcolor{keyword}{call }\hyperlink{interfacegtdata__generic_1_1create}{create}( &
378           & var = hst % dimvars(dimvars\_size + 1), &   \textcolor{comment}{! (out)}
379           & url = trim(time\_url) // trim(nv\_suffix), & \textcolor{comment}{! (in)}
380           & length = 2, xtype = \textcolor{stringliteral}{'integer'} )            \textcolor{comment}{! (in)}
381         hst % time\_nv\_index = dimvars\_size + 1
382         \textcolor{keyword}{call }\hyperlink{interfacegtdata__generic_1_1put__attr}{put\_attr}( var = hst % dimvars(dimvars\_size + 1), & \textcolor{comment}{! (inout)}
383           & name = \textcolor{stringliteral}{'long\_name'}, &                               \textcolor{comment}{! (in)}
384           & \textcolor{keywordtype}{value} = \textcolor{stringliteral}{'number of vertices of time'})               \textcolor{comment}{! (in)}
385         \textcolor{keyword}{call }\hyperlink{interfacegtdata__generic_1_1put__attr}{put\_attr}( var = hst % dimvars(dimvars\_size + 1), & \textcolor{comment}{! (inout)}
386           & name = \textcolor{stringliteral}{'units'}, \textcolor{keywordtype}{value} = \textcolor{stringliteral}{'1'} )                       \textcolor{comment}{! (in)}
387         \textcolor{keyword}{call }\hyperlink{interfacegtdata__generic_1_1put}{put}( var = hst % dimvars(dimvars\_size + 1), & \textcolor{comment}{! (inout)}
388           & \textcolor{keywordtype}{value} = (/1, 2/) )                             \textcolor{comment}{! (in)}
389         hst % dim\_value\_written(dimvars\_size + 1) = .true.
390 \textcolor{keywordflow}{      end if}
391       \textcolor{comment}{! "time\_bnds" 変数の作成 (既に作成されていたら何もしない)}
392       \textcolor{comment}{!}
393       bnds\_exist = .false.
394       \textcolor{keywordflow}{do} i = 1, nvars
395         \textcolor{keyword}{call }\hyperlink{interfacegtdata__generic_1_1inquire}{inquire}( &
396           & var = hst % vars(i), &   \textcolor{comment}{! (in)}
397           & name = bnds\_name\_check ) \textcolor{comment}{! (out)}
398         \textcolor{keywordflow}{if} ( trim(time\_name) // trim(bnds\_suffix) == trim(bnds\_name\_check) ) \textcolor{keywordflow}{then}
399           bnds\_exist = .true.
400           \textcolor{keywordflow}{exit}
401 \textcolor{keywordflow}{        end if}
402 \textcolor{keywordflow}{      end do}
403       \textcolor{keywordflow}{if} ( \textcolor{keyword}{associated}(dimord) )  \textcolor{keyword}{deallocate}( dimord )
404       \textcolor{keywordflow}{if} ( .not. bnds\_exist ) \textcolor{keywordflow}{then}
405         \textcolor{keyword}{call }\hyperlink{interfacegtool__history__generic_1_1historyaddvariable}{historyaddvariable}( &
406           &  history = hst, &                                 \textcolor{comment}{! (inout)}
407           &  varname = trim(time\_name) // trim(bnds\_suffix), &
408           &     dims = \hyperlink{interfacedc__string_1_1stoa}{stoa}( trim(time\_name) // trim(nv\_suffix), &
409           &                  trim(time\_name) ), &             \textcolor{comment}{! (in)}
410           & longname = \textcolor{stringliteral}{'bounds of time'}, &                    \textcolor{comment}{! (in)}
411           & \hyperlink{structdc__units_1_1units}{units} = hst % unlimited\_units, &                  \textcolor{comment}{! (in)}
412           & xtype = time\_xtype )                              \textcolor{comment}{! (in)}
413 \textcolor{keywordflow}{      end if}
414     \textcolor{comment}{! 平均処理が不要な場合}
415     \textcolor{comment}{!}
416     \textcolor{keywordflow}{else}
417       hst % var\_avr\_count(nvars) = -1
418       \textcolor{comment}{! 割り付け}
419       \textcolor{comment}{!}
420       var\_avr\_length = 1
421       hst % var\_avr\_data(nvars) % length = var\_avr\_length
422       \textcolor{keyword}{allocate}(hst % var\_avr\_data(nvars) % a\_DataAvr(var\_avr\_length))
423       hst % var\_avr\_data(nvars) % a\_DataAvr = 0.0\_dp
424       \textcolor{comment}{! デフォルト値設定}
425       \textcolor{comment}{!}
426       hst % var\_avr\_firstput = .true.
427       hst % var\_avr\_coefsum(nvars) = 0.0\_dp
428       hst % var\_avr\_baseint(nvars) = 0.0\_dp
429 \textcolor{comment}{!!$      call DCDiffTimeCreate( &}
430 \textcolor{comment}{!!$        & hst % var\_avr\_baseint(nvars), & ! (out)}
431 \textcolor{comment}{!!$        & sec = 0.0\_DP )                   ! (in)}
432       hst % var\_avr\_prevtime(nvars) = hst % var\_avr\_baseint(nvars)
433 \textcolor{keywordflow}{    end if}
434     \textcolor{comment}{! 終了処理, 例外処理}
435     \textcolor{comment}{! Termination and Exception handling}
436     \textcolor{comment}{!}
437 999 \textcolor{keywordflow}{continue}
438     \textcolor{keywordflow}{if} ( \textcolor{keyword}{associated}(dimvars) ) \textcolor{keyword}{deallocate}( dimvars )
439     \textcolor{keywordflow}{if} ( \textcolor{keyword}{associated}(dimord) )  \textcolor{keyword}{deallocate}( dimord )
440     \textcolor{keyword}{call }\hyperlink{namespacedc__error_a0104aee83ee5752b1a9f6152b11864a8}{storeerror}(stat, subname, err, cause\_c)
441     \textcolor{keyword}{call }\hyperlink{namespacedc__trace_ae44de97565a3bdd685789c7748b37e37}{endsub}(subname)
\end{DoxyCode}
Here is the call graph for this function\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{historyaddvariable_8f90_acf0d7af06caeec679cca4c099b53f6cd_cgraph}
\end{center}
\end{figure}
\mbox{\Hypertarget{historyaddvariable_8f90_a59e160540a64fe551ec3ecb5a829bdf3}\label{historyaddvariable_8f90_a59e160540a64fe551ec3ecb5a829bdf3}} 
\index{historyaddvariable.\+f90@{historyaddvariable.\+f90}!historyaddvariable2@{historyaddvariable2}}
\index{historyaddvariable2@{historyaddvariable2}!historyaddvariable.\+f90@{historyaddvariable.\+f90}}
\subsubsection{\texorpdfstring{historyaddvariable2()}{historyaddvariable2()}}
{\footnotesize\ttfamily subroutine historyaddvariable2 (\begin{DoxyParamCaption}\item[{type(gt\+\_\+history\+\_\+varinfo), intent(in)}]{varinfo,  }\item[{type(gt\+\_\+history), intent(inout), optional}]{history,  }\item[{logical, intent(out), optional}]{err }\end{DoxyParamCaption})}



Definition at line 445 of file historyaddvariable.\+f90.



References dc\+\_\+trace\+::beginsub(), dc\+\_\+trace\+::dbgmessage(), gtool\+\_\+history\+\_\+internal\+::default, dc\+\_\+types\+::dp, dc\+\_\+trace\+::endsub(), dc\+\_\+string\+::joinchar(), dc\+\_\+types\+::string, and dc\+\_\+types\+::token.


\begin{DoxyCode}
445     \textcolor{comment}{!}
446     \textcolor{comment}{!== 変数定義}
447     \textcolor{comment}{!}
448     \textcolor{comment}{! gtool4 データ内の変数の定義を行います。このサブルーチンを}
449     \textcolor{comment}{! 用いる前に、 HistoryCreate による初期設定が必要です。}
450     \textcolor{comment}{!}
451     \textcolor{comment}{! 既に gtool4 データが存在し、そのデータ内の変数と全く同じ}
452     \textcolor{comment}{! 構造の変数を定義したい場合は HistoryCopyVariable を利用すると}
453     \textcolor{comment}{! 便利です。}
454     \textcolor{comment}{!}
455     \textcolor{comment}{! *HistoryAddVariable* というサブルーチン名は 2 つの別々の}
456     \textcolor{comment}{! サブルーチンの総称名です。下記のサブルーチンも参照ください。}
457     \textcolor{comment}{!}
458     \textcolor{keywordtype}{use }\hyperlink{namespacedc__string}{dc\_string}\textcolor{keywordtype}{, only}: \hyperlink{namespacedc__string_a20412554f8f648165d202319119cf628}{joinchar}
459     \textcolor{keywordtype}{use }\hyperlink{namespacegtool__history__generic}{gtool\_history\_generic}\textcolor{keywordtype}{, only}: \hyperlink{interfacegtool__history__generic_1_1historyaddvariable}{historyaddvariable}
460     \textcolor{keywordtype}{use }\hyperlink{namespacegtool__history__types}{gtool\_history\_types}\textcolor{keywordtype}{, only}: \hyperlink{structgtool__history__types_1_1gt__history}{gt\_history}, 
      \hyperlink{structgtool__history__types_1_1gt__history__axis}{gt\_history\_axis}, \hyperlink{structgtool__history__types_1_1gt__history__varinfo}{gt\_history\_varinfo}, 
      \hyperlink{structgtool__history__types_1_1gt__history__attr}{gt\_history\_attr}
461     \textcolor{keywordtype}{use }\hyperlink{namespacegtool__history__internal}{gtool\_history\_internal}\textcolor{keywordtype}{, only}: \hyperlink{namespacegtool__history__internal_aa7fc82d2ca1961a254be1acb599afbb1}{default}, 
      \hyperlink{interfacegtool__history__internal_1_1append__attrs}{append\_attrs}
462     \textcolor{keywordtype}{use }\hyperlink{namespacedc__trace}{dc\_trace}\textcolor{keywordtype}{, only}: \hyperlink{namespacedc__trace_aca1efe8bae50b85f74980a8c4d704dd8}{beginsub}, \hyperlink{namespacedc__trace_ae44de97565a3bdd685789c7748b37e37}{endsub}, \hyperlink{namespacedc__trace_a2a38fceb4cf9baf298d63456238c3fea}{dbgmessage}
463     \textcolor{keywordtype}{use }\hyperlink{namespacedc__types}{dc\_types}\textcolor{keywordtype}{, only}: \hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}, \hyperlink{namespacedc__types_a6d28eb015ba84292a06f4ff25165b376}{token}, \hyperlink{namespacedc__types_ac74a34430fcd3d0eb2344f19d536c086}{dp}
464     \textcolor{keywordtype}{implicit none}
465     \textcolor{keywordtype}{type}(\hyperlink{structgtool__history__types_1_1gt__history__varinfo}{gt\_history\_varinfo}), \textcolor{keywordtype}{intent(in)}             :: varinfo
466                               \textcolor{comment}{! 変数情報を格納した構造体}
467                               \textcolor{comment}{!}
468                               \textcolor{comment}{! ここに指定するものは、}
469                               \textcolor{comment}{! HistoryVarinfoCreate によって}
470                               \textcolor{comment}{! 初期設定されていなければなりません。}
471                               \textcolor{comment}{!}
472     \textcolor{keywordtype}{type}(\hyperlink{structgtool__history__types_1_1gt__history}{gt\_history}),         \textcolor{keywordtype}{intent(inout)}, \textcolor{keywordtype}{optional}:: history
473                               \textcolor{comment}{! 出力ファイルの設定に関する情報を}
474                               \textcolor{comment}{! 格納した構造体}
475                               \textcolor{comment}{!}
476                               \textcolor{comment}{! ここに指定するものは、}
477                               \textcolor{comment}{! HistoryCreate によって初期設定}
478                               \textcolor{comment}{! されていなければなりません。}
479                               \textcolor{comment}{!}
480     \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(out)}, \textcolor{keywordtype}{optional}:: err
481                               \textcolor{comment}{! 例外処理用フラグ.}
482                               \textcolor{comment}{! デフォルトでは, この手続き内でエラーが}
483                               \textcolor{comment}{! 生じた場合, プログラムは強制終了します.}
484                               \textcolor{comment}{! 引数 *err* が与えられる場合,}
485                               \textcolor{comment}{! プログラムは強制終了せず, 代わりに}
486                               \textcolor{comment}{! *err* に .true. が代入されます.}
487                               \textcolor{comment}{!}
488                               \textcolor{comment}{! Exception handling flag.}
489                               \textcolor{comment}{! By default, when error occur in}
490                               \textcolor{comment}{! this procedure, the program aborts.}
491                               \textcolor{comment}{! If this *err* argument is given,}
492                               \textcolor{comment}{! .true. is substituted to *err* and}
493                               \textcolor{comment}{! the program does not abort.}
494     \textcolor{keywordtype}{character(len = *)}, \textcolor{keywordtype}{parameter}:: subname = \textcolor{stringliteral}{"HistoryAddVariable2"}
495   \textcolor{keywordflow}{continue}
496     \textcolor{keyword}{call }\hyperlink{namespacedc__trace_aca1efe8bae50b85f74980a8c4d704dd8}{beginsub}(subname, \textcolor{stringliteral}{'varname=<%c>, dims=<%c>, longname=<%c>'}, &
497       & c1=trim(varinfo % name), c2=trim(\hyperlink{namespacedc__string_a20412554f8f648165d202319119cf628}{joinchar}(varinfo % dims)),   &
498       & c3=trim(varinfo % longname)                               )
499     \textcolor{keyword}{call }\hyperlink{interfacegtool__history__generic_1_1historyaddvariable}{historyaddvariable}( &
500       & history = history, &              \textcolor{comment}{! (inout)}
501       & varname = varinfo % name, &       \textcolor{comment}{! (in)}
502       & dims = varinfo % dims, &          \textcolor{comment}{! (in)}
503       & longname = varinfo % longname, &  \textcolor{comment}{! (in)}
504       & \hyperlink{structdc__units_1_1units}{units} = varinfo % units, &        \textcolor{comment}{! (in)}
505       & xtype = varinfo % xtype, &        \textcolor{comment}{! (in)}
506       & time\_average = varinfo % time\_average, & \textcolor{comment}{! (in) optional}
507       & err = err )                              \textcolor{comment}{! (out) optional}
508     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}( varinfo % attrs )) \textcolor{keywordflow}{then}
509       \textcolor{keyword}{call }\hyperlink{interfacegtool__history__internal_1_1append__attrs}{append\_attrs}( varinfo % name, varinfo % attrs, history )
510 \textcolor{keywordflow}{    end if}
511     \textcolor{keyword}{call }\hyperlink{namespacedc__trace_ae44de97565a3bdd685789c7748b37e37}{endsub}(subname)
\end{DoxyCode}
Here is the call graph for this function\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{historyaddvariable_8f90_a59e160540a64fe551ec3ecb5a829bdf3_cgraph}
\end{center}
\end{figure}
