\hypertarget{gtvarlimitbinary_8f90}{}\section{gtdata/gtvarlimitbinary.f90 File Reference}
\label{gtvarlimitbinary_8f90}\index{gtdata/gtvarlimitbinary.\+f90@{gtdata/gtvarlimitbinary.\+f90}}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine \hyperlink{gtvarlimitbinary_8f90_aa5ec261b1bb171b5041216b7eb5b31d3}{gtvarxformbinary} (var1, var2, err)
\item 
subroutine \hyperlink{gtvarlimitbinary_8f90_af5617bdb440d28ef6bae0dc011f4b443}{adjust\+\_\+slice} (var1, var2, idim1, idim2, offset, stepfact)
\item 
subroutine \hyperlink{gtvarlimitbinary_8f90_a8ea50056ca865ff48beedd3b2a9d087c}{getmatch} (var1, var2, ndim1, ndim2, map1, map2)
\item 
logical function \hyperlink{gtvarlimitbinary_8f90_abd9c4656669c789fac44493bd9303c8c}{map\+\_\+finished} (map)
\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{gtvarlimitbinary_8f90_af5617bdb440d28ef6bae0dc011f4b443}\label{gtvarlimitbinary_8f90_af5617bdb440d28ef6bae0dc011f4b443}} 
\index{gtvarlimitbinary.\+f90@{gtvarlimitbinary.\+f90}!adjust\+\_\+slice@{adjust\+\_\+slice}}
\index{adjust\+\_\+slice@{adjust\+\_\+slice}!gtvarlimitbinary.\+f90@{gtvarlimitbinary.\+f90}}
\subsubsection{\texorpdfstring{adjust\+\_\+slice()}{adjust\_slice()}}
{\footnotesize\ttfamily subroutine gtvarxformbinary\+::adjust\+\_\+slice (\begin{DoxyParamCaption}\item[{type(gt\+\_\+variable), intent(in)}]{var1,  }\item[{type(gt\+\_\+variable), intent(in)}]{var2,  }\item[{integer, intent(in)}]{idim1,  }\item[{integer, intent(in)}]{idim2,  }\item[{integer, intent(out)}]{offset,  }\item[{integer, intent(out)}]{stepfact }\end{DoxyParamCaption})}



Definition at line 119 of file gtvarlimitbinary.\+f90.


\begin{DoxyCode}
119     \textcolor{keywordtype}{use }gtdata\_generic\textcolor{keywordtype}{, only}: \hyperlink{interfacegtdata__netcdf__generic_1_1get}{get}, \hyperlink{interfacegtdata__netcdf__generic_1_1open}{open}, \hyperlink{interfacegtdata__netcdf__generic_1_1close}{close}
120     \textcolor{keywordtype}{type}(gt\_variable), \textcolor{keywordtype}{intent(in)}:: var1, var2
121     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)}:: idim1, idim2
122     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(out)}:: offset, stepfact
123     \textcolor{keywordtype}{type}(gt\_variable):: var\_d
124     \textcolor{keywordtype}{integer}:: n, buf(1)
125     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable}:: val1(:), val2(:)
126   \textcolor{keywordflow}{continue}
127     \textcolor{keyword}{call }beginsub(\textcolor{stringliteral}{'adjust\_slice'})
128     \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1open}{open}(var\_d, source\_var=var1, dimord=idim1, count\_compact=.true.)
129     \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1inquire}{inquire}(var\_d, size=n)
130     \textcolor{keyword}{allocate}(val1(n))
131     \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1get}{get}(var\_d, val1, n)
132     \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1close}{close}(var\_d)
133     \textcolor{comment}{!}
134     \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1open}{open}(var\_d, source\_var=var2, dimord=idim2, count\_compact=.true.)
135     \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1inquire}{inquire}(var\_d, size=n)
136     \textcolor{keyword}{allocate}(val2(n))
137     \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1get}{get}(var\_d, val2, n)
138     \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1close}{close}(var\_d)
139     \textcolor{comment}{!}
140     buf(1:1) = minloc(abs(val1(:) - val2(1)))
141     offset = buf(1) - 1
142     \textcolor{keywordflow}{if} (\textcolor{keyword}{size}(val2) < 2 .or. \textcolor{keyword}{size}(val1) < 2) \textcolor{keywordflow}{then}
143       stepfact = 1
144     \textcolor{keywordflow}{else}
145       buf(1:1) = minloc(abs(val1(:) - val2(2)))
146       stepfact = buf(1) - (offset + 1)
147 \textcolor{keywordflow}{    endif}
148     \textcolor{comment}{!}
149     \textcolor{keyword}{deallocate}(val1, val2)
150     \textcolor{keyword}{call }endsub(\textcolor{stringliteral}{'adjust\_slice'})
\end{DoxyCode}
\mbox{\Hypertarget{gtvarlimitbinary_8f90_a8ea50056ca865ff48beedd3b2a9d087c}\label{gtvarlimitbinary_8f90_a8ea50056ca865ff48beedd3b2a9d087c}} 
\index{gtvarlimitbinary.\+f90@{gtvarlimitbinary.\+f90}!getmatch@{getmatch}}
\index{getmatch@{getmatch}!gtvarlimitbinary.\+f90@{gtvarlimitbinary.\+f90}}
\subsubsection{\texorpdfstring{getmatch()}{getmatch()}}
{\footnotesize\ttfamily subroutine gtvarxformbinary\+::getmatch (\begin{DoxyParamCaption}\item[{type(gt\+\_\+variable), intent(in)}]{var1,  }\item[{type(gt\+\_\+variable), intent(in)}]{var2,  }\item[{integer, intent(in)}]{ndim1,  }\item[{integer, intent(in)}]{ndim2,  }\item[{integer, dimension(\+:), intent(out)}]{map1,  }\item[{integer, dimension(\+:), intent(out)}]{map2 }\end{DoxyParamCaption})}



