gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
gdncattrinquire.f90
Go to the documentation of this file.
1! -*- mode: f90; coding: utf-8 -*-
2!> @file gdncattrinquire.f90
3!>
4!> @author GFD Dennou Club
5!> @copyright Copyright (C) GFD Dennou Club, 2000-2026. All rights reserved. <br/>
6!> License is BSD-2-Clause. See [COPYRIGHT](@ref COPYRIGHT) in detail
7!>
8!> @en
9!> @brief Inquire attribute information
10!> @enden
11!>
12!> @ja
13!> @brief 属性情報の問い合わせ
14!> @endja
15!>
16
17!>
18!> @en
19!> @brief Get attribute type information
20!>
21!> Returns the type name of the specified attribute.
22!> @enden
23!>
24!> @ja
25!> @brief 属性の型情報を取得
26!>
27!> 指定された属性の型名を返します。
28!> @endja
29!>
30!> @param[in] var @en Variable handle @enden @ja 変数ハンドル @endja
31!> @param[in] attrname @en Attribute name @enden @ja 属性名 @endja
32!> @param[out] xtype @en Type name (optional) @enden @ja 型名 (省略可能) @endja
33!>
34subroutine gdncattrinquire(var, attrname, xtype)
38 use netcdf, only: nf90_max_name, nf90_noerr, nf90_inquire_attribute
39 implicit none
40 type(gd_nc_variable), intent(in):: var
41 character(len=*), intent(in):: attrname
42 character(len=*), intent(out), optional:: xtype
43 type(gd_nc_variable_entry):: ent
44 integer:: varid, i_xtype, stat
45 character(len=NF90_MAX_NAME):: anam
46 stat = vtable_lookup(var, ent)
47 if (stat /= nf90_noerr) return
48 if (present(xtype)) then
49 call inquireplus(var, attrname, varid, anam)
50 stat = nf90_inquire_attribute(ent%fileid, varid, anam, xtype=i_xtype)
51 if (stat /= nf90_noerr) i_xtype = 0
52 call gdncxtypename(i_xtype, xtype)
53 endif
54end subroutine
55
56!>
57!> @en
58!> @brief Get actual varid and attribute name for netCDF access
59!>
60!> Determines the actual varid and attribute name to use for netCDF access:
61!> - If attrname starts with '+': Force global attribute
62!> - If attrname starts with '-': Search variable attribute, then global
63!> @enden
64!>
65!> @ja
66!> @brief netCDF アクセス用の実際の varid と属性名を取得
67!>
68!> netCDF アクセスに使う実際の varid と属性名を決定します:
69!> - attrname の先頭が '+': グローバル属性を強制指示
70!> - attrname の先頭が '-': 変数属性、グローバル属性の順で検索
71!> @endja
72!>
73!> @param[in] var @en Variable handle @enden @ja 変数ハンドル @endja
74!> @param[in] attrname @en Attribute name (may have prefix) @enden @ja 属性名 (接頭辞を含む場合あり) @endja
75!> @param[out] varid @en netCDF variable ID @enden @ja netCDF 変数 ID @endja
76!> @param[out] nf_attrname @en netCDF attribute name @enden @ja netCDF 属性名 @endja
77!>
78subroutine gdncattrinquireplus(var, attrname, varid, nf_attrname)
81 use dc_url, only: gt_plus
82 use netcdf, only: nf90_global, nf90_noerr, nf90_inquire_attribute
83 type(gd_nc_variable), intent(in):: var
84 character(len=*), intent(in):: attrname
85 integer, intent(out):: varid
86 type(gd_nc_variable_entry):: ent
87 character(len=*), intent(out):: nf_attrname
88 integer:: stat, n
89 stat = vtable_lookup(var, ent)
90 if (stat /= nf90_noerr) return
91 if (attrname(1:1) == gt_plus) then
92 varid = nf90_global
93 nf_attrname = attrname(2: )
94 else if (attrname(1:1) == '-') then
95 varid = ent%varid
96 nf_attrname = attrname(2: )
97 stat = nf90_inquire_attribute(ent%fileid, varid, nf_attrname, len = n)
98 if (stat == nf90_noerr) return
99 varid = nf90_global
100 else
101 varid = ent%varid
102 nf_attrname = attrname
103 endif
104end subroutine gdncattrinquireplus
subroutine gdncattrinquire(var, attrname, xtype)
subroutine gdncattrinquireplus(var, attrname, varid, nf_attrname)
Variable URL string parser.
Definition dc_url.f90:61
character, parameter, public gt_plus
Definition dc_url.f90:109
integer function, public vtable_lookup(var, entry)