\hypertarget{gdncvarcreate_8f90}{}\section{gtdata/gtdata\+\_\+netcdf/gdncvarcreate.f90 File Reference}
\label{gdncvarcreate_8f90}\index{gtdata/gtdata\+\_\+netcdf/gdncvarcreate.\+f90@{gtdata/gtdata\+\_\+netcdf/gdncvarcreate.\+f90}}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine \hyperlink{gdncvarcreate_8f90_ac592ad9b3edfbe1cb2c40be54c7e78e5}{gdncvarcreate} (var, url, xtype, dims, overwrite, err)
\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{gdncvarcreate_8f90_ac592ad9b3edfbe1cb2c40be54c7e78e5}\label{gdncvarcreate_8f90_ac592ad9b3edfbe1cb2c40be54c7e78e5}} 
\index{gdncvarcreate.\+f90@{gdncvarcreate.\+f90}!gdncvarcreate@{gdncvarcreate}}
\index{gdncvarcreate@{gdncvarcreate}!gdncvarcreate.\+f90@{gdncvarcreate.\+f90}}
\subsubsection{\texorpdfstring{gdncvarcreate()}{gdncvarcreate()}}
{\footnotesize\ttfamily subroutine gdncvarcreate (\begin{DoxyParamCaption}\item[{type(gd\+\_\+nc\+\_\+variable), intent(out)}]{var,  }\item[{character(len = $\ast$), intent(in)}]{url,  }\item[{character(len = $\ast$), intent(in)}]{xtype,  }\item[{type(gd\+\_\+nc\+\_\+variable), dimension(\+:), intent(in)}]{dims,  }\item[{logical, intent(in), optional}]{overwrite,  }\item[{logical, intent(out), optional}]{err }\end{DoxyParamCaption})}



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



References dc\+\_\+trace\+::beginsub(), dc\+\_\+trace\+::dbgmessage(), dc\+\_\+trace\+::endsub(), gdncfiledefinemode(), gdncfileopen(), dc\+\_\+error\+::gt\+\_\+edimmultidim, dc\+\_\+error\+::gt\+\_\+edimnodim, dc\+\_\+error\+::gt\+\_\+enomem, dc\+\_\+error\+::gt\+\_\+eotherfile, dc\+\_\+error\+::storeerror(), dc\+\_\+types\+::string, gtdata\+\_\+netcdf\+\_\+internal\+::vtable\+\_\+add(), and gtdata\+\_\+netcdf\+\_\+internal\+::vtable\+\_\+lookup().


\begin{DoxyCode}
14   \textcolor{comment}{!}
15   \textcolor{comment}{!== 変数作成}
16   \textcolor{comment}{!}
17   \textcolor{comment}{! 変数 URL *url* に変数を作成します.}
18   \textcolor{comment}{! 変数が依存する次元を *dims* に与えます.}
19   \textcolor{comment}{! 返される引数 *var* には変数 ID などの情報が格納されます.}
20   \textcolor{comment}{!}
21   \textcolor{comment}{! *overwrite* に .true. を設定すると上書き可能なモードになります.}
22   \textcolor{comment}{! デフォルトは上書き不可です.}
23   \textcolor{comment}{! *err* を与える場合, 次元変数生成時にエラーが生じても}
24   \textcolor{comment}{! プログラムを終了せず, *err* に .false. が返ります.}
25   \textcolor{comment}{!}
26   \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}, \hyperlink{structgtdata__netcdf__types_1_1gd__nc__variable__search}{gd\_nc\_variable\_search}
27   \textcolor{keywordtype}{use }\hyperlink{namespacedc__types}{dc\_types}\textcolor{keywordtype}{, only}: \hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}
28   \textcolor{keywordtype}{use }\hyperlink{namespacedc__string}{dc\_string}\textcolor{keywordtype}{, only}: \hyperlink{interfacedc__string_1_1strieq}{strieq}
29   \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__netcdf__internal}{gtdata\_netcdf\_internal}\textcolor{keywordtype}{, only}: \hyperlink{namespacegtdata__netcdf__internal_ae0fc3a443b08733d689ce0aad981eb71}{vtable\_add}, 
      \hyperlink{namespacegtdata__netcdf__internal_afe013c8012ec100bf1e94e5147c340de}{vtable\_lookup}
