Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
libcdi
Commits
5db17b1f
Commit
5db17b1f
authored
Sep 28, 2009
by
Uwe Schulzweida
Browse files
more grib_api stuff
parent
edf44616
Changes
9
Show whitespace changes
Inline
Side-by-side
ChangeLog
View file @
5db17b1f
...
...
@@ -8,7 +8,9 @@
* cdfDefLonLat2D: added attributes for Panoply
* added support for netCDF timeseries without grid
* added support for netCDF timeseries with only one grid axis
* gribDefLevel: bug fix for pressure level units millibar
* julday_add_seconds: bug fix for adjusting negative seconds
* stream_cdf:cdfReadVarSliceDP: bug fix for swapxy
* Version 1.4.0 released
2009-06-15 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
...
...
src/stream_cdf.c
View file @
5db17b1f
...
...
@@ -3086,7 +3086,7 @@ int cdfReadVarSliceDP(int streamID, int varID, int levelID, double *data, int *n
int
xid
=
UNDEFID
,
yid
=
UNDEFID
,
zid
=
UNDEFID
;
int
ncvarid
;
int
tsID
;
int
gridsize
;
int
gridsize
,
xsize
,
ysize
;
size_t
size
;
size_t
start
[
4
];
size_t
count
[
4
];
...
...
@@ -3096,7 +3096,7 @@ int cdfReadVarSliceDP(int streamID, int varID, int levelID, double *data, int *n
int
gridindex
;
int
zaxisindex
;
int
vlistID
;
int
i
;
int
i
,
j
;
int
ndimsp
;
int
dimids
[
9
];
int
swapyz
=
FALSE
;
...
...
@@ -3126,6 +3126,8 @@ int cdfReadVarSliceDP(int streamID, int varID, int levelID, double *data, int *n
timeID
=
vlistInqVarTime
(
vlistID
,
varID
);
gridsize
=
gridInqSize
(
gridID
);
xsize
=
gridInqXsize
(
gridID
);
ysize
=
gridInqYsize
(
gridID
);
streamptr
->
numvals
+=
gridsize
;
...
...
@@ -3268,10 +3270,22 @@ int cdfReadVarSliceDP(int streamID, int varID, int levelID, double *data, int *n
cdf_get_vara_double
(
fileID
,
ncvarid
,
start
,
count
,
data
);
if
(
swapxy
)
{
double
*
tdata
;
tdata
=
(
double
*
)
malloc
(
gridsize
*
sizeof
(
double
));
memcpy
(
tdata
,
data
,
gridsize
*
sizeof
(
double
));
for
(
j
=
0
;
j
<
ysize
;
++
j
)
for
(
i
=
0
;
i
<
xsize
;
++
i
)
data
[
j
*
xsize
+
i
]
=
tdata
[
i
*
ysize
+
j
];
free
(
tdata
);
}
*
nmiss
=
0
;
if
(
vlistInqVarMissvalUsed
(
vlistID
,
varID
)
==
TRUE
)
{
missval
=
vlistInqVarMissval
(
vlistID
,
varID
);
// printf("XXX %31.0f %31.0f %31.0f %31.0f\n", missval, (float)data[0]);
for
(
i
=
0
;
i
<
gridsize
;
i
++
)
if
(
DBL_IS_EQUAL
(
data
[
i
],
missval
)
)
*
nmiss
+=
1
;
}
...
...
@@ -3495,7 +3509,7 @@ void cdfCreateRecords(int streamID, int tsID)
static
char
func
[]
=
"cdfCreateRecords"
;
int
varID
,
levelID
,
recID
,
vrecID
,
zaxisID
;
int
nvars
,
nlev
,
nrecs
,
nvrecs
;
RECORD
*
records
=
NULL
;
record_t
*
records
=
NULL
;
int
*
recIDs
=
NULL
;
int
vlistID
;
stream_t
*
streamptr
;
...
...
@@ -3515,7 +3529,7 @@ void cdfCreateRecords(int streamID, int tsID)
streamptr
->
nrecs
+=
nrecs
;
if
(
nrecs
>
0
)
records
=
(
RECORD
*
)
malloc
(
nrecs
*
sizeof
(
RECORD
));
if
(
nrecs
>
0
)
records
=
(
record_t
*
)
malloc
(
nrecs
*
sizeof
(
record_t
));
streamptr
->
tsteps
[
tsID
].
records
=
records
;
streamptr
->
tsteps
[
tsID
].
nrecs
=
nrecs
;
streamptr
->
tsteps
[
tsID
].
nallrecs
=
nrecs
;
...
...
@@ -3559,7 +3573,7 @@ void cdfCreateRecords(int streamID, int tsID)
streamptr
->
nrecs
+=
nvrecs
;
records
=
(
RECORD
*
)
malloc
(
nrecs
*
sizeof
(
RECORD
));
records
=
(
record_t
*
)
malloc
(
nrecs
*
sizeof
(
record_t
));
streamptr
->
tsteps
[
tsID
].
records
=
records
;
streamptr
->
tsteps
[
tsID
].
nrecs
=
nvrecs
;
streamptr
->
tsteps
[
tsID
].
nallrecs
=
nrecs
;
...
...
@@ -3568,7 +3582,7 @@ void cdfCreateRecords(int streamID, int tsID)
memcpy
(
streamptr
->
tsteps
[
tsID
].
records
,
streamptr
->
tsteps
[
0
].
records
,
nrecs
*
sizeof
(
RECORD
));
nrecs
*
sizeof
(
record_t
));
if
(
nvrecs
)
{
...
...
@@ -3594,7 +3608,7 @@ void cdfCreateRecords(int streamID, int tsID)
streamptr
->
nrecs
+=
nvrecs
;
records
=
(
RECORD
*
)
malloc
(
nrecs
*
sizeof
(
RECORD
));
records
=
(
record_t
*
)
malloc
(
nrecs
*
sizeof
(
record_t
));
streamptr
->
tsteps
[
tsID
].
records
=
records
;
streamptr
->
tsteps
[
tsID
].
nrecs
=
nvrecs
;
streamptr
->
tsteps
[
tsID
].
nallrecs
=
nrecs
;
...
...
@@ -3603,7 +3617,7 @@ void cdfCreateRecords(int streamID, int tsID)
memcpy
(
streamptr
->
tsteps
[
tsID
].
records
,
streamptr
->
tsteps
[
0
].
records
,
nrecs
*
sizeof
(
RECORD
));
nrecs
*
sizeof
(
record_t
));
recIDs
=
(
int
*
)
malloc
(
nvrecs
*
sizeof
(
int
));
streamptr
->
tsteps
[
tsID
].
recIDs
=
recIDs
;
...
...
src/stream_cgribex.c
View file @
5db17b1f
...
...
@@ -275,7 +275,7 @@ int cgribexInqRecord(int streamID, int *varID, int *levelID)
case GRID_GAUSSIAN:
{
if ( ISEC4_NumValues != ISEC2_NumLon*ISEC2_NumLat )
Error(func, "
wrong datasize! isec4len = %d isec2len = %d
",
Error(func, "
numberOfPoints (%d) and gridSize (%d) differ!
",
ISEC4_NumValues, ISEC2_NumLon*ISEC2_NumLat);
break;
}
...
...
@@ -287,7 +287,7 @@ int cgribexInqRecord(int streamID, int *varID, int *levelID)
}
default:
{
Error(func, "%s grid unsupported", gridNamePtr(gridtype));
Error(func, "%s grid unsupported
!
", gridNamePtr(gridtype));
break;
}
}
...
...
@@ -320,7 +320,7 @@ void cgribexAddRecord(int streamID, int code, int *isec1, int *isec2, double *fs
int
level1
,
level2
;
int
numavg
;
int
lbounds
=
0
;
RECORD
*
record
;
record_t
*
record
;
grid_t
grid
;
int
vlistID
;
stream_t
*
streamptr
;
...
...
@@ -363,7 +363,7 @@ void cgribexAddRecord(int streamID, int code, int *isec1, int *isec2, double *fs
case
GRID_GAUSSIAN
:
{
if
(
ISEC4_NumValues
!=
ISEC2_NumLon
*
ISEC2_NumLat
)
Error
(
func
,
"
wrong datasize! isec4len = %d isec2len = %d
"
,
Error
(
func
,
"
numberOfPoints (%d) and gridSize (%d) differ!
"
,
ISEC4_NumValues
,
ISEC2_NumLon
*
ISEC2_NumLat
);
grid
.
size
=
ISEC4_NumValues
;
grid
.
xsize
=
ISEC2_NumLon
;
...
...
@@ -452,7 +452,7 @@ void cgribexAddRecord(int streamID, int code, int *isec1, int *isec2, double *fs
case
GRID_LCC
:
{
if
(
ISEC4_NumValues
!=
ISEC2_NumLon
*
ISEC2_NumLat
)
Error
(
func
,
"
wrong datasize! isec4len = %d isec2len = %d
"
,
Error
(
func
,
"
numberOfPoints (%d) and gridSize (%d) differ!
"
,
ISEC4_NumValues
,
ISEC2_NumLon
*
ISEC2_NumLat
);
grid
.
size
=
ISEC4_NumValues
;
...
...
@@ -498,7 +498,7 @@ void cgribexAddRecord(int streamID, int code, int *isec1, int *isec2, double *fs
}
default:
{
Error
(
func
,
"%s grid unsupported"
,
gridNamePtr
(
gridtype
));
Error
(
func
,
"%s grid unsupported
!
"
,
gridNamePtr
(
gridtype
));
break
;
}
}
...
...
@@ -845,7 +845,7 @@ void cgribexScanTimestep1(int streamID)
{
streamptr
->
tsteps
[
0
].
recordSize
=
nrecords
;
streamptr
->
tsteps
[
0
].
records
=
(
RECORD
*
)
realloc
(
streamptr
->
tsteps
[
0
].
records
,
nrecords
*
sizeof
(
RECORD
));
(
record_t
*
)
realloc
(
streamptr
->
tsteps
[
0
].
records
,
nrecords
*
sizeof
(
record_t
));
}
streamptr
->
tsteps
[
0
].
recIDs
=
(
int
*
)
malloc
(
nrecords
*
sizeof
(
int
));
...
...
@@ -1948,11 +1948,10 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev
level
=
zaxisInqLevel
(
zaxisID
,
levelID
);
if
(
level
<
0
)
Warning
(
func
,
"
p
ressure level of %f Pa is below
0.
"
,
level
);
Warning
(
func
,
"
P
ressure level of %f Pa is below
zero!
"
,
level
);
zaxisInqUnits
(
zaxisID
,
units
);
if
(
memcmp
(
units
,
"hPa"
,
3
)
==
0
||
memcmp
(
units
,
"mb"
,
2
)
==
0
)
level
=
level
*
100
;
if
(
memcmp
(
units
,
"Pa"
,
3
)
!=
0
)
level
*=
100
;
ilevel
=
(
int
)
level
;
if
(
level
<
32768
&&
(
level
<
100
||
modf
(
level
/
100
,
&
dum
)
>
0
)
)
...
...
src/stream_ext.c
View file @
5db17b1f
...
...
@@ -259,7 +259,7 @@ void extAddRecord(int streamID, int code, int level, int xysize,
int
levelID
=
0
;
int
tsID
,
recID
,
varID
;
int
datatype
;
RECORD
*
record
;
record_t
*
record
;
grid_t
grid
;
int
vlistID
;
stream_t
*
streamptr
;
...
...
@@ -313,7 +313,7 @@ void extCmpRecord(int streamID, int tsID, int recID, off_t position, int code,
static
char
func
[]
=
"extCmpRecord"
;
int
varID
=
0
;
int
levelID
=
0
;
RECORD
*
record
;
record_t
*
record
;
stream_t
*
streamptr
;
streamptr
=
stream_to_pointer
(
streamID
);
...
...
@@ -446,7 +446,7 @@ void extScanTimestep1(int streamID)
{
streamptr
->
tsteps
[
0
].
recordSize
=
nrecords
;
streamptr
->
tsteps
[
0
].
records
=
(
RECORD
*
)
realloc
(
streamptr
->
tsteps
[
0
].
records
,
nrecords
*
sizeof
(
RECORD
));
(
record_t
*
)
realloc
(
streamptr
->
tsteps
[
0
].
records
,
nrecords
*
sizeof
(
record_t
));
}
streamptr
->
tsteps
[
0
].
recIDs
=
(
int
*
)
malloc
(
nrecords
*
sizeof
(
int
));
...
...
src/stream_gribapi.c
View file @
5db17b1f
...
...
@@ -27,7 +27,7 @@ extern int cdiInventoryMode;
typedef
struct
{
int
code
;
int
table
;
int
discip
line
;
int
discip
;
int
level1
;
int
level2
;
int
ltype
;
...
...
@@ -61,11 +61,11 @@ int gribapiGetGridType(grib_handle *gh)
}
case
GRIBAPI_GTYPE_GAUSSIAN
:
{
/*
if ( ISEC2_Reduced )
long
lpar
;
GRIB_CHECK
(
grib_get_long
(
gh
,
"Ni"
,
&
lpar
),
0
);
if
(
lpar
<
0
)
gridtype
=
GRID_GAUSSIAN_REDUCED
;
else
*/
gridtype
=
GRID_GAUSSIAN
;
break
;
}
...
...
@@ -175,7 +175,7 @@ void gribapiAddRecord(int streamID, int code, grib_handle *gh,
int
level1
,
level2
;
int
numavg
;
int
lbounds
=
0
;
RECORD
*
record
;
record_t
*
record
;
grid_t
grid
;
int
vlistID
;
stream_t
*
streamptr
;
...
...
@@ -186,6 +186,7 @@ void gribapiAddRecord(int streamID, int code, grib_handle *gh,
int
status
;
long
numberOfPoints
;
size_t
datasize
;
int
discip
=
0
;
streamptr
=
stream_to_pointer
(
streamID
);
...
...
@@ -194,6 +195,9 @@ void gribapiAddRecord(int streamID, int code, grib_handle *gh,
recID
=
recordNewEntry
(
streamID
,
tsID
);
record
=
&
streamptr
->
tsteps
[
tsID
].
records
[
recID
];
GRIB_CHECK
(
grib_get_long
(
gh
,
"discipline"
,
&
lpar
),
0
);
discip
=
(
int
)
lpar
;
GRIB_CHECK
(
grib_get_long
(
gh
,
"parameterCategory"
,
&
lpar
),
0
);
table_num
=
(
int
)
lpar
;
...
...
@@ -226,6 +230,7 @@ void gribapiAddRecord(int streamID, int code, grib_handle *gh,
(
*
record
).
position
=
position
;
(
*
record
).
code
=
code
;
(
*
record
).
table
=
table_num
;
(
*
record
).
discip
=
discip
;
(
*
record
).
ilevel
=
level1
;
(
*
record
).
ilevel2
=
level2
;
(
*
record
).
ltype
=
leveltype
;
...
...
@@ -257,27 +262,34 @@ void gribapiAddRecord(int streamID, int code, grib_handle *gh,
nlat
=
lpar
;
if
(
numberOfPoints
!=
nlon
*
nlat
)
Error
(
func
,
"
wrong datasize! isec4len = %d isec2len = %d
"
,
Error
(
func
,
"
numberOfPoints (%d) and gridSize (%d) differ!
"
,
(
int
)
numberOfPoints
,
nlon
*
nlat
);
grid
.
size
=
numberOfPoints
;
grid
.
xsize
=
nlon
;
grid
.
ysize
=
nlat
;
grid
.
xinc
=
0
;
grid
.
yinc
=
0
;
grid
.
xdef
=
0
;
/* if ( ISEC2_FirstLon != 0 || ISEC2_LastLon != 0 ) */
GRIB_CHECK
(
grib_get_double
(
gh
,
"longitudeOfFirstGridPointInDegrees"
,
&
grid
.
xfirst
),
0
);
GRIB_CHECK
(
grib_get_double
(
gh
,
"longitudeOfLastGridPointInDegrees"
,
&
grid
.
xlast
),
0
);
GRIB_CHECK
(
grib_get_double
(
gh
,
"latitudeOfFirstGridPointInDegrees"
,
&
grid
.
yfirst
),
0
);
GRIB_CHECK
(
grib_get_double
(
gh
,
"latitudeOfLastGridPointInDegrees"
,
&
grid
.
ylast
),
0
);
GRIB_CHECK
(
grib_get_double
(
gh
,
"iDirectionIncrementInDegrees"
,
&
grid
.
xinc
),
0
);
if
(
gridtype
==
GRID_LONLAT
)
GRIB_CHECK
(
grib_get_double
(
gh
,
"jDirectionIncrementInDegrees"
,
&
grid
.
yinc
),
0
);
if
(
IS_NOT_EQUAL
(
grid
.
xfirst
,
0
)
||
IS_NOT_EQUAL
(
grid
.
xlast
,
0
)
)
{
if
(
grid
.
xsize
>
1
)
{
/*
if ( ISEC2_ResFlag && ISEC2_LonIncr > 0 )
grid.xinc = ISEC2_LonIncr
* 0.001
;
grid.xinc = ISEC2_LonIncr;
else
grid.xinc = (ISEC2_LastLon - ISEC2_FirstLon)
* 0.001
/ (grid.xsize - 1);
grid.xinc = (ISEC2_LastLon - ISEC2_FirstLon) / (grid.xsize - 1);
*/
/* correct xinc if necessary */
/*
if ( ISEC2_FirstLon == 0 && ISEC2_LastLon > 354
000
)
if ( ISEC2_FirstLon == 0 && ISEC2_LastLon > 354 )
{
double xinc = 360. / grid.xsize;
...
...
@@ -289,28 +301,20 @@ void gribapiAddRecord(int streamID, int code, grib_handle *gh,
}
*/
}
/*
grid.xfirst = ISEC2_FirstLon * 0.001;
grid.xlast = ISEC2_LastLon * 0.001;
*/
grid
.
xdef
=
2
;
}
grid
.
ydef
=
0
;
/*
if ( IS
EC2_FirstLat !=
0 || IS
EC2_LastLat !=
0
)
*/
if
(
IS
_NOT_EQUAL
(
grid
.
yfirst
,
0
)
||
IS
_NOT_EQUAL
(
grid
.
ylast
,
0
)
)
{
if
(
grid
.
ysize
>
1
)
{
/*
if ( ISEC2_ResFlag && ISEC2_LatIncr > 0 )
grid.yinc = ISEC2_LatIncr
* 0.001
;
grid.yinc = ISEC2_LatIncr;
else
grid.yinc = (ISEC2_LastLat - ISEC2_FirstLat)
* 0.001
/ (grid.ysize - 1);
grid.yinc = (ISEC2_LastLat - ISEC2_FirstLat) / (grid.ysize - 1);
*/
}
/*
grid.yfirst = ISEC2_FirstLat * 0.001;
grid.ylast = ISEC2_LastLat * 0.001;
*/
grid
.
ydef
=
2
;
}
break
;
...
...
@@ -354,7 +358,7 @@ void gribapiAddRecord(int streamID, int code, grib_handle *gh,
case GRID_LCC:
{
if ( ISEC4_NumValues != ISEC2_NumLon*ISEC2_NumLat )
Error(func, "
wrong datasize! isec4len = %d isec2len = %d
",
Error(func, "
numberOfPoints (%d) and gridSize (%d) differ!
",
ISEC4_NumValues, ISEC2_NumLon*ISEC2_NumLat);
grid.size = ISEC4_NumValues;
...
...
@@ -404,7 +408,7 @@ void gribapiAddRecord(int streamID, int code, grib_handle *gh,
*/
default:
{
Error
(
func
,
"%s grid unsupported"
,
gridNamePtr
(
gridtype
));
Error
(
func
,
"%s grid unsupported
!
"
,
gridNamePtr
(
gridtype
));
break
;
}
}
...
...
@@ -591,6 +595,7 @@ void gribapiScanTimestep1(int streamID)
stream_t
*
streamptr
;
grib_handle
*
gh
=
NULL
;
int
leveltype
;
int
discip
=
0
;
long
editionNumber
;
long
lpar
;
int
bitsPerValue
;
...
...
@@ -670,11 +675,14 @@ void gribapiScanTimestep1(int streamID)
else
{
GRIB_CHECK
(
grib_get_long
(
gh
,
"discipline"
,
&
lpar
),
0
);
discip
=
(
int
)
lpar
;
/*
if ( lpar != 255 && warn_lpar )
{
Warning
(
func
,
"GRIB2 discipline
%ld
unsupported!"
,
lpar
);
Warning(func, "GRIB2
key >
discipline
<
unsupported!", lpar);
warn_lpar = FALSE;
}
*/
GRIB_CHECK
(
grib_get_long
(
gh
,
"parameterCategory"
,
&
lpar
),
0
);
table_num
=
(
int
)
lpar
;
...
...
@@ -731,7 +739,7 @@ void gribapiScanTimestep1(int streamID)
datetime
.
time
=
vtime
;
compVar
.
code
=
rcode
;
compVar
.
table
=
table_num
;
compVar
.
discip
line
=
0
;
compVar
.
discip
=
discip
;
compVar
.
level1
=
level1
;
compVar
.
level2
=
level2
;
compVar
.
ltype
=
leveltype
;
...
...
@@ -740,7 +748,7 @@ void gribapiScanTimestep1(int streamID)
{
compVar0
.
code
=
streamptr
->
tsteps
[
0
].
records
[
recID
].
code
;
compVar0
.
table
=
streamptr
->
tsteps
[
0
].
records
[
recID
].
table
;
compVar0
.
discip
line
=
0
;
compVar0
.
discip
=
streamptr
->
tsteps
[
0
].
records
[
recID
].
discip
;
compVar0
.
level1
=
streamptr
->
tsteps
[
0
].
records
[
recID
].
ilevel
;
compVar0
.
level2
=
streamptr
->
tsteps
[
0
].
records
[
recID
].
ilevel2
;
compVar0
.
ltype
=
streamptr
->
tsteps
[
0
].
records
[
recID
].
ltype
;
...
...
@@ -822,7 +830,7 @@ void gribapiScanTimestep1(int streamID)
{
streamptr
->
tsteps
[
0
].
recordSize
=
nrecords
;
streamptr
->
tsteps
[
0
].
records
=
(
RECORD
*
)
realloc
(
streamptr
->
tsteps
[
0
].
records
,
nrecords
*
sizeof
(
RECORD
));
(
record_t
*
)
realloc
(
streamptr
->
tsteps
[
0
].
records
,
nrecords
*
sizeof
(
record_t
));
}
streamptr
->
tsteps
[
0
].
recIDs
=
(
int
*
)
malloc
(
nrecords
*
sizeof
(
int
));
...
...
@@ -887,6 +895,7 @@ int gribapiScanTimestep2(int streamID)
stream_t
*
streamptr
;
grib_handle
*
gh
=
NULL
;
int
leveltype
;
int
discip
=
0
;
long
editionNumber
;
long
lpar
;
double
dlevel
=
0
;
...
...
@@ -986,6 +995,9 @@ int gribapiScanTimestep2(int streamID)
}
else
{
GRIB_CHECK
(
grib_get_long
(
gh
,
"discipline"
,
&
lpar
),
0
);
discip
=
(
int
)
lpar
;
GRIB_CHECK
(
grib_get_long
(
gh
,
"parameterCategory"
,
&
lpar
),
0
);
table_num
=
(
int
)
lpar
;
...
...
@@ -1056,7 +1068,7 @@ int gribapiScanTimestep2(int streamID)
datetime
.
time
=
vtime
;
compVar
.
code
=
rcode
;
compVar
.
table
=
table_num
;
compVar
.
discip
line
=
0
;
compVar
.
discip
=
discip
;
compVar
.
level1
=
level1
;
compVar
.
level2
=
level2
;
compVar
.
ltype
=
leveltype
;
...
...
@@ -1064,7 +1076,7 @@ int gribapiScanTimestep2(int streamID)
{
compVar0
.
code
=
streamptr
->
tsteps
[
tsID
].
records
[
recID
].
code
;
compVar0
.
table
=
streamptr
->
tsteps
[
tsID
].
records
[
recID
].
table
;
compVar0
.
discip
line
=
0
;
compVar0
.
discip
=
streamptr
->
tsteps
[
tsID
].
records
[
recID
].
discip
;
compVar0
.
level1
=
streamptr
->
tsteps
[
tsID
].
records
[
recID
].
ilevel
;
compVar0
.
level2
=
streamptr
->
tsteps
[
tsID
].
records
[
recID
].
ilevel2
;
compVar0
.
ltype
=
streamptr
->
tsteps
[
tsID
].
records
[
recID
].
ltype
;
...
...
@@ -1113,7 +1125,7 @@ int gribapiScanTimestep2(int streamID)
compVar0
.
code
=
streamptr
->
tsteps
[
tsID
].
records
[
recID
].
code
;
compVar0
.
table
=
streamptr
->
tsteps
[
tsID
].
records
[
recID
].
table
;
compVar0
.
discip
line
=
0
;
compVar0
.
discip
=
streamptr
->
tsteps
[
tsID
].
records
[
recID
].
discip
;
compVar0
.
level1
=
streamptr
->
tsteps
[
tsID
].
records
[
recID
].
ilevel
;
compVar0
.
level2
=
streamptr
->
tsteps
[
tsID
].
records
[
recID
].
ilevel2
;
compVar0
.
ltype
=
streamptr
->
tsteps
[
tsID
].
records
[
recID
].
ltype
;
...
...
@@ -1205,6 +1217,7 @@ int gribapiScanTimestep(int streamID)
stream_t
*
streamptr
;
grib_handle
*
gh
=
NULL
;
int
leveltype
;
int
discip
=
0
;
long
editionNumber
;
long
lpar
;
double
dlevel
=
0
;
...
...
@@ -1306,6 +1319,9 @@ int gribapiScanTimestep(int streamID)
}
else
{
GRIB_CHECK
(
grib_get_long
(
gh
,
"discipline"
,
&
lpar
),
0
);
discip
=
(
int
)
lpar
;
GRIB_CHECK
(
grib_get_long
(
gh
,
"parameterCategory"
,
&
lpar
),
0
);
table_num
=
(
int
)
lpar
;
...
...
@@ -1379,7 +1395,7 @@ int gribapiScanTimestep(int streamID)
datetime
.
time
=
vtime
;
compVar
.
code
=
rcode
;
compVar
.
table
=
table_num
;
compVar
.
discip
line
=
0
;
compVar
.
discip
=
discip
;
compVar
.
level1
=
level1
;
compVar
.
level2
=
level2
;
compVar
.
ltype
=
leveltype
;
...
...
@@ -1388,7 +1404,7 @@ int gribapiScanTimestep(int streamID)
recID
=
streamptr
->
tsteps
[
1
].
recIDs
[
vrecID
];
compVar0
.
code
=
streamptr
->
tsteps
[
tsID
].
records
[
recID
].
code
;
compVar0
.
table
=
streamptr
->
tsteps
[
tsID
].
records
[
recID
].
table
;
compVar0
.
discip
line
=
0
;
compVar0
.
discip
=
streamptr
->
tsteps
[
tsID
].
records
[
recID
].
discip
;
compVar0
.
level1
=
streamptr
->
tsteps
[
tsID
].
records
[
recID
].
ilevel
;
compVar0
.
level2
=
streamptr
->
tsteps
[
tsID
].
records
[
recID
].
ilevel2
;
compVar0
.
ltype
=
streamptr
->
tsteps
[
tsID
].
records
[
recID
].
ltype
;
...
...
@@ -1435,7 +1451,7 @@ int gribapiScanTimestep(int streamID)
compVar0
.
code
=
streamptr
->
tsteps
[
tsID
].
records
[
recID
].
code
;
compVar0
.
table
=
streamptr
->
tsteps
[
tsID
].
records
[
recID
].
table
;
compVar0
.
discip
line
=
0
;
compVar0
.
discip
=
streamptr
->
tsteps
[
tsID
].
records
[
recID
].
discip
;
compVar0
.
level1
=
streamptr
->
tsteps
[
tsID
].
records
[
recID
].
ilevel
;
compVar0
.
level2
=
streamptr
->
tsteps
[
tsID
].
records
[
recID
].
ilevel2
;
compVar0
.
ltype
=
streamptr
->
tsteps
[
tsID
].
records
[
recID
].
ltype
;
...
...
@@ -1702,10 +1718,10 @@ void gribapiDefGrid(grib_handle *gh, int gridID)
GRIB_CHECK
(
grib_set_long
(
gh
,
"Ni"
,
nlon
),
0
);
GRIB_CHECK
(
grib_set_long
(
gh
,
"Nj"
,
nlat
),
0
);
GRIB_CHECK
(
grib_set_double
(
gh
,
"latitudeOfFirstGridPointInDegrees"
,
gridInqYval
(
gridID
,
0
)),
0
);
GRIB_CHECK
(
grib_set_double
(
gh
,
"latitudeOfLastGridPointInDegrees"
,
gridInqYval
(
gridID
,
nlat
-
1
)),
0
);
GRIB_CHECK
(
grib_set_double
(
gh
,
"longitudeOfFirstGridPointInDegrees"
,
gridInqXval
(
gridID
,
0
)),
0
);
GRIB_CHECK
(
grib_set_double
(
gh
,
"longitudeOfLastGridPointInDegrees"
,
gridInqXval
(
gridID
,
nlon
-
1
)),
0
);
GRIB_CHECK
(
grib_set_double
(
gh
,
"latitudeOfFirstGridPointInDegrees"
,
gridInqYval
(
gridID
,
0
)),
0
);
GRIB_CHECK
(
grib_set_double
(
gh
,
"latitudeOfLastGridPointInDegrees"
,
gridInqYval
(
gridID
,
nlat
-
1
)),
0
);
GRIB_CHECK
(
grib_set_double
(
gh
,
"iDirectionIncrementInDegrees"
,
gridInqXinc
(
gridID
)),
0
);
/*
if ( fabs(gridInqXinc(gridID)*1000 - ISEC2_LonIncr) > FLT_EPSILON )
...
...
@@ -1903,13 +1919,10 @@ void gribapiDefLevel(grib_handle *gh, int code, int zaxisID, int levelID)
level
=
zaxisInqLevel
(
zaxisID
,
levelID
);
if
(
level
<
0
)
Warning
(
func
,
"
p
ressure level of %f Pa is below
0.
"
,
level
);
Warning
(
func
,
"
P
ressure level of %f Pa is below
zero!
"
,
level
);
zaxisInqUnits
(
zaxisID
,
units
);
if
(
memcmp
(
units
,
"hPa"
,
3
)
==
0
||
memcmp
(
units
,
"mb"
,
2
)
==
0
)
level
=
level
;
else
level
/=
100
;
if
(
memcmp
(
units
,
"Pa"
,
2
)
==
0
)
level
/=
100
;
GRIB_CHECK
(
grib_set_long
(
gh
,
"typeOfFirstFixedSurface"
,
GRIBAPI_LTYPE_ISOBARIC
),
0
);
GRIB_CHECK
(
grib_set_double
(
gh
,
"level"
,
level
),
0
);
...
...
src/stream_ieg.c
View file @
5db17b1f
...
...
@@ -628,7 +628,7 @@ void iegAddRecord(int streamID, int code, int *pdb, int *gdb, double *vct,
int
level1
,
level2
;
int
gridtype
;
int
lbounds
=
0
;
RECORD
*
record
;
record_t
*
record
;
grid_t
grid
;
int
vlistID
;
stream_t
*
streamptr
;
...
...
@@ -779,7 +779,7 @@ void iegCmpRecord(int streamID, int tsID, int recID, off_t position, int code,
static
char
func
[]
=
"iegCmpRecord"
;
int
varID
=
0
;
int
levelID
=
0
;
RECORD
*
record
;
record_t
*
record
;
stream_t
*
streamptr
;
streamptr
=
stream_to_pointer
(
streamID
);
...
...
@@ -931,7 +931,7 @@ void iegScanTimestep1(int streamID)
{
streamptr
->
tsteps
[
0
].
recordSize
=
nrecords
;
streamptr
->
tsteps
[
0
].
records
=
(
RECORD
*
)
realloc
(
streamptr
->
tsteps
[
0
].
records
,
nrecords
*
sizeof
(
RECORD
));
(
record_t
*
)
realloc
(
streamptr
->
tsteps
[
0
].
records
,
nrecords
*
sizeof
(
record_t
));
}
streamptr
->
tsteps
[
0
].
recIDs
=
(
int
*
)
malloc
(
nrecords
*
sizeof
(
int
));
...
...
src/stream_int.h
View file @
5db17b1f
...
...
@@ -146,17 +146,18 @@ typedef struct
int
ilevel
;
int
ilevel2
;
int
ltype
;
int
discip
;
short
table
;
short
used
;
short
code
;
short
varID
;
short
levelID
;
}
RECORD
;
record_t
;
typedef
struct
{
RECORD
*
records
;
record_t
*
records
;
int
recordSize
;
/* number of allocated records */
int
*
recIDs
;
/* IDs of non constant records */
int
nrecs
;
/* number of used records */
...
...
@@ -292,7 +293,7 @@ int recordNewEntry(int streamID, int tsID);
void
cdiCreateTimesteps
(
int
streamID
);
void
recordInitEntry
(
RECORD
*
record
);
void
recordInitEntry
(
record_t
*
record
);
void
cdiCheckZaxis
(
int
zaxisID
);
...
...
src/stream_record.c
View file @
5db17b1f
...
...
@@ -17,7 +17,7 @@
#include "stream_ieg.h"
void
recordInitEntry
(
RECORD
*
record
)
void
recordInitEntry
(
record_t
*
record
)
{
(
*
record
).
position
=
CDI_UNDEFID
;
(
*
record
).
size
=
0
;
...
...
@@ -34,7 +34,7 @@ int recordNewEntry(int streamID, int tsID)
static
char
func
[]
=
"recordNewEntry"
;
int
recordID
=
0
;
int
recordSize
;
RECORD
*
records
;
record_t
*
records
;
stream_t
*
streamptr
;
streamptr
=
stream_to_pointer
(
streamID
);
...
...
@@ -49,11 +49,11 @@ int recordNewEntry(int streamID, int tsID)
{
int
i
;
recordSize
=
1
;
/* <<<<---- */
records
=
(
RECORD
*
)
malloc
(
recordSize
*
sizeof
(
RECORD
));
records
=
(
record_t
*
)
malloc
(
recordSize
*
sizeof
(
record_t
));
if
(
records
==
NULL
)
{
Message
(
func
,
"recordSize = %d"
,
recordSize
);
SysError
(
func
,
"Allocation of
RECORD
TABLE failed"
);
SysError
(
func
,
"Allocation of
record_t
TABLE failed"
);
}
for
(
i
=
0
;
i
<
recordSize
;
i
++
)
...
...
@@ -75,11 +75,11 @@ int recordNewEntry(int streamID, int tsID)
int
i
;
recordSize
=
2
*
recordSize
;
records
=
(
RECORD
*
)
realloc
(
records
,
recordSize
*
sizeof
(
RECORD
));
records
=
(
record_t
*
)
realloc
(
records
,
recordSize
*
sizeof
(
record_t
));
if
(
records
==
NULL
)
{
Message
(
func
,
"recordSize = %d"
,
recordSize
);
SysError
(
func
,
"Reallocation of
RECORD
TABLE failed"
);
SysError
(
func
,
"Reallocation of
record_t
TABLE failed"
);
}
recordID
=
recordSize
/
2
;