Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
libcdi
Commits
26ad266b
Commit
26ad266b
authored
Apr 17, 2017
by
Uwe Schulzweida
Browse files
Check attribute datatype.
parent
668dd3fe
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/stream_cdf_i.c
View file @
26ad266b
...
...
@@ -1146,6 +1146,7 @@ void cdf_scan_var_attr(int nvars, ncvar_t *ncvars, ncdim_t *ncdims, int timedimi
size_t
attstringsize
=
sizeof
(
attstring
);
bool
isText
=
xtypeIsText
(
atttype
);
bool
isNumber
=
xtypeIsFloat
(
atttype
)
||
xtypeIsInt
(
atttype
);
if
(
isText
)
{
cdfGetAttText
(
ncid
,
ncvarid
,
attname
,
sizeof
(
attstring
),
attstring
);
...
...
@@ -1176,12 +1177,13 @@ void cdf_scan_var_attr(int nvars, ncvar_t *ncvars, ncdim_t *ncdims, int timedimi
ncvars
[
ncvarid
].
param
=
cdiEncodeParam
(
pnum
,
pcat
,
pdis
);
cdf_set_var
(
ncvars
,
ncvarid
,
TRUE
);
}
else
if
(
!
is
Text
&&
strcmp
(
attname
,
"code"
)
==
0
)
else
if
(
is
Number
&&
strcmp
(
attname
,
"code"
)
==
0
)
{
cdfGetAttInt
(
ncid
,
ncvarid
,
attname
,
1
,
&
ncvars
[
ncvarid
].
code
);
printf
(
"code %d
\n
"
,
ncvars
[
ncvarid
].
code
);
cdf_set_var
(
ncvars
,
ncvarid
,
TRUE
);
}
else
if
(
!
is
Text
&&
strcmp
(
attname
,
"table"
)
==
0
)
else
if
(
is
Number
&&
strcmp
(
attname
,
"table"
)
==
0
)
{
int
tablenum
;
cdfGetAttInt
(
ncid
,
ncvarid
,
attname
,
1
,
&
tablenum
);
...
...
@@ -1211,19 +1213,19 @@ void cdf_scan_var_attr(int nvars, ncvar_t *ncvars, ncdim_t *ncdims, int timedimi
set_zaxistype
(
attstring
,
&
ncvars
[
ncvarid
].
zaxistype
);
cdf_set_var
(
ncvars
,
ncvarid
,
TRUE
);
}
else
if
(
!
is
Text
&&
strcmp
(
attname
,
"trunc_count"
)
==
0
)
else
if
(
is
Number
&&
strcmp
(
attname
,
"trunc_count"
)
==
0
)
{
cdfGetAttInt
(
ncid
,
ncvarid
,
attname
,
1
,
&
ncvars
[
ncvarid
].
truncation
);
}
else
if
(
!
is
Text
&&
strcmp
(
attname
,
"truncation"
)
==
0
)
else
if
(
is
Number
&&
strcmp
(
attname
,
"truncation"
)
==
0
)
{
cdfGetAttInt
(
ncid
,
ncvarid
,
attname
,
1
,
&
ncvars
[
ncvarid
].
truncation
);
}
else
if
(
!
is
Text
&&
strcmp
(
attname
,
"number_of_grid_in_reference"
)
==
0
)
else
if
(
is
Number
&&
strcmp
(
attname
,
"number_of_grid_in_reference"
)
==
0
)
{
cdfGetAttInt
(
ncid
,
ncvarid
,
attname
,
1
,
&
ncvars
[
ncvarid
].
position
);
}
else
if
(
!
is
Text
&&
strcmp
(
attname
,
"add_offset"
)
==
0
)
else
if
(
is
Number
&&
strcmp
(
attname
,
"add_offset"
)
==
0
)
{
cdfGetAttDouble
(
ncid
,
ncvarid
,
attname
,
1
,
&
ncvars
[
ncvarid
].
addoffset
);
/*
...
...
@@ -1233,7 +1235,7 @@ void cdf_scan_var_attr(int nvars, ncvar_t *ncvars, ncdim_t *ncdims, int timedimi
*/
/* (also used for lon/lat) cdf_set_var(ncvars, ncvarid, TRUE); */
}
else
if
(
!
is
Text
&&
strcmp
(
attname
,
"scale_factor"
)
==
0
)
else
if
(
is
Number
&&
strcmp
(
attname
,
"scale_factor"
)
==
0
)
{
cdfGetAttDouble
(
ncid
,
ncvarid
,
attname
,
1
,
&
ncvars
[
ncvarid
].
scalefactor
);
/*
...
...
@@ -1407,19 +1409,19 @@ void cdf_scan_var_attr(int nvars, ncvar_t *ncvars, ncdim_t *ncdims, int timedimi
ncdims
[
ncvars
[
ncvarid
].
dimids
[
0
]].
dimtype
=
Z_AXIS
;
}
}
else
if
(
!
is
Text
&&
strcmp
(
attname
,
"_FillValue"
)
==
0
)
else
if
(
is
Number
&&
strcmp
(
attname
,
"_FillValue"
)
==
0
)
{
cdfGetAttDouble
(
ncid
,
ncvarid
,
attname
,
1
,
&
ncvars
[
ncvarid
].
fillval
);
ncvars
[
ncvarid
].
deffillval
=
true
;
/* cdf_set_var(ncvars, ncvarid, TRUE); */
}
else
if
(
!
is
Text
&&
strcmp
(
attname
,
"missing_value"
)
==
0
)
else
if
(
is
Number
&&
strcmp
(
attname
,
"missing_value"
)
==
0
)
{
cdfGetAttDouble
(
ncid
,
ncvarid
,
attname
,
1
,
&
ncvars
[
ncvarid
].
missval
);
ncvars
[
ncvarid
].
defmissval
=
true
;
/* cdf_set_var(ncvars, ncvarid, TRUE); */
}
else
if
(
strcmp
(
attname
,
"valid_range"
)
==
0
&&
attlen
==
2
)
else
if
(
isNumber
&&
strcmp
(
attname
,
"valid_range"
)
==
0
&&
attlen
==
2
)
{
if
(
ncvars
[
ncvarid
].
lvalidrange
==
false
)
{
...
...
@@ -1439,7 +1441,7 @@ void cdf_scan_var_attr(int nvars, ncvar_t *ncvars, ncdim_t *ncdims, int timedimi
}
}
}
else
if
(
strcmp
(
attname
,
"valid_min"
)
==
0
&&
attlen
==
1
)
else
if
(
isNumber
&&
strcmp
(
attname
,
"valid_min"
)
==
0
&&
attlen
==
1
)
{
if
(
ncvars
[
ncvarid
].
lvalidrange
==
false
)
{
...
...
@@ -1456,7 +1458,7 @@ void cdf_scan_var_attr(int nvars, ncvar_t *ncvars, ncdim_t *ncdims, int timedimi
}
}
}
else
if
(
strcmp
(
attname
,
"valid_max"
)
==
0
&&
attlen
==
1
)
else
if
(
isNumber
&&
strcmp
(
attname
,
"valid_max"
)
==
0
&&
attlen
==
1
)
{
if
(
ncvars
[
ncvarid
].
lvalidrange
==
false
)
{
...
...
@@ -1520,9 +1522,10 @@ void cdf_scan_var_attr(int nvars, ncvar_t *ncvars, ncdim_t *ncdims, int timedimi
cdf_scan_attr_axis
(
ncvars
,
ncdims
,
ncvarid
,
attstring
,
attlen
,
nvdims
,
dimidsp
,
name
);
}
}
else
if
(
(
strcmp
(
attname
,
"realization"
)
==
0
)
||
(
strcmp
(
attname
,
"ensemble_members"
)
==
0
)
||
(
strcmp
(
attname
,
"forecast_init_type"
)
==
0
)
)
else
if
(
isNumber
&&
(
strcmp
(
attname
,
"realization"
)
==
0
||
strcmp
(
attname
,
"ensemble_members"
)
==
0
||
strcmp
(
attname
,
"forecast_init_type"
)
==
0
)
)
{
int
temp
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment