gtool5 Fortran 90/95 ライブラリ 1.0.0-rc5
English
Loading...
Searching...
No Matches
Data Types | Functions/Subroutines | Variables
gtdata_internal_vartable Module Reference

Data Types

interface  dimrange
 

Functions/Subroutines

subroutine, public vartable_dump (vid)
 
subroutine, public vartableadd (vid, class, cid)
 
subroutine, public vartabledelete (vid, action, err)
 
subroutine, public vartablelookup (vid, class, cid)
 
subroutine, public vartablemore (vid, err)
 
integer function, public ndims (vid)
 
subroutine, public query_growable (vid, result)
 

Variables

integer, parameter, public vid_invalid = -1
 
integer, parameter, public vtb_class_unused = 0
 
integer, parameter, public vtb_class_netcdf = 1
 
integer, parameter, public classes_max = 2
 
type(gd_nc_variable_search), save, public gdnc_search
 

Detailed Description

gtool 変数表管理

このモジュールは gtool モジュールから直接には引用されないため、 相当むちゃな名前の使い方をしている。ユーザは呼んではならない。

gtool 変数というのは実は単なるハンドルと多次元イテレータであり、 ハンドルは小さな整数値である。 実体にアクセスするためには、ハンドル値をキーにしてまずマップ表を引き、 そこで得られた vid をキーにして変数表を引いて、 種別と種別ごとの変数番号を得る。これらはたかだかポインタ+オフセット 参照程度のコストである。 gtool 変数は実体変数からイテレータが必要なだけ作成されるが、 この変数表は実体変数につき1エントリしか作成しないので、参照数を持つ。 このため、実体変数は変数に付いて参照数管理をしなくてもよくなる。

Function/Subroutine Documentation

◆ ndims()

integer function, public gtdata_internal_vartable::ndims ( integer, intent(in)  vid)

変数の次元数を取得

Parameters
[in]vid変数ID
Returns
次元数

Definition at line 356 of file gtdata_internal_vartable.f90.

358 use gtdata_netcdf_generic, only: gdncinquire => inquire
359 use dc_error, only: storeerror, nf90_einval
360 integer, intent(in):: vid
361 integer:: class, cid
362 call vartablelookup(vid, class, cid)
363 select case(class)
364 case(vtb_class_netcdf)
365 call gdncinquire(gd_nc_variable(cid), ndims=result)
366 case default
367 call storeerror(nf90_einval, 'gtdata::ndims')
368 end select
エラー処理用モジュール
Definition dc_error.f90:454
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition dc_error.f90:891

References ndims(), dc_error::storeerror(), vartablelookup(), and vtb_class_netcdf.

Here is the call graph for this function:

◆ query_growable()

subroutine, public gtdata_internal_vartable::query_growable ( integer, intent(in)  vid,
logical, intent(out)  result 
)

変数が無制限次元を持つか問い合わせ

Parameters
[in]vid変数ID
[out]result無制限次元を持つ場合 .true.

Definition at line 384 of file gtdata_internal_vartable.f90.

387 use dc_error, only: storeerror, nf90_einval
388 integer, intent(in):: vid
389 logical, intent(out):: result
390 integer:: class, cid
391 call vartablelookup(vid, class, cid)
392 select case(class)
393 case(vtb_class_netcdf)
394 call inquire(gd_nc_variable(cid), growable=result)
395 case default
396 call storeerror(nf90_einval, 'gtdata::ndims')
397 end select

References dc_error::storeerror(), vartablelookup(), and vtb_class_netcdf.

Here is the call graph for this function:

◆ vartable_dump()

subroutine, public gtdata_internal_vartable::vartable_dump ( integer, intent(in)  vid)

デバッグ用変数テーブルエントリのダンプ

Parameters
[in]vidダンプする変数ID

Definition at line 106 of file gtdata_internal_vartable.f90.