30   \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__netcdf__file__generic}{gtdata\_netcdf\_file\_generic}\textcolor{keywordtype}{, only}: \hyperlink{gdncfileopen_8f90_a4f95f1f240238c6a431b39ea8e7c6f47}{gdncfileopen}, 
      \hyperlink{gdncfiledefinemode_8f90_afbd7b3565fcb4698e5f7eadf62fb4b35}{gdncfiledefinemode}
31   \textcolor{keywordtype}{use }\hyperlink{namespacedc__url}{dc\_url}\textcolor{keywordtype}{, only}: \hyperlink{interfacedc__url_1_1urlsplit}{urlsplit}
32   \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}
33   \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__netcdf__generic}{gtdata\_netcdf\_generic}\textcolor{keywordtype}{, only}: \hyperlink{interfacegtdata__netcdf__generic_1_1tostring}{tostring} \textcolor{comment}{! for debug}
34   \textcolor{keywordtype}{use }netcdf\textcolor{keywordtype}{, only}: &
35     & nf90\_noerr, nf90\_float, nf90\_double, nf90\_int, nf90\_char, nf90\_ebaddim, nf90\_def\_var
36   \textcolor{keywordtype}{use }\hyperlink{namespacedc__error}{dc\_error}\textcolor{keywordtype}{, only}: \hyperlink{namespacedc__error_a0104aee83ee5752b1a9f6152b11864a8}{storeerror}, \hyperlink{namespacedc__error_a253c222db80053c2ddcac9a384424949}{gt\_enomem}, 
      \hyperlink{namespacedc__error_a1765119e975f85daf47c383c9c763fc1}{gt\_eotherfile}, &
