Loading...
Searching...
No Matches
gdncvarputattrchar.f90
Go to the documentation of this file.
1!
2!= 属性の付加
3!
4! Authors:: Eizi TOYODA, Yasuhiro MORIKAWA
5! Version:: $Id: gdncvarputattrchar.f90,v 1.2 2009-05-25 09:51:59 morikawa Exp $
6! Tag Name:: $Name: $
7! Copyright:: Copyright (C) GFD Dennou Club, 2000-2007. All rights reserved.
8! License:: See COPYRIGHT[link:../../COPYRIGHT]
9!
10! 以下のサブルーチン、関数は gtdata_netcdf_generic から gtdata_netcdf_generic#Put_Attr
11! として提供されます。
12
13subroutine gdncvarputattrchar(var, name, val, xtype, err)
17 use netcdf, only: &
18 & nf90_global, &
19 & nf90_noerr, &
20 & nf90_put_att, &
21 & nf90_del_att
22 use dc_url, only: gt_plus
23 use dc_error
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
38 stat = vtable_lookup(var, ent)
39 if (stat /= nf90_noerr) goto 999
40 if (len(val) == 0) then
41 if (name(1:1) == gt_plus) 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
59 stat = gdncfiledefinemode( ent % fileid )
60 if (stat /= nf90_noerr) goto 999
61 if (name(1:1) == gt_plus) then
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
74 call put_attr(var, name, ip, err)
75 deallocate(ip)
76 endif
77 return
78
79300 continue
80 call get_array(rp, val)
81 if (associated(rp)) then
82 call put_attr(var, name, rp, err)
83 deallocate(rp)
84 endif
85 return
86
87400 continue
88 call get_array(dp, val)
89 if (associated(dp)) then
90 call put_attr(var, name, dp, err)
91 deallocate(dp)
92 endif
93 return
94end subroutine gdncvarputattrchar
subroutine gdncvarputattrchar(var, name, val, xtype, err)
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition dc_error.f90:830
character, parameter, public gt_plus
Definition dc_url.f90:92
integer function, public vtable_lookup(var, entry)