\hypertarget{gtvarlimit_8f90}{}\section{gtdata/gtvarlimit.f90 File Reference}
\label{gtvarlimit_8f90}\index{gtdata/gtvarlimit.\+f90@{gtdata/gtvarlimit.\+f90}}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine \hyperlink{gtvarlimit_8f90_a83b7ff374f6128f84532a53c2a3b2935}{gtvarlimit\+\_\+iiii} (var, dimord, start, count, stride, err)
\item 
subroutine \hyperlink{gtvarlimit_8f90_a29ade81799ba86531d3aec49f949d216}{gtvarlimit} (var, string, err)
\item 
subroutine \hyperlink{gtvarlimit_8f90_a3ab399280ae0a9c47ef63d17a9cbb1ae}{limit\+\_\+one} (string)
\item 
subroutine \hyperlink{gtvarlimit_8f90_a94e803f7f864a2956bece716f16a6a57}{region\+\_\+spec} (dimord, string, start, count, stride)
\item 
real function \hyperlink{gtvarlimit_8f90_a84b815e1598fad755fc5b5ca03612997}{value\+\_\+to\+\_\+index} (dimord, value)
\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{gtvarlimit_8f90_a29ade81799ba86531d3aec49f949d216}\label{gtvarlimit_8f90_a29ade81799ba86531d3aec49f949d216}} 
\index{gtvarlimit.\+f90@{gtvarlimit.\+f90}!gtvarlimit@{gtvarlimit}}
\index{gtvarlimit@{gtvarlimit}!gtvarlimit.\+f90@{gtvarlimit.\+f90}}
\subsubsection{\texorpdfstring{gtvarlimit()}{gtvarlimit()}}
{\footnotesize\ttfamily subroutine gtvarlimit (\begin{DoxyParamCaption}\item[{type(gt\+\_\+variable), intent(inout)}]{var,  }\item[{character(len = $\ast$), intent(in)}]{string,  }\item[{logical, intent(out), optional}]{err }\end{DoxyParamCaption})}



Definition at line 147 of file gtvarlimit.\+f90.



References dc\+\_\+trace\+::beginsub(), dc\+\_\+trace\+::endsub(), dc\+\_\+url\+::gt\+\_\+comma, gtdata\+\_\+internal\+\_\+map\+::gtvar\+\_\+dump(), and limit\+\_\+one().


\begin{DoxyCode}
147   \textcolor{comment}{!}
148   \textcolor{comment}{!== 入出力範囲の拘束 (文字列で指定)}
149   \textcolor{comment}{!}
150   \textcolor{comment}{! 変数 *var* 次元の入出力範囲を拘束します。}
151   \textcolor{comment}{! *Limit* は 2 つのサブルーチンの総称名であり、}
152   \textcolor{comment}{! 別の指定方法もあります。まずは上記のサブルーチンを参照してください。}
153   \textcolor{comment}{!}
154   \textcolor{comment}{! 指定方法は、*string* に}
155   \textcolor{comment}{! \{gtool4 netCDF 規約\}[link:../xref.htm#label-6] の}
156   \textcolor{comment}{! 「5.4 コンマ記法」に述べられる範囲指定表現を用います。}
157   \textcolor{comment}{! 凡例を以下に挙げます。}
158   \textcolor{comment}{!}
159   \textcolor{comment}{!     <dim>=<lower>}
160   \textcolor{comment}{!}
161   \textcolor{comment}{!     <dim>=<lower>:<upper>}
162   \textcolor{comment}{!}
163   \textcolor{comment}{!     <dim>=<lower>:<upper>:<stride>}
164   \textcolor{comment}{!}
165   \textcolor{comment}{! ここで、<tt><dim></tt> は次元番号または次元名であり、}
166   \textcolor{comment}{! <tt><lower></tt>, <tt><upper></tt>}
167   \textcolor{comment}{! は座標値または "<tt>^</tt>" を前置した格子番号です。}
168   \textcolor{comment}{! <tt><stride></tt> は格子数です。}
169   \textcolor{comment}{!}
170   \textcolor{comment}{! エラーが生じた場合、メッセージを出力}
171   \textcolor{comment}{! してプログラムは強制終了します。*err* を与えてある場合には}
172   \textcolor{comment}{! の引数に .true. が返り、プログラムは終了しません。}
173   \textcolor{comment}{!}
174   \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__types}{gtdata\_types}\textcolor{keywordtype}{, only}: \hyperlink{structgtdata__types_1_1gt__variable}{gt\_variable}
175   \textcolor{keywordtype}{use }\hyperlink{namespacedc__trace}{dc\_trace}\textcolor{keywordtype}{, only}: \hyperlink{namespacedc__trace_aca1efe8bae50b85f74980a8c4d704dd8}{beginsub}, \hyperlink{namespacedc__trace_ae44de97565a3bdd685789c7748b37e37}{endsub}
176   \textcolor{keywordtype}{use }\hyperlink{namespacedc__url}{dc\_url}\textcolor{keywordtype}{, only}: \hyperlink{namespacedc__url_a61f457425e29d1452036669b43735790}{gt\_comma}
177   \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__internal__map}{gtdata\_internal\_map}\textcolor{keywordtype}{, only}: \hyperlink{namespacegtdata__internal__map_acbda65a71acbd7d3ba6175c6f4fceff0}{gtvar\_dump}
178   \textcolor{keywordtype}{type}(\hyperlink{structgtdata__types_1_1gt__variable}{gt\_variable}),  \textcolor{keywordtype}{intent(inout)}:: var
179   \textcolor{keywordtype}{character(len = *)}, \textcolor{keywordtype}{intent(in)}   :: \hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}
180   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(out)}, \textcolor{keywordtype}{optional}   :: err
181   \textcolor{keywordtype}{integer}:: is, ie
182 \textcolor{keywordflow}{continue}
183   \textcolor{keyword}{call }\hyperlink{namespacedc__trace_aca1efe8bae50b85f74980a8c4d704dd8}{beginsub}(\textcolor{stringliteral}{'GTVarLimit'}, \textcolor{stringliteral}{'var=%d lim=<%c>'}, i=(/var%mapid/), c1=trim(
      \hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}))
