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
f83dbd41
Commit
f83dbd41
authored
Jul 25, 2006
by
Uwe Schulzweida
Browse files
support of 1 to 32 bit GRIB data
parent
44091c76
Changes
13
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
f83dbd41
2006-08-
??
Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
2006-08-
01
Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* using GRIB library version 1.0.1
* add DATATYPE PACK1 to PACK32
* change DATATYPE from byte to bit
* split GRIB level type 105 with env var SPLIT_LTYPE_105
* file.c: remove declaration of getpagesize (report: Mark Hadfield)
* tableWrite: bug fix for undefined strings
...
...
doc/tex/variable.tex
View file @
f83dbd41
...
...
@@ -12,17 +12,17 @@ one of the following time types must be specified:
\end{minipage}
\vspace*
{
3mm
}
The default data type is
2 byte
for GRIB and
4 byte
for all other
The default data type is
16 bit
for GRIB and
32 bit
for all other
file format types. To change the data type use one of the following
predefined constants:
\vspace*
{
3mm
}
\hspace*
{
8mm
}
\begin{minipage}
{
15cm
}
\begin{deflist}
{{
\large\tt
DATATYPE
\_
PACK1
\ \
}}
\item
[{\large\tt DATATYPE\_PACK
1
}]
1
packed b
yte
(only for GRIB)
\item
[{\large\tt DATATYPE\_PACK
2
}]
2
packed b
yte
(only for GRIB)
\item
[{\large\tt DATATYPE\_PACK
3
}]
3
packed b
yte
(only for GRIB)
\item
[{\large\tt DATATYPE\_REAL
4
}]
4 byte
floating point
\item
[{\large\tt DATATYPE\_REAL
8
}]
8 byte
floating point
\item
[{\large\tt DATATYPE\_PACK
8
}]
8
packed b
it
(only for GRIB)
\item
[{\large\tt DATATYPE\_PACK
16
}]
16
packed b
it
(only for GRIB)
\item
[{\large\tt DATATYPE\_PACK
24
}]
24
packed b
it
(only for GRIB)
\item
[{\large\tt DATATYPE\_REAL
32
}]
32 bit
floating point
\item
[{\large\tt DATATYPE\_REAL
64
}]
64 bit
floating point
\end{deflist}
\end{minipage}
prog/cdi.c
View file @
f83dbd41
...
...
@@ -311,14 +311,14 @@ static void printShortinfo(int streamID, int vlistID, int vardis)
prec
=
vlistInqVarDatatype
(
vlistID
,
varID
);
if
(
prec
==
DATATYPE_PACK
)
strcpy
(
pstr
,
"P0"
);
else
if
(
prec
==
DATATYPE_PACK
1
)
strcpy
(
pstr
,
"P1"
);
else
if
(
prec
==
DATATYPE_PACK
2
)
strcpy
(
pstr
,
"P2"
);
else
if
(
prec
==
DATATYPE_PACK
3
)
strcpy
(
pstr
,
"P3"
);
else
if
(
prec
==
DATATYPE_
REAL4
)
strcpy
(
pstr
,
"R4"
);
else
if
(
prec
==
DATATYPE_
REAL8
)
strcpy
(
pstr
,
"R8"
);
else
if
(
prec
==
DATATYPE_INT
1
)
strcpy
(
pstr
,
"I1"
);
else
if
(
prec
==
DATATYPE_INT
2
)
strcpy
(
pstr
,
"I2"
);
else
if
(
prec
==
DATATYPE_INT
4
)
strcpy
(
pstr
,
"I4"
);
else
if
(
prec
==
DATATYPE_PACK
8
)
strcpy
(
pstr
,
"P1"
);
else
if
(
prec
==
DATATYPE_PACK
16
)
strcpy
(
pstr
,
"P2"
);
else
if
(
prec
==
DATATYPE_PACK
24
)
strcpy
(
pstr
,
"P3"
);
else
if
(
prec
==
DATATYPE_
FLT32
)
strcpy
(
pstr
,
"R4"
);
else
if
(
prec
==
DATATYPE_
FLT64
)
strcpy
(
pstr
,
"R8"
);
else
if
(
prec
==
DATATYPE_INT
8
)
strcpy
(
pstr
,
"I1"
);
else
if
(
prec
==
DATATYPE_INT
16
)
strcpy
(
pstr
,
"I2"
);
else
if
(
prec
==
DATATYPE_INT
32
)
strcpy
(
pstr
,
"I4"
);
else
strcpy
(
pstr
,
"-1"
);
fprintf
(
stdout
,
" %-3s"
,
pstr
);
...
...
@@ -597,11 +597,11 @@ static void setDefaultDataType(char *datatypestr)
datatype
=
atoi
(
datatypestr
);
datatypestr
++
;
if
(
datatype
==
1
)
DefaultDataType
=
DATATYPE_PACK
1
;
else
if
(
datatype
==
2
)
DefaultDataType
=
DATATYPE_PACK
2
;
else
if
(
datatype
==
3
)
DefaultDataType
=
DATATYPE_PACK
3
;
else
if
(
datatype
==
4
)
DefaultDataType
=
DATATYPE_
REAL4
;
else
if
(
datatype
==
8
)
DefaultDataType
=
DATATYPE_
REAL8
;
if
(
datatype
==
1
)
DefaultDataType
=
DATATYPE_PACK
8
;
else
if
(
datatype
==
2
)
DefaultDataType
=
DATATYPE_PACK
16
;
else
if
(
datatype
==
3
)
DefaultDataType
=
DATATYPE_PACK
24
;
else
if
(
datatype
==
4
)
DefaultDataType
=
DATATYPE_
FLT32
;
else
if
(
datatype
==
8
)
DefaultDataType
=
DATATYPE_
FLT64
;
else
{
fprintf
(
stderr
,
"Unsupported datatype %d!
\n
"
,
datatype
);
...
...
src/cdi.h
View file @
f83dbd41
...
...
@@ -37,11 +37,40 @@ extern "C" {
#define DATATYPE_PACK1 1
#define DATATYPE_PACK2 2
#define DATATYPE_PACK3 3
#define DATATYPE_REAL4 4
#define DATATYPE_REAL8 5
#define DATATYPE_INT1 6
#define DATATYPE_INT2 7
#define DATATYPE_INT4 8
#define DATATYPE_PACK4 4
#define DATATYPE_PACK5 5
#define DATATYPE_PACK6 6
#define DATATYPE_PACK7 7
#define DATATYPE_PACK8 8
#define DATATYPE_PACK9 9
#define DATATYPE_PACK10 10
#define DATATYPE_PACK11 11
#define DATATYPE_PACK12 12
#define DATATYPE_PACK13 13
#define DATATYPE_PACK14 14
#define DATATYPE_PACK15 15
#define DATATYPE_PACK16 16
#define DATATYPE_PACK17 17
#define DATATYPE_PACK18 18
#define DATATYPE_PACK19 19
#define DATATYPE_PACK20 20
#define DATATYPE_PACK21 21
#define DATATYPE_PACK22 22
#define DATATYPE_PACK23 23
#define DATATYPE_PACK24 24
#define DATATYPE_PACK25 25
#define DATATYPE_PACK26 26
#define DATATYPE_PACK27 27
#define DATATYPE_PACK28 28
#define DATATYPE_PACK29 29
#define DATATYPE_PACK30 30
#define DATATYPE_PACK31 31
#define DATATYPE_PACK32 32
#define DATATYPE_FLT32 132
#define DATATYPE_FLT64 164
#define DATATYPE_INT8 208
#define DATATYPE_INT16 216
#define DATATYPE_INT32 232
/* GRID types */
...
...
src/griblib.c
View file @
f83dbd41
/* Generated automatically from m214003 on Tue Ju
n
2
0 08:25
:2
4
CEST 2006 */
/* Generated automatically from m214003 on Tue Ju
l
2
5 14:09
:2
6
CEST 2006 */
#if defined (HAVE_CONFIG_H)
# include "config.h"
...
...
@@ -47,11 +47,11 @@
#endif
#if defined (INT32)
# define GRIBPACK INT32
# define GRIBPACK
unsigned
INT32
# define PACK_GRIB packInt32
# define UNPACK_GRIB unpackInt32
#else
# define GRIBPACK INT64
# define GRIBPACK
unsigned
INT64
# define PACK_GRIB packInt64
# define UNPACK_GRIB unpackInt64
#endif
...
...
@@ -3055,13 +3055,13 @@ int encodeBDS(GRIBPACK *lGrib, int *gribLen, int decscale, int *isec2, int *isec
int
z
=
*
gribLen
;
int
i
,
jloop
;
int
blockLength
,
PackStart
,
Flag
;
int
binscale
=
0
,
pval
;
int
byte_per_
val
ue
;
int
binscale
=
0
;
unsigned
int
p
val
;
int
nbpv
;
/* ibits = BitsPerInt; */
double
max_nbpv_pow2
;
int
exponent
,
mantissa
;
int
fill_byte
s
=
0
;
int
unused_bit
s
=
0
;
double
fpval
;
double
factor
=
1
,
fmin
,
fmax
,
zref
;
double
range
,
rangec
;
...
...
@@ -3076,29 +3076,29 @@ int encodeBDS(GRIBPACK *lGrib, int *gribLen, int decscale, int *isec2, int *isec
Message
(
func
,
"complex packing of spectral data unsupported, using simple packing!"
);
}
byte_per_value
=
ISEC4_NumBits
>>
3
;
if
(
ISEC2_GridType
==
GTYPE_SPECTRAL
)
{
*
datstart
=
15
;
*
datstart
=
15
;
PackStart
=
1
;
Flag
=
128
;
blockLength
=
11
+
4
+
byte_per_value
*
(
datasize
-
1
);
blockLength
=
11
+
4
+
(
ISEC4_NumBits
*
(
datasize
-
1
)
+
7
)
/
8
;
}
else
{
*
datstart
=
11
;
*
datstart
=
11
;
PackStart
=
0
;
Flag
=
0
;
blockLength
=
11
+
byte_per_value
*
datasize
;
blockLength
=
11
+
(
ISEC4_NumBits
*
datasize
+
7
)
/
8
;
}
if
(
(
blockLength
%
2
)
==
1
)
{
fill_bytes
=
1
;
Flag
+=
(
fill_bytes
*
8
);
blockLength
++
;
}
if
(
(
blockLength
%
2
)
==
1
)
blockLength
++
;
if
(
ISEC2_GridType
==
GTYPE_SPECTRAL
)
unused_bits
=
blockLength
*
8
-
15
*
8
-
ISEC4_NumBits
*
(
datasize
-
1
);
else
unused_bits
=
blockLength
*
8
-
11
*
8
-
ISEC4_NumBits
*
(
datasize
);
Flag
+=
unused_bits
;
if
(
decscale
)
{
...
...
@@ -3209,7 +3209,7 @@ int encodeBDS(GRIBPACK *lGrib, int *gribLen, int decscale, int *isec2, int *isec
if
(
PackStart
)
Put1Real
(
data
[
0
]);
*
datsize
=
(
datasize
-
PackStart
)
*
byte_per_value
;
*
datsize
=
(
(
datasize
-
PackStart
)
*
ISEC4_NumBits
+
7
)
/
8
;
if
(
ISEC4_NumBits
==
8
)
{
...
...
@@ -3220,12 +3220,12 @@ int encodeBDS(GRIBPACK *lGrib, int *gribLen, int decscale, int *isec2, int *isec
#elif defined (__uxp__)
#pragma loop novrec
#endif
for
(
i
=
PackStart
;
i
<
datasize
;
i
++
)
for
(
i
=
PackStart
;
i
<
datasize
;
i
++
)
{
fpval
=
((
data
[
i
]
-
zref
)
*
factor
+
0
.
5
);
if
(
fpval
>
max_nbpv_pow2
)
fpval
=
max_nbpv_pow2
;
if
(
fpval
<
0
)
fpval
=
0
;
pval
=
(
int
)
fpval
;
pval
=
(
unsigned
int
)
fpval
;
lGrib
[
z
]
=
pval
;
z
++
;
}
...
...
@@ -3239,12 +3239,12 @@ int encodeBDS(GRIBPACK *lGrib, int *gribLen, int decscale, int *isec2, int *isec
#elif defined (__uxp__)
#pragma loop novrec
#endif
for
(
i
=
PackStart
;
i
<
datasize
;
i
++
)
for
(
i
=
PackStart
;
i
<
datasize
;
i
++
)
{
fpval
=
((
data
[
i
]
-
zref
)
*
factor
+
0
.
5
);
if
(
fpval
>
max_nbpv_pow2
)
fpval
=
max_nbpv_pow2
;
if
(
fpval
<
0
)
fpval
=
0
;
pval
=
(
int
)
fpval
;
pval
=
(
unsigned
int
)
fpval
;
lGrib
[
z
]
=
pval
>>
8
;
lGrib
[
z
+
1
]
=
pval
;
z
+=
2
;
...
...
@@ -3259,24 +3259,89 @@ int encodeBDS(GRIBPACK *lGrib, int *gribLen, int decscale, int *isec2, int *isec
#elif defined (__uxp__)
#pragma loop novrec
#endif
for
(
i
=
PackStart
;
i
<
datasize
;
i
++
)
for
(
i
=
PackStart
;
i
<
datasize
;
i
++
)
{
fpval
=
((
data
[
i
]
-
zref
)
*
factor
+
0
.
5
);
if
(
fpval
>
max_nbpv_pow2
)
fpval
=
max_nbpv_pow2
;
if
(
fpval
<
0
)
fpval
=
0
;
pval
=
(
int
)
fpval
;
pval
=
(
unsigned
int
)
fpval
;
lGrib
[
z
]
=
pval
>>
16
;
lGrib
[
z
+
1
]
=
pval
>>
8
;
lGrib
[
z
+
2
]
=
pval
;
z
+=
3
;
}
}
else
if
(
ISEC4_NumBits
==
32
)
{
#if defined (CRAY)
#pragma _CRI ivdep
#elif defined (SX)
#pragma vdir nodep
#elif defined (__uxp__)
#pragma loop novrec
#endif
for
(
i
=
PackStart
;
i
<
datasize
;
i
++
)
{
fpval
=
((
data
[
i
]
-
zref
)
*
factor
+
0
.
5
);
if
(
fpval
>
max_nbpv_pow2
)
fpval
=
max_nbpv_pow2
;
if
(
fpval
<
0
)
fpval
=
0
;
pval
=
(
unsigned
int
)
fpval
;
lGrib
[
z
]
=
pval
>>
24
;
lGrib
[
z
+
1
]
=
pval
>>
16
;
lGrib
[
z
+
2
]
=
pval
>>
8
;
lGrib
[
z
+
3
]
=
pval
;
z
+=
4
;
}
}
else
if
(
ISEC4_NumBits
>
0
&&
ISEC4_NumBits
<=
32
)
{
int
cbits
,
jbits
;
unsigned
int
c
;
static
unsigned
int
mask
[]
=
{
0
,
1
,
3
,
7
,
15
,
31
,
63
,
127
,
255
};
/* code from gribw routine flist2bitstream */
cbits
=
8
;
c
=
0
;
for
(
i
=
PackStart
;
i
<
datasize
;
i
++
)
{
/* note float -> unsigned int .. truncate */
fpval
=
((
data
[
i
]
-
zref
)
*
factor
+
0
.
5
);
if
(
fpval
>
max_nbpv_pow2
)
fpval
=
max_nbpv_pow2
;
if
(
fpval
<
0
)
fpval
=
0
;
pval
=
(
unsigned
int
)
fpval
;
jbits
=
ISEC4_NumBits
;
while
(
cbits
<=
jbits
)
{
if
(
cbits
==
8
)
{
jbits
-=
8
;
lGrib
[
z
++
]
=
(
pval
>>
jbits
)
&
255
;
}
else
{
jbits
-=
cbits
;
lGrib
[
z
++
]
=
(
c
<<
cbits
)
+
((
pval
>>
jbits
)
&
mask
[
cbits
]);
cbits
=
8
;
c
=
0
;
}
}
/* now jbits < cbits */
if
(
jbits
)
{
c
=
(
c
<<
jbits
)
+
(
pval
&
mask
[
jbits
]);
cbits
-=
jbits
;
}
}
if
(
cbits
!=
8
)
lGrib
[
z
++
]
=
c
<<
cbits
;
}
else
{
Error
(
func
,
"Unimplemented packing factor %d"
,
ISEC4_NumBits
);
}
if
(
fill_bytes
)
if
(
unused_bits
>=
8
)
Put1Byte
(
0
);
/* Fillbyte */
*
gribLen
=
z
;
...
...
@@ -4249,6 +4314,7 @@ static int decodeBDS(int decscale, unsigned char *bds, int *isec2, int *isec4, d
int
tbits
=
0
;
int
n_bits
=
ISEC4_NumBits
;
int
t_bits
=
0
;
jmask
=
(
1
<<
n_bits
)
-
1
;
/* code from wgrib routine BDS_unpack */
for
(
i
=
0
;
i
<
jlend
;
i
++
)
...
...
@@ -7877,7 +7943,7 @@ int gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
return
(
gribLen
);
}
static
const
char
grb_libvers
[]
=
"1.0.
0
"
" of ""Ju
n
2
0
2006"" ""
08:25
:2
4
"
;
static
const
char
grb_libvers
[]
=
"1.0.
1
"
" of ""Ju
l
2
5
2006"" ""
14:09
:2
6
"
;
...
...
src/stream_cdf.c
View file @
f83dbd41
...
...
@@ -277,11 +277,11 @@ int cdfInqDatatype(int xtype)
{
int
datatype
;
if
(
xtype
==
NC_BYTE
)
datatype
=
DATATYPE_INT
1
;
else
if
(
xtype
==
NC_SHORT
)
datatype
=
DATATYPE_INT
2
;
else
if
(
xtype
==
NC_INT
)
datatype
=
DATATYPE_INT
4
;
else
if
(
xtype
==
NC_FLOAT
)
datatype
=
DATATYPE_
REAL4
;
else
datatype
=
DATATYPE_
REAL8
;
if
(
xtype
==
NC_BYTE
)
datatype
=
DATATYPE_INT
8
;
else
if
(
xtype
==
NC_SHORT
)
datatype
=
DATATYPE_INT
16
;
else
if
(
xtype
==
NC_INT
)
datatype
=
DATATYPE_INT
32
;
else
if
(
xtype
==
NC_FLOAT
)
datatype
=
DATATYPE_
FLT32
;
else
datatype
=
DATATYPE_
FLT64
;
return
(
datatype
);
}
...
...
@@ -292,10 +292,10 @@ int cdfDefDatatype(int datatype)
{
int
xtype
;
if
(
datatype
==
DATATYPE_INT
1
)
xtype
=
NC_BYTE
;
else
if
(
datatype
==
DATATYPE_INT
2
)
xtype
=
NC_SHORT
;
else
if
(
datatype
==
DATATYPE_INT
4
)
xtype
=
NC_INT
;
else
if
(
datatype
==
DATATYPE_
REAL8
)
xtype
=
NC_DOUBLE
;
if
(
datatype
==
DATATYPE_INT
8
)
xtype
=
NC_BYTE
;
else
if
(
datatype
==
DATATYPE_INT
16
)
xtype
=
NC_SHORT
;
else
if
(
datatype
==
DATATYPE_INT
32
)
xtype
=
NC_INT
;
else
if
(
datatype
==
DATATYPE_
FLT64
)
xtype
=
NC_DOUBLE
;
else
xtype
=
NC_FLOAT
;
return
(
xtype
);
...
...
@@ -805,7 +805,7 @@ void cdfDefTrajLon(int streamID, int gridID)
int
vlistID
;
int
xtype
=
NC_DOUBLE
;
if
(
gridInqPrec
(
gridID
)
==
DATATYPE_
REAL4
)
xtype
=
NC_FLOAT
;
if
(
gridInqPrec
(
gridID
)
==
DATATYPE_
FLT32
)
xtype
=
NC_FLOAT
;
vlistID
=
streamInqVlist
(
streamID
);
fileID
=
streamInqFileID
(
streamID
);
...
...
@@ -862,7 +862,7 @@ void cdfDefTrajLat(int streamID, int gridID)
int
vlistID
;
int
xtype
=
NC_DOUBLE
;
if
(
gridInqPrec
(
gridID
)
==
DATATYPE_
REAL4
)
xtype
=
NC_FLOAT
;
if
(
gridInqPrec
(
gridID
)
==
DATATYPE_
FLT32
)
xtype
=
NC_FLOAT
;
vlistID
=
streamInqVlist
(
streamID
);
fileID
=
streamInqFileID
(
streamID
);
...
...
@@ -924,7 +924,7 @@ void cdfDefXaxis(int streamID, int gridID)
int
vlistID
;
int
xtype
=
NC_DOUBLE
;
if
(
gridInqPrec
(
gridID
)
==
DATATYPE_
REAL4
)
xtype
=
NC_FLOAT
;
if
(
gridInqPrec
(
gridID
)
==
DATATYPE_
FLT32
)
xtype
=
NC_FLOAT
;
vlistID
=
streamInqVlist
(
streamID
);
fileID
=
streamInqFileID
(
streamID
);
...
...
@@ -1040,7 +1040,7 @@ void cdfDefYaxis(int streamID, int gridID)
int
vlistID
;
int
xtype
=
NC_DOUBLE
;
if
(
gridInqPrec
(
gridID
)
==
DATATYPE_
REAL4
)
xtype
=
NC_FLOAT
;
if
(
gridInqPrec
(
gridID
)
==
DATATYPE_
FLT32
)
xtype
=
NC_FLOAT
;
vlistID
=
streamInqVlist
(
streamID
);
fileID
=
streamInqFileID
(
streamID
);
...
...
@@ -1163,7 +1163,7 @@ void cdfDefLonLat2D(int streamID, int gridID)
int
vlistID
;
int
xtype
=
NC_DOUBLE
;
if
(
gridInqPrec
(
gridID
)
==
DATATYPE_
REAL4
)
xtype
=
NC_FLOAT
;
if
(
gridInqPrec
(
gridID
)
==
DATATYPE_
FLT32
)
xtype
=
NC_FLOAT
;
vlistID
=
streamInqVlist
(
streamID
);
fileID
=
streamInqFileID
(
streamID
);
...
...
@@ -1475,7 +1475,7 @@ void cdfDefCell(int streamID, int gridID)
int
vlistID
;
int
xtype
=
NC_DOUBLE
;
if
(
gridInqPrec
(
gridID
)
==
DATATYPE_
REAL4
)
xtype
=
NC_FLOAT
;
if
(
gridInqPrec
(
gridID
)
==
DATATYPE_
FLT32
)
xtype
=
NC_FLOAT
;
vlistID
=
streamInqVlist
(
streamID
);
fileID
=
streamInqFileID
(
streamID
);
...
...
@@ -1745,7 +1745,7 @@ void cdfDefZaxis(int streamID, int zaxisID)
int
zaxisindex
;
int
xtype
=
NC_DOUBLE
;
if
(
zaxisInqPrec
(
zaxisID
)
==
DATATYPE_
REAL4
)
xtype
=
NC_FLOAT
;
if
(
zaxisInqPrec
(
zaxisID
)
==
DATATYPE_
FLT32
)
xtype
=
NC_FLOAT
;
vlistID
=
streamInqVlist
(
streamID
);
fileID
=
streamInqFileID
(
streamID
);
...
...
@@ -2381,7 +2381,7 @@ void cdfWriteVarDP(int streamID, int varID, double *data, int nmiss)
if
(
nmiss
>
0
)
cdfDefMissval
(
streamID
,
varID
,
dtype
);
/* if ( dtype == DATATYPE_INT
1
|| dtype == DATATYPE_INT
2
|| dtype == DATATYPE_INT
4
) */
/* if ( dtype == DATATYPE_INT
8
|| dtype == DATATYPE_INT
16
|| dtype == DATATYPE_INT
32
) */
{
int
laddoffset
,
lscalefactor
;
double
addoffset
,
scalefactor
;
...
...
@@ -2694,7 +2694,7 @@ int cdfWriteVarSliceDP(int streamID, int varID, int levelID, double *data, int n
if
(
nmiss
>
0
)
cdfDefMissval
(
streamID
,
varID
,
dtype
);
/* if ( dtype == DATATYPE_INT
1
|| dtype == DATATYPE_INT
2
|| dtype == DATATYPE_INT
4
) */
/* if ( dtype == DATATYPE_INT
8
|| dtype == DATATYPE_INT
16
|| dtype == DATATYPE_INT
32
) */
{
int
laddoffset
,
lscalefactor
;
double
addoffset
,
scalefactor
;
...
...
@@ -3972,7 +3972,7 @@ int cdfInqContents(int streamID)
memset
(
&
grid
,
0
,
sizeof
(
GRID
));
grid
.
prec
=
DATATYPE_
REAL8
;
grid
.
prec
=
DATATYPE_
FLT64
;
grid
.
trunc
=
ncvars
[
ncvarid
].
truncation
;
if
(
ncvars
[
ncvarid
].
gridtype
==
GRID_TRAJECTORY
)
...
...
@@ -3997,7 +3997,7 @@ int cdfInqContents(int streamID)
size
=
xsize
;
}
if
(
ncvars
[
xvarid
].
xtype
==
NC_FLOAT
)
grid
.
prec
=
DATATYPE_
REAL4
;
if
(
ncvars
[
xvarid
].
xtype
==
NC_FLOAT
)
grid
.
prec
=
DATATYPE_
FLT32
;
grid
.
xvals
=
(
double
*
)
malloc
(
size
*
sizeof
(
double
));
cdf_get_var_double
(
fileID
,
xvarid
,
grid
.
xvals
);
strcpy
(
grid
.
xname
,
ncvars
[
xvarid
].
name
);
...
...
@@ -4030,7 +4030,7 @@ int cdfInqContents(int streamID)
else
size
=
ysize
;
}
if
(
ncvars
[
yvarid
].
xtype
==
NC_FLOAT
)
grid
.
prec
=
DATATYPE_
REAL4
;
if
(
ncvars
[
yvarid
].
xtype
==
NC_FLOAT
)
grid
.
prec
=
DATATYPE_
FLT32
;
grid
.
yvals
=
(
double
*
)
malloc
(
size
*
sizeof
(
double
));
cdf_get_var_double
(
fileID
,
yvarid
,
grid
.
yvals
);
strcpy
(
grid
.
yname
,
ncvars
[
yvarid
].
name
);
...
...
@@ -4311,14 +4311,14 @@ int cdfInqContents(int streamID)
if
(
zaxisType
==
UNDEFID
)
zaxisType
=
ZAXIS_GENERIC
;
zprec
=
DATATYPE_
REAL8
;
zprec
=
DATATYPE_
FLT64
;
if
(
zvarid
!=
UNDEFID
)
{
pname
=
ncvars
[
zvarid
].
name
;
plongname
=
ncvars
[
zvarid
].
longname
;
punits
=
ncvars
[
zvarid
].
units
;
if
(
ncvars
[
zvarid
].
xtype
==
NC_FLOAT
)
zprec
=
DATATYPE_
REAL4
;
if
(
ncvars
[
zvarid
].
xtype
==
NC_FLOAT
)
zprec
=
DATATYPE_
FLT32
;
if
(
(
len
=
strlen
(
pname
))
>
2
)
if
(
pname
[
len
-
2
]
==
'_'
&&
isdigit
((
int
)
pname
[
len
-
1
])
)
pname
[
len
-
2
]
=
0
;
...
...
src/stream_ext.c
View file @
f83dbd41
...
...
@@ -30,8 +30,8 @@ int extInqDatatype(int prec)
{
int
datatype
;
if
(
prec
==
DOUBLE_PRECISION
)
datatype
=
DATATYPE_
REAL8
;
else
datatype
=
DATATYPE_
REAL4
;
if
(
prec
==
DOUBLE_PRECISION
)
datatype
=
DATATYPE_
FLT64
;
else
datatype
=
DATATYPE_
FLT32
;
return
(
datatype
);
}
...
...
@@ -41,10 +41,10 @@ int extDefDatatype(int datatype)
{
int
prec
;
if
(
datatype
!=
DATATYPE_
REAL4
&&
datatype
!=
DATATYPE_
REAL8
)
datatype
=
DATATYPE_
REAL4
;
if
(
datatype
!=
DATATYPE_
FLT32
&&
datatype
!=
DATATYPE_
FLT64
)
datatype
=
DATATYPE_
FLT32
;
if
(
datatype
==
DATATYPE_
REAL8
)
prec
=
DOUBLE_PRECISION
;
if
(
datatype
==
DATATYPE_
FLT64
)
prec
=
DOUBLE_PRECISION
;
else
prec
=
SINGLE_PRECISION
;
return
(
prec
);
...
...
src/stream_grb.c
View file @
f83dbd41
...
...
@@ -812,8 +812,8 @@ void grbAddRecord(int streamID, int code, int *isec1, int *isec2, double *fsec2,
lbounds
=
gribGetZaxisHasBounds
(
ISEC1_LevelType
);
if
(
prec
>
DATATYPE_PACK
3
)
prec
=
DATATYPE_PACK3
;
if
(
prec
<
DATATYPE_PACK
)
prec
=
DATATYPE_PACK
;
if
(
prec
>
3
2
)
prec
=
DATATYPE_PACK3
2
;
if
(
prec
<
0
)
prec
=
DATATYPE_PACK
;
varAddRecord
(
recID
,
code
,
gridID
,
leveltype
,
lbounds
,
level1
,
level2
,
prec
,
&
varID
,
&
levelID
,
numavg
,
ISEC1_CodeTable
);
...
...
@@ -932,21 +932,10 @@ void grbScanTimestep1(int streamID)
level2
=
ISEC1_Level2
;
if
(
ISEC1_LevelType
==
100
)
level1
*=
100
;
switch
(
ISEC4_NumBits
)
{
case
8
:
prec
=
DATATYPE_PACK1
;
break
;
case
16
:
prec
=
DATATYPE_PACK2
;
break
;
case
24
:
prec
=
DATATYPE_PACK3
;
break
;
default:
prec
=
DATATYPE_PACK
;
break
;
}
if
(
ISEC4_NumBits
>
0
&&
ISEC4_NumBits
<=
32
)
prec
=
ISEC4_NumBits
;
else
prec
=
DATATYPE_PACK
;
gribDateTime
(
isec1
,
&
vdate
,
&
vtime
);
...
...
@@ -1870,15 +1859,10 @@ void grbDefData(int datatype, int *isec4, int gridID)
if
(
datatype
!=
UNDEFID
)
{
if
(
datatype
!=
DATATYPE_PACK
&&
datatype
!=
DATATYPE_PACK1
&&
datatype
!=
DATATYPE_PACK2
&&
datatype
!=
DATATYPE_PACK3
)
{
if
(
datatype
==
DATATYPE_REAL8
)
datatype
=
DATATYPE_PACK3
;
else
datatype
=
DATATYPE_PACK2
;
}
datatype
*=
8
;
if
(
datatype
==
8
||
datatype
==
16
||
datatype
==
24
)
if
(
datatype
>
0
&&
datatype
<=
32
)
ISEC4_NumBits
=
datatype
;
else
if
(
datatype
==
DATATYPE_FLT64
)
ISEC4_NumBits
=
24
;
else
ISEC4_NumBits
=
16
;
}
...
...
src/stream_hdf.c
View file @
f83dbd41
...
...
@@ -257,11 +257,11 @@ int hdfInqDatatype(int xtype)
{
int
datatype
;
if
(
xtype
==
H5T_NATIVE_CHAR
)
datatype
=
DATATYPE_INT
1
;
else
if
(
xtype
==
H5T_NATIVE_SHORT
)
datatype
=
DATATYPE_INT
2
;
else
if
(
xtype
==
H5T_NATIVE_INT
)
datatype
=
DATATYPE_INT
4
;
else
if
(
xtype
==
H5T_NATIVE_FLOAT
)
datatype
=
DATATYPE_
REAL4
;
else
datatype
=
DATATYPE_
REAL8
;
if
(
xtype
==
H5T_NATIVE_CHAR
)
datatype
=
DATATYPE_INT
8
;
else
if
(
xtype
==
H5T_NATIVE_SHORT
)
datatype
=
DATATYPE_INT
16
;
else
if
(
xtype
==
H5T_NATIVE_INT
)
datatype
=
DATATYPE_INT
32
;
else
if
(
xtype
==
H5T_NATIVE_FLOAT
)
datatype
=
DATATYPE_
FLT32
;
else
datatype
=
DATATYPE_
FLT64
;
return
(
datatype
);
}
...
...
@@ -273,10 +273,10 @@ int hdfDefDatatype(int datatype)
{
int
xtype
;
if
(
datatype
==
DATATYPE_INT
1
)
xtype
=
H5T_NATIVE_CHAR
;
else
if
(
datatype
==
DATATYPE_INT
2
)
xtype
=
H5T_NATIVE_SHORT
;
else
if
(
datatype
==
DATATYPE_INT
4
)
xtype
=
H5T_NATIVE_INT
;
else
if
(
datatype
==
DATATYPE_
REAL8
)
xtype
=
H5T_NATIVE_DOUBLE
;
if
(
datatype
==
DATATYPE_INT
8
)
xtype
=
H5T_NATIVE_CHAR
;
else
if
(
datatype
==
DATATYPE_INT
16
)
xtype
=
H5T_NATIVE_SHORT
;
else
if
(
datatype
==
DATATYPE_INT
32
)
xtype
=
H5T_NATIVE_INT
;
else
if
(
datatype
==
DATATYPE_
FLT64
)
xtype
=
H5T_NATIVE_DOUBLE
;
else
xtype
=
H5T_NATIVE_FLOAT
;
return
(
xtype
);
...
...
@@ -432,7 +432,7 @@ void hdfDefMissval(int streamID, int varID, int dtype)
missval
=
vlistInqVarMissval
(
vlistID
,
varID
);
if
(
streams
[
streamID
].
ncmode
==
2
)
hdf_redef
(
fileID
);
if
(
dtype
==
DATATYPE_
REAL8
)
if
(
dtype
==
DATATYPE_
FLT64
)