61 character(STRING),
parameter,
public:: &
62 & gtool4_netCDF_Conventions = &
63 &
"http://www.gfd-dennou.org/library/gtool4/conventions/"
65 character(STRING),
parameter,
public:: &
66 & gtool4_netCDF_version =
"4.3"
107 character(*),
intent(in):: varname
109 type(
gt_history),
intent(inout),
target,
optional:: history
112 character(*),
parameter:: subname =
"append_attrs"
114 call beginsub(subname,
'varname=<%c>, size(attrs(:))=<%d>', &
115 & c1=trim(varname), i=(/
size(attrs(:))/))
116 if (
present(history))
then
122 do i = 1,
size( attrs(:) )
124 if (
strhead(
'char', trim(
lchar(attrs(i)%attrtype))) )
then
126 & varname, attrs(i)%attrname, &
127 & trim(attrs(i)%Charvalue), hst )
128 elseif (
strhead(
'int', trim(
lchar(attrs(i)%attrtype))) )
then
129 if ( attrs(i)%array )
then
132 & varname, attrs(i)%attrname , &
133 & attrs(i)%Intarray, hst )
137 & varname, attrs(i)%attrname , &
138 & attrs(i)%Intvalue, hst )
140 elseif (
strhead(
'real', trim(
lchar(attrs(i)%attrtype))) )
then
141 if ( attrs(i)%array )
then
144 & varname, attrs(i)%attrname, attrs(i)%Realarray, hst)
148 & varname, attrs(i)%attrname, attrs(i)%Realvalue, hst)
150 elseif (
strhead(
'double', trim(
lchar(attrs(i)%attrtype))) )
then
151 if ( attrs(i)%array )
then
152 call dbgmessage(
'Doublearray(:) is selected.')
154 & varname, attrs(i)%attrname, attrs(i)%Doublearray, hst)
158 & varname, attrs(i)%attrname, attrs(i)%Doublevalue, hst)
160 elseif (
strhead(
'logical', trim(
lchar(attrs(i)%attrtype))) )
then
162 & varname, attrs(i)%attrname, attrs(i)%Logicalvalue, hst)
164 call dbgmessage(
'attrtype=<%c>=<%c>is Invalid.' , &
165 & c1=trim(attrs(i)%attrtype) , &
166 & c2=trim(
lchar(attrs(i)%attrtype)) )
188 logical,
intent(out),
optional :: err
190 character(STRING) :: cause_c
191 character(STRING),
parameter:: subname =
"copy_attrs"
196 call dbgmessage(
'size(from)=<%d>, size(to)=<%d>, So copy <%d> times.', &
197 & i=(/
size(from),
size(to), min(
size(from),
size(to)) /) )
198 if (
size(to) <
size(from) )
then
200 cause_c =
'from is larger than to'
204 do i = 1, min(
size(from),
size(to) )
206 to(i)%attrname = from(i)%attrname
207 to(i)%attrtype = from(i)%attrtype
208 to(i)%array = from(i)%array
210 if (
strhead(
'char', trim(
lchar(from(i)%attrtype))) )
then
211 to(i)%Charvalue = from(i)%Charvalue
213 &
lchar(
'Int'), trim(
lchar(from(i)%attrtype))))
then
214 if ( from(i)%array )
then
215 allocate( to(i)%Intarray(
size(from(i)%Intarray) ) )
216 to(i)%Intarray = from(i)%Intarray
218 to(i)%Intvalue = from(i)%Intvalue
221 &
lchar(
'Real'), trim(
lchar(from(i)%attrtype))))
then
222 if ( from(i)%array )
then
223 allocate( to(i)%Realarray(
size(from(i)%Realarray) ) )
224 to(i)%Realarray = from(i)%Realarray
226 to(i)%Realvalue = from(i)%Realvalue
229 &
lchar(
'Double'), trim(
lchar(from(i)%attrtype))))
then
230 if ( from(i)%array )
then
231 allocate( to(i)%Doublearray(
size(from(i)%Doublearray) ) )
232 to(i)%Doublearray = from(i)%Doublearray
234 to(i)%Doublevalue = from(i)%Doublevalue
236 elseif (
strhead(
'logical', trim(
lchar(from(i)%attrtype))) )
then
237 to(i)%Logicalvalue = from(i)%Logicalvalue
240 cause_c = from(i)%attrtype
245 call storeerror(stat, subname, err, cause_c=cause_c)
260 type(gt_history),
intent(inout):: history
261 integer,
intent(in):: dimord
263 real(DP),
allocatable::
value(:)
266 if (dimord == history % unlimited_index)
then
267 if (.not.
associated(history % count))
return
268 length = maxval(history % count(:))
270 call inquire(history % dimvars(dimord), size=length)
272 if (length == 0)
return
273 allocate(value(length))
274 if (dimord == history % unlimited_index)
then
275 value(:) = (/(real(i, dp), i = 1, length)/)
278 & + (value(:) - 1.0_dp) * history % interval
283 call slice(history % dimvars(dimord), 1, start=1, count=length)
285 value(:) = (/(real(i, dp), i = 1, length)/)
287 call put(history % dimvars(dimord),
value,
size(
value), err)
301 type(gt_history),
intent(in):: history
302 character(len = *),
intent(in):: varname
303 character(len = string):: name
304 character(len = *),
parameter:: subname =
'lookup_variable_ord'
306 call beginsub(subname,
'var=%c', c1 = trim(varname))
307 if (
associated(history % vars))
then
308 do, result = 1,
size(history % vars)
309 call inquire(history % vars(result), name=name)
310 if (name == varname)
goto 999
311 call dbgmessage(
'no match <%c> <%c>', c1=trim(name), c2=trim(varname))
316 call endsub(subname,
"result=%d", i=(/result/))
330 type(gt_history),
intent(in):: history
331 character(len = *),
intent(in):: varname
332 character(len = STRING) :: cause_c
333 integer,
intent(out),
optional:: ord
336 character(len = *),
parameter:: subname =
'lookup_variable'
338 call beginsub(subname,
'%c', c1=trim(varname))
341 if (
present(ord)) ord = 0
345 result = history % vars(i)
346 if (
present(ord)) ord = i
349 if (
present(ord))
then
357 call storeerror(stat, subname, cause_c=cause_c)
358 if (
present(ord)) ordwork = ord
359 call endsub(subname,
"ord=%d (0: not found)", i=(/ordwork/))
371 type(gt_history),
intent(in):: history
372 character(len = *),
intent(in):: dimname
373 integer,
intent(out),
optional:: ord
375 character(len = STRING):: name, cause_c
377 character(len = *),
parameter:: subname =
'lookup_dimension'
379 call beginsub(subname,
'dimname=%c', c1=trim(dimname))
381 if (
present(ord)) ord = 0
383 if (
associated(history % dimvars))
then
384 do, i = 1,
size(history % dimvars)
385 call inquire(history % dimvars(i), name=name)
386 if (name == trim(dimname))
then
387 result = history % dimvars(i)
388 if (
present(ord)) ord = i
395 if (
present(ord))
then
402 call storeerror(stat, subname, cause_c=cause_c)
403 if (
present(ord)) ordwork = ord
404 call endsub(subname,
'ord=%d (0:not found)', i=(/ordwork/))
418 type(gt_history),
intent(in):: history
419 character(len = *),
intent(in):: name
420 type(gt_variable),
intent(out):: var
421 logical,
intent(out):: err
423 character(STRING) :: cause_c
424 character(len = *),
parameter:: subname =
'lookup_var_or_dim'
426 call beginsub(subname,
'name=<%c>', c1=trim(name))
440 cause_c =
"Any vars and dims are not found"
443 call endsub(subname,
'ord=%d (0:not found)', i=(/ord/))
手続引用仕様. いずれ差し替えられるように外部関数にしておく。
subroutine, public storeerror(number, where, err, cause_c, cause_i)
integer, parameter, public gt_ebaddimname
integer, parameter, public dc_noerr
エラー等を保持
integer, parameter, public gt_eargsizemismatch
integer, parameter, public gt_ebadattrname
subroutine, public dbgmessage(fmt, i, r, d, l, n, c1, c2, c3, ca)
subroutine, public beginsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca, version)
subroutine, public endsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca)
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ
integer, parameter, public dp
倍精度実数型変数
type(gt_history), target, save, public default