107 use dc_trace, only: dbgmessage
110 integer, intent(in):: vid
111 character(10):: class
112 if (.not. allocated(table)) return
113 if (vid <= 0 .or. vid > size(table)) return
114 select case(table(vid)%class)
115 case(vtb_class_netcdf)
116 class = 'netcdf'
117 case default
118 write(class, fmt="(i10)") table(vid)%class
119 end select
120 call dbgmessage('[vartable %d: class=%c cid=%d ref=%d]', &
121 & i=(/vid, table(vid)%cid, table(vid)%refcount/), &
122 & c1=trim(class))
123 select case(table(vid)%class)
124 case(vtb_class_netcdf)
125 call dbgmessage('[%c]', c1=trim(tostring(gd_nc_variable(table(vid)%cid))))
126 end select
変数に関する問い合わせ
デバッグ時の追跡用モジュール
Definition dc_trace.f90:150
subroutine, public dbgmessage(fmt, i, r, d, l, n, c1, c2, c3, ca)
Definition dc_trace.f90:661

References dc_trace::dbgmessage(), vtb_class_netcdf, and vtb_class_unused.

Here is the call graph for this function:

◆ vartableadd()

subroutine, public gtdata_internal_vartable::vartableadd ( integer, intent(out)  vid,
integer, intent(in)  class,
integer, intent(in)  cid 
)

変数テーブルにエントリを追加

同じ class と cid を持つエントリが既に存在する場合、 その参照カウントを増加します。そうでなければ新しいエントリを作成します。

Parameters
[out]vid割り当てられた変数ID
[in]class変数クラス (VTB_CLASS_NETCDF 等)
[in]cidクラス固有のID

Definition at line 168 of file gtdata_internal_vartable.f90.

169 use dc_trace, only: dbgmessage
170 integer, intent(out):: vid
171 integer, intent(in):: class, cid
172 type(VAR_TABLE_ENTRY), allocatable:: tmp_table(:)
173 integer:: n
174 continue
175 ! 必要ならば初期幅確保
176 if (.not. allocated(table)) then
177 allocate(table(table_ini_size))
178 call entry_cleanup(table(:))
179 endif
180 ! 該当があれば参照数増加
181 do, n = 1, size(table)
182 if (table(n)%class == class .and. table(n)%cid == cid) then
183 table(n)%refcount = table(n)%refcount + 1
184 call dbgmessage('gtdata_vartable.add(class=%d cid=%d) found (ref=%d)', &
185 & i=(/table(n)%class, table(n)%cid, table(n)%refcount/))
186 vid = n
187 return
188 endif
189 enddo
190 ! もし空きが無ければ表を拡張
191 if (all(table(:)%class /= vtb_class_unused)) then
192 n = size(table)
193 allocate(tmp_table(n))
194 tmp_table(:) = table(:)
195 deallocate(table)
196 allocate(table(n * 2))
197 table(1:n) = tmp_table(1:n)
198 deallocate(tmp_table)
199 table(n+1:n*2) = var_table_entry(vtb_class_unused, -1, 0)
200 endif
201 do, n = 1, size(table)
202 if (table(n)%class == vtb_class_unused) then
203 table(n)%class = class
204 table(n)%cid = cid
205 table(n)%refcount = 1
206 vid = n
207 return
208 endif
209 enddo
210 vid = vid_invalid

References dc_trace::dbgmessage(), vid_invalid, and vtb_class_unused.

Here is the call graph for this function:

◆ vartabledelete()

subroutine, public gtdata_internal_vartable::vartabledelete ( integer, intent(in)  vid,
logical, intent(out)  action,
logical, intent(out), optional  err 
)

変数テーブルからエントリを削除

参照カウントを減少させます。ゼロになった場合、 実際の削除を行うべきことを示すために action に .true. が設定されます。

Parameters
[in]vid削除する変数ID
[out]action実際の削除を行うべきかどうか
[out]errエラーフラグ (省略可能)