Definition at line 158 of file gtvarlimitbinary.\+f90.



References dc\+\_\+units\+::add\+\_\+okay(), map\+\_\+finished(), and dc\+\_\+types\+::string.


\begin{DoxyCode}
158     \textcolor{keywordtype}{use }\hyperlink{namespacedc__types}{dc\_types}\textcolor{keywordtype}{, only}: \hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}
159     \textcolor{keywordtype}{use }\hyperlink{namespacedc__units}{dc\_units}\textcolor{keywordtype}{, only}: units, \hyperlink{namespacedc__units_ac0da92106f72e724931c4918550b3dbe}{add\_okay}, \textcolor{keyword}{assignment}(=), clear, deallocate
160     \textcolor{keywordtype}{use }gtdata\_generic\textcolor{keywordtype}{, only}: \hyperlink{interfacegtdata__netcdf__generic_1_1get__attr}{get\_attr}, \hyperlink{interfacegtdata__netcdf__generic_1_1open}{open}, \hyperlink{interfacegtdata__netcdf__generic_1_1close}{close}
161     \textcolor{keywordtype}{type}(gt\_variable), \textcolor{keywordtype}{intent(in)}:: var1, var2
162     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)}:: ndim1, ndim2
163     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(out)}:: map1(:), map2(:)
164     \textcolor{keywordtype}{type}(gt\_variable):: var\_d
165     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{allocatable}:: map(:, :)
166     \textcolor{keywordtype}{integer}:: i, j
167     \textcolor{keywordtype}{character(STRING)}:: su1, su2
168     \textcolor{keywordtype}{type}(units), \textcolor{keywordtype}{allocatable}:: u1(:), u2(:)
169   \textcolor{keywordflow}{continue}
170     \textcolor{keyword}{call }beginsub(\textcolor{stringliteral}{'getmatch'})
171     \textcolor{comment}{! 返却値はデフォルト 0}
172     map1(:) = 0
173     map2(:) = 0
174     \textcolor{comment}{! 表の構築: 初期値は消去法をとることを示す}
175     \textcolor{keyword}{allocate}(map(ndim1, ndim2))
176     map(:, :) = 1
177 
178     \textcolor{comment}{! 単位による対応 --- 加算可能でなければ対にしない}
179     \textcolor{comment}{! 単位の構成}
180     \textcolor{keyword}{allocate}(u1(ndim1), u2(ndim2))
181     \textcolor{keywordflow}{do}, i = 1, ndim1
182       \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1open}{open}(var\_d, var1, i, count\_compact=.true.)
183       \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1get__attr}{get\_attr}(var\_d, \textcolor{stringliteral}{'units'}, su1)
184       \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1close}{close}(var\_d)
185       \textcolor{keyword}{call }clear(u1(i))
186       u1(i) = su1
187 \textcolor{keywordflow}{    enddo}
188     \textcolor{keywordflow}{do}, j = 1, ndim2
189       \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1open}{open}(var\_d, var2, j, count\_compact=.true.)
190       \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1get__attr}{get\_attr}(var\_d, \textcolor{stringliteral}{'units'}, su2)
191       \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1close}{close}(var\_d)
192       \textcolor{keyword}{call }clear(u2(j))
193       u2(j) = su2
194 \textcolor{keywordflow}{    enddo}
195     \textcolor{comment}{! 処理}
196     \textcolor{keywordflow}{do}, i = 1, ndim1
197       \textcolor{keywordflow}{do}, j = 1, ndim2
198         \textcolor{keywordflow}{if} (.not. \hyperlink{namespacedc__units_ac0da92106f72e724931c4918550b3dbe}{add\_okay}(u1(i), u2(j))) &
199           & map(i, j) = 0
200 \textcolor{keywordflow}{      enddo}
201 \textcolor{keywordflow}{    enddo}
202     \textcolor{comment}{! 単位の廃棄}
203     \textcolor{keywordflow}{do}, i = 1, ndim1
204       \textcolor{keyword}{call }deallocate(u1(i))
205 \textcolor{keywordflow}{    enddo}
206     \textcolor{keywordflow}{do}, j = 1, ndim2
207       \textcolor{keyword}{call }deallocate(u2(j))
208 \textcolor{keywordflow}{    enddo}
209     \textcolor{keyword}{deallocate}(u1, u2)
210 
211     \textcolor{keywordflow}{if} (\hyperlink{gtvarlimitbinary_8f90_abd9c4656669c789fac44493bd9303c8c}{map\_finished}(map)) \textcolor{keywordflow}{goto} 1000
212 
213     \textcolor{comment}{! --- it fails ---}
214     \textcolor{keyword}{call }endsub(\textcolor{stringliteral}{'getmatch'}, \textcolor{stringliteral}{'fail'})
215     \textcolor{keywordflow}{return}
216 
217 1000 \textcolor{keywordflow}{continue}
218     \textcolor{keywordflow}{do}, i = 1, ndim1
219       \textcolor{keyword}{call }dbgmessage(\textcolor{stringliteral}{'map(%d, :)=%*d'}, i=(/i, map(i,:)/), n=(/ndim2/))
220 \textcolor{keywordflow}{    enddo}
221     \textcolor{keywordflow}{do}, i = 1, ndim1
222       \textcolor{keywordflow}{if} (all(map(i, :) <= 0)) \textcolor{keywordflow}{then}
223         map1(i) = 0
224       \textcolor{keywordflow}{else}
225         map1(i:i) = maxloc(map(i, :))
226 \textcolor{keywordflow}{      endif}
227 \textcolor{keywordflow}{    enddo}
228     \textcolor{keywordflow}{do}, j = 1, ndim2
229       \textcolor{keywordflow}{if} (all(map(:, j) <= 0)) \textcolor{keywordflow}{then} 
230         map2(j) = 0
231       \textcolor{keywordflow}{else}
232         map2(j:j) = maxloc(map(:, j), dim=1)
233 \textcolor{keywordflow}{      endif}
234 \textcolor{keywordflow}{    enddo}
235     \textcolor{keyword}{call }endsub(\textcolor{stringliteral}{'getmatch'}, \textcolor{stringliteral}{'okay'})
\end{DoxyCode}
Here is the call graph for this function\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{gtvarlimitbinary_8f90_a8ea50056ca865ff48beedd3b2a9d087c_cgraph}
\end{center}
\end{figure}
\mbox{\Hypertarget{gtvarlimitbinary_8f90_aa5ec261b1bb171b5041216b7eb5b31d3}\label{gtvarlimitbinary_8f90_aa5ec261b1bb171b5041216b7eb5b31d3}} 
\index{gtvarlimitbinary.\+f90@{gtvarlimitbinary.\+f90}!gtvarxformbinary@{gtvarxformbinary}}
\index{gtvarxformbinary@{gtvarxformbinary}!gtvarlimitbinary.\+f90@{gtvarlimitbinary.\+f90}}
\subsubsection{\texorpdfstring{gtvarxformbinary()}{gtvarxformbinary()}}
{\footnotesize\ttfamily subroutine gtvarxformbinary (\begin{DoxyParamCaption}\item[{type(gt\+\_\+variable), intent(inout)}]{var1,  }\item[{type(gt\+\_\+variable), intent(inout)}]{var2,  }\item[{logical, intent(out), optional}]{err }\end{DoxyParamCaption})}



