57 use netcdf,
only: nf90_noerr, nf90_max_name, &
58 & nf90_inquire_variable, nf90_inquire_dimension, nf90_inquire
61 integer,
intent(out),
optional:: ndims
62 integer,
intent(out),
optional:: dimlen
63 logical,
intent(out),
optional:: growable
64 character(*),
intent(out),
optional:: name
65 character(*),
intent(out),
optional:: url
66 character(*),
intent(out),
optional:: xtype
70 integer:: stat, length, i, i_xtype, idim_growable
71 character(len = *),
parameter:: subname =
'GDNcVarInquire'
72 character(len = NF90_MAX_NAME):: buffer
73 character(len = NF90_MAX_NAME):: fbuffer
75 call beginsub(subname,
'var.id=%d', i=(/var%id/))
78 if (
present(ndims)) ndims = -1
79 if (
present(dimlen)) dimlen = -1
83 if (stat /= nf90_noerr)
then
84 call endsub(subname,
'var not found')
90 if (
present(ndims))
then
91 if (
associated(ent%dimids))
then
92 ndims =
size(ent%dimids)
98 if (
present(dimlen))
then
100 if (ent%dimid > 0)
then
102 stat = nf90_inquire_dimension(ent%fileid, ent%dimid, len = dimlen)
103 if (stat /= nf90_noerr)
then
105 call endsub(subname,
'dimlen err')
110 if (
associated(ent%dimids))
then
111 do, i = 1,
size(ent%dimids)
112 stat = nf90_inquire_dimension(ent%fileid, ent%dimids(i), len = length)
113 if (stat /= nf90_noerr)
then
117 dimlen = dimlen * length
123 if (
present(xtype))
then
124 stat = nf90_inquire_variable(ent%fileid, ent%varid, xtype=i_xtype)
125 if (stat /= nf90_noerr) i_xtype = 0
129 if (
present(name))
then
134 if (
present(url))
then
136 call dbgmessage(
'ent%%fileid=%d', i=(/ent%fileid/))
138 url = trim(fbuffer) //
'?' // buffer
141 if (
present(growable))
then
144 if (stat /= nf90_noerr)
return
145 stat = nf90_inquire(ent%fileid, unlimiteddimid = idim_growable)
146 if (stat /= nf90_noerr)
return
148 if (ent%varid > 0)
then
149 if (.not.
associated(ent%dimids))
return
150 do, i = 1,
size(ent%dimids)
151 if (ent%dimids(i) == idim_growable) growable = .true.
154 growable = (ent%dimid == idim_growable)
159 call endsub(subname,
'ok')
166 & nf90_inquire_dimension, nf90_inquire_variable, nf90_noerr
168 character(len = *),
intent(out):: varname
169 if (ent%dimid > 0)
then
170 stat = nf90_inquire_dimension(ent%fileid, ent%dimid, name = varname)
172 stat = nf90_inquire_variable(ent%fileid, ent%varid, name = varname)
174 if (stat /= nf90_noerr) varname =
""
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)