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
aeb17b06
Commit
aeb17b06
authored
Jun 17, 2016
by
Uwe Schulzweida
Browse files
netCDF4: added support for attribute type NC_USHORT and NC_UINT.
parent
1be5179c
Changes
3
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
aeb17b06
2016-06-?? Uwe Schulzweida
2016-06-17 Uwe Schulzweida
* netCDF4: added support for attribute type NC_USHORT and NC_UINT
2016-06-10 Uwe Schulzweida
* Version 1.7.2 released
...
...
src/cdf_write.c
View file @
aeb17b06
...
...
@@ -190,13 +190,20 @@ void cdfDefineAttributes(int vlistID, int varID, int fileID, int ncvarID)
len
=
(
size_t
)
attlen
;
cdf_put_att_text
(
fileID
,
ncvarID
,
attname
,
len
,
atttxt
);
}
else
if
(
atttype
==
DATATYPE_INT16
||
atttype
==
DATATYPE_INT32
)
else
if
(
atttype
==
DATATYPE_INT16
||
atttype
==
DATATYPE_INT32
||
atttype
==
DATATYPE_UINT16
||
atttype
==
DATATYPE_UINT32
)
{
size_t
attSize
=
(
size_t
)
attlen
*
sizeof
(
int
);
int
*
attint
=
(
int
*
)
resizeBuf
(
&
attBuf
,
&
attBufSize
,
attSize
);
vlistInqAttInt
(
vlistID
,
varID
,
attname
,
attlen
,
&
attint
[
0
]);
len
=
(
size_t
)
attlen
;
cdf_put_att_int
(
fileID
,
ncvarID
,
attname
,
atttype
==
DATATYPE_INT16
?
NC_SHORT
:
NC_INT
,
len
,
attint
);
nc_type
xtype
=
(
atttype
==
DATATYPE_INT16
)
?
NC_SHORT
:
#if defined (HAVE_NETCDF4)
(
atttype
==
DATATYPE_UINT16
)
?
NC_USHORT
:
(
atttype
==
DATATYPE_UINT32
)
?
NC_UINT
:
#endif
NC_INT
;
cdf_put_att_int
(
fileID
,
ncvarID
,
attname
,
xtype
,
len
,
attint
);
}
else
if
(
atttype
==
DATATYPE_FLT32
||
atttype
==
DATATYPE_FLT64
)
{
...
...
src/stream_cdf.c
View file @
aeb17b06
...
...
@@ -5997,38 +5997,41 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID,
if
(
ncvars
[
ncvarid
].
natts
)
{
int
attnum
;
int
iatt
;
nc_type
attrtype
;
size_t
attlen
;
char
attname
[
CDI_MAX_NAME
];
const
int
attstringlen
=
8192
;
char
attstring
[
8192
];
int
nvatts
=
ncvars
[
ncvarid
].
natts
;
for
(
iatt
=
0
;
iatt
<
nvatts
;
iatt
++
)
for
(
int
iatt
=
0
;
iatt
<
nvatts
;
++
iatt
)
{
attnum
=
ncvars
[
ncvarid
].
atts
[
iatt
];
int
attnum
=
ncvars
[
ncvarid
].
atts
[
iatt
];
cdf_inq_attname
(
ncid
,
ncvarid
,
attnum
,
attname
);
cdf_inq_attlen
(
ncid
,
ncvarid
,
attname
,
&
attlen
);
cdf_inq_atttype
(
ncid
,
ncvarid
,
attname
,
&
attrtype
);
if
(
attrtype
==
NC_SHORT
||
attrtype
==
NC_INT
)
if
(
attrtype
==
NC_SHORT
||
attrtype
==
NC_INT
#if defined (HAVE_NETCDF4)
||
attrtype
==
NC_USHORT
||
attrtype
==
NC_UINT
#endif
)
{
int
attint
[
attlen
];
cdfGetAttInt
(
ncid
,
ncvarid
,
attname
,
(
int
)
attlen
,
attint
);
if
(
attrtype
==
NC_SHORT
)
vlistDefAttInt
(
vlistID
,
varID
,
attname
,
DATATYPE_INT16
,
(
int
)
attlen
,
attint
);
else
vlistDefAttInt
(
vlistID
,
varID
,
attname
,
DATATYPE_INT32
,
(
int
)
attlen
,
attint
);
int
datatype
=
(
attrtype
==
NC_SHORT
)
?
DATATYPE_INT16
:
#if defined (HAVE_NETCDF4)
(
attrtype
==
NC_USHORT
)
?
DATATYPE_UINT16
:
(
attrtype
==
NC_UINT
)
?
DATATYPE_UINT32
:
#endif
DATATYPE_INT32
;
vlistDefAttInt
(
vlistID
,
varID
,
attname
,
datatype
,
(
int
)
attlen
,
attint
);
}
else
if
(
attrtype
==
NC_FLOAT
||
attrtype
==
NC_DOUBLE
)
{
double
attflt
[
attlen
];
cdfGetAttDouble
(
ncid
,
ncvarid
,
attname
,
(
int
)
attlen
,
attflt
);
if
(
attrtype
==
NC_FLOAT
)
vlistDefAttFlt
(
vlistID
,
varID
,
attname
,
DATATYPE_FLT32
,
(
int
)
attlen
,
attflt
);
else
vlistDefAttFlt
(
vlistID
,
varID
,
attname
,
DATATYPE_FLT64
,
(
int
)
attlen
,
attflt
);
int
datatype
=
(
attrtype
==
NC_FLOAT
)
?
DATATYPE_FLT32
:
DATATYPE_FLT64
;
vlistDefAttFlt
(
vlistID
,
varID
,
attname
,
datatype
,
(
int
)
attlen
,
attflt
);
}
else
if
(
xtypeIsText
(
attrtype
)
)
{
...
...
@@ -6225,20 +6228,16 @@ void scan_global_attributes(int fileID, int vlistID, stream_t *streamptr, int ng
{
int
attint
[
attlen
];
cdfGetAttInt
(
fileID
,
NC_GLOBAL
,
attname
,
(
int
)
attlen
,
attint
);
if
(
xtype
==
NC_SHORT
)
vlistDefAttInt
(
vlistID
,
CDI_GLOBAL
,
attname
,
DATATYPE_INT16
,
(
int
)
attlen
,
attint
);
else
vlistDefAttInt
(
vlistID
,
CDI_GLOBAL
,
attname
,
DATATYPE_INT32
,
(
int
)
attlen
,
attint
);
int
datatype
=
(
xtype
==
NC_SHORT
)
?
DATATYPE_INT16
:
DATATYPE_INT32
;
vlistDefAttInt
(
vlistID
,
CDI_GLOBAL
,
attname
,
datatype
,
(
int
)
attlen
,
attint
);
}
}
else
if
(
xtype
==
NC_FLOAT
||
xtype
==
NC_DOUBLE
)
{
double
attflt
[
attlen
];
cdfGetAttDouble
(
fileID
,
NC_GLOBAL
,
attname
,
(
int
)
attlen
,
attflt
);
if
(
xtype
==
NC_FLOAT
)
vlistDefAttFlt
(
vlistID
,
CDI_GLOBAL
,
attname
,
DATATYPE_FLT32
,
(
int
)
attlen
,
attflt
);
else
vlistDefAttFlt
(
vlistID
,
CDI_GLOBAL
,
attname
,
DATATYPE_FLT64
,
(
int
)
attlen
,
attflt
);
int
datatype
=
(
xtype
==
NC_FLOAT
)
?
DATATYPE_FLT32
:
DATATYPE_FLT64
;
vlistDefAttFlt
(
vlistID
,
CDI_GLOBAL
,
attname
,
datatype
,
(
int
)
attlen
,
attflt
);
}
}
}
...
...
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