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
 

Function/Subroutine Documentation

◆ ndims()

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

Definition at line 201 of file gtdata_internal_vartable.f90.

203 use gtdata_netcdf_generic, only: gdncinquire => inquire
204 use dc_error, only: storeerror, nf90_einval
205 integer, intent(in):: vid
206 integer:: class, cid
207 call vartablelookup(vid, class, cid)
208 select case(class)
209 case(vtb_class_netcdf)
210 call gdncinquire(gd_nc_variable(cid), ndims=result)
211 case default
212 call storeerror(nf90_einval, 'gtdata::ndims')
213 end select
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition dc_error.f90:830

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 
)

Definition at line 216 of file gtdata_internal_vartable.f90.

219 use dc_error, only: storeerror, nf90_einval
220 integer, intent(in):: vid
221 logical, intent(out):: result
222 integer:: class, cid
223 call vartablelookup(vid, class, cid)
224 select case(class)
225 case(vtb_class_netcdf)
226 call inquire(gd_nc_variable(cid), growable=result)
227 case default
228 call storeerror(nf90_einval, 'gtdata::ndims')
229 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)

Definition at line 62 of file gtdata_internal_vartable.f90.

63 use dc_trace, only: dbgmessage
66 integer, intent(in):: vid
67 character(10):: class
68 if (.not. allocated(table)) return
69 if (vid <= 0 .or. vid > size(table)) return
70 select case(table(vid)%class)
71 case(vtb_class_netcdf)
72 class = 'netcdf'
73 case default
74 write(class, fmt="(i10)") table(vid)%class
75 end select
76 call dbgmessage('[vartable %d: class=%c cid=%d ref=%d]', &
77 & i=(/vid, table(vid)%cid, table(vid)%refcount/), &
78 & c1=trim(class))
79 select case(table(vid)%class)
80 case(vtb_class_netcdf)
81 call dbgmessage('[%c]', c1=trim(tostring(gd_nc_variable(table(vid)%cid))))
82 end select

References vtb_class_netcdf, and vtb_class_unused.

◆ vartableadd()

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

Definition at line 92 of file gtdata_internal_vartable.f90.

93 use dc_trace, only: dbgmessage
94 integer, intent(out):: vid
95 integer, intent(in):: class, cid
96 type(VAR_TABLE_ENTRY), allocatable:: tmp_table(:)
97 integer:: n
98 continue
99 ! 必要ならば初期幅確保
100 if (.not. allocated(table)) then
101 allocate(table(table_ini_size))
102 call entry_cleanup(table(:))
103 endif
104 ! 該当があれば参照数増加
105 do, n = 1, size(table)
106 if (table(n)%class == class .and. table(n)%cid == cid) then
107 table(n)%refcount = table(n)%refcount + 1
108 call dbgmessage('gtdata_vartable.add(class=%d cid=%d) found (ref=%d)', &
109 & i=(/table(n)%class, table(n)%cid, table(n)%refcount/))
110 vid = n
111 return
112 endif
113 enddo
114 ! もし空きが無ければ表を拡張
115 if (all(table(:)%class /= vtb_class_unused)) then
116 n = size(table)
117 allocate(tmp_table(n))
118 tmp_table(:) = table(:)
119 deallocate(table)
120 allocate(table(n * 2))
121 table(1:n) = tmp_table(1:n)
122 deallocate(tmp_table)
123 table(n+1:n*2) = var_table_entry(vtb_class_unused, -1, 0)
124 endif
125 do, n = 1, size(table)
126 if (table(n)%class == vtb_class_unused) then
127 table(n)%class = class
128 table(n)%cid = cid
129 table(n)%refcount = 1
130 vid = n
131 return
132 endif
133 enddo
134 vid = vid_invalid

References vid_invalid, and vtb_class_unused.

◆ vartabledelete()

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

Definition at line 137 of file gtdata_internal_vartable.f90.

138 integer, intent(in):: vid
139 logical, intent(out):: action
140 logical, intent(out), optional:: err
141 if (.not. allocated(table)) goto 999
142 if (vid <= 0 .or. vid > size(table)) goto 999
143 if (table(vid)%class <= vtb_class_unused) goto 999
144 if (table(vid)%class > classes_max) goto 999
145 table(vid)%refcount = max(table(vid)%refcount - 1, 0)
146 action = (table(vid)%refcount == 0)
147 if (present(err)) err = .false.
148 return
149999 continue
150 action = .false.
151 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 
)

Definition at line 154 of file gtdata_internal_vartable.f90.

155 ! 同じファイル番号の変数表の中身を返す
156 integer, intent(in):: vid
157 integer, intent(out), optional:: class, cid
158 if (.not. allocated(table)) goto 999
159 if (vid <= 0 .or. vid > size(table)) goto 999
160 if (table(vid)%class <= vtb_class_unused) goto 999
161 if (table(vid)%class > classes_max) goto 999
162 if (present(class)) class = table(vid)%class
163 if (present(cid)) cid = table(vid)%cid
164 return
165999 continue
166 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 
)

Definition at line 169 of file gtdata_internal_vartable.f90.

170 ! 同じファイル番号の参照カウントを増加する。
171 integer, intent(in):: vid
172 logical, intent(out), optional:: err
173 if (.not. allocated(table)) goto 999
174 if (vid <= 0 .or. vid > size(table)) goto 999
175 if (table(vid)%class <= vtb_class_unused) goto 999
176 if (table(vid)%class > classes_max) goto 999
177 table(vid)%refcount = table(vid)%refcount + 1
178 if (present(err)) err = .false.
179 return
180999 continue
181 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 37 of file gtdata_internal_vartable.f90.

37 integer, parameter, public :: CLASSES_MAX = 2

◆ gdnc_search

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

Definition at line 48 of file gtdata_internal_vartable.f90.

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

◆ vid_invalid

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

Definition at line 33 of file gtdata_internal_vartable.f90.

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

◆ vtb_class_netcdf

integer, parameter, public gtdata_internal_vartable::vtb_class_netcdf = 1

Definition at line 36 of file gtdata_internal_vartable.f90.

36 integer, parameter, public :: VTB_CLASS_NETCDF = 1

◆ vtb_class_unused

integer, parameter, public gtdata_internal_vartable::vtb_class_unused = 0

Definition at line 35 of file gtdata_internal_vartable.f90.

35 integer, parameter, public :: VTB_CLASS_UNUSED = 0