184   \textcolor{keyword}{call }\hyperlink{namespacegtdata__internal__map_acbda65a71acbd7d3ba6175c6f4fceff0}{gtvar\_dump}(var)
185   \textcolor{comment}{! コンマで区切って解釈}
186   is = 1
187   \textcolor{keywordflow}{do}
188     ie = index(\hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}(is: ), \hyperlink{namespacedc__url_a61f457425e29d1452036669b43735790}{gt\_comma})
189     \textcolor{keywordflow}{if} (ie == 0) \textcolor{keywordflow}{exit}
190     \textcolor{keyword}{call }\hyperlink{gtvarlimit_8f90_a3ab399280ae0a9c47ef63d17a9cbb1ae}{limit\_one}(\hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}(is: is+ie-2))
191     is = is + ie
192     \textcolor{keywordflow}{if} (is > len(\hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string})) \textcolor{keywordflow}{exit}
193 \textcolor{keywordflow}{  enddo}
194   \textcolor{keyword}{call }\hyperlink{gtvarlimit_8f90_a3ab399280ae0a9c47ef63d17a9cbb1ae}{limit\_one}(\hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}(is: ))
195   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(err)) err = .false.
196   \textcolor{keyword}{call }\hyperlink{namespacedc__trace_ae44de97565a3bdd685789c7748b37e37}{endsub}(\textcolor{stringliteral}{'GTVarLimit'})
197   \textcolor{keywordflow}{return}
198 \textcolor{keyword}{contains}
199 
200 \textcolor{keyword}{  subroutine }\hyperlink{gtvarlimit_8f90_a3ab399280ae0a9c47ef63d17a9cbb1ae}{limit\_one}(string)
201     \textcolor{keywordtype}{use }\hyperlink{namespacedc__url}{dc\_url}\textcolor{keywordtype}{,         only}: \hyperlink{namespacedc__url_a7136bff4d1b5152ca579575eb6a99f75}{gt\_equal}
202     \textcolor{keywordtype}{use }\hyperlink{namespacedc__string}{dc\_string}\textcolor{keywordtype}{,      only}: \hyperlink{interfacedc__string_1_1strieq}{strieq}, \hyperlink{interfacedc__string_1_1stoi}{stoi}
203     \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__generic}{gtdata\_generic}\textcolor{keywordtype}{, only}: \hyperlink{interfacegtdata__generic_1_1del__dim}{del\_dim}, \hyperlink{interfacegtdata__generic_1_1dimname__to__dimord}{dimname\_to\_dimord}
204     \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__generic}{gtdata\_generic}\textcolor{keywordtype}{, only}: \hyperlink{interfacegtdata__generic_1_1del__dim}{del\_dim}, \hyperlink{interfacegtdata__generic_1_1dimname__to__dimord}{dimname\_to\_dimord}, 
      \hyperlink{interfacegtdata__generic_1_1limit}{limit}