Definition at line 14 of file gtvarlimitbinary.\+f90.



References adjust\+\_\+slice(), dc\+\_\+error\+::dc\+\_\+noerr, getmatch(), dc\+\_\+error\+::gt\+\_\+efake, dc\+\_\+error\+::gt\+\_\+enomatchdim, gtdata\+\_\+internal\+\_\+map\+::gtvar\+\_\+dump(), gtdata\+\_\+internal\+\_\+map\+::map\+\_\+allocate(), gtdata\+\_\+internal\+\_\+map\+::map\+\_\+apply(), and dc\+\_\+error\+::storeerror().


\begin{DoxyCode}
14   \textcolor{comment}{!}
15   \textcolor{comment}{!== 2 つの変数の次元配置の共通化}
16   \textcolor{comment}{!}
17   \textcolor{comment}{! 変数 <b>var1</b> の次元構成が <b>var2</b> の次元構成と同じになるように}
18   \textcolor{comment}{! 範囲拘束を行います。過剰な次元が <b>var1</b> にある場合、隠蔽}
19   \textcolor{comment}{! を行います。(追加もできるようにする予定です)。}
20   \textcolor{comment}{!}
21   \textcolor{comment}{! エラーが生じた場合、メッセージを出力}
22   \textcolor{comment}{! してプログラムは強制終了します。*err* を与えてある場合には}
23   \textcolor{comment}{! の引数に .true. が返り、プログラムは終了しません。}
24   \textcolor{comment}{!}
25   \textcolor{comment}{!--}
26   \textcolor{comment}{! 二つの変数 var1, var2 に入出力範囲拘束を加えて次元配置を共通化する。}
27   \textcolor{comment}{! 結果の次元構成はとりあえずモデルで使えるように決めた。}
28   \textcolor{comment}{!    var2 の空間を保持する。var1 を変形する。}
29   \textcolor{comment}{!    var2 の次元は (有幅・縮退ともに) var2 における幅がとられる。}
30   \textcolor{comment}{!    したがって var1 においては存在しないか var2 をカバーする幅で}
31   \textcolor{comment}{!    なければならない。}
32   \textcolor{comment}{!    var2 にない var1 の次元は見えないようになるので縮退しているか}
33   \textcolor{comment}{!    存在しないのでなければならない。}
34   \textcolor{comment}{!++}
35   \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__types}{gtdata\_types}\textcolor{keywordtype}{, only}: gt\_variable
36   \textcolor{keywordtype}{use }gtdata\_generic\textcolor{keywordtype}{, only}: \hyperlink{interfacegtdata__netcdf__generic_1_1inquire}{inquire}, get\_slice
37   \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__internal__map}{gtdata\_internal\_map}\textcolor{keywordtype}{, only}: \hyperlink{namespacegtdata__internal__map_a53ed1ebec2d5efdf436782f9956fb13d}{map\_allocate}, 
      \hyperlink{namespacegtdata__internal__map_a0ae3e37d788b82682e1c22b0dfe09214}{map\_apply}, \hyperlink{structgtdata__internal__map_1_1gt__dimmap}{gt\_dimmap}, \hyperlink{namespacegtdata__internal__map_acbda65a71acbd7d3ba6175c6f4fceff0}{gtvar\_dump}