Definition at line 234 of file gtdata_internal_vartable.f90.

235 integer, intent(in):: vid
236 logical, intent(out):: action
237 logical, intent(out), optional:: err
238 if (.not. allocated(table)) goto 999
239 if (vid <= 0 .or. vid > size(table)) goto 999
240 if (table(vid)%class <= vtb_class_unused) goto 999
241 if (table(vid)%class > classes_max) goto 999
242 table(vid)%refcount = max(table(vid)%refcount - 1, 0)
243 action = (table(vid)%refcount == 0)
244 if (present(err)) err = .false.
245 return
246999 continue
247 action = .false.
248 if (present(err)) err = .true.

References classes_max, and vtb_class_unused.

◆ vartablelookup()

subroutine, public gtdata_internal_vartable::vartablelookup ( integer, intent(in)  vid,
integer, intent(out), optional  class,
integer, intent(out), optional  cid 
)

変数テーブルエントリを検索

指定された vid を持つエントリの class と cid を返します。

Parameters
[in]vid検索する変数ID
[out]class変数クラス (省略可能)
[out]cidクラス固有のID (省略可能)

Definition at line 270 of file gtdata_internal_vartable.f90.

271 integer, intent(in):: vid
272 integer, intent(out), optional:: class, cid
273 if (.not. allocated(table)) goto 999
274 if (vid <= 0 .or. vid > size(table)) goto 999
275 if (table(vid)%class <= vtb_class_unused) goto 999
276 if (table(vid)%class > classes_max) goto 999
277 if (present(class)) class = table(vid)%class
278 if (present(cid)) cid = table(vid)%cid
279 return
280999 continue
281 if (present(class)) class = vtb_class_unused

References classes_max, and vtb_class_unused.

◆ vartablemore()

subroutine, public gtdata_internal_vartable::vartablemore ( integer, intent(in)  vid,
logical, intent(out), optional  err 
)

変数テーブルエントリの参照カウントを増加

Parameters
[in]vid変数ID
[out]errエラーフラグ (省略可能)

Definition at line 297 of file gtdata_internal_vartable.f90.

298 integer, intent(in):: vid
299 logical, intent(out), optional:: err
300 if (.not. allocated(table)) goto 999
301 if (vid <= 0 .or. vid > size(table)) goto 999
302 if (table(vid)%class <= vtb_class_unused) goto 999
303 if (table(vid)%class > classes_max) goto 999
304 table(vid)%refcount = table(vid)%refcount + 1
305 if (present(err)) err = .false.
306 return
307999 continue
308 if (present(err)) err = .true.

References classes_max, and vtb_class_unused.

Variable Documentation

◆ classes_max

integer, parameter, public gtdata_internal_vartable::classes_max = 2

Definition at line 70 of file gtdata_internal_vartable.f90.

70 integer, parameter, public :: CLASSES_MAX = 2

◆ gdnc_search

type(gd_nc_variable_search), save, public gtdata_internal_vartable::gdnc_search

Definition at line 81 of file gtdata_internal_vartable.f90.

81 type(GD_NC_VARIABLE_SEARCH), public, save:: gdnc_search

◆ vid_invalid

integer, parameter, public gtdata_internal_vartable::vid_invalid = -1

Definition at line 66 of file gtdata_internal_vartable.f90.

66 integer, parameter, public :: vid_invalid = -1

◆ vtb_class_netcdf

integer, parameter, public gtdata_internal_vartable::vtb_class_netcdf = 1

Definition at line 69 of file gtdata_internal_vartable.f90.

69 integer, parameter, public :: VTB_CLASS_NETCDF = 1

◆ vtb_class_unused

integer, parameter, public gtdata_internal_vartable::vtb_class_unused = 0

Definition at line 68 of file gtdata_internal_vartable.f90.

68 integer, parameter, public :: VTB_CLASS_UNUSED = 0