205     \textcolor{keywordtype}{character(len = *)}, \textcolor{keywordtype}{intent(in)}:: \hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}
206     \textcolor{keywordtype}{integer}:: equal, dimord
207     \textcolor{keywordtype}{integer}:: start, count, stride, \hyperlink{interfacedc__string_1_1strhead}{strhead}
208     \textcolor{keywordtype}{logical}:: myerr
209 
210     \textcolor{keywordflow}{if} (\hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string} == \textcolor{stringliteral}{''}) \textcolor{keywordflow}{return}
211 
212     \hyperlink{interfacedc__string_1_1strhead}{strhead} = 4
213     \textcolor{keywordflow}{if} (len(\hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}) < 4) \hyperlink{interfacedc__string_1_1strhead}{strhead} = len(\hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string})
214 
215     \textcolor{keywordflow}{if} (\hyperlink{interfacedc__string_1_1strieq}{strieq}(\hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}(1:\hyperlink{interfacedc__string_1_1strhead}{strhead}), \textcolor{stringliteral}{"IGN:"})) \textcolor{keywordflow}{then}
216       \textcolor{comment}{! 隠蔽型指定子 ign:<dim> または ign:<dim>=<start>}
217       equal = index(\hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}, \hyperlink{namespacedc__url_a7136bff4d1b5152ca579575eb6a99f75}{gt\_equal})
218       \textcolor{keywordflow}{if} (equal == 0) \textcolor{keywordflow}{then}
219         start = 1
220       \textcolor{keywordflow}{else}
221         start = \hyperlink{interfacedc__string_1_1stoi}{stoi}(\hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}(equal+1: ), default=1)
222 \textcolor{keywordflow}{      endif}
223       dimord = \hyperlink{interfacegtdata__generic_1_1dimname__to__dimord}{dimname\_to\_dimord}(var, \hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}(5: equal-1))
224       \textcolor{keyword}{call }\hyperlink{interfacegtdata__generic_1_1limit}{limit}(var, dimord, start, 1, 1, err)
225       \textcolor{keyword}{call }\hyperlink{interfacegtdata__generic_1_1del__dim}{del\_dim}(var, dimord, myerr)
226       \textcolor{keywordflow}{return}
227 \textcolor{keywordflow}{    endif}
228 
229     \textcolor{comment}{! 限定型指定子 <dim>=<start>:<finish>:<stride>}
230     \textcolor{comment}{! いまは実装がバグっていて <start>:<count>:<stride> になってる}
231     \textcolor{comment}{!}
232     equal = index(\hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}, \hyperlink{namespacedc__url_a7136bff4d1b5152ca579575eb6a99f75}{gt\_equal})
233     \textcolor{keywordflow}{if} (equal == 0) \textcolor{keywordflow}{return}
234     dimord = \hyperlink{interfacegtdata__generic_1_1dimname__to__dimord}{dimname\_to\_dimord}(var, \hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}(1: equal-1))
235     \textcolor{keywordflow}{if} (dimord <= 0) \textcolor{keywordflow}{return}
236     \textcolor{comment}{!}
237     \textcolor{keyword}{call }\hyperlink{gtvarlimit_8f90_a94e803f7f864a2956bece716f16a6a57}{region\_spec}(dimord, \hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}(equal+1: ), start, count, stride)
238     \textcolor{keyword}{call }\hyperlink{interfacegtdata__generic_1_1limit}{limit}(var, dimord, start, count, stride, err)
239 \textcolor{keyword}{  end subroutine }\hyperlink{gtvarlimit_8f90_a3ab399280ae0a9c47ef63d17a9cbb1ae}{limit\_one}
240 
241   \textcolor{comment}{!}
242   \textcolor{comment}{! 範囲指定の = のあとを : で区切ってマップにいれる}
243   \textcolor{comment}{!}
244 \textcolor{keyword}{  subroutine }\hyperlink{gtvarlimit_8f90_a94e803f7f864a2956bece716f16a6a57}{region\_spec}(dimord, string, start, count, stride)
245     \textcolor{keywordtype}{use }\hyperlink{namespacedc__types}{dc\_types}\textcolor{keywordtype}{, only}: \hyperlink{namespacedc__types_a6d28eb015ba84292a06f4ff25165b376}{token}
246     \textcolor{keywordtype}{use }\hyperlink{namespacedc__string}{dc\_string}\textcolor{keywordtype}{, only}: \hyperlink{interfacedc__string_1_1index__ofs}{index\_ofs}, \hyperlink{interfacedc__string_1_1stoi}{stoi}
247     \textcolor{keywordtype}{use }\hyperlink{namespacedc__url}{dc\_url}\textcolor{keywordtype}{, only}: \hyperlink{namespacedc__url_adf1b8d55d944dc6510d8ba57d54bc168}{gt\_circumflex}, \hyperlink{namespacedc__url_a8a012262cb2d70e929fb1d929c1f5752}{gt\_colon}
248     \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__internal__map}{gtdata\_internal\_map}\textcolor{keywordtype}{, only}: \hyperlink{interfacegtdata__internal__map_1_1dimrange}{dimrange}
249     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)}:: dimord
250     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(out)}:: start, count, stride
251     \textcolor{keywordtype}{character(len = *)}, \textcolor{keywordtype}{intent(in)}:: string
252     \textcolor{keywordtype}{integer}:: colon, prev\_colon, finish, dimlo, dimhi
253     \textcolor{keywordtype}{character(len = token)}:: val(3)
254   \textcolor{keywordflow}{continue}
255     colon = index(string, \hyperlink{namespacedc__url_a8a012262cb2d70e929fb1d929c1f5752}{gt\_colon})
256     \textcolor{keywordflow}{if} (colon == 0) \textcolor{keywordflow}{then}
257       \textcolor{comment}{! コロンがない場合は上下端に同じ値}
258       val(1) = string(1: )
259       val(2) = val(1)
260       val(3) = \textcolor{stringliteral}{""}
261     \textcolor{keywordflow}{else}
262       val(1) = string(1: colon - 1)
263       prev\_colon = colon
264       colon = \hyperlink{interfacedc__string_1_1index__ofs}{index\_ofs}(string, colon + 1, \hyperlink{namespacedc__url_a8a012262cb2d70e929fb1d929c1f5752}{gt\_colon})
265       \textcolor{keywordflow}{if} (colon > 0) \textcolor{keywordflow}{then}
266         val(2) = string(prev\_colon + 1: colon - 1)
267         val(3) = string(colon + 1: )
268       \textcolor{keywordflow}{else}
269         val(2) = string(prev\_colon + 1: )
270         val(3) = \textcolor{stringliteral}{""}
271 \textcolor{keywordflow}{      endif}
272 \textcolor{keywordflow}{    endif}
273     \textcolor{keywordflow}{if} (val(3) == \textcolor{stringliteral}{""}) val(3) = \textcolor{stringliteral}{"^1"}
274 
275     \textcolor{keywordflow}{if} (val(1)(1:1) == \hyperlink{namespacedc__url_adf1b8d55d944dc6510d8ba57d54bc168}{gt\_circumflex}) \textcolor{keywordflow}{then}
276       start = \hyperlink{interfacedc__string_1_1stoi}{stoi}(val(1)(2: ))
277     \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (val(1) == val(2)) \textcolor{keywordflow}{then}
278       start = nint(\hyperlink{gtvarlimit_8f90_a84b815e1598fad755fc5b5ca03612997}{value\_to\_index}(dimord, val(1)))
279     \textcolor{keywordflow}{else}
280       start = \hyperlink{interfacedc__scaledsec_1_1floor}{floor}(\hyperlink{gtvarlimit_8f90_a84b815e1598fad755fc5b5ca03612997}{value\_to\_index}(dimord, val(1)))
281 \textcolor{keywordflow}{    endif}
282     \textcolor{keywordflow}{if} (val(2) == val(1)) \textcolor{keywordflow}{then}
283       finish = start
284     \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (val(2)(1:1) == \hyperlink{namespacedc__url_adf1b8d55d944dc6510d8ba57d54bc168}{gt\_circumflex}) \textcolor{keywordflow}{then}
285       finish = \hyperlink{interfacedc__string_1_1stoi}{stoi}(val(2)(2: ))
286     \textcolor{keywordflow}{else}
287       finish = \hyperlink{interfacedc__scaledsec_1_1ceiling}{ceiling}(\hyperlink{gtvarlimit_8f90_a84b815e1598fad755fc5b5ca03612997}{value\_to\_index}(dimord, val(2)))
288 \textcolor{keywordflow}{    endif}
289 
290     \textcolor{keyword}{call }\hyperlink{interfacegtdata__internal__map_1_1dimrange}{dimrange}(var, dimord, dimlo, dimhi)
291     start = \hyperlink{interfacedc__date__generic_1_1min}{min}(\hyperlink{interfacedc__date__generic_1_1max}{max}(dimlo, start), dimhi)
292     finish = \hyperlink{interfacedc__date__generic_1_1min}{min}(\hyperlink{interfacedc__date__generic_1_1max}{max}(dimlo, finish), dimhi)
293     count = \hyperlink{interfacedc__scaledsec_1_1abs}{abs}(finish - start) + 1
294 
295     \textcolor{keywordflow}{if} (val(3)(1:1) == \hyperlink{namespacedc__url_adf1b8d55d944dc6510d8ba57d54bc168}{gt\_circumflex}) \textcolor{keywordflow}{then}
296       stride = \hyperlink{interfacedc__string_1_1stoi}{stoi}(val(3)(2: ))
297     \textcolor{keywordflow}{else}
298       stride = \hyperlink{interfacedc__string_1_1stoi}{stoi}(val(3))
299 \textcolor{keywordflow}{    endif}
300     stride = \hyperlink{interfacedc__scaledsec_1_1sign}{sign}(stride, finish - start)
301 \textcolor{keyword}{  end subroutine }\hyperlink{gtvarlimit_8f90_a94e803f7f864a2956bece716f16a6a57}{region\_spec}
302 
303 \textcolor{keyword}{  real }\textcolor{keyword}{function }\hyperlink{gtvarlimit_8f90_a84b815e1598fad755fc5b5ca03612997}{value\_to\_index}(dimord, value) \textcolor{keyword}{result}(result)
304     \textcolor{comment}{!}
305     \textcolor{comment}{! GTVarLimit の引数 *var* に格納される変数の次元 *dimord*}
306     \textcolor{comment}{! に格納されるデータのうち, *value* が格納される}
307     \textcolor{comment}{! 格子番号を整数値にして返します.}
308     \textcolor{comment}{!}
309     \textcolor{comment}{! 例えば次元に以下のデータが格納されているとします.}
310     \textcolor{comment}{!}
311     \textcolor{comment}{!     0.05  0.1  0.15  0.20  0.25  0.30}
312     \textcolor{comment}{!}
313     \textcolor{comment}{! この場合, *value* に 0.15 が与えられれば戻り値は 3. となります.}
314     \textcolor{comment}{! また *value* に 0.225 が与えられれば戻り値は 4.5 となります.}
315     \textcolor{comment}{!}
316     \textcolor{comment}{!}
317     \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__types}{gtdata\_types}\textcolor{keywordtype}{, only}: \hyperlink{structgtdata__types_1_1gt__variable}{gt\_variable}
318     \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__generic}{gtdata\_generic}\textcolor{keywordtype}{, only}: \hyperlink{interfacegtdata__generic_1_1get}{get}, \hyperlink{interfacegtdata__generic_1_1open}{open}, \hyperlink{interfacegtdata__generic_1_1close}{close}
319     \textcolor{keywordtype}{use }\hyperlink{namespacedc__string}{dc\_string}\textcolor{keywordtype}{, only}: \hyperlink{interfacedc__string_1_1stod}{stod}
320     \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}
321     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)}:: dimord
322     \textcolor{keywordtype}{character(len = *)}, \textcolor{keywordtype}{intent(in)}:: value
323     \textcolor{keywordtype}{type}(\hyperlink{structgtdata__types_1_1gt__variable}{gt\_variable}):: axisvar
324     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{pointer}:: axisval(:) => null()
325     \textcolor{keywordtype}{real}:: val
326     \textcolor{keywordtype}{integer}:: i
327   \textcolor{keywordflow}{continue}
328 
329     \textcolor{keyword}{call }\hyperlink{namespacedc__trace_aca1efe8bae50b85f74980a8c4d704dd8}{beginsub}(\textcolor{stringliteral}{'value\_to\_index'}, \textcolor{stringliteral}{'var=%d dimord=%d value=%c'}, &
330       & i=(/var%mapid, dimord/), c1=trim(\textcolor{keywordtype}{value}))
331 
332     \textcolor{keyword}{call }\hyperlink{interfacegtdata__generic_1_1open}{open}(axisvar, var, dimord, count\_compact=.true.)
333     \textcolor{keyword}{nullify}(axisval)
334     \textcolor{keyword}{call }\hyperlink{interfacegtdata__generic_1_1get}{get}(axisvar, axisval)
335     \textcolor{keyword}{call }\hyperlink{interfacegtdata__generic_1_1close}{close}(axisvar)
336     \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(axisval)) \textcolor{keywordflow}{then}
337       result = -1.0
338       \textcolor{keywordflow}{return}
339     \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (\textcolor{keyword}{size}(axisval) < 2) \textcolor{keywordflow}{then}
340       result = 1.0
341       \textcolor{keywordflow}{goto} 900
342 \textcolor{keywordflow}{    endif}
343 
344     val = \hyperlink{interfacedc__string_1_1stod}{stod}(\textcolor{keywordtype}{value})
345 
346     \textcolor{comment}{! call DbgMessage('value=%f axis=(/%*r/)', r=(/val, axisval(:)/), &}
347     \textcolor{comment}{!    & n=(/size(axisval)/))}
348 
349     \textcolor{keywordflow}{do}, i = 1, \textcolor{keyword}{size}(axisval) - 1
350       \textcolor{keywordflow}{if} (axisval(i + 1) == axisval(i)) \textcolor{keywordflow}{then}
351         result = \textcolor{keywordtype}{real(i)} + 0.5
352         \textcolor{keywordflow}{goto} 900
353 \textcolor{keywordflow}{      endif}
354       result = i + (val - axisval(i)) / (axisval(i + 1) - axisval(i))
355       \textcolor{keywordflow}{if} (result <= (i + 1)) \textcolor{keywordflow}{goto} 900
356 \textcolor{keywordflow}{    enddo}
357 
358 900 \textcolor{keywordflow}{continue}
359     \textcolor{keyword}{call }\hyperlink{namespacedc__trace_ae44de97565a3bdd685789c7748b37e37}{endsub}(\textcolor{stringliteral}{'value\_to\_index'}, \textcolor{stringliteral}{'(%c) = %r'}, &
360       & c1=trim(\textcolor{keywordtype}{value}), r=(/result/))
361     \textcolor{keyword}{deallocate}(axisval)
362 \textcolor{keyword}{  end function }\hyperlink{gtvarlimit_8f90_a84b815e1598fad755fc5b5ca03612997}{value\_to\_index}
363 
\end{DoxyCode}
Here is the call graph for this function\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{gtvarlimit_8f90_a29ade81799ba86531d3aec49f949d216_cgraph}
\end{center}
\end{figure}
\mbox{\Hypertarget{gtvarlimit_8f90_a83b7ff374f6128f84532a53c2a3b2935}\label{gtvarlimit_8f90_a83b7ff374f6128f84532a53c2a3b2935}} 
\index{gtvarlimit.\+f90@{gtvarlimit.\+f90}!gtvarlimit\+\_\+iiii@{gtvarlimit\+\_\+iiii}}
\index{gtvarlimit\+\_\+iiii@{gtvarlimit\+\_\+iiii}!gtvarlimit.\+f90@{gtvarlimit.\+f90}}
\subsubsection{\texorpdfstring{gtvarlimit\+\_\+iiii()}{gtvarlimit\_iiii()}}
{\footnotesize\ttfamily subroutine gtvarlimit\+\_\+iiii (\begin{DoxyParamCaption}\item[{type(gt\+\_\+variable), intent(inout)}]{var,  }\item[{integer, intent(in)}]{dimord,  }\item[{integer, intent(in), optional}]{start,  }\item[{integer, intent(in), optional}]{count,  }\item[{integer, intent(in), optional}]{stride,  }\item[{logical, intent(out), optional}]{err }\end{DoxyParamCaption})}



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



References dc\+\_\+trace\+::beginsub(), dc\+\_\+trace\+::dbgmessage(), dc\+\_\+error\+::dc\+\_\+noerr, dc\+\_\+trace\+::endsub(), gtdata\+\_\+internal\+\_\+map\+::map\+\_\+lookup(), gtdata\+\_\+internal\+\_\+map\+::map\+\_\+set(), and dc\+\_\+error\+::storeerror().


\begin{DoxyCode}
14   \textcolor{comment}{!}
15   \textcolor{comment}{!== 入出力範囲の拘束 (数値で指定)}
16   \textcolor{comment}{!}
17   \textcolor{comment}{! 変数 *var* 次元の入出力範囲を拘束します。}
18   \textcolor{comment}{! Limit を呼び出した後では Slice でその範囲の外に入出力範囲を}
19   \textcolor{comment}{! 設定できなくなります。これにより、変数全体ではなく一部を}
20   \textcolor{comment}{! Slice\_Next サブルーチンを用いて走査できるようになります。}
21   \textcolor{comment}{!}
22   \textcolor{comment}{! 指定方法は、変数 *var* の *dimord* 番目の次元を基点 *start*,}
23   \textcolor{comment}{! 格子総数 *count* 間隔 *stride* に限定します。}
24   \textcolor{comment}{! このあとでは、スライス指定の第1格子は *start* 番目の格子を}
25   \textcolor{comment}{! 指示することになり、スライス指定での格子数は *count* 個を}
26   \textcolor{comment}{! 越えることができなくなり、スライス指定で間引きなしを指定すると}
27   \textcolor{comment}{! *stride* 個ごとの指定を指示することになります。}
28   \textcolor{comment}{!}
29   \textcolor{comment}{! エラーが生じた場合、メッセージを出力}
30   \textcolor{comment}{! してプログラムは強制終了します。*err* を与えてある場合には}
31   \textcolor{comment}{! の引数に .true. が返り、プログラムは終了しません。}
32   \textcolor{comment}{!}
33   \textcolor{comment}{! *Limit* は 2 つのサブルーチンの総称名であり、}
34   \textcolor{comment}{! 他にも \{gtool4 netCDF 規約\}[link:../xref.htm#label-6] の}
35   \textcolor{comment}{! 「5.4 コンマ記法」を用いて指定することも可能です。}
36   \textcolor{comment}{! 下記のサブルーチンを参照してください。}
37   \textcolor{comment}{!}
38   \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__types}{gtdata\_types}\textcolor{keywordtype}{, only}: \hyperlink{structgtdata__types_1_1gt__variable}{gt\_variable}
39   \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__internal__map}{gtdata\_internal\_map}\textcolor{keywordtype}{, only}: \hyperlink{namespacegtdata__internal__map_a076911f777be03f10a2c024dac7efdad}{map\_lookup}, 
      \hyperlink{structgtdata__internal__map_1_1gt__dimmap}{gt\_dimmap}, \hyperlink{interfacegtdata__internal__map_1_1dimrange}{dimrange}, \hyperlink{namespacegtdata__internal__map_a2e6a789c1c8f4850421da11f10081cb7}{map\_set}