38   \textcolor{keywordtype}{use }\hyperlink{namespacedc__error}{dc\_error}\textcolor{keywordtype}{, only}: \hyperlink{namespacedc__error_a0104aee83ee5752b1a9f6152b11864a8}{storeerror}, \hyperlink{namespacedc__error_a075d54962bd00046a4c02cc3a76a39df}{gt\_enomatchdim}, 
      \hyperlink{namespacedc__error_a3c706700d7fb6c0ff705558066f8e583}{gt\_efake}, \hyperlink{namespacedc__error_a64841a3c9e3ef7d5ddb175e5770f7dfe}{dc\_noerr}
39   \textcolor{keywordtype}{use }dc\_trace\textcolor{keywordtype}{, only}: beginsub, endsub, dbgmessage
40   \textcolor{keywordtype}{implicit none}
41   \textcolor{keywordtype}{type}(gt\_variable), \textcolor{keywordtype}{intent(inout)}:: var1, var2
42   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(out)}, \textcolor{keywordtype}{optional}:: err
43   \textcolor{keywordtype}{integer}:: ndim1, ndim2, ndimo
44   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{allocatable}:: map1(:), map2(:)
45   \textcolor{keywordtype}{type}(\hyperlink{structgtdata__internal__map_1_1gt__dimmap}{gt\_dimmap}), \textcolor{keywordtype}{pointer}:: newmap(:)
46   \textcolor{keywordtype}{integer}:: i, j, stat
47   \textcolor{keywordtype}{character(*)}, \textcolor{keywordtype}{parameter}:: subnam = \textcolor{stringliteral}{"GTVarXformBinary"}
48 \textcolor{keywordflow}{continue}
49   \textcolor{keyword}{call }beginsub(subnam, \textcolor{stringliteral}{'mapid=[%d, %d]'}, i=(/var1%mapid, var2%mapid/))
50   \textcolor{keyword}{call }\hyperlink{namespacegtdata__internal__map_acbda65a71acbd7d3ba6175c6f4fceff0}{gtvar\_dump}(var1)
51   \textcolor{keyword}{call }\hyperlink{namespacegtdata__internal__map_acbda65a71acbd7d3ba6175c6f4fceff0}{gtvar\_dump}(var2)
52   \textcolor{comment}{!}
53   \textcolor{comment}{! 二つの変数 var1, var2 から共有次元を調べ、対応表 map1, map2 をつくる。}
54   \textcolor{comment}{!}
55   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(err)) err = .false.
56   \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1inquire}{inquire}(var1, alldims=ndim1)
57   \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1inquire}{inquire}(var2, alldims=ndim2)
58   ndimo = \hyperlink{interfacedc__date__generic_1_1max}{max}(ndim1, ndim2, 0)
59   \textcolor{keyword}{allocate}(map1(1:ndim1), map2(1:ndim2))
60   \textcolor{keyword}{call }\hyperlink{gtvarlimitbinary_8f90_a8ea50056ca865ff48beedd3b2a9d087c}{getmatch}(var1, var2, ndim1, ndim2, map1, map2)
61   \textcolor{keyword}{call }dbgmessage(\textcolor{stringliteral}{'map1=%*d map2=%*d'}, i=(/map1(1:ndim1), map2(1:ndim2)/), n=(/ndim1, ndim2/))
62   \textcolor{keywordflow}{if} (all(map2(1:ndim2) == 0)) \textcolor{keywordflow}{then}
63     stat = \hyperlink{namespacedc__error_a075d54962bd00046a4c02cc3a76a39df}{gt\_enomatchdim}
64     \textcolor{keywordflow}{goto} 999
65 \textcolor{keywordflow}{  endif}
66   \textcolor{comment}{!}
67   \textcolor{comment}{! 再配置テーブル作成開始}
68   \textcolor{comment}{!}
69   ndimo = ndim2 + count(map1(1:ndim1) == 0)
70   \textcolor{keyword}{call }\hyperlink{namespacegtdata__internal__map_a53ed1ebec2d5efdf436782f9956fb13d}{map\_allocate}(newmap, ndimo)
71   \textcolor{comment}{!}
72   \textcolor{comment}{! 1..ndim2 は map2 によって var2 の次元たちにマップする}
73   \textcolor{comment}{!}
74   newmap(1:ndim2)%dimno = map2(1:ndim2)
75   \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1inquire}{inquire}(var2, allcount=newmap(1:ndim2)%allcount)
76   \textcolor{keyword}{call }get\_slice(var2, count=newmap(1:ndim2)%count)
77   \textcolor{keywordflow}{do}, j = 1, ndim2
78     \textcolor{keywordflow}{if} (map2(j) == 0) \textcolor{keywordflow}{then}
79       newmap(j)%start = 1
80       newmap(j)%stride = 1
81       \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1inquire}{inquire}(var2, j, url=newmap(j)%url)
82     \textcolor{keywordflow}{else}
83       \textcolor{comment}{! 位置対応によって var1 側での開始位置を決定する}
84       \textcolor{keyword}{call }\hyperlink{gtvarlimitbinary_8f90_af5617bdb440d28ef6bae0dc011f4b443}{adjust\_slice}(var1, var2, map2(j), j, &
85         & newmap(j)%start, newmap(j)%stride)
86 \textcolor{keywordflow}{    endif}
87 \textcolor{keywordflow}{  enddo}
88   \textcolor{comment}{!}
89   \textcolor{comment}{! ndim2+1.. ndimo は var2 に対応させられない var1 の次元をおく}
90   \textcolor{comment}{!}
91   j = 0
92   loop1: \textcolor{keywordflow}{do}, i = ndim2 + 1, ndimo
93     \textcolor{keywordflow}{do}
94       j = j + 1
95       \textcolor{keywordflow}{if} (j > ndim1) \textcolor{keywordflow}{exit} loop1
96       \textcolor{keywordflow}{if} (map1(j) <= 0) \textcolor{keywordflow}{exit}
97 \textcolor{keywordflow}{    enddo}
98     newmap(i)%dimno = j
99     \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1inquire}{inquire}(var1, dimord=j, allcount=newmap(i)%allcount)
100     \textcolor{keyword}{call }get\_slice(var1, dimord=j, start=newmap(i)%start, &
101       & count=newmap(i)%count, stride=newmap(i)%stride)
102 \textcolor{keywordflow}{  end do} loop1
103   \textcolor{comment}{!}
104   \textcolor{keyword}{call }\hyperlink{namespacegtdata__internal__map_a0ae3e37d788b82682e1c22b0dfe09214}{map\_apply}(var1, map=newmap)
105   \textcolor{comment}{!}
106   stat = \hyperlink{namespacedc__error_a64841a3c9e3ef7d5ddb175e5770f7dfe}{dc\_noerr}
107 999 \textcolor{keywordflow}{continue}
108   \textcolor{keyword}{call }\hyperlink{namespacedc__error_a0104aee83ee5752b1a9f6152b11864a8}{storeerror}(stat, subnam, err)
109   \textcolor{keyword}{call }endsub(subnam, \textcolor{stringliteral}{'stat=%d'}, i=(/stat/))
110   \textcolor{keyword}{deallocate}(map1, map2)
111   \textcolor{keywordflow}{return}
112 \textcolor{keyword}{contains}
113 
114   \textcolor{comment}{!}
115   \textcolor{comment}{! 二つの次元変数を調べ、軸上位置が対応するように}
116   \textcolor{comment}{! start シフト数と stride ファクタを決定する}
117   \textcolor{comment}{!}
118 \textcolor{keyword}{  subroutine }\hyperlink{gtvarlimitbinary_8f90_af5617bdb440d28ef6bae0dc011f4b443}{adjust\_slice}(var1, var2, idim1, idim2, offset, stepfact)
119     \textcolor{keywordtype}{use }gtdata\_generic\textcolor{keywordtype}{, only}: \hyperlink{interfacegtdata__netcdf__generic_1_1get}{get}, \hyperlink{interfacegtdata__netcdf__generic_1_1open}{open}, \hyperlink{interfacegtdata__netcdf__generic_1_1close}{close}
120     \textcolor{keywordtype}{type}(gt\_variable), \textcolor{keywordtype}{intent(in)}:: var1, var2
121     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)}:: idim1, idim2
122     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(out)}:: offset, stepfact
123     \textcolor{keywordtype}{type}(gt\_variable):: var\_d
124     \textcolor{keywordtype}{integer}:: n, buf(1)
125     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable}:: val1(:), val2(:)
126   \textcolor{keywordflow}{continue}
127     \textcolor{keyword}{call }beginsub(\textcolor{stringliteral}{'adjust\_slice'})
128     \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1open}{open}(var\_d, source\_var=var1, dimord=idim1, count\_compact=.true.)
129     \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1inquire}{inquire}(var\_d, size=n)
130     \textcolor{keyword}{allocate}(val1(n))
131     \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1get}{get}(var\_d, val1, n)
132     \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1close}{close}(var\_d)
133     \textcolor{comment}{!}
134     \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1open}{open}(var\_d, source\_var=var2, dimord=idim2, count\_compact=.true.)
135     \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1inquire}{inquire}(var\_d, size=n)
136     \textcolor{keyword}{allocate}(val2(n))
137     \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1get}{get}(var\_d, val2, n)
138     \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1close}{close}(var\_d)
139     \textcolor{comment}{!}
140     buf(1:1) = minloc(abs(val1(:) - val2(1)))
141     offset = buf(1) - 1
142     \textcolor{keywordflow}{if} (\textcolor{keyword}{size}(val2) < 2 .or. \textcolor{keyword}{size}(val1) < 2) \textcolor{keywordflow}{then}
143       stepfact = 1
144     \textcolor{keywordflow}{else}
145       buf(1:1) = minloc(abs(val1(:) - val2(2)))
146       stepfact = buf(1) - (offset + 1)
147 \textcolor{keywordflow}{    endif}
148     \textcolor{comment}{!}
149     \textcolor{keyword}{deallocate}(val1, val2)
150     \textcolor{keyword}{call }endsub(\textcolor{stringliteral}{'adjust\_slice'})
151 \textcolor{keyword}{  end subroutine }\hyperlink{gtvarlimitbinary_8f90_af5617bdb440d28ef6bae0dc011f4b443}{adjust\_slice}
152 
153   \textcolor{comment}{!}
154   \textcolor{comment}{! 二つの変数から共有次元を調べ、対応表 map1, map2 を作る。}
155   \textcolor{comment}{! すなわち、それぞれの次元番号から相方の次元番号を得る表である。}
156   \textcolor{comment}{!}
157 \textcolor{keyword}{  subroutine }\hyperlink{gtvarlimitbinary_8f90_a8ea50056ca865ff48beedd3b2a9d087c}{getmatch}(var1, var2, ndim1, ndim2, map1, map2)
158     \textcolor{keywordtype}{use }\hyperlink{namespacedc__types}{dc\_types}\textcolor{keywordtype}{, only}: \hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}
159     \textcolor{keywordtype}{use }\hyperlink{namespacedc__units}{dc\_units}\textcolor{keywordtype}{, only}: units, \hyperlink{namespacedc__units_ac0da92106f72e724931c4918550b3dbe}{add\_okay}, \textcolor{keyword}{assignment}(=), clear, deallocate
160     \textcolor{keywordtype}{use }gtdata\_generic\textcolor{keywordtype}{, only}: \hyperlink{interfacegtdata__netcdf__generic_1_1get__attr}{get\_attr}, \hyperlink{interfacegtdata__netcdf__generic_1_1open}{open}, \hyperlink{interfacegtdata__netcdf__generic_1_1close}{close}
161     \textcolor{keywordtype}{type}(gt\_variable), \textcolor{keywordtype}{intent(in)}:: var1, var2
162     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)}:: ndim1, ndim2
163     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(out)}:: map1(:), map2(:)
164     \textcolor{keywordtype}{type}(gt\_variable):: var\_d
165     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{allocatable}:: map(:, :)
166     \textcolor{keywordtype}{integer}:: i, j
167     \textcolor{keywordtype}{character(STRING)}:: su1, su2
168     \textcolor{keywordtype}{type}(units), \textcolor{keywordtype}{allocatable}:: u1(:), u2(:)
169   \textcolor{keywordflow}{continue}
170     \textcolor{keyword}{call }beginsub(\textcolor{stringliteral}{'getmatch'})
171     \textcolor{comment}{! 返却値はデフォルト 0}
172     map1(:) = 0
173     map2(:) = 0
174     \textcolor{comment}{! 表の構築: 初期値は消去法をとることを示す}
175     \textcolor{keyword}{allocate}(map(ndim1, ndim2))
176     map(:, :) = 1
177 
178     \textcolor{comment}{! 単位による対応 --- 加算可能でなければ対にしない}
179     \textcolor{comment}{! 単位の構成}
180     \textcolor{keyword}{allocate}(u1(ndim1), u2(ndim2))
181     \textcolor{keywordflow}{do}, i = 1, ndim1
182       \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1open}{open}(var\_d, var1, i, count\_compact=.true.)
183       \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1get__attr}{get\_attr}(var\_d, \textcolor{stringliteral}{'units'}, su1)
184       \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1close}{close}(var\_d)
185       \textcolor{keyword}{call }clear(u1(i))
186       u1(i) = su1
187 \textcolor{keywordflow}{    enddo}
188     \textcolor{keywordflow}{do}, j = 1, ndim2
189       \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1open}{open}(var\_d, var2, j, count\_compact=.true.)
190       \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1get__attr}{get\_attr}(var\_d, \textcolor{stringliteral}{'units'}, su2)
191       \textcolor{keyword}{call }\hyperlink{interfacegtdata__netcdf__generic_1_1close}{close}(var\_d)
192       \textcolor{keyword}{call }clear(u2(j))
193       u2(j) = su2
194 \textcolor{keywordflow}{    enddo}
195     \textcolor{comment}{! 処理}
196     \textcolor{keywordflow}{do}, i = 1, ndim1
197       \textcolor{keywordflow}{do}, j = 1, ndim2
198         \textcolor{keywordflow}{if} (.not. \hyperlink{namespacedc__units_ac0da92106f72e724931c4918550b3dbe}{add\_okay}(u1(i), u2(j))) &
199           & map(i, j) = 0
200 \textcolor{keywordflow}{      enddo}
201 \textcolor{keywordflow}{    enddo}
202     \textcolor{comment}{! 単位の廃棄}
203     \textcolor{keywordflow}{do}, i = 1, ndim1
204       \textcolor{keyword}{call }deallocate(u1(i))
205 \textcolor{keywordflow}{    enddo}
206     \textcolor{keywordflow}{do}, j = 1, ndim2
207       \textcolor{keyword}{call }deallocate(u2(j))
208 \textcolor{keywordflow}{    enddo}
209     \textcolor{keyword}{deallocate}(u1, u2)
210 
211     \textcolor{keywordflow}{if} (\hyperlink{gtvarlimitbinary_8f90_abd9c4656669c789fac44493bd9303c8c}{map\_finished}(map)) \textcolor{keywordflow}{goto} 1000
212 
213     \textcolor{comment}{! --- it fails ---}
214     \textcolor{keyword}{call }endsub(\textcolor{stringliteral}{'getmatch'}, \textcolor{stringliteral}{'fail'})
215     \textcolor{keywordflow}{return}
216 
217 1000 \textcolor{keywordflow}{continue}
218     \textcolor{keywordflow}{do}, i = 1, ndim1
219       \textcolor{keyword}{call }dbgmessage(\textcolor{stringliteral}{'map(%d, :)=%*d'}, i=(/i, map(i,:)/), n=(/ndim2/))
220 \textcolor{keywordflow}{    enddo}
221     \textcolor{keywordflow}{do}, i = 1, ndim1
222       \textcolor{keywordflow}{if} (all(map(i, :) <= 0)) \textcolor{keywordflow}{then}
223         map1(i) = 0
224       \textcolor{keywordflow}{else}
225         map1(i:i) = maxloc(map(i, :))
226 \textcolor{keywordflow}{      endif}
227 \textcolor{keywordflow}{    enddo}
228     \textcolor{keywordflow}{do}, j = 1, ndim2
229       \textcolor{keywordflow}{if} (all(map(:, j) <= 0)) \textcolor{keywordflow}{then} 
230         map2(j) = 0
231       \textcolor{keywordflow}{else}
232         map2(j:j) = maxloc(map(:, j), dim=1)
233 \textcolor{keywordflow}{      endif}
234 \textcolor{keywordflow}{    enddo}
235     \textcolor{keyword}{call }endsub(\textcolor{stringliteral}{'getmatch'}, \textcolor{stringliteral}{'okay'})
236 \textcolor{keyword}{  end subroutine }\hyperlink{gtvarlimitbinary_8f90_a8ea50056ca865ff48beedd3b2a9d087c}{getmatch}
237 
238 \textcolor{keyword}{  logical }\textcolor{keyword}{function }\hyperlink{gtvarlimitbinary_8f90_abd9c4656669c789fac44493bd9303c8c}{map\_finished}(map) \textcolor{keyword}{result}(result)
239     \textcolor{keywordtype}{integer}:: map(:, :)
240     \textcolor{keywordtype}{integer}:: i, j, ni
241   \textcolor{keywordflow}{continue}
242     \textcolor{keyword}{call }beginsub(\textcolor{stringliteral}{'map\_finished'})
243     ni = \textcolor{keyword}{size}(map, dim=1)
244     \textcolor{keywordflow}{do}, i = 1, ni
245       \textcolor{keywordflow}{if} (count(map(i, :) > 0) > 1) \textcolor{keywordflow}{then}
246         result = .false.
247         \textcolor{keywordflow}{goto} 999
248 \textcolor{keywordflow}{      endif}
249 \textcolor{keywordflow}{    enddo}
250     \textcolor{keywordflow}{do}, j = 1, ni
251       \textcolor{keywordflow}{if} (count(map(j, :) > 0) > 1) \textcolor{keywordflow}{then}
252         result = .false.
253         \textcolor{keywordflow}{goto} 999
254 \textcolor{keywordflow}{      endif}
255 \textcolor{keywordflow}{    enddo}
256     result = .true.
257 999 \textcolor{keywordflow}{continue}
258     \textcolor{keyword}{call }endsub(\textcolor{stringliteral}{'map\_finished'})
259 \textcolor{keyword}{  end function }\hyperlink{gtvarlimitbinary_8f90_abd9c4656669c789fac44493bd9303c8c}{map\_finished}
260 
\end{DoxyCode}
Here is the call graph for this function\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{gtvarlimitbinary_8f90_aa5ec261b1bb171b5041216b7eb5b31d3_cgraph}
\end{center}
\end{figure}
\mbox{\Hypertarget{gtvarlimitbinary_8f90_abd9c4656669c789fac44493bd9303c8c}\label{gtvarlimitbinary_8f90_abd9c4656669c789fac44493bd9303c8c}} 
\index{gtvarlimitbinary.\+f90@{gtvarlimitbinary.\+f90}!map\+\_\+finished@{map\+\_\+finished}}
\index{map\+\_\+finished@{map\+\_\+finished}!gtvarlimitbinary.\+f90@{gtvarlimitbinary.\+f90}}
\subsubsection{\texorpdfstring{map\+\_\+finished()}{map\_finished()}}
{\footnotesize\ttfamily logical function gtvarxformbinary\+::map\+\_\+finished (\begin{DoxyParamCaption}\item[{integer, dimension(\+:, \+:)}]{map }\end{DoxyParamCaption})}



