\hypertarget{gtvaropenbydimord_8f90}{}\section{gtdata/gtvaropenbydimord.f90 File Reference}
\label{gtvaropenbydimord_8f90}\index{gtdata/gtvaropenbydimord.\+f90@{gtdata/gtvaropenbydimord.\+f90}}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine \hyperlink{gtvaropenbydimord_8f90_af9708266edff2064dbb1e427c0157f3a}{gtvaropenbydimord} (var, source\+\_\+var, dimord, count\+\_\+compact, err)
\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{gtvaropenbydimord_8f90_af9708266edff2064dbb1e427c0157f3a}\label{gtvaropenbydimord_8f90_af9708266edff2064dbb1e427c0157f3a}} 
\index{gtvaropenbydimord.\+f90@{gtvaropenbydimord.\+f90}!gtvaropenbydimord@{gtvaropenbydimord}}
\index{gtvaropenbydimord@{gtvaropenbydimord}!gtvaropenbydimord.\+f90@{gtvaropenbydimord.\+f90}}
\subsubsection{\texorpdfstring{gtvaropenbydimord()}{gtvaropenbydimord()}}
{\footnotesize\ttfamily subroutine gtvaropenbydimord (\begin{DoxyParamCaption}\item[{type(gt\+\_\+variable), intent(out)}]{var,  }\item[{type(gt\+\_\+variable), intent(in)}]{source\+\_\+var,  }\item[{integer, intent(in)}]{dimord,  }\item[{logical, intent(in), optional}]{count\+\_\+compact,  }\item[{logical, intent(out), optional}]{err }\end{DoxyParamCaption})}



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



References dc\+\_\+trace\+::beginsub(), dc\+\_\+trace\+::dbgmessage(), dc\+\_\+error\+::dc\+\_\+noerr, gtdata\+\_\+internal\+\_\+map\+::dimord\+\_\+skip\+\_\+compact(), dc\+\_\+trace\+::endsub(), dc\+\_\+error\+::gt\+\_\+efake, dc\+\_\+error\+::gt\+\_\+enomoredims, gtdata\+\_\+internal\+\_\+map\+::map\+\_\+create(), gtdata\+\_\+internal\+\_\+map\+::map\+\_\+dup(), gtdata\+\_\+internal\+\_\+map\+::map\+\_\+lookup(), gtdata\+\_\+internal\+\_\+map\+::map\+\_\+set(), dc\+\_\+present\+::present\+\_\+and\+\_\+true(), dc\+\_\+error\+::storeerror(), dc\+\_\+types\+::string, and gtdata\+\_\+internal\+\_\+map\+::var\+\_\+class().


\begin{DoxyCode}
13   \textcolor{comment}{!}
14   \textcolor{comment}{!== gtool4 データのオープン}
15   \textcolor{comment}{!}
16   \textcolor{comment}{! 既に開かれた変数 *source\_var* の *dimord* 番目の次元にあたる変数を}
17   \textcolor{comment}{! 開き var に格納します。順序 *dimord* は現在の入出力範囲が}
18   \textcolor{comment}{! 幅１になっている (コンパクト化している) を飛ばした}
19   \textcolor{comment}{! 順序であすが、*count\_compact* に <tt>.true.</tt>を指定すると}
20   \textcolor{comment}{! すべての次元のなかの順序になります。}
21   \textcolor{comment}{!}
22   \textcolor{comment}{! Open された変数は必ず Close されなければなりません。}
23   \textcolor{comment}{!}
24   \textcolor{comment}{! *dimord* == 0 の場合は変数自体を再度開きます。これは参照カウンタを}
25   \textcolor{comment}{! 増加させる手段です。}
26   \textcolor{comment}{!}
27   \textcolor{comment}{! *Open* は 2 つのサブルーチンの総称名であり、}
28   \textcolor{comment}{! 変数 URL を直接指定することで開くことも可能です。}
29   \textcolor{comment}{! 下記のサブルーチンを参照ください。}
30   \textcolor{comment}{!}
31   \textcolor{comment}{!=== 補足}
32   \textcolor{comment}{!}
33   \textcolor{comment}{! 変数 URL にファイル名部を指定しない場合、gtool.nc であるとみなされます。}
34   \textcolor{comment}{!}
35   \textcolor{comment}{! 変数 URL にファイル名だけを指定した場合、開かれる変数は以下の規則}
36   \textcolor{comment}{! で選択されます。}
37   \textcolor{comment}{!}
38   \textcolor{comment}{! * 次元変数は選択されない}
39   \textcolor{comment}{! * なるべく先に定義された変数が選択される}
40   \textcolor{comment}{!}
41   \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__types}{gtdata\_types}\textcolor{keywordtype}{, only}: \hyperlink{structgtdata__types_1_1gt__variable}{gt\_variable}
42   \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__internal__map}{gtdata\_internal\_map}\textcolor{keywordtype}{, only}: \hyperlink{namespacegtdata__internal__map_a86b920031832bea17e70a6bf4623c3d9}{var\_class}, vtb\_class\_netcdf, vtb\_class\_memory,
       &
