76 end type var_table_entry
78 type(var_table_entry),
save,
allocatable:: table(:)
79 integer,
parameter:: table_ini_size = 16
86 private:: var_table_entry, table, table_ini_size
87 private:: entry_cleanup
90 module procedure dimrange_direct
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)
118 write(
class, fmt=
"(i10)") table(vid)%class
120 call dbgmessage(
'[vartable %d: class=%c cid=%d ref=%d]', &
121 & i=(/vid, table(vid)%cid, table(vid)%refcount/), &
123 select case(table(vid)%class)
140 subroutine entry_cleanup(vtb_entry)
141 type(var_table_entry),
intent(out):: vtb_entry(:)
143 vtb_entry(:)%cid = -1
144 vtb_entry(:)%refcount = 0
145 end subroutine entry_cleanup
170 integer,
intent(out):: vid
171 integer,
intent(in)::
class, cid
172 type(var_table_entry),
allocatable:: tmp_table(:)
176 if (.not.
allocated(table))
then
177 allocate(table(table_ini_size))
178 call entry_cleanup(table(:))
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/))
193 allocate(tmp_table(n))
194 tmp_table(:) = table(:)
196 allocate(table(n * 2))
197 table(1:n) = tmp_table(1:n)
198 deallocate(tmp_table)
201 do, n = 1,
size(table)
203 table(n)%class = class
205 table(n)%refcount = 1
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
242 table(vid)%refcount = max(table(vid)%refcount - 1, 0)
243 action = (table(vid)%refcount == 0)
244 if (
present(err)) err = .false.
248 if (
present(err)) err = .true.
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
277 if (
present(class))
class = table(vid)%class
278 if (
present(cid)) cid = table(vid)%cid
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
304 table(vid)%refcount = table(vid)%refcount + 1
305 if (
present(err)) err = .false.
308 if (
present(err)) err = .true.
326 subroutine dimrange_direct(vid, dimlo, dimhi)
330 integer,
intent(in):: vid
331 integer,
intent(out):: dimlo, dimhi
339 call storeerror(nf90_einval,
'gtdata::dimrange')
341 end subroutine dimrange_direct
356 integer function ndims(vid)
result(result)
360 integer,
intent(in):: vid
388 integer,
intent(in):: vid
389 logical,
intent(out):: result
subroutine, public storeerror(number, where, err, cause_c, cause_i)
subroutine, public dbgmessage(fmt, i, r, d, l, n, c1, c2, c3, ca)
Provides kind type parameter values.
integer, parameter, public string
Character length for string
subroutine, public vartabledelete(vid, action, err)
subroutine, public vartablelookup(vid, class, cid)
integer, parameter, public classes_max
integer, parameter, public vid_invalid
subroutine, public query_growable(vid, result)
subroutine, public vartablemore(vid, err)
subroutine, public vartableadd(vid, class, cid)
integer, parameter, public vtb_class_netcdf
type(gd_nc_variable_search), save, public gdnc_search
subroutine, public vartable_dump(vid)
integer function, public ndims(vid)
integer, parameter, public vtb_class_unused