Definition at line 239 of file gtvarlimitbinary.\+f90.


\begin{DoxyCode}
239     \textcolor{keywordtype}{integer}:: map(:, :)
240     \textcolor{keywordtype}{integer}:: i, j, ni
241   \textcolor{keywordflow}{continue}
242     \textcolor{keyword}{call }beginsub(\textcolor{stringliteral}{'map\_finished'})
243     ni = \textcolor{keyword}{size}(map, dim=1)
244     \textcolor{keywordflow}{do}, i = 1, ni
245       \textcolor{keywordflow}{if} (count(map(i, :) > 0) > 1) \textcolor{keywordflow}{then}
246         result = .false.
247         \textcolor{keywordflow}{goto} 999
248 \textcolor{keywordflow}{      endif}
249 \textcolor{keywordflow}{    enddo}
250     \textcolor{keywordflow}{do}, j = 1, ni
251       \textcolor{keywordflow}{if} (count(map(j, :) > 0) > 1) \textcolor{keywordflow}{then}
252         result = .false.
253         \textcolor{keywordflow}{goto} 999
254 \textcolor{keywordflow}{      endif}
255 \textcolor{keywordflow}{    enddo}
256     result = .true.
257 999 \textcolor{keywordflow}{continue}
258     \textcolor{keyword}{call }endsub(\textcolor{stringliteral}{'map\_finished'})
\end{DoxyCode}
