gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
Functions/Subroutines
gdncvarattr.f90 File Reference

Attribute enumeration for netCDF variables. More...

Go to the source code of this file.

Functions/Subroutines

subroutine gdncvarattrrewind (var)
 
subroutine gdncvarattrnext (var, name, vend)
 

Detailed Description

Attribute enumeration for netCDF variables.

Author
GFD Dennou Club

Definition in file gdncvarattr.f90.

Function/Subroutine Documentation

◆ gdncvarattrnext()

subroutine gdncvarattrnext ( type(gd_nc_variable), intent(in)  var,
character(len = *), intent(out)  name,
logical, intent(out), optional  vend 
)

Get next attribute name in enumeration

Returns the next attribute name. Variable attributes are returned first, then global attributes (prefixed with '+').

Parameters
[in]varVariable handle
[out]nameAttribute name (empty string when done)
[out]vendTrue when all attributes enumerated (optional)

Definition at line 77 of file gdncvarattr.f90.

80 use netcdf, only: nf90_noerr, nf90_max_name, nf90_inq_attname, nf90_global
81 use dc_url, only: gt_plus
82 implicit none
83 type(GD_NC_VARIABLE), intent(in):: var
84 character(len = *), intent(out):: name
85 type(GD_NC_VARIABLE_ENTRY):: ent
86 logical, intent(out), optional:: vend
87 character(len = NF90_MAX_NAME):: attrname
88 integer:: stat
89 integer:: new_attrid
90
91 stat = vtable_lookup(var, ent)
92 if (stat /= nf90_noerr) goto 999
93
94 new_attrid = ent%attrid
95 ! 最初は変数属性の検索
96 if (ent%attrid >= 0) then
97 new_attrid = ent%attrid + 1
98 stat = nf90_inq_attname(ent%fileid, ent%varid, new_attrid, attrname)
99 if (stat == nf90_noerr) then
100 name = attrname
101 stat = vtable_set_attrid(var, new_attrid)
102 vend = .false.
103 return
104 end if
105 new_attrid = -1
106 endif
107
108 ! 次は大域属性の検索
109 stat = nf90_inq_attname(ent%fileid, nf90_global, -new_attrid, attrname)
110 if (stat == nf90_noerr) then
111 new_attrid = new_attrid - 1
112 name = gt_plus // attrname
113 stat = vtable_set_attrid(var, new_attrid)
114 vend = .false.
115 return
116 endif
117
118999 continue
119 ! ここでは attrid の再設定はしない。次呼んでもエラーになるのが適当。
120 vend = .true.
121 name = ""
122 return
Variable URL string parser.
Definition dc_url.f90:61
character, parameter, public gt_plus
Definition dc_url.f90:109
integer function, public vtable_set_attrid(var, attrid)
integer function, public vtable_lookup(var, entry)

References dc_url::gt_plus, gtdata_netcdf_internal::vtable_lookup(), and gtdata_netcdf_internal::vtable_set_attrid().

Here is the call graph for this function:

◆ gdncvarattrrewind()

subroutine gdncvarattrrewind ( type(gd_nc_variable), intent(in)  var)

Reset attribute iterator to beginning

Parameters
[in]varVariable handle

Definition at line 43 of file gdncvarattr.f90.

46 use dc_trace, only: dbgmessage
47 implicit none
48 type(GD_NC_VARIABLE), intent(in):: var
49 integer:: stat
50 character(len = *), parameter:: subname = 'GDNcVarAttrRewind'
51
52 stat = vtable_set_attrid(var, 0)
53 call dbgmessage("%c %d", c1=subname, i=(/stat/))
Debug tracing module.
Definition dc_trace.f90:150
subroutine, public dbgmessage(fmt, i, r, d, l, n, c1, c2, c3, ca)
Definition dc_trace.f90:680

References dc_trace::dbgmessage(), and gtdata_netcdf_internal::vtable_set_attrid().

Here is the call graph for this function: