gdncvarputattrchar.f90 File Reference

Go to the source code of this file.

Functions/Subroutines

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

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 
)

Definition at line 14 of file gdncvarputattrchar.f90.

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

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
37 continue
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 
67 999 continue
68  call storeerror(stat, 'GDNcVarPutAttrChar', err, cause_c=name)
69  return
70 
71 200 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 
79 300 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 
87 400 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
integer function, public vtable_lookup(var, entry)
integer function gdncfiledefinemode(fileid)
character, parameter, public gt_plus
Definition: dc_url.f90:92
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition: dc_error.f90:830
文字型変数の操作.
Definition: dc_string.f90:24
Here is the call graph for this function: