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

Put character attribute to netCDF variable. More...

Go to the source code of this file.

Functions/Subroutines

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

Detailed Description

Put character attribute to netCDF variable.

Author
Eizi TOYODA, Yasuhiro MORIKAWA

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 
)

Set character attribute value

Sets a character attribute on a variable. If xtype is specified, the value is converted to that numeric type before storage. If name starts with '+', it is treated as a global attribute. Empty value deletes the attribute.

Parameters
[in]varVariable handle
[in]nameAttribute name
[in]valCharacter value to set
[in]xtypeTarget type for conversion (optional)
[out]errError flag (optional)

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
Error handling module.
Definition dc_error.f90:454
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition dc_error.f90:891
Handling character types.
Definition dc_string.f90:83
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)

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

Here is the call graph for this function: