17 use netcdf, only: &
18 & nf90_global, &
19 & nf90_noerr, &
20 & nf90_put_att, &
21 & nf90_del_att
24 use dc_string, only: get_array
26 implicit none
27 type(GD_NC_VARIABLE), intent(in):: var
28 character(len = *), intent(in):: name
29 character(len = *), intent(in):: val
30 character(len = *), intent(in), optional:: xtype
31 logical, intent(out), optional:: err
32 integer, pointer:: ip(:)
33 real, pointer:: rp(:)
34 double precision, pointer:: dp(:)
35 integer:: stat
36 type(GD_NC_VARIABLE_ENTRY):: ent
37continue
39 if (stat /= nf90_noerr) goto 999
40 if (len(val) == 0) then
42 stat = nf90_del_att(ent%fileid, nf90_global, name = name(2:))
43 else
44 stat = nf90_del_att(ent%fileid, ent%varid, name = name)
45 endif
46 goto 999
47 endif
48 if ( present(xtype) ) then
49 select case(xtype)
50 case("INTEGER", "integer", "int")
51 goto 200
52 case("REAL", "real", "float")
53 goto 300
54 case("DOUBLEPRECISION", "DOUBLE", "double")
55 goto 400
56 end select
57 end if
58
60 if (stat /= nf90_noerr) goto 999
62 stat = nf90_put_att(ent%fileid, nf90_global, name(2:), trim(val) )
63 else
64 stat = nf90_put_att(ent%fileid, ent%varid, name, trim(val) )
65 endif
66
67999 continue
68 call storeerror(stat,
'GDNcVarPutAttrChar', err, cause_c=name)
69 return
70
71200 continue
72 call get_array(ip, val)
73 if (associated(ip)) then
75 deallocate(ip)
76 endif
77 return
78
79300 continue
80 call get_array(rp, val)
81 if (associated(rp)) then
83 deallocate(rp)
84 endif
85 return
86
87400 continue
88 call get_array(dp, val)
89 if (associated(dp)) then
91 deallocate(dp)
92 endif
93 return
subroutine, public storeerror(number, where, err, cause_c, cause_i)
character, parameter, public gt_plus
integer function, public vtable_lookup(var, entry)