gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
gdncvarputattrchar.f90
Go to the documentation of this file.
1
21
48subroutine gdncvarputattrchar(var, name, val, xtype, err)
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
129end subroutine gdncvarputattrchar
subroutine gdncvarputattrchar(var, name, val, xtype, err)
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)