40   \textcolor{keywordtype}{use }\hyperlink{namespacedc__error}{dc\_error}\textcolor{keywordtype}{, only}: \hyperlink{namespacedc__error_a64841a3c9e3ef7d5ddb175e5770f7dfe}{dc\_noerr}, nf90\_einval, \hyperlink{namespacedc__error_a0104aee83ee5752b1a9f6152b11864a8}{storeerror}
41   \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}
42   \textcolor{keywordtype}{implicit none}
43   \textcolor{keywordtype}{type}(\hyperlink{structgtdata__types_1_1gt__variable}{gt\_variable}), \textcolor{keywordtype}{intent(inout)}:: var
44   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)}             :: dimord
45   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} , \textcolor{keywordtype}{optional}  :: start, count, stride
46   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(out)}, \textcolor{keywordtype}{optional}  :: err
47   \textcolor{keywordtype}{type}(\hyperlink{structgtdata__internal__map_1_1gt__dimmap}{gt\_dimmap}), \textcolor{keywordtype}{allocatable}:: map(:)
48   \textcolor{keywordtype}{integer}:: iolo, iohi, uilo, uihi, lowerlim, upperlim, dimlo, dimhi
49   \textcolor{keywordtype}{integer}:: ndims, stat
50 
51   stat = nf90\_einval
52   \textcolor{keyword}{call }\hyperlink{namespacedc__trace_aca1efe8bae50b85f74980a8c4d704dd8}{beginsub}(\textcolor{stringliteral}{'GTVarLimit\_iiii'}, &
53     & \textcolor{stringliteral}{'var%d-dim%d start=%d count=%d stride=%d'}, &
54     & i=(/var%mapid, dimord, start, count, stride/))
55   \textcolor{comment}{! エラーチェック}
56   \textcolor{keywordflow}{if} (dimord < 1) \textcolor{keywordflow}{then}
57     print *, \textcolor{stringliteral}{"dimord ="}, dimord, \textcolor{stringliteral}{" < 1"}
58     \textcolor{keywordflow}{goto} 999
59 \textcolor{keywordflow}{  endif}
60   \textcolor{keywordflow}{if} (stride == 0) \textcolor{keywordflow}{then}
61     print *, \textcolor{stringliteral}{"stride == 0"}
62     \textcolor{keywordflow}{goto} 999
63 \textcolor{keywordflow}{  endif}
64   \textcolor{keyword}{call }\hyperlink{namespacegtdata__internal__map_a076911f777be03f10a2c024dac7efdad}{map\_lookup}(var, ndims=ndims)
65   \textcolor{keywordflow}{if} (ndims <= 0) \textcolor{keywordflow}{then}
66     print *, \textcolor{stringliteral}{"ndims ="}, ndims, \textcolor{stringliteral}{" <= 0"}
67     \textcolor{keywordflow}{goto} 999
68 \textcolor{keywordflow}{  endif}
69   \textcolor{keywordflow}{if} (dimord > ndims) \textcolor{keywordflow}{then}
70     print *, \textcolor{stringliteral}{"dimrod ="}, dimord, \textcolor{stringliteral}{" > ndims ="}, ndims
71     \textcolor{keywordflow}{goto} 999
72 \textcolor{keywordflow}{  endif}
73   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(map)) \textcolor{keywordflow}{then}
74     \textcolor{keyword}{deallocate}(map)
75 \textcolor{keywordflow}{  end if}
76   \textcolor{keyword}{allocate}(map(ndims))
77   \textcolor{keyword}{call }\hyperlink{namespacegtdata__internal__map_a076911f777be03f10a2c024dac7efdad}{map\_lookup}(var, map=map)
78   \textcolor{comment}{! (/lowerlim, upperlim/) は内部格子の範囲 (降順可)}
79   lowerlim = \hyperlink{interfacedc__date__generic_1_1min}{min}(start, start + (count - 1) * stride)
80   upperlim = \hyperlink{interfacedc__date__generic_1_1max}{max}(start, start + (count - 1) * stride)
81   \textcolor{keyword}{call }\hyperlink{interfacegtdata__internal__map_1_1dimrange}{dimrange}(var, dimord, dimlo, dimhi)
82   \textcolor{keywordflow}{if} (lowerlim < dimlo) \textcolor{keywordflow}{then}
83     print *, \textcolor{stringliteral}{"lowerlim = "}, lowerlim, \textcolor{stringliteral}{" < dimlo ="}, dimlo
84     \textcolor{keywordflow}{goto} 999
85 \textcolor{keywordflow}{  endif}
86   \textcolor{keywordflow}{if} (upperlim > dimhi) \textcolor{keywordflow}{then}
87     print *, \textcolor{stringliteral}{"upperlim = "}, upperlim, \textcolor{stringliteral}{" < dimhi ="}, dimhi
88     \textcolor{keywordflow}{goto} 999
89 \textcolor{keywordflow}{  endif}
90 
91   \textcolor{keyword}{call }\hyperlink{namespacedc__trace_a2a38fceb4cf9baf298d63456238c3fea}{dbgmessage}(\textcolor{stringliteral}{'@ lowerlim=%d upperlim=%d'}, i=(/lowerlim, upperlim/))
92 
93   \textcolor{comment}{! 入出力範囲を内部格子番号に変えておく}
94   uilo = map(dimord)%start
95   iolo = 1 + map(dimord)%step * (uilo - 1) + map(dimord)%offset
96   uihi = map(dimord)%start + (map(dimord)%count - 1) * map(dimord)%stride
97   iohi = 1 + map(dimord)%step * (uihi - 1) + map(dimord)%offset
98 
99   \textcolor{keyword}{call }\hyperlink{namespacedc__trace_a2a38fceb4cf9baf298d63456238c3fea}{dbgmessage}(\textcolor{stringliteral}{'@ userindex=%d %d, internal=%d %d'}, &
100     & i=(/uilo, uihi, iolo, iohi/))
101   \textcolor{keyword}{call }\hyperlink{namespacedc__trace_a2a38fceb4cf9baf298d63456238c3fea}{dbgmessage}(\textcolor{stringliteral}{'@ DbgMessage offset %d -> %d step=%d'}, &
102     & i=(/map(dimord)%offset, (start-1), stride/))
103 
104   \textcolor{comment}{! 制限を課す。offset が変わればユーザ格子番号の意味が変わる}
105   map(dimord)%offset = start - 1
106   map(dimord)%allcount = count
107   map(dimord)%step = stride
108 
109   \textcolor{comment}{! 入出力範囲を内部格子番号からユーザ格子番号に戻す}
110   uilo = 1 + (iolo - 1 - map(dimord)%offset) / map(dimord)%step
111   uihi = 1 + (iohi - 1 - map(dimord)%offset) / map(dimord)%step
112   \textcolor{keyword}{call }\hyperlink{namespacedc__trace_a2a38fceb4cf9baf298d63456238c3fea}{dbgmessage}(\textcolor{stringliteral}{'@ userindex=%d %d'}, i=(/uilo, uihi/))
113 
114   \textcolor{comment}{! それぞれは制限 [1 .. allcount] の中になければならない}
115   uilo = \hyperlink{interfacedc__date__generic_1_1max}{max}(1, \hyperlink{interfacedc__date__generic_1_1min}{min}(map(dimord)%allcount, uilo))
116   uihi = \hyperlink{interfacedc__date__generic_1_1max}{max}(1, \hyperlink{interfacedc__date__generic_1_1min}{min}(map(dimord)%allcount, uihi))
117 
118   \textcolor{keyword}{call }\hyperlink{namespacedc__trace_a2a38fceb4cf9baf298d63456238c3fea}{dbgmessage}(\textcolor{stringliteral}{'@ userindex=%d %d orig\_stride=%d'}, &
119     & i=(/uilo, uihi, map(dimord)%stride/))
120 
121   \textcolor{comment}{! 元のストライドの符号は無視し、正に固定する}
122   map(dimord)%stride = \hyperlink{interfacedc__date__generic_1_1max}{max}(1, \hyperlink{interfacedc__scaledsec_1_1abs}{abs}(map(dimord)%stride))
123   map(dimord)%start = \hyperlink{interfacedc__date__generic_1_1min}{min}(uilo, uihi)
124   map(dimord)%count = 1 + \hyperlink{interfacedc__scaledsec_1_1abs}{abs}(uihi - uilo) / map(dimord)%stride
125 
126   \textcolor{keyword}{call }\hyperlink{namespacegtdata__internal__map_a2e6a789c1c8f4850421da11f10081cb7}{map\_set}(var, map, stat)
127   \textcolor{keywordflow}{if} (stat /= 0) \textcolor{keyword}{call }\hyperlink{namespacedc__trace_a2a38fceb4cf9baf298d63456238c3fea}{dbgmessage}(\textcolor{stringliteral}{"map\_set fail"})
128 
129 999 \textcolor{keywordflow}{continue}
130   \textcolor{keyword}{call }\hyperlink{namespacedc__error_a0104aee83ee5752b1a9f6152b11864a8}{storeerror}(stat, \textcolor{stringliteral}{'GTVarLimit\_iiii'}, err)
131   \textcolor{keyword}{call }\hyperlink{namespacedc__trace_ae44de97565a3bdd685789c7748b37e37}{endsub}(\textcolor{stringliteral}{'GTVarLimit\_iiii'})
\end{DoxyCode}
Here is the call graph for this function\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{gtvarlimit_8f90_a83b7ff374f6128f84532a53c2a3b2935_cgraph}
\end{center}
\end{figure}
\mbox{\Hypertarget{gtvarlimit_8f90_a3ab399280ae0a9c47ef63d17a9cbb1ae}\label{gtvarlimit_8f90_a3ab399280ae0a9c47ef63d17a9cbb1ae}} 
\index{gtvarlimit.\+f90@{gtvarlimit.\+f90}!limit\+\_\+one@{limit\+\_\+one}}
\index{limit\+\_\+one@{limit\+\_\+one}!gtvarlimit.\+f90@{gtvarlimit.\+f90}}
\subsubsection{\texorpdfstring{limit\+\_\+one()}{limit\_one()}}
{\footnotesize\ttfamily subroutine gtvarlimit\+::limit\+\_\+one (\begin{DoxyParamCaption}\item[{character(len = $\ast$), intent(in)}]{string }\end{DoxyParamCaption})}



Definition at line 201 of file gtvarlimit.\+f90.



References dc\+\_\+url\+::gt\+\_\+equal, and region\+\_\+spec().



Referenced by gtvarlimit(), and gtvarslicec().


\begin{DoxyCode}
201     \textcolor{keywordtype}{use }\hyperlink{namespacedc__url}{dc\_url}\textcolor{keywordtype}{,         only}: \hyperlink{namespacedc__url_a7136bff4d1b5152ca579575eb6a99f75}{gt\_equal}
202     \textcolor{keywordtype}{use }\hyperlink{namespacedc__string}{dc\_string}\textcolor{keywordtype}{,      only}: \hyperlink{interfacedc__string_1_1strieq}{strieq}, \hyperlink{interfacedc__string_1_1stoi}{stoi}
203     \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__generic}{gtdata\_generic}\textcolor{keywordtype}{, only}: \hyperlink{interfacegtdata__generic_1_1del__dim}{del\_dim}, \hyperlink{interfacegtdata__generic_1_1dimname__to__dimord}{dimname\_to\_dimord}
204     \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__generic}{gtdata\_generic}\textcolor{keywordtype}{, only}: \hyperlink{interfacegtdata__generic_1_1del__dim}{del\_dim}, \hyperlink{interfacegtdata__generic_1_1dimname__to__dimord}{dimname\_to\_dimord}, 
      \hyperlink{interfacegtdata__generic_1_1limit}{limit}
205     \textcolor{keywordtype}{character(len = *)}, \textcolor{keywordtype}{intent(in)}:: \hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}
206     \textcolor{keywordtype}{integer}:: equal, dimord
207     \textcolor{keywordtype}{integer}:: start, count, stride, \hyperlink{interfacedc__string_1_1strhead}{strhead}
208     \textcolor{keywordtype}{logical}:: myerr
209 
210     \textcolor{keywordflow}{if} (\hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string} == \textcolor{stringliteral}{''}) \textcolor{keywordflow}{return}
211 
212     \hyperlink{interfacedc__string_1_1strhead}{strhead} = 4
213     \textcolor{keywordflow}{if} (len(\hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}) < 4) \hyperlink{interfacedc__string_1_1strhead}{strhead} = len(\hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string})
214 
215     \textcolor{keywordflow}{if} (\hyperlink{interfacedc__string_1_1strieq}{strieq}(\hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}(1:\hyperlink{interfacedc__string_1_1strhead}{strhead}), \textcolor{stringliteral}{"IGN:"})) \textcolor{keywordflow}{then}
216       \textcolor{comment}{! 隠蔽型指定子 ign:<dim> または ign:<dim>=<start>}
217       equal = index(\hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}, \hyperlink{namespacedc__url_a7136bff4d1b5152ca579575eb6a99f75}{gt\_equal})
218       \textcolor{keywordflow}{if} (equal == 0) \textcolor{keywordflow}{then}
219         start = 1
220       \textcolor{keywordflow}{else}
221         start = \hyperlink{interfacedc__string_1_1stoi}{stoi}(\hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}(equal+1: ), default=1)
222 \textcolor{keywordflow}{      endif}
223       dimord = \hyperlink{interfacegtdata__generic_1_1dimname__to__dimord}{dimname\_to\_dimord}(var, \hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}(5: equal-1))
224       \textcolor{keyword}{call }\hyperlink{interfacegtdata__generic_1_1limit}{limit}(var, dimord, start, 1, 1, err)
225       \textcolor{keyword}{call }\hyperlink{interfacegtdata__generic_1_1del__dim}{del\_dim}(var, dimord, myerr)
226       \textcolor{keywordflow}{return}
227 \textcolor{keywordflow}{    endif}
228 
229     \textcolor{comment}{! 限定型指定子 <dim>=<start>:<finish>:<stride>}
230     \textcolor{comment}{! いまは実装がバグっていて <start>:<count>:<stride> になってる}
231     \textcolor{comment}{!}
232     equal = index(\hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}, \hyperlink{namespacedc__url_a7136bff4d1b5152ca579575eb6a99f75}{gt\_equal})
233     \textcolor{keywordflow}{if} (equal == 0) \textcolor{keywordflow}{return}
234     dimord = \hyperlink{interfacegtdata__generic_1_1dimname__to__dimord}{dimname\_to\_dimord}(var, \hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}(1: equal-1))
235     \textcolor{keywordflow}{if} (dimord <= 0) \textcolor{keywordflow}{return}
236     \textcolor{comment}{!}
237     \textcolor{keyword}{call }\hyperlink{gtvarlimit_8f90_a94e803f7f864a2956bece716f16a6a57}{region\_spec}(dimord, \hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}(equal+1: ), start, count, stride)
238     \textcolor{keyword}{call }\hyperlink{interfacegtdata__generic_1_1limit}{limit}(var, dimord, start, count, stride, err)
\end{DoxyCode}
Here is the call graph for this function\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{gtvarlimit_8f90_a3ab399280ae0a9c47ef63d17a9cbb1ae_cgraph}
\end{center}
\end{figure}
Here is the caller graph for this function\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=236pt]{gtvarlimit_8f90_a3ab399280ae0a9c47ef63d17a9cbb1ae_icgraph}
\end{center}
\end{figure}
\mbox{\Hypertarget{gtvarlimit_8f90_a94e803f7f864a2956bece716f16a6a57}\label{gtvarlimit_8f90_a94e803f7f864a2956bece716f16a6a57}} 
\index{gtvarlimit.\+f90@{gtvarlimit.\+f90}!region\+\_\+spec@{region\+\_\+spec}}
\index{region\+\_\+spec@{region\+\_\+spec}!gtvarlimit.\+f90@{gtvarlimit.\+f90}}
\subsubsection{\texorpdfstring{region\+\_\+spec()}{region\_spec()}}
{\footnotesize\ttfamily subroutine gtvarlimit\+::region\+\_\+spec (\begin{DoxyParamCaption}\item[{integer, intent(in)}]{dimord,  }\item[{character(len = $\ast$), intent(in)}]{string,  }\item[{integer, intent(out)}]{start,  }\item[{integer, intent(out)}]{count,  }\item[{integer, intent(out)}]{stride }\end{DoxyParamCaption})}