43     & \hyperlink{namespacegtdata__internal__map_abd624f8e775fa18a68b90ed01ec6e0f3}{map\_dup}, \hyperlink{namespacegtdata__internal__map_ab8c5494c00d4dd85417e891b762f77d9}{map\_create}, \hyperlink{namespacegtdata__internal__map_a076911f777be03f10a2c024dac7efdad}{map\_lookup}, \hyperlink{structgtdata__internal__map_1_1gt__dimmap}{gt\_dimmap}, &
44     & \hyperlink{namespacegtdata__internal__map_a2e6a789c1c8f4850421da11f10081cb7}{map\_set}, \hyperlink{namespacegtdata__internal__map_a44f4fb36cd72433854ba6bdc6634500f}{dimord\_skip\_compact}
45   \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__netcdf__generic}{gtdata\_netcdf\_generic}\textcolor{keywordtype}{, only}: \hyperlink{interfacegtdata__generic_1_1open}{open}, \hyperlink{interfacegtdata__generic_1_1inquire}{inquire}
46   \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__netcdf__types}{gtdata\_netcdf\_types}\textcolor{keywordtype}{, only}: \hyperlink{structgtdata__netcdf__types_1_1gd__nc__variable}{gd\_nc\_variable}
47   \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__generic}{gtdata\_generic}\textcolor{keywordtype}{, only}: gt\_open => \hyperlink{interfacegtdata__generic_1_1open}{open}
48   \textcolor{keywordtype}{use }\hyperlink{namespacedc__present}{dc\_present}\textcolor{keywordtype}{, only}: \hyperlink{namespacedc__present_ab280582985ee69fda00e2a0bf09194af}{present\_and\_true}
49   \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}
50   \textcolor{keywordtype}{use }\hyperlink{namespacedc__string}{dc\_string}\textcolor{keywordtype}{, only}: \hyperlink{interfacedc__string_1_1cprintf}{cprintf}
51   \textcolor{keywordtype}{use }\hyperlink{namespacedc__error}{dc\_error}\textcolor{keywordtype}{, only}: \hyperlink{namespacedc__error_a0104aee83ee5752b1a9f6152b11864a8}{storeerror}, \hyperlink{namespacedc__error_adbe5d07dca84213ae01fef87caf04be3}{gt\_enomoredims}, 
      \hyperlink{namespacedc__error_adbe5d07dca84213ae01fef87caf04be3}{gt\_enomoredims}, &
52     & \hyperlink{namespacedc__error_a64841a3c9e3ef7d5ddb175e5770f7dfe}{dc\_noerr}, \hyperlink{namespacedc__error_a3c706700d7fb6c0ff705558066f8e583}{gt\_efake}
53   \textcolor{keywordtype}{use }\hyperlink{namespacedc__types}{dc\_types}\textcolor{keywordtype}{, only}: \hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}
54   \textcolor{keywordtype}{implicit none}
55   \textcolor{keywordtype}{type}(\hyperlink{structgtdata__types_1_1gt__variable}{gt\_variable}), \textcolor{keywordtype}{intent(out)}:: var
56   \textcolor{keywordtype}{type}(\hyperlink{structgtdata__types_1_1gt__variable}{gt\_variable}), \textcolor{keywordtype}{intent(in)}:: source\_var
57   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)}:: dimord
58   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(in)}, \textcolor{keywordtype}{optional}:: count\_compact
59   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(out)}, \textcolor{keywordtype}{optional}:: err
60   \textcolor{keywordtype}{integer}:: sclass, scid, ld, sndims, stat, udimord, idimord, cause\_i
61   \textcolor{keywordtype}{type}(\hyperlink{structgtdata__netcdf__types_1_1gd__nc__variable}{gd\_nc\_variable}):: gdnc
62   \textcolor{keywordtype}{type}(\hyperlink{structgtdata__internal__map_1_1gt__dimmap}{gt\_dimmap}), \textcolor{keywordtype}{allocatable}:: map\_src(:)
63   \textcolor{keywordtype}{type}(\hyperlink{structgtdata__internal__map_1_1gt__dimmap}{gt\_dimmap}):: map\_result(1)
64   \textcolor{keywordtype}{logical}:: cnt\_compact
65   \textcolor{keywordtype}{character(STRING)} :: endsub\_msg
66   \textcolor{keywordtype}{character(len = *)},      \textcolor{keywordtype}{parameter}:: subname = \textcolor{stringliteral}{"GTVarOpen-By-Dimord"}
67   \textcolor{keywordtype}{character(len = *)},      \textcolor{keywordtype}{parameter}:: version = &
68     & \textcolor{stringliteral}{'$Name:  $'} // &
69     & \textcolor{stringliteral}{'$Id: gtvaropenbydimord.f90,v 1.5 2009-07-04 04:58:06 morikawa Exp $'}
70 continue
71   \textcolor{keyword}{call }\hyperlink{namespacedc__trace_aca1efe8bae50b85f74980a8c4d704dd8}{beginsub}(subname, \textcolor{stringliteral}{'var.mapid=%d dimord=%d '}, &
72     & i=(/source\_var%mapid, dimord/), version=version)
73   stat = \hyperlink{namespacedc__error_a64841a3c9e3ef7d5ddb175e5770f7dfe}{dc\_noerr}
74   cause\_i = dimord
75 \textcolor{keyword}{  end}sub\_msg = \textcolor{stringliteral}{''}
76 
77   \textcolor{comment}{! 変数それ自体を開き直す処理}
78   \textcolor{keywordflow}{if} (dimord == 0) \textcolor{keywordflow}{then}
79     \textcolor{keyword}{call }\hyperlink{namespacegtdata__internal__map_abd624f8e775fa18a68b90ed01ec6e0f3}{map\_dup}(var, source\_var)
80     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(err)) err = .false.
81 \textcolor{keyword}{    end}sub\_msg = \textcolor{stringliteral}{'dup'}
82     \textcolor{keywordflow}{goto} 999
83 \textcolor{keywordflow}{  endif}
84 
85   \textcolor{comment}{! 表を引き、dimord 番 (count\_compact に注意) の次元の内部変数}
86   \textcolor{comment}{! 次元番号を調べる。}
87   \textcolor{keyword}{call }\hyperlink{namespacegtdata__internal__map_a076911f777be03f10a2c024dac7efdad}{map\_lookup}(source\_var, ndims=sndims)
88   \textcolor{keywordflow}{if} (sndims <= 0 .or. dimord > sndims) \textcolor{keywordflow}{then}
89     stat = \hyperlink{namespacedc__error_adbe5d07dca84213ae01fef87caf04be3}{gt\_enomoredims}
90     \textcolor{keywordflow}{goto} 999
91 \textcolor{keywordflow}{  endif}
92   \textcolor{keyword}{allocate}(map\_src(sndims))
93   \textcolor{keyword}{call }\hyperlink{namespacegtdata__internal__map_a076911f777be03f10a2c024dac7efdad}{map\_lookup}(source\_var, map=map\_src)
94   cnt\_compact = .false.
95   \textcolor{keywordflow}{if} (\hyperlink{namespacedc__present_ab280582985ee69fda00e2a0bf09194af}{present\_and\_true}(count\_compact)) \textcolor{keywordflow}{then}
96     cnt\_compact = .true.
97   \textcolor{keywordflow}{else}
98     cnt\_compact = .false.
99 \textcolor{keywordflow}{  end if}
100   \textcolor{keyword}{call }\hyperlink{namespacedc__trace_a2a38fceb4cf9baf298d63456238c3fea}{dbgmessage}(\textcolor{stringliteral}{'count\_compact=%y'}, l=(/cnt\_compact/))
101 
102   \textcolor{keywordflow}{if} (cnt\_compact) \textcolor{keywordflow}{then}
103     udimord = dimord
104   \textcolor{keywordflow}{else}
105     udimord = \hyperlink{namespacegtdata__internal__map_a44f4fb36cd72433854ba6bdc6634500f}{dimord\_skip\_compact}(dimord, map=map\_src)
106 \textcolor{keywordflow}{  endif}
107   \textcolor{keywordflow}{if} (udimord <= 0 .or. udimord > \textcolor{keyword}{size}(map\_src)) \textcolor{keywordflow}{then}
108     stat = \hyperlink{namespacedc__error_adbe5d07dca84213ae01fef87caf04be3}{gt\_enomoredims}
109     \textcolor{keywordflow}{goto} 999
110 \textcolor{keywordflow}{  endif}
111 
112   idimord = map\_src(udimord)%dimno
113   \textcolor{keywordflow}{if} (idimord < 1) \textcolor{keywordflow}{then}
114     \textcolor{keyword}{call }gt\_open(var, map\_src(udimord)%url, err=err)
115     \textcolor{comment}{! storeerror はしなくてよい}
116     \textcolor{keyword}{deallocate}(map\_src)
117     \textcolor{keywordflow}{goto} 999
118 \textcolor{keywordflow}{  endif}
119 
120   \textcolor{comment}{! 実態種別に合わせ「次元変数オープン」処理}
121   \textcolor{keyword}{call }\hyperlink{namespacegtdata__internal__map_a86b920031832bea17e70a6bf4623c3d9}{var\_class}(source\_var, sclass, scid)
122   \textcolor{keywordflow}{if} (sclass == vtb\_class\_netcdf) \textcolor{keywordflow}{then}
123     \textcolor{keyword}{call }\hyperlink{interfacegtdata__generic_1_1open}{open}(gdnc, \hyperlink{structgtdata__netcdf__types_1_1gd__nc__variable}{gd\_nc\_variable}(scid), idimord, err)
124     \textcolor{keyword}{call }\hyperlink{interfacegtdata__generic_1_1inquire}{inquire}(gdnc, dimlen=ld)
125     \textcolor{keyword}{call }\hyperlink{namespacegtdata__internal__map_ab8c5494c00d4dd85417e891b762f77d9}{map\_create}(var, vtb\_class\_netcdf, gdnc%id, 1, (/ld/), stat)
126     \textcolor{keywordflow}{if} (stat /= \hyperlink{namespacedc__error_a64841a3c9e3ef7d5ddb175e5770f7dfe}{dc\_noerr}) \textcolor{keywordflow}{then}
127       cause\_i = 1
128       \textcolor{keywordflow}{goto} 999
129 \textcolor{keywordflow}{    end if}
130     \textcolor{keyword}{call }\hyperlink{namespacegtdata__internal__map_a076911f777be03f10a2c024dac7efdad}{map\_lookup}(var, map=map\_result)
131     map\_result(1)%offset = map\_src(udimord)%offset
132     map\_result(1)%step = map\_src(udimord)%step
133     map\_result(1)%allcount = map\_src(udimord)%allcount
134     map\_result(1)%start = map\_src(udimord)%start
135     map\_result(1)%count = map\_src(udimord)%count
136     map\_result(1)%stride = map\_src(udimord)%stride
137     \textcolor{keyword}{call }\hyperlink{namespacegtdata__internal__map_a2e6a789c1c8f4850421da11f10081cb7}{map\_set}(var, map=map\_result, stat=stat)
138   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (sclass == vtb\_class\_memory) \textcolor{keywordflow}{then}
139     var = source\_var
140     stat = \hyperlink{namespacedc__error_a64841a3c9e3ef7d5ddb175e5770f7dfe}{dc\_noerr}
141   \textcolor{keywordflow}{else}
142     stat = \hyperlink{namespacedc__error_a3c706700d7fb6c0ff705558066f8e583}{gt\_efake}
143 \textcolor{keywordflow}{  endif}
144 
145   \textcolor{keyword}{deallocate}(map\_src)
146 \textcolor{keyword}{  end}sub\_msg = CPrintf(\textcolor{stringliteral}{'result\_var=%d'}, i=(/var%mapid/))
147 999 \textcolor{keywordflow}{continue}
148   \textcolor{keyword}{call }\hyperlink{namespacedc__error_a0104aee83ee5752b1a9f6152b11864a8}{storeerror}(stat, subname, cause\_i=cause\_i, err=err)
149   \textcolor{keyword}{call }\hyperlink{namespacedc__trace_ae44de97565a3bdd685789c7748b37e37}{endsub}(subname, \textcolor{stringliteral}{'%c'}, c1=trim(endsub\_msg))
\end{DoxyCode}
Here is the call graph for this function\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{gtvaropenbydimord_8f90_af9708266edff2064dbb1e427c0157f3a_cgraph}
\end{center}
\end{figure}
