\hypertarget{gdncvarinquire_8f90}{}\section{gtdata/gtdata\+\_\+netcdf/gdncvarinquire.f90 File Reference}
\label{gdncvarinquire_8f90}\index{gtdata/gtdata\+\_\+netcdf/gdncvarinquire.\+f90@{gtdata/gtdata\+\_\+netcdf/gdncvarinquire.\+f90}}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine \hyperlink{gdncvarinquire_8f90_a2cda3863b94a5654e1f6d7b315053d3f}{gdncvarinquire} (var, ndims, dimlen, growable, name, url, xtype)
\item 
subroutine \hyperlink{gdncvarinquire_8f90_a3a79b9d1884aa67e5f4c8bfe65ce4f35}{local\+\_\+getname} (ent, varname)
\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{gdncvarinquire_8f90_a2cda3863b94a5654e1f6d7b315053d3f}\label{gdncvarinquire_8f90_a2cda3863b94a5654e1f6d7b315053d3f}} 
\index{gdncvarinquire.\+f90@{gdncvarinquire.\+f90}!gdncvarinquire@{gdncvarinquire}}
\index{gdncvarinquire@{gdncvarinquire}!gdncvarinquire.\+f90@{gdncvarinquire.\+f90}}
\subsubsection{\texorpdfstring{gdncvarinquire()}{gdncvarinquire()}}
{\footnotesize\ttfamily subroutine gdncvarinquire (\begin{DoxyParamCaption}\item[{type(gd\+\_\+nc\+\_\+variable), intent(in)}]{var,  }\item[{integer, intent(out), optional}]{ndims,  }\item[{integer, intent(out), optional}]{dimlen,  }\item[{logical, intent(out), optional}]{growable,  }\item[{character($\ast$), intent(out), optional}]{name,  }\item[{character($\ast$), intent(out), optional}]{url,  }\item[{character($\ast$), intent(out), optional}]{xtype }\end{DoxyParamCaption})}



Definition at line 19 of file gdncvarinquire.\+f90.



References gdncxtypename(), local\+\_\+getname(), and gtdata\+\_\+netcdf\+\_\+internal\+::vtable\+\_\+lookup().


\begin{DoxyCode}
19   \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__netcdf__types}{gtdata\_netcdf\_types}\textcolor{keywordtype}{, only}: \hyperlink{structgtdata__netcdf__types_1_1gd__nc__variable}{gd\_nc\_variable}, 
      \hyperlink{structgtdata__netcdf__types_1_1gd__nc__variable__entry}{gd\_nc\_variable\_entry}
20   \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__netcdf__file__generic}{gtdata\_netcdf\_file\_generic}\textcolor{keywordtype}{, only}: gdncfileinquire
21   \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__netcdf__internal}{gtdata\_netcdf\_internal}\textcolor{keywordtype}{, only}: \hyperlink{namespacegtdata__netcdf__internal_afe013c8012ec100bf1e94e5147c340de}{vtable\_lookup}
22   \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__netcdf__generic}{gtdata\_netcdf\_generic}\textcolor{keywordtype}{, only}: \hyperlink{gdncxtypename_8f90_a61d937db46bd95ad9652b0c86987f5db}{gdncxtypename}
23   \textcolor{keywordtype}{use }dc\_trace\textcolor{keywordtype}{, only}: beginsub, endsub, dbgmessage
24   \textcolor{keywordtype}{use }netcdf\textcolor{keywordtype}{, only}: nf90\_noerr, nf90\_max\_name, &
25     & nf90\_inquire\_variable, nf90\_inquire\_dimension, nf90\_inquire
26   \textcolor{keywordtype}{implicit none}
27   \textcolor{keywordtype}{type}(\hyperlink{structgtdata__netcdf__types_1_1gd__nc__variable}{gd\_nc\_variable}), \textcolor{keywordtype}{intent(in)}:: var
28   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(out)}, \textcolor{keywordtype}{optional}:: ndims
29           \textcolor{comment}{! 変数の次元数}
30   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(out)}, \textcolor{keywordtype}{optional}:: dimlen
31           \textcolor{comment}{! 変数が１次元である場合、次元長}
32   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(out)}, \textcolor{keywordtype}{optional}:: growable
33           \textcolor{comment}{! 変数が成長可能次元を持つか}
34   \textcolor{keywordtype}{character(*)}, \textcolor{keywordtype}{intent(out)}, \textcolor{keywordtype}{optional}:: name
35           \textcolor{comment}{! 文字型引数が短いと値の切り詰めが起こりうる。'?' のあとの変数名}
36   \textcolor{keywordtype}{character(*)}, \textcolor{keywordtype}{intent(out)}, \textcolor{keywordtype}{optional}:: url
37           \textcolor{comment}{! 変数名、少なくともファイル名を含む、なるべく長い名前}
38   \textcolor{keywordtype}{character(*)}, \textcolor{keywordtype}{intent(out)}, \textcolor{keywordtype}{optional}:: xtype
39           \textcolor{comment}{! 変数の型名}
40 
41   \textcolor{comment}{! 内部変数}
42   \textcolor{keywordtype}{type}(\hyperlink{structgtdata__netcdf__types_1_1gd__nc__variable__entry}{gd\_nc\_variable\_entry}):: ent
43   \textcolor{keywordtype}{integer}:: stat, length, i, i\_xtype, idim\_growable
44   \textcolor{keywordtype}{character(len = *)}, \textcolor{keywordtype}{parameter}:: subname = \textcolor{stringliteral}{'GDNcVarInquire'}
45   \textcolor{keywordtype}{character(len = NF90\_MAX\_NAME)}:: buffer
46   \textcolor{keywordtype}{character(len = NF90\_MAX\_NAME)}:: fbuffer
47 \textcolor{keywordflow}{continue}
48   \textcolor{keyword}{call }beginsub(subname, \textcolor{stringliteral}{'var.id=%d'}, i=(/var%id/))
49 
50   \textcolor{comment}{! フェイルセーフ用にエラー値をまず入れる}
51   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(ndims)) ndims = -1
52   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dimlen)) dimlen = -1
53 
54   \textcolor{comment}{! 変数実体の探索}
55   stat = \hyperlink{namespacegtdata__netcdf__internal_afe013c8012ec100bf1e94e5147c340de}{vtable\_lookup}(var, ent)
56   \textcolor{keywordflow}{if} (stat /= nf90\_noerr) \textcolor{keywordflow}{then}
57     \textcolor{keyword}{call }endsub(subname, \textcolor{stringliteral}{'var not found'})
58     \textcolor{keywordflow}{return}
59 \textcolor{keywordflow}{  endif}
60 
61   \textcolor{comment}{! 各引数が与えられている場合について値を取得する動作を}
62 
63   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(ndims)) \textcolor{keywordflow}{then}
64     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(ent%dimids)) \textcolor{keywordflow}{then}
65       ndims = \textcolor{keyword}{size}(ent%dimids)
66     \textcolor{keywordflow}{else}
67       ndims = 0
68 \textcolor{keywordflow}{    endif}
69 \textcolor{keywordflow}{  endif}
70 
71   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dimlen)) \textcolor{keywordflow}{then}
72     dimlen = 1
73     \textcolor{keywordflow}{if} (ent%dimid > 0) \textcolor{keywordflow}{then}
74       \textcolor{comment}{! 実体に次元としての問い合わせが可能な場合}
75       stat = nf90\_inquire\_dimension(ent%fileid, ent%dimid, len = dimlen)
76       \textcolor{keywordflow}{if} (stat /= nf90\_noerr) \textcolor{keywordflow}{then}
77         dimlen = -1
78         \textcolor{keyword}{call }endsub(subname, \textcolor{stringliteral}{'dimlen err'})
79         \textcolor{keywordflow}{return}
80 \textcolor{keywordflow}{      endif}
81     \textcolor{keywordflow}{else}
82       \textcolor{comment}{! 実体が変数として問い合わせるしかない場合}
83       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(ent%dimids)) \textcolor{keywordflow}{then}
84         \textcolor{keywordflow}{do}, i = 1, \textcolor{keyword}{size}(ent%dimids)
85           stat = nf90\_inquire\_dimension(ent%fileid, ent%dimids(i), len = length)
86           \textcolor{keywordflow}{if} (stat /= nf90\_noerr) \textcolor{keywordflow}{then}
87             dimlen = -1
88             \textcolor{keywordflow}{exit}
89 \textcolor{keywordflow}{          endif}
90           dimlen = dimlen * length
91 \textcolor{keywordflow}{        enddo}
92 \textcolor{keywordflow}{      endif}
93 \textcolor{keywordflow}{    endif}
94 \textcolor{keywordflow}{  endif}
95 
96   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(xtype)) \textcolor{keywordflow}{then}
97     stat = nf90\_inquire\_variable(ent%fileid, ent%varid, xtype=i\_xtype)
98     \textcolor{keywordflow}{if} (stat /= nf90\_noerr) i\_xtype = 0
99     \textcolor{keyword}{call }\hyperlink{gdncxtypename_8f90_a61d937db46bd95ad9652b0c86987f5db}{gdncxtypename}(i\_xtype, xtype)
100 \textcolor{keywordflow}{  endif}
101 
102   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(name)) \textcolor{keywordflow}{then}
103     \textcolor{keyword}{call }\hyperlink{gdncvarinquire_8f90_a3a79b9d1884aa67e5f4c8bfe65ce4f35}{local\_getname}(ent, buffer)
104     name = buffer
105 \textcolor{keywordflow}{  endif}
106 
107   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(url)) \textcolor{keywordflow}{then}
108     \textcolor{keyword}{call }\hyperlink{gdncvarinquire_8f90_a3a79b9d1884aa67e5f4c8bfe65ce4f35}{local\_getname}(ent, buffer)
109     \textcolor{keyword}{call }dbgmessage(\textcolor{stringliteral}{'ent%%fileid=%d'}, i=(/ent%fileid/))
110     \textcolor{keyword}{call }gdncfileinquire(ent%fileid, name=fbuffer)
111     url = trim(fbuffer) // \textcolor{stringliteral}{'?'} // buffer
112 \textcolor{keywordflow}{  endif}
113 
114   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(growable)) \textcolor{keywordflow}{then}
115     growable = .false.
116     stat = \hyperlink{namespacegtdata__netcdf__internal_afe013c8012ec100bf1e94e5147c340de}{vtable\_lookup}(var, ent)
117     \textcolor{keywordflow}{if} (stat /= nf90\_noerr) \textcolor{keywordflow}{return}
118     stat = nf90\_inquire(ent%fileid, unlimiteddimid = idim\_growable)
119     \textcolor{keywordflow}{if} (stat /= nf90\_noerr) \textcolor{keywordflow}{return}
120 
121     \textcolor{keywordflow}{if} (ent%varid > 0) \textcolor{keywordflow}{then}
122       \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(ent%dimids)) \textcolor{keywordflow}{return}
123       \textcolor{keywordflow}{do}, i = 1, \textcolor{keyword}{size}(ent%dimids)
124         \textcolor{keywordflow}{if} (ent%dimids(i) == idim\_growable) growable = .true.
125 \textcolor{keywordflow}{      enddo}
126     \textcolor{keywordflow}{else}
127       growable = (ent%dimid == idim\_growable)
128 \textcolor{keywordflow}{    endif}
129 \textcolor{keywordflow}{  endif}
130 
131   \textcolor{comment}{! 安全に終った}
132   \textcolor{keyword}{call }endsub(subname, \textcolor{stringliteral}{'ok'})
133   \textcolor{keywordflow}{return}
134 
135 \textcolor{keyword}{contains}
136 
137 \textcolor{keyword}{  subroutine }\hyperlink{gdncvarinquire_8f90_a3a79b9d1884aa67e5f4c8bfe65ce4f35}{local\_getname}(ent, varname)
138     \textcolor{keywordtype}{use }netcdf\textcolor{keywordtype}{, only}: &
139       & nf90\_inquire\_dimension, nf90\_inquire\_variable, nf90\_noerr
140     \textcolor{keywordtype}{type}(\hyperlink{structgtdata__netcdf__types_1_1gd__nc__variable__entry}{gd\_nc\_variable\_entry}), \textcolor{keywordtype}{intent(in)}:: ent
141     \textcolor{keywordtype}{character(len = *)}, \textcolor{keywordtype}{intent(out)}:: varname
142     \textcolor{keywordflow}{if} (ent%dimid > 0) \textcolor{keywordflow}{then}
143       stat = nf90\_inquire\_dimension(ent%fileid, ent%dimid, name = varname)
144     \textcolor{keywordflow}{else}
145       stat = nf90\_inquire\_variable(ent%fileid, ent%varid, name = varname)
146 \textcolor{keywordflow}{    endif}
147     \textcolor{keywordflow}{if} (stat /= nf90\_noerr) varname = \textcolor{stringliteral}{""}
148 \textcolor{keyword}{  end subroutine }\hyperlink{gdncvarinquire_8f90_a3a79b9d1884aa67e5f4c8bfe65ce4f35}{local\_getname}
149 
\end{DoxyCode}
Here is the call graph for this function\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=309pt]{gdncvarinquire_8f90_a2cda3863b94a5654e1f6d7b315053d3f_cgraph}
\end{center}
\end{figure}
\mbox{\Hypertarget{gdncvarinquire_8f90_a3a79b9d1884aa67e5f4c8bfe65ce4f35}\label{gdncvarinquire_8f90_a3a79b9d1884aa67e5f4c8bfe65ce4f35}} 
\index{gdncvarinquire.\+f90@{gdncvarinquire.\+f90}!local\+\_\+getname@{local\+\_\+getname}}
\index{local\+\_\+getname@{local\+\_\+getname}!gdncvarinquire.\+f90@{gdncvarinquire.\+f90}}
\subsubsection{\texorpdfstring{local\+\_\+getname()}{local\_getname()}}
{\footnotesize\ttfamily subroutine gdncvarinquire\+::local\+\_\+getname (\begin{DoxyParamCaption}\item[{type(gd\+\_\+nc\+\_\+variable\+\_\+entry), intent(in)}]{ent,  }\item[{character(len = $\ast$), intent(out)}]{varname }\end{DoxyParamCaption})}



Definition at line 138 of file gdncvarinquire.\+f90.


\begin{DoxyCode}
138     \textcolor{keywordtype}{use }netcdf\textcolor{keywordtype}{, only}: &
139       & nf90\_inquire\_dimension, nf90\_inquire\_variable, nf90\_noerr
140     \textcolor{keywordtype}{type}(\hyperlink{structgtdata__netcdf__types_1_1gd__nc__variable__entry}{gd\_nc\_variable\_entry}), \textcolor{keywordtype}{intent(in)}:: ent
141     \textcolor{keywordtype}{character(len = *)}, \textcolor{keywordtype}{intent(out)}:: varname
142     \textcolor{keywordflow}{if} (ent%dimid > 0) \textcolor{keywordflow}{then}
143       stat = nf90\_inquire\_dimension(ent%fileid, ent%dimid, name = varname)
144     \textcolor{keywordflow}{else}
145       stat = nf90\_inquire\_variable(ent%fileid, ent%varid, name = varname)
146 \textcolor{keywordflow}{    endif}
147     \textcolor{keywordflow}{if} (stat /= nf90\_noerr) varname = \textcolor{stringliteral}{""}
\end{DoxyCode}