Definition at line 245 of file gtvarlimit.\+f90.



References dc\+\_\+url\+::gt\+\_\+circumflex, dc\+\_\+url\+::gt\+\_\+colon, dc\+\_\+types\+::token, and value\+\_\+to\+\_\+index().



Referenced by limit\+\_\+one().


\begin{DoxyCode}
245     \textcolor{keywordtype}{use }\hyperlink{namespacedc__types}{dc\_types}\textcolor{keywordtype}{, only}: \hyperlink{namespacedc__types_a6d28eb015ba84292a06f4ff25165b376}{token}
246     \textcolor{keywordtype}{use }\hyperlink{namespacedc__string}{dc\_string}\textcolor{keywordtype}{, only}: \hyperlink{interfacedc__string_1_1index__ofs}{index\_ofs}, \hyperlink{interfacedc__string_1_1stoi}{stoi}
247     \textcolor{keywordtype}{use }\hyperlink{namespacedc__url}{dc\_url}\textcolor{keywordtype}{, only}: \hyperlink{namespacedc__url_adf1b8d55d944dc6510d8ba57d54bc168}{gt\_circumflex}, \hyperlink{namespacedc__url_a8a012262cb2d70e929fb1d929c1f5752}{gt\_colon}
248     \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__internal__map}{gtdata\_internal\_map}\textcolor{keywordtype}{, only}: \hyperlink{interfacegtdata__internal__map_1_1dimrange}{dimrange}
249     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)}:: dimord
250     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(out)}:: start, count, stride
251     \textcolor{keywordtype}{character(len = *)}, \textcolor{keywordtype}{intent(in)}:: string
252     \textcolor{keywordtype}{integer}:: colon, prev\_colon, finish, dimlo, dimhi
253     \textcolor{keywordtype}{character(len = token)}:: val(3)
254   \textcolor{keywordflow}{continue}
255     colon = index(string, \hyperlink{namespacedc__url_a8a012262cb2d70e929fb1d929c1f5752}{gt\_colon})
256     \textcolor{keywordflow}{if} (colon == 0) \textcolor{keywordflow}{then}
257       \textcolor{comment}{! コロンがない場合は上下端に同じ値}
258       val(1) = string(1: )
259       val(2) = val(1)
260       val(3) = \textcolor{stringliteral}{""}
261     \textcolor{keywordflow}{else}
262       val(1) = string(1: colon - 1)
263       prev\_colon = colon
264       colon = \hyperlink{interfacedc__string_1_1index__ofs}{index\_ofs}(string, colon + 1, \hyperlink{namespacedc__url_a8a012262cb2d70e929fb1d929c1f5752}{gt\_colon})
265       \textcolor{keywordflow}{if} (colon > 0) \textcolor{keywordflow}{then}
266         val(2) = string(prev\_colon + 1: colon - 1)
267         val(3) = string(colon + 1: )
268       \textcolor{keywordflow}{else}
269         val(2) = string(prev\_colon + 1: )
270         val(3) = \textcolor{stringliteral}{""}
271 \textcolor{keywordflow}{      endif}
272 \textcolor{keywordflow}{    endif}
273     \textcolor{keywordflow}{if} (val(3) == \textcolor{stringliteral}{""}) val(3) = \textcolor{stringliteral}{"^1"}
274 
275     \textcolor{keywordflow}{if} (val(1)(1:1) == \hyperlink{namespacedc__url_adf1b8d55d944dc6510d8ba57d54bc168}{gt\_circumflex}) \textcolor{keywordflow}{then}
276       start = \hyperlink{interfacedc__string_1_1stoi}{stoi}(val(1)(2: ))
277     \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (val(1) == val(2)) \textcolor{keywordflow}{then}
278       start = nint(\hyperlink{gtvarlimit_8f90_a84b815e1598fad755fc5b5ca03612997}{value\_to\_index}(dimord, val(1)))
279     \textcolor{keywordflow}{else}
280       start = \hyperlink{interfacedc__scaledsec_1_1floor}{floor}(\hyperlink{gtvarlimit_8f90_a84b815e1598fad755fc5b5ca03612997}{value\_to\_index}(dimord, val(1)))
281 \textcolor{keywordflow}{    endif}
282     \textcolor{keywordflow}{if} (val(2) == val(1)) \textcolor{keywordflow}{then}
283       finish = start
284     \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (val(2)(1:1) == \hyperlink{namespacedc__url_adf1b8d55d944dc6510d8ba57d54bc168}{gt\_circumflex}) \textcolor{keywordflow}{then}
285       finish = \hyperlink{interfacedc__string_1_1stoi}{stoi}(val(2)(2: ))
286     \textcolor{keywordflow}{else}
287       finish = \hyperlink{interfacedc__scaledsec_1_1ceiling}{ceiling}(\hyperlink{gtvarlimit_8f90_a84b815e1598fad755fc5b5ca03612997}{value\_to\_index}(dimord, val(2)))
288 \textcolor{keywordflow}{    endif}
289 
290     \textcolor{keyword}{call }\hyperlink{interfacegtdata__internal__map_1_1dimrange}{dimrange}(var, dimord, dimlo, dimhi)
291     start = \hyperlink{interfacedc__date__generic_1_1min}{min}(\hyperlink{interfacedc__date__generic_1_1max}{max}(dimlo, start), dimhi)
292     finish = \hyperlink{interfacedc__date__generic_1_1min}{min}(\hyperlink{interfacedc__date__generic_1_1max}{max}(dimlo, finish), dimhi)
293     count = \hyperlink{interfacedc__scaledsec_1_1abs}{abs}(finish - start) + 1
294 
295     \textcolor{keywordflow}{if} (val(3)(1:1) == \hyperlink{namespacedc__url_adf1b8d55d944dc6510d8ba57d54bc168}{gt\_circumflex}) \textcolor{keywordflow}{then}
296       stride = \hyperlink{interfacedc__string_1_1stoi}{stoi}(val(3)(2: ))
297     \textcolor{keywordflow}{else}
298       stride = \hyperlink{interfacedc__string_1_1stoi}{stoi}(val(3))
299 \textcolor{keywordflow}{    endif}
300     stride = \hyperlink{interfacedc__scaledsec_1_1sign}{sign}(stride, finish - start)
\end{DoxyCode}
Here is the call graph for this function\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{gtvarlimit_8f90_a94e803f7f864a2956bece716f16a6a57_cgraph}
\end{center}
\end{figure}
Here is the caller graph for this function\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=341pt]{gtvarlimit_8f90_a94e803f7f864a2956bece716f16a6a57_icgraph}
\end{center}
\end{figure}
\mbox{\Hypertarget{gtvarlimit_8f90_a84b815e1598fad755fc5b5ca03612997}\label{gtvarlimit_8f90_a84b815e1598fad755fc5b5ca03612997}} 
\index{gtvarlimit.\+f90@{gtvarlimit.\+f90}!value\+\_\+to\+\_\+index@{value\+\_\+to\+\_\+index}}
\index{value\+\_\+to\+\_\+index@{value\+\_\+to\+\_\+index}!gtvarlimit.\+f90@{gtvarlimit.\+f90}}
\subsubsection{\texorpdfstring{value\+\_\+to\+\_\+index()}{value\_to\_index()}}
{\footnotesize\ttfamily real function gtvarlimit\+::value\+\_\+to\+\_\+index (\begin{DoxyParamCaption}\item[{integer, intent(in)}]{dimord,  }\item[{character(len = $\ast$), intent(in)}]{value }\end{DoxyParamCaption})}