37     & \hyperlink{namespacedc__error_a4ff8be5fd3e7ac95e3617778d2226510}{gt\_edimnodim}, \hyperlink{namespacedc__error_ab34090b3ac05d7dd3e5602af3d5bb588}{gt\_edimmultidim}
38   \textcolor{keywordtype}{implicit none}
39   \textcolor{keywordtype}{type}(\hyperlink{structgtdata__netcdf__types_1_1gd__nc__variable}{gd\_nc\_variable}), \textcolor{keywordtype}{intent(out)}:: var
40   \textcolor{keywordtype}{character(len = *)}, \textcolor{keywordtype}{intent(in)}:: url
41   \textcolor{keywordtype}{character(len = *)}, \textcolor{keywordtype}{intent(in)}:: xtype
42   \textcolor{keywordtype}{type}(\hyperlink{structgtdata__netcdf__types_1_1gd__nc__variable}{gd\_nc\_variable}), \textcolor{keywordtype}{intent(in)}:: dims(:)
43   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(in)}, \textcolor{keywordtype}{optional}:: overwrite
44   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(out)}, \textcolor{keywordtype}{optional}:: err
45   \textcolor{keywordtype}{type}(\hyperlink{structgtdata__netcdf__types_1_1gd__nc__variable__search}{gd\_nc\_variable\_search}):: ent
46   \textcolor{keywordtype}{type}(\hyperlink{structgtdata__netcdf__types_1_1gd__nc__variable__entry}{gd\_nc\_variable\_entry}):: ent\_dim
47   \textcolor{keywordtype}{character(len = string)}:: filename, varname
48   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{allocatable}:: dimids(:)
49   \textcolor{keywordtype}{integer}:: stat, nvdims, i
50   \textcolor{keywordtype}{integer}:: nc\_xtype
51   \textcolor{keywordtype}{logical}:: clobber
52   \textcolor{keywordtype}{intrinsic} trim
53   \textcolor{keywordtype}{character(len = *)}, \textcolor{keywordtype}{parameter}:: subnam = \textcolor{stringliteral}{"GDNcVarCreate"}
54 \textcolor{keywordflow}{continue}
55   clobber = .false.
56   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(overwrite)) clobber = overwrite
57   \textcolor{keyword}{call }\hyperlink{namespacedc__trace_aca1efe8bae50b85f74980a8c4d704dd8}{beginsub}(subnam)
58   \textcolor{keyword}{call }\hyperlink{namespacedc__trace_a2a38fceb4cf9baf298d63456238c3fea}{dbgmessage}(\textcolor{stringliteral}{'url=%c'}, c1=trim(url))
59   \textcolor{keyword}{call }\hyperlink{namespacedc__trace_a2a38fceb4cf9baf298d63456238c3fea}{dbgmessage}(\textcolor{stringliteral}{'xtype=%c'}, c1=trim(xtype))
60   \textcolor{keyword}{call }\hyperlink{namespacedc__trace_a2a38fceb4cf9baf298d63456238c3fea}{dbgmessage}(\textcolor{stringliteral}{'dims=(/%*d/)'}, i=(/dims(:)%id/), n=(/\textcolor{keyword}{size}(dims)/))
61   \textcolor{keyword}{call }\hyperlink{namespacedc__trace_a2a38fceb4cf9baf298d63456238c3fea}{dbgmessage}(\textcolor{stringliteral}{'ovwr=%y'}, l=(/clobber/))
62 
63   \textcolor{comment}{! もし必要ならファイル作成}
64   \textcolor{keyword}{call }\hyperlink{interfacedc__url_1_1urlsplit}{urlsplit}(url, filename, varname)
65   \textcolor{keyword}{call }\hyperlink{gdncfileopen_8f90_a4f95f1f240238c6a431b39ea8e7c6f47}{gdncfileopen}(ent%fileid, filename, stat=stat, writable=.true., &
66     & overwrite=clobber)
67   \textcolor{keywordflow}{if} (stat /= nf90\_noerr) \textcolor{keywordflow}{goto} 999
68 
69   \textcolor{comment}{! 次元にまつわる準備}
70   nvdims = \textcolor{keyword}{size}(dims)
71   \textcolor{keyword}{allocate}(dimids(\hyperlink{interfacedc__date__generic_1_1max}{max}(1, nvdims)), stat=stat)
72   \textcolor{keywordflow}{if} (stat /= 0) \textcolor{keywordflow}{then}
73     stat = \hyperlink{namespacedc__error_a253c222db80053c2ddcac9a384424949}{gt\_enomem}
74     \textcolor{keywordflow}{goto} 999
75 \textcolor{keywordflow}{  end if}
76   \textcolor{keywordflow}{do}, i = 1, nvdims
77     stat = \hyperlink{namespacegtdata__netcdf__internal_afe013c8012ec100bf1e94e5147c340de}{vtable\_lookup}(dims(i), ent\_dim)
78     \textcolor{keywordflow}{if} (stat /= nf90\_noerr) \textcolor{keywordflow}{then}
79       stat = nf90\_ebaddim
80       \textcolor{keywordflow}{goto} 999
81 \textcolor{keywordflow}{    endif}
82     \textcolor{keywordflow}{if} (ent%fileid /= ent\_dim%fileid) \textcolor{keywordflow}{then}
83       stat = \hyperlink{namespacedc__error_a1765119e975f85daf47c383c9c763fc1}{gt\_eotherfile}
84       \textcolor{keywordflow}{goto} 999
85 \textcolor{keywordflow}{    endif}
86     \textcolor{keywordflow}{if} (ent\_dim%dimid <= 0) \textcolor{keywordflow}{then}
87       stat = \hyperlink{namespacedc__error_ab34090b3ac05d7dd3e5602af3d5bb588}{gt\_edimmultidim}
88       \textcolor{keywordflow}{goto} 999
89 \textcolor{keywordflow}{    endif}
90     dimids(i) = ent\_dim%dimid
91 \textcolor{keywordflow}{  enddo}
92   ent%dimid = 0
93 
94   \textcolor{comment}{! 変数の型の判定}
95   nc\_xtype = nf90\_float
96   \textcolor{keywordflow}{if} (\hyperlink{interfacedc__string_1_1strieq}{strieq}(xtype, \textcolor{stringliteral}{"double"}) .or. \hyperlink{interfacedc__string_1_1strieq}{strieq}(xtype, \textcolor{stringliteral}{"DOUBLEPRECISION"})) \textcolor{keywordflow}{then}
97     nc\_xtype = nf90\_double
98 \textcolor{keywordflow}{  endif}
99   \textcolor{keywordflow}{if} (\hyperlink{interfacedc__string_1_1strieq}{strieq}(xtype, \textcolor{stringliteral}{"int"}) .or. \hyperlink{interfacedc__string_1_1strieq}{strieq}(xtype, \textcolor{stringliteral}{"INTEGER"})) \textcolor{keywordflow}{then}
100     nc\_xtype = nf90\_int
101 \textcolor{keywordflow}{  endif}
102   \textcolor{keywordflow}{if} (\hyperlink{interfacedc__string_1_1strieq}{strieq}(xtype, \textcolor{stringliteral}{"char"}) .or. \hyperlink{interfacedc__string_1_1strieq}{strieq}(xtype, \textcolor{stringliteral}{"CHARACTER"})) \textcolor{keywordflow}{then}
103     nc\_xtype = nf90\_char
104 \textcolor{keywordflow}{  endif}
105 
106   \textcolor{comment}{! 本当の変数作成操作}
107   stat = \hyperlink{gdncfiledefinemode_8f90_afbd7b3565fcb4698e5f7eadf62fb4b35}{gdncfiledefinemode}(ent%fileid)
108   \textcolor{keywordflow}{if} (stat /= nf90\_noerr) \textcolor{keywordflow}{goto} 999
109   \textcolor{keywordflow}{if} ( nvdims == 0 ) \textcolor{keywordflow}{then}
110     stat = nf90\_def\_var(ent%fileid, name = trim(varname), &
111       & xtype = nc\_xtype, varid=ent%varid)
112   \textcolor{keywordflow}{else}
113     stat = nf90\_def\_var(ent%fileid, name = trim(varname), &
114       & xtype = nc\_xtype, dimids = dimids, varid=ent%varid)
115 \textcolor{keywordflow}{  end if}
116   \textcolor{keywordflow}{if} (stat /= nf90\_noerr) \textcolor{keywordflow}{goto} 999
117 
118   \textcolor{comment}{! 登録}
119   stat = \hyperlink{namespacegtdata__netcdf__internal_ae0fc3a443b08733d689ce0aad981eb71}{vtable\_add}(var, ent)
120 
121 999 \textcolor{keywordflow}{continue}
122   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(dimids)) \textcolor{keyword}{deallocate}(dimids)
123   \textcolor{keywordflow}{if} (stat /= nf90\_noerr) var % id = -1
124   \textcolor{keyword}{call }\hyperlink{namespacedc__error_a0104aee83ee5752b1a9f6152b11864a8}{storeerror}(stat, subnam, err, cause\_c=url)
125   \textcolor{keyword}{call }\hyperlink{namespacedc__trace_ae44de97565a3bdd685789c7748b37e37}{endsub}(subnam, \textcolor{stringliteral}{'stat=%d, var.id=%d'}, i=(/stat, var % id/))
\end{DoxyCode}
Here is the call graph for this function\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{gdncvarcreate_8f90_ac592ad9b3edfbe1cb2c40be54c7e78e5_cgraph}
\end{center}
\end{figure}
