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
4ccb6ce0
Commit
4ccb6ce0
authored
Oct 15, 2013
by
Uwe Schulzweida
Browse files
added support for GRIB2 key typeOfGeneratingProcess
parent
6fad748b
Changes
9
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
4ccb6ce0
...
...
@@ -3,9 +3,10 @@
* Version 1.6.2 released
* using CGRIBEX library version 1.6.2
2013-10-
09
Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
2013-10-
15
Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* file.c: replaced getpagesize() by sysconf(_SC_PAGESIZE)
* added support for GRIB2 key typeOfGeneratingProcess
* added interface function vlistDefVarTypeOfGeneratingProcess() and vlistInqVarTypeOfGeneratingProcess()
2013-10-07 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
...
...
src/cdi.h
View file @
4ccb6ce0
...
...
@@ -539,6 +539,9 @@ int vlistInqVarTimave(int vlistID, int varID);
void
vlistDefVarTimaccu
(
int
vlistID
,
int
varID
,
int
timaccu
);
int
vlistInqVarTimaccu
(
int
vlistID
,
int
varID
);
void
vlistDefVarTypeOfGeneratingProcess
(
int
vlistID
,
int
varID
,
int
typeOfGeneratingProcess
);
int
vlistInqVarTypeOfGeneratingProcess
(
int
vlistID
,
int
varID
);
int
vlistInqVarSize
(
int
vlistID
,
int
varID
);
void
vlistDefIndex
(
int
vlistID
,
int
varID
,
int
levID
,
int
index
);
...
...
src/cdi.inc
View file @
4ccb6ce0
...
...
@@ -4,7 +4,7 @@
!
!
Author
:
!
-------
!
Uwe
Schulzweida
,
MPI
-
MET
,
Hamburg
,
Septem
ber
2013
!
Uwe
Schulzweida
,
MPI
-
MET
,
Hamburg
,
Octo
ber
2013
!
INTEGER
CDI_MAX_NAME
...
...
@@ -1145,6 +1145,17 @@
!
INTEGER
varID
)
EXTERNAL
vlistInqVarTimaccu
!
vlistDefVarTypeOfGeneratingProcess
!
(
INTEGER
vlistID
,
!
INTEGER
varID
,
!
INTEGER
typeOfGeneratingProcess
)
EXTERNAL
vlistDefVarTypeOfGeneratingProcess
INTEGER
vlistInqVarTypeOfGeneratingProcess
!
(
INTEGER
vlistID
,
!
INTEGER
varID
)
EXTERNAL
vlistInqVarTypeOfGeneratingProcess
INTEGER
vlistInqVarSize
!
(
INTEGER
vlistID
,
!
INTEGER
varID
)
...
...
src/cdiFortran.c
View file @
4ccb6ce0
...
...
@@ -261,6 +261,8 @@ FCALLSCSUB3 (vlistDefVarTimave, VLISTDEFVARTIMAVE, vlistdefvartimave, INT, INT,
FCALLSCFUN2
(
INT
,
vlistInqVarTimave
,
VLISTINQVARTIMAVE
,
vlistinqvartimave
,
INT
,
INT
)
FCALLSCSUB3
(
vlistDefVarTimaccu
,
VLISTDEFVARTIMACCU
,
vlistdefvartimaccu
,
INT
,
INT
,
INT
)
FCALLSCFUN2
(
INT
,
vlistInqVarTimaccu
,
VLISTINQVARTIMACCU
,
vlistinqvartimaccu
,
INT
,
INT
)
FCALLSCSUB3
(
vlistDefVarTypeOfGeneratingProcess
,
VLISTDEFVARTYPEOFGENERATINGPROCESS
,
vlistdefvartypeofgeneratingprocess
,
INT
,
INT
,
INT
)
FCALLSCFUN2
(
INT
,
vlistInqVarTypeOfGeneratingProcess
,
VLISTINQVARTYPEOFGENERATINGPROCESS
,
vlistinqvartypeofgeneratingprocess
,
INT
,
INT
)
FCALLSCFUN2
(
INT
,
vlistInqVarSize
,
VLISTINQVARSIZE
,
vlistinqvarsize
,
INT
,
INT
)
FCALLSCSUB4
(
vlistDefIndex
,
VLISTDEFINDEX
,
vlistdefindex
,
INT
,
INT
,
INT
,
INT
)
FCALLSCFUN3
(
INT
,
vlistInqIndex
,
VLISTINQINDEX
,
vlistinqindex
,
INT
,
INT
,
INT
)
...
...
src/stream_gribapi.c
View file @
4ccb6ce0
...
...
@@ -925,18 +925,21 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
Get the ensemble Info from the grib-2 Tables and update the intermediate datastructure.
Further update to the "vlist" is handled in the same way as for GRIB-1 by "cdi_generate_vars"
*/
{
int
status
;
status
=
grib_get_long
(
gh
,
"typeOfEnsembleForecast"
,
&
ens_forecast_type
);
if
(
status
==
0
)
{
GRIB_CHECK
(
grib_get_long
(
gh
,
"numberOfForecastsInEnsemble"
,
&
ens_count
),
0
);
GRIB_CHECK
(
grib_get_long
(
gh
,
"perturbationNumber"
,
&
ens_index
),
0
);
}
}
status
=
grib_get_long
(
gh
,
"typeOfEnsembleForecast"
,
&
ens_forecast_type
);
if
(
status
==
0
)
{
GRIB_CHECK
(
grib_get_long
(
gh
,
"numberOfForecastsInEnsemble"
,
&
ens_count
),
0
);
GRIB_CHECK
(
grib_get_long
(
gh
,
"perturbationNumber"
,
&
ens_index
),
0
);
}
if
(
ens_index
>
0
)
varDefEnsembleInfo
(
varID
,
(
int
)
ens_index
,
(
int
)
ens_count
,
(
int
)
ens_forecast_type
);
long
typeOfGeneratingProcess
=
0
;
status
=
grib_get_long
(
gh
,
"typeOfGeneratingProcess"
,
&
typeOfGeneratingProcess
);
if
(
status
==
0
)
varDefTypeOfGeneratingProcess
(
varID
,
(
int
)
typeOfGeneratingProcess
);
int
i
;
long
lval
;
double
dval
;
...
...
@@ -1255,9 +1258,22 @@ int gribapiScanTimestep1(stream_t * streamptr)
if
(
warn_time
)
if
(
memcmp
(
&
datetime
,
&
datetime0
,
sizeof
(
DateTime
))
!=
0
)
{
Warning
(
"Inconsistent verification time (param=%s level=%d)"
,
paramstr
,
level1
);
warn_time
=
FALSE
;
}
if
(
datetime0
.
date
==
10101
&&
datetime0
.
time
==
0
)
{
datetime0
.
date
=
datetime
.
date
;
datetime0
.
time
=
datetime
.
time
;
gribapiGetDataDateTime
(
gh
,
&
rdate
,
&
rtime
);
fcast
=
gribapiTimeIsFC
(
gh
);
if
(
fcast
)
tunit
=
gribapiGetTimeUnits
(
gh
);
}
else
{
Warning
(
"Inconsistent verification time (param=%s level=%d)"
,
paramstr
,
level1
);
warn_time
=
FALSE
;
}
}
}
else
{
...
...
@@ -2184,17 +2200,23 @@ int gribapiDefDateTimeRel(int editionNumber, grib_handle *gh, int rdate, int rti
}
static
void
gribapiDefTime
(
int
editionNumber
,
grib_handle
*
gh
,
int
vdate
,
int
vtime
,
int
tsteptype
,
int
numavg
,
int
taxisID
,
int
gcinit
)
void
gribapiDefTime
(
int
editionNumber
,
int
typeOfGeneratingProcess
,
grib_handle
*
gh
,
int
vdate
,
int
vtime
,
int
tsteptype
,
int
numavg
,
int
taxisID
,
int
gcinit
)
{
int
taxistype
=
-
1
;
int
timeunit
;
int
factor
;
if
(
taxisID
!=
-
1
)
taxistype
=
taxisInqType
(
taxisID
);
timeunit
=
taxisInqTunit
(
taxisID
);
factor
=
gribapiDefStepUnits
(
gh
,
timeunit
,
gcinit
);
if
(
typeOfGeneratingProcess
==
196
)
{
vdate
=
10101
;
vtime
=
0
;
taxistype
=
TAXIS_ABSOLUTE
;
}
/*
else if ( typeOfGeneratingProcess == 9 )
{
}
*/
if
(
taxistype
==
TAXIS_RELATIVE
)
{
...
...
@@ -2202,6 +2224,8 @@ void gribapiDefTime(int editionNumber, grib_handle *gh , int vdate, int vtime, i
int
calendar
=
taxisInqCalendar
(
taxisID
);
int
rdate
=
taxisInqRdate
(
taxisID
);
int
rtime
=
taxisInqRtime
(
taxisID
);
int
timeunit
=
taxisInqTunit
(
taxisID
);
int
factor
=
gribapiDefStepUnits
(
gh
,
timeunit
,
gcinit
);
status
=
gribapiDefDateTimeRel
(
editionNumber
,
gh
,
rdate
,
rtime
,
vdate
,
vtime
,
tsteptype
,
factor
,
calendar
,
gcinit
);
...
...
@@ -2548,7 +2572,7 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int ljpeg, i
GRIB_CHECK
(
grib_set_long
(
gh
,
"Ni"
,
gridInqGMEni
(
gridID
)),
0
);
GRIB_CHECK
(
grib_set_long
(
gh
,
"n2"
,
gridInqGMEni2
(
gridID
)),
0
);
GRIB_CHECK
(
grib_set_long
(
gh
,
"n3"
,
gridInqGMEni3
(
gridID
)),
0
);
GRIB_CHECK
(
grib_set_long
(
gh
,
"latitudeOfThePolePoint"
,
90000
),
0
);
GRIB_CHECK
(
grib_set_long
(
gh
,
"latitudeOfThePolePoint"
,
90000
000
),
0
);
GRIB_CHECK
(
grib_set_long
(
gh
,
"longitudeOfThePolePoint"
,
0
),
0
);
GRIB_CHECK
(
grib_set_long
(
gh
,
"numberOfDataPoints"
,
gridInqSize
(
gridID
)),
0
);
...
...
@@ -2957,6 +2981,7 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
int
param
;
int
lieee
=
FALSE
;
int
ensID
,
ensCount
,
forecast_type
;
/* Ensemble Data */
int
typeOfGeneratingProcess
;
long
bitsPerValue
;
long
editionNumber
=
2
;
char
name
[
256
];
...
...
@@ -2966,6 +2991,8 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
param
=
vlistInqVarParam
(
vlistID
,
varID
);
datatype
=
vlistInqVarDatatype
(
vlistID
,
varID
);
typeOfGeneratingProcess
=
vlistInqVarTypeOfGeneratingProcess
(
vlistID
,
varID
);
vlistInqVarName
(
vlistID
,
varID
,
name
);
#if defined(GRIBAPIENCODETEST)
...
...
@@ -2976,6 +3003,9 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
GRIB_CHECK
(
grib_get_long
(
gh
,
"editionNumber"
,
&
editionNumber
),
0
);
if
(
typeOfGeneratingProcess
==
-
1
)
typeOfGeneratingProcess
=
0
;
if
(
!
gc
->
init
)
GRIB_CHECK
(
grib_set_long
(
gh
,
"typeOfGeneratingProcess"
,
typeOfGeneratingProcess
),
0
);
if
(
!
gc
->
init
)
gribapiDefInstitut
(
gh
,
vlistID
,
varID
);
if
(
!
gc
->
init
)
gribapiDefModel
(
gh
,
vlistID
,
varID
);
...
...
@@ -2988,7 +3018,8 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
GRIB_CHECK(grib_set_long(gh, "perturbationNumber", ensID ), 0);
}
*/
gribapiDefTime
(
editionNumber
,
gh
,
vdate
,
vtime
,
tsteptype
,
numavg
,
vlistInqTaxis
(
vlistID
),
gc
->
init
);
gribapiDefTime
(
editionNumber
,
typeOfGeneratingProcess
,
gh
,
vdate
,
vtime
,
tsteptype
,
numavg
,
vlistInqTaxis
(
vlistID
),
gc
->
init
);
if
(
editionNumber
==
2
&&
(
datatype
==
DATATYPE_FLT32
||
datatype
==
DATATYPE_FLT64
)
)
lieee
=
TRUE
;
...
...
src/varscan.c
View file @
4ccb6ce0
...
...
@@ -38,41 +38,42 @@ leveltable_t;
typedef
struct
{
int
param
;
int
prec
;
int
tsteptype
;
int
timave
;
int
timaccu
;
int
gridID
;
int
zaxistype
;
int
ltype
;
/* GRIB level type */
int
lbounds
;
int
level_sf
;
int
level_unit
;
int
zaxisID
;
int
nlevels
;
int
levelTableSize
;
int
param
;
int
prec
;
int
tsteptype
;
int
timave
;
int
timaccu
;
int
gridID
;
int
zaxistype
;
int
ltype
;
/* GRIB level type */
int
lbounds
;
int
level_sf
;
int
level_unit
;
int
zaxisID
;
int
nlevels
;
int
levelTableSize
;
leveltable_t
*
levelTable
;
int
instID
;
int
modelID
;
int
tableID
;
int
comptype
;
// compression type
int
complevel
;
// compression level
int
lmissval
;
double
missval
;
char
*
name
;
char
*
longname
;
char
*
units
;
ensinfo_t
*
ensdata
;
int
instID
;
int
modelID
;
int
tableID
;
int
comptype
;
// compression type
int
complevel
;
// compression level
int
lmissval
;
double
missval
;
char
*
name
;
char
*
longname
;
char
*
units
;
ensinfo_t
*
ensdata
;
int
typeOfGeneratingProcess
;
#if defined (HAVE_LIBGRIB_API)
/* (Optional) list of keyword/double value pairs */
int
opt_grib_dbl_nentries
;
char
*
opt_grib_dbl_keyword
[
MAX_OPT_GRIB_ENTRIES
];
double
opt_grib_dbl_val
[
MAX_OPT_GRIB_ENTRIES
];
int
opt_grib_dbl_nentries
;
char
*
opt_grib_dbl_keyword
[
MAX_OPT_GRIB_ENTRIES
];
double
opt_grib_dbl_val
[
MAX_OPT_GRIB_ENTRIES
];
/* (Optional) list of keyword/integer value pairs */
int
opt_grib_int_nentries
;
char
*
opt_grib_int_keyword
[
MAX_OPT_GRIB_ENTRIES
];
int
opt_grib_int_val
[
MAX_OPT_GRIB_ENTRIES
];
int
opt_grib_int_nentries
;
char
*
opt_grib_int_keyword
[
MAX_OPT_GRIB_ENTRIES
];
int
opt_grib_int_val
[
MAX_OPT_GRIB_ENTRIES
];
#endif
}
vartable_t
;
...
...
@@ -104,6 +105,7 @@ void paramInitEntry(int varID, int param)
vartable
[
varID
].
instID
=
UNDEFID
;
vartable
[
varID
].
modelID
=
UNDEFID
;
vartable
[
varID
].
tableID
=
UNDEFID
;
vartable
[
varID
].
typeOfGeneratingProcess
=
UNDEFID
;
vartable
[
varID
].
comptype
=
COMPRESS_NONE
;
vartable
[
varID
].
complevel
=
1
;
vartable
[
varID
].
lmissval
=
0
;
...
...
@@ -589,6 +591,9 @@ void cdi_generate_vars(stream_t *streamptr)
vlistDefVarTimaccu
(
vlistID
,
varID
,
timaccu
);
vlistDefVarCompType
(
vlistID
,
varID
,
comptype
);
if
(
vartable
[
varid
].
typeOfGeneratingProcess
!=
UNDEFID
)
vlistDefVarTypeOfGeneratingProcess
(
vlistID
,
varID
,
vartable
[
varid
].
typeOfGeneratingProcess
);
if
(
vartable
[
varid
].
lmissval
)
vlistDefVarMissval
(
vlistID
,
varID
,
vartable
[
varid
].
missval
);
if
(
vartable
[
varid
].
name
)
vlistDefVarName
(
vlistID
,
varID
,
vartable
[
varid
].
name
);
...
...
@@ -1002,6 +1007,12 @@ void varDefEnsembleInfo(int varID, int ens_idx, int ens_count, int forecast_type
}
void
varDefTypeOfGeneratingProcess
(
int
varID
,
int
typeOfGeneratingProcess
)
{
vartable
[
varID
].
typeOfGeneratingProcess
=
typeOfGeneratingProcess
;
}
void
varDefOptGribInt
(
int
varID
,
long
lval
,
const
char
*
keyword
)
{
#if defined (HAVE_LIBGRIB_API)
...
...
src/varscan.h
View file @
4ccb6ce0
...
...
@@ -29,6 +29,9 @@ void varDefTable(int varID, int tableID);
int
varInqTable
(
int
varID
);
void
varDefEnsembleInfo
(
int
varID
,
int
ens_idx
,
int
ens_count
,
int
forecast_type
);
void
varDefTypeOfGeneratingProcess
(
int
varID
,
int
typeOfGeneratingProcess
);
void
varDefOptGribInt
(
int
varID
,
long
lval
,
const
char
*
keyword
);
void
varDefOptGribDbl
(
int
varID
,
double
dval
,
const
char
*
keyword
);
int
varOptGribNentries
(
int
varID
);
...
...
src/vlist.h
View file @
4ccb6ce0
...
...
@@ -81,6 +81,7 @@ typedef struct
int
tableID
;
int
timave
;
int
timaccu
;
int
typeOfGeneratingProcess
;
int
chunktype
;
int
xyz
;
int
missvalused
;
/* TRUE if missval is defined */
...
...
src/vlist_var.c
View file @
4ccb6ce0
...
...
@@ -1431,6 +1431,32 @@ int vlistInqVarTimaccu(int vlistID, int varID)
}
void
vlistDefVarTypeOfGeneratingProcess
(
int
vlistID
,
int
varID
,
int
typeOfGeneratingProcess
)
{
vlist_t
*
vlistptr
;
if
(
reshGetStatus
(
vlistID
,
&
vlist_ops
)
==
CLOSED
)
{
xwarning
(
"%s"
,
"Operation not executed."
);
return
;
}
vlistptr
=
vlist_to_pointer
(
vlistID
);
vlistptr
->
vars
[
varID
].
typeOfGeneratingProcess
=
typeOfGeneratingProcess
;
}
int
vlistInqVarTypeOfGeneratingProcess
(
int
vlistID
,
int
varID
)
{
vlist_t
*
vlistptr
;
vlistptr
=
vlist_to_pointer
(
vlistID
);
return
(
vlistptr
->
vars
[
varID
].
typeOfGeneratingProcess
);
}
void
vlistDestroyVarName
(
int
vlistID
,
int
varID
)
{
vlist_t
*
vlistptr
;
...
...
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