Definition at line 304 of file gtvarlimit.\+f90.



References dc\+\_\+trace\+::beginsub(), dc\+\_\+trace\+::dbgmessage(), and dc\+\_\+trace\+::endsub().



Referenced by region\+\_\+spec().


\begin{DoxyCode}
304     \textcolor{comment}{!}
305     \textcolor{comment}{! GTVarLimit の引数 *var* に格納される変数の次元 *dimord*}
306     \textcolor{comment}{! に格納されるデータのうち, *value* が格納される}
307     \textcolor{comment}{! 格子番号を整数値にして返します.}
308     \textcolor{comment}{!}
309     \textcolor{comment}{! 例えば次元に以下のデータが格納されているとします.}
310     \textcolor{comment}{!}
311     \textcolor{comment}{!     0.05  0.1  0.15  0.20  0.25  0.30}
312     \textcolor{comment}{!}
313     \textcolor{comment}{! この場合, *value* に 0.15 が与えられれば戻り値は 3. となります.}
314     \textcolor{comment}{! また *value* に 0.225 が与えられれば戻り値は 4.5 となります.}
315     \textcolor{comment}{!}
316     \textcolor{comment}{!}
317     \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__types}{gtdata\_types}\textcolor{keywordtype}{, only}: \hyperlink{structgtdata__types_1_1gt__variable}{gt\_variable}
318     \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__generic}{gtdata\_generic}\textcolor{keywordtype}{, only}: \hyperlink{interfacegtdata__generic_1_1get}{get}, \hyperlink{interfacegtdata__generic_1_1open}{open}, \hyperlink{interfacegtdata__generic_1_1close}{close}
319     \textcolor{keywordtype}{use }\hyperlink{namespacedc__string}{dc\_string}\textcolor{keywordtype}{, only}: \hyperlink{interfacedc__string_1_1stod}{stod}
320     \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}
321     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)}:: dimord
322     \textcolor{keywordtype}{character(len = *)}, \textcolor{keywordtype}{intent(in)}:: value
323     \textcolor{keywordtype}{type}(\hyperlink{structgtdata__types_1_1gt__variable}{gt\_variable}):: axisvar
324     \textcolor{keywordtype}{real}, \textcolor{keywordtype}{pointer}:: axisval(:) => null()
325     \textcolor{keywordtype}{real}:: val
326     \textcolor{keywordtype}{integer}:: i
327   \textcolor{keywordflow}{continue}
328 
329     \textcolor{keyword}{call }\hyperlink{namespacedc__trace_aca1efe8bae50b85f74980a8c4d704dd8}{beginsub}(\textcolor{stringliteral}{'value\_to\_index'}, \textcolor{stringliteral}{'var=%d dimord=%d value=%c'}, &
330       & i=(/var%mapid, dimord/), c1=trim(\textcolor{keywordtype}{value}))
331 
332     \textcolor{keyword}{call }\hyperlink{interfacegtdata__generic_1_1open}{open}(axisvar, var, dimord, count\_compact=.true.)
333     \textcolor{keyword}{nullify}(axisval)
334     \textcolor{keyword}{call }\hyperlink{interfacegtdata__generic_1_1get}{get}(axisvar, axisval)
335     \textcolor{keyword}{call }\hyperlink{interfacegtdata__generic_1_1close}{close}(axisvar)
336     \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(axisval)) \textcolor{keywordflow}{then}
337       result = -1.0
338       \textcolor{keywordflow}{return}
339     \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (\textcolor{keyword}{size}(axisval) < 2) \textcolor{keywordflow}{then}
340       result = 1.0
341       \textcolor{keywordflow}{goto} 900
342 \textcolor{keywordflow}{    endif}
343 
344     val = \hyperlink{interfacedc__string_1_1stod}{stod}(\textcolor{keywordtype}{value})
345 
346     \textcolor{comment}{! call DbgMessage('value=%f axis=(/%*r/)', r=(/val, axisval(:)/), &}
347     \textcolor{comment}{!    & n=(/size(axisval)/))}
348 
349     \textcolor{keywordflow}{do}, i = 1, \textcolor{keyword}{size}(axisval) - 1
350       \textcolor{keywordflow}{if} (axisval(i + 1) == axisval(i)) \textcolor{keywordflow}{then}
351         result = \textcolor{keywordtype}{real(i)} + 0.5
352         \textcolor{keywordflow}{goto} 900
353 \textcolor{keywordflow}{      endif}
354       result = i + (val - axisval(i)) / (axisval(i + 1) - axisval(i))
355       \textcolor{keywordflow}{if} (result <= (i + 1)) \textcolor{keywordflow}{goto} 900
356 \textcolor{keywordflow}{    enddo}
357 
358 900 \textcolor{keywordflow}{continue}
359     \textcolor{keyword}{call }\hyperlink{namespacedc__trace_ae44de97565a3bdd685789c7748b37e37}{endsub}(\textcolor{stringliteral}{'value\_to\_index'}, \textcolor{stringliteral}{'(%c) = %r'}, &
360       & c1=trim(\textcolor{keywordtype}{value}), r=(/result/))
361     \textcolor{keyword}{deallocate}(axisval)
\end{DoxyCode}
Here is the call graph for this function\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{gtvarlimit_8f90_a84b815e1598fad755fc5b5ca03612997_cgraph}
\end{center}
\end{figure}
Here is the caller graph for this function\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{gtvarlimit_8f90_a84b815e1598fad755fc5b5ca03612997_icgraph}
\end{center}
\end{figure}
