gtool5 Fortran 90/95 ライブラリ 1.0.0-rc5
English
Loading...
Searching...
No Matches
gdncvarattr.f90 File Reference

netCDF 変数の属性列挙 More...

Go to the source code of this file.

Functions/Subroutines

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

Detailed Description

netCDF 変数の属性列挙

Author
GFD Dennou Club

変数のすべての属性を列挙するには:

  1. attr_rewind(var) を呼び出してイテレータをリセット
  2. ループ内で attr_next(var, name, [end]) を呼び出す
  3. name が各属性名を返す; 終了時は空文字列
  4. オプションで end が真になることでも終了を判定可能

グローバル属性は名前の先頭に '+' が付加されて現れます。

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 )

列挙の次の属性名を取得

次の属性名を返します。変数属性が先に返され、 その後グローバル属性 ('+' 接頭辞付き) が返されます。

Parameters
[in]var変数ハンドル
[out]name属性名 (終了時は空文字列)
[out]vend全属性列挙完了時に真 (省略可能)

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
変数 URL の文字列解析
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)

属性イテレータを先頭にリセット

Parameters
[in]var変数ハンドル

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/))
デバッグ時の追跡用モジュール
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: