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

netCDF 変数に文字属性を設定 More...

Go to the source code of this file.

Functions/Subroutines

subroutine gdncvarputattrchar (var, name, val, xtype, err)

Detailed Description

netCDF 変数に文字属性を設定

Author
Eizi TOYODA, Yasuhiro MORIKAWA

これらのサブルーチン、関数は gtdata_netcdf_generic から gtdata_netcdf_generic#Put_Attr として提供されます。

Definition in file gdncvarputattrchar.f90.

Function/Subroutine Documentation

◆ gdncvarputattrchar()

subroutine gdncvarputattrchar ( type(gd_nc_variable), intent(in) var,
character(len = *), intent(in) name,
character(len = *), intent(in) val,
character(len = *), intent(in), optional xtype,
logical, intent(out), optional err )

文字属性値を設定

変数に文字属性を設定します。xtype が指定された場合、 値はその数値型に変換されてから格納されます。 name が '+' で始まる場合、グローバル属性として扱われます。 空の value は属性を削除します。

Parameters
[in]var変数ハンドル
[in]name属性名
[in]val設定する文字値
[in]xtype変換先の型 (省略可能)
[out]errエラーフラグ (省略可能)

Definition at line 48 of file gdncvarputattrchar.f90.

52 use netcdf, only: &
53 & nf90_global, &
54 & nf90_noerr, &
55 & nf90_put_att, &
56 & nf90_del_att
57 use dc_url, only: gt_plus
58 use dc_error
59 use dc_string, only: get_array
61 implicit none
62 type(GD_NC_VARIABLE), intent(in):: var
63 character(len = *), intent(in):: name
64 character(len = *), intent(in):: val
65 character(len = *), intent(in), optional:: xtype
66 logical, intent(out), optional:: err
67 integer, pointer:: ip(:)
68 real, pointer:: rp(:)
69 double precision, pointer:: dp(:)
70 integer:: stat
71 type(GD_NC_VARIABLE_ENTRY):: ent
72continue
73 stat = vtable_lookup(var, ent)
74 if (stat /= nf90_noerr) goto 999
75 if (len(val) == 0) then
76 if (name(1:1) == gt_plus) then
77 stat = nf90_del_att(ent%fileid, nf90_global, name = name(2:))
78 else
79 stat = nf90_del_att(ent%fileid, ent%varid, name = name)
80 endif
81 goto 999
82 endif
83 if ( present(xtype) ) then
84 select case(xtype)
85 case("INTEGER", "integer", "int")
86 goto 200
87 case("REAL", "real", "float")
88 goto 300
89 case("DOUBLEPRECISION", "DOUBLE", "double")
90 goto 400
91 end select
92 end if
93
94 stat = gdncfiledefinemode( ent % fileid )
95 if (stat /= nf90_noerr) goto 999
96 if (name(1:1) == gt_plus) then
97 stat = nf90_put_att(ent%fileid, nf90_global, name(2:), trim(val) )
98 else
99 stat = nf90_put_att(ent%fileid, ent%varid, name, trim(val) )
100 endif
101
102999 continue
103 call storeerror(stat, 'GDNcVarPutAttrChar', err, cause_c=name)
104 return
105
106200 continue
107 call get_array(ip, val)
108 if (associated(ip)) then
109 call put_attr(var, name, ip, err)
110 deallocate(ip)
111 endif
112 return
113
114300 continue
115 call get_array(rp, val)
116 if (associated(rp)) then
117 call put_attr(var, name, rp, err)
118 deallocate(rp)
119 endif
120 return
121
122400 continue
123 call get_array(dp, val)
124 if (associated(dp)) then
125 call put_attr(var, name, dp, err)
126 deallocate(dp)
127 endif
128 return
エラー処理用モジュール
Definition dc_error.f90:454
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition dc_error.f90:891
文字型変数の操作
Definition dc_string.f90:83
変数 URL の文字列解析
Definition dc_url.f90:61
character, parameter, public gt_plus
Definition dc_url.f90:109
integer function, public vtable_lookup(var, entry)

References dc_url::gt_plus, dc_error::storeerror(), and gtdata_netcdf_internal::vtable_lookup().

Here is the call graph for this function: