43 end type var_table_entry
45 type(var_table_entry),
save,
allocatable:: table(:)
46 integer,
parameter:: table_ini_size = 16
53 private:: var_table_entry, table, table_ini_size
54 private:: entry_cleanup
57 module procedure dimrange_direct
63 use dc_trace
, only: dbgmessage
66 integer,
intent(in):: vid
68 if (.not.
allocated(table))
return 69 if (vid <= 0 .or. vid >
size(table))
return 70 select case(table(vid)%class)
74 write(
class, fmt=
"(i10)") table(vid)%class
76 call dbgmessage(
'[vartable %d: class=%c cid=%d ref=%d]', &
77 & i=(/vid, table(vid)%cid, table(vid)%refcount/), &
79 select case(table(vid)%class)
85 subroutine entry_cleanup(vtb_entry)
86 type(var_table_entry),
intent(out):: vtb_entry(:)
89 vtb_entry(:)%refcount = 0
90 end subroutine entry_cleanup
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(:)
100 if (.not.
allocated(table))
then 101 allocate(table(table_ini_size))
102 call entry_cleanup(table(:))
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/))
117 allocate(tmp_table(n))
118 tmp_table(:) = table(:)
120 allocate(table(n * 2))
121 table(1:n) = tmp_table(1:n)
122 deallocate(tmp_table)
125 do, n = 1,
size(table)
127 table(n)%class = class
129 table(n)%refcount = 1
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
145 table(vid)%refcount = max(table(vid)%refcount - 1, 0)
146 action = (table(vid)%refcount == 0)
147 if (
present(err)) err = .false.
151 if (
present(err)) err = .true.
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
162 if (
present(class))
class = table(vid)%class
163 if (
present(cid)) cid = table(vid)%cid
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
177 table(vid)%refcount = table(vid)%refcount + 1
178 if (
present(err)) err = .false.
181 if (
present(err)) err = .true.
184 subroutine dimrange_direct(vid, dimlo, dimhi)
188 integer,
intent(in):: vid
189 integer,
intent(out):: dimlo, dimhi
197 call storeerror(nf90_einval,
'gtdata::dimrange')
199 end subroutine dimrange_direct
201 integer function ndims(vid)
result(result)
205 integer,
intent(in):: vid
220 integer,
intent(in):: vid
221 logical,
intent(out):: result
subroutine, public vartabledelete(vid, action, err)
integer, parameter, public classes_max
subroutine, public vartable_dump(vid)
type(gd_nc_variable_search), save, public gdnc_search
integer, parameter, public vtb_class_netcdf
integer, parameter, public vid_invalid
integer, parameter, public gt_efake
subroutine, public storeerror(number, where, err, cause_c, cause_i)
integer function, public ndims(vid)
subroutine, public vartablemore(vid, err)
integer, parameter, public vtb_class_unused
subroutine, public vartablelookup(vid, class, cid)
Provides kind type parameter values.
subroutine, public vartableadd(vid, class, cid)
subroutine, public query_growable(vid, result)
integer, parameter, public string
Character length for string.