Creates a dimension variable at the specified URL. The dimension length is specified by length. The returned var contains the variable ID and other information.
Setting overwrite to .true. enables overwrite mode (default: no overwrite). If err is provided, errors return .false. instead of terminating.
61 use netcdf, only: nf90_noerr, nf90_float, nf90_int, nf90_double, nf90_char, &
62 & nf90_def_var, nf90_def_dim
65 implicit none
66 type(GD_NC_VARIABLE), intent(out):: var
67 character(len = *), intent(in):: url
68 character(len = *), intent(in):: xtype
69 integer, intent(in):: length
70 logical, intent(in), optional:: overwrite
71 logical, intent(out), optional:: err
72 type(GD_NC_VARIABLE_SEARCH):: ent
73 character(len = string):: filename, varname, cause_c
74 integer:: stat
75 integer:: nc_xtype
76 character(len = *), parameter:: subname = "GDNcVarCreateD"
77continue
78 call beginsub(subname,
'url=<%c>, xtype=<%c>, length=<%d>', &
79 & c1=trim(url), c2=trim(xtype), i=(/length/))
80 cause_c = trim(url)
81
82
83 call urlsplit(url, file=filename, var=varname)
84 call gdncfileopen(ent%fileid, filename, stat=stat, writable=.true., &
85 & overwrite=overwrite)
86 if (stat /= nf90_noerr) goto 999
88 if (stat /= nf90_noerr) goto 999
89
90
91 nc_xtype = nf90_float
92 if (
strieq(xtype,
"double"))
then
93 nc_xtype = nf90_double
94 else if (
strieq(xtype,
"DOUBLEPRECISION"))
then
95 nc_xtype = nf90_double
96 end if
97 if (
strieq(xtype,
"int"))
then
98 nc_xtype = nf90_int
99 else if (
strieq(xtype,
"INTEGER"))
then
100 nc_xtype = nf90_int
101 end if
102 if (
strieq(xtype,
"char"))
then
103 nc_xtype = nf90_char
104 else if (
strieq(xtype,
"CHARACTER"))
then
105 nc_xtype = nf90_char
106 end if
107
108
109 stat = nf90_def_dim(ent%fileid, trim(varname), len=length, dimid=ent%dimid)
110 if (stat /= nf90_noerr) goto 999
111 stat = nf90_def_var(ent%fileid, trim(varname), &
112 & xtype=nc_xtype, dimids=(/ent%dimid/), varid=ent%varid)
113 if (stat /= nf90_noerr) goto 999
114
116 if (stat /= nf90_noerr) goto 999
117
118999 continue
119 call storeerror(stat, subname, err, cause_c=cause_c)
121 call endsub(subname,
'stat=%d', i=(/stat/))
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Handling character types.
subroutine, public dbgmessage(fmt, i, r, d, l, n, c1, c2, c3, ca)
subroutine, public beginsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca, version)
subroutine, public endsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca)
Provides kind type parameter values.
integer, parameter, public string
Character length for string
Variable URL string parser.
integer function, public vtable_add(var, entry)