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
ca0eadcc
Commit
ca0eadcc
authored
Jan 05, 2018
by
Uwe Schulzweida
Browse files
Added support for GRIB2 key shapeOfTheEarth.
parent
4aa56e7b
Changes
4
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
ca0eadcc
...
...
@@ -4,6 +4,7 @@
2018-01-05 Uwe Schulzweida
* Added support for GRIB2 key shapeOfTheEarth
* Replaced vlistDefVarProductDefinitionTemplate() by cdiDefKeyInt().
* Replaced vlistDefVarTypeOfGeneratingProcess() by cdiDefKeyInt().
...
...
src/cdi.h
View file @
ca0eadcc
...
...
@@ -808,6 +808,9 @@ size_t gridInqYCvals(int gridID, char *ycvals[]);
#define CDI_KEY_LOCALTABLESVERSION 802 // GRIB2 localTablesVersion
#define CDI_KEY_TYPEOFGENERATINGPROCESS 803 // GRIB2 typeOfGeneratingProcess
#define CDI_KEY_PRODUCTDEFINITIONTEMPLATE 804 // GRIB2 productDefinitionTemplate
#define CDI_KEY_TYPEOFPROCESSEDDATA 805 // GRIB2 typeOfProcessedData
#define CDI_KEY_SHAPEOFTHEEARTH 806 // GRIB2 shapeOfTheEarth
#define CDI_KEY_BACKGROUNDPROCESS 807 // GRIB2 backgroundProcess
// cdiDefKeyInt: Define a CDI varianble integer value from a key
int
cdiDefKeyInt
(
int
cdiID
,
int
varID
,
int
key
,
int
value
);
...
...
src/cdi.inc
View file @
ca0eadcc
...
...
@@ -1589,6 +1589,12 @@
PARAMETER
(
CDI_KEY_TYPEOFGENERATINGPROCESS
=
803
)
INTEGER
CDI_KEY_PRODUCTDEFINITIONTEMPLATE
PARAMETER
(
CDI_KEY_PRODUCTDEFINITIONTEMPLATE
=
804
)
INTEGER
CDI_KEY_TYPEOFPROCESSEDDATA
PARAMETER
(
CDI_KEY_TYPEOFPROCESSEDDATA
=
805
)
INTEGER
CDI_KEY_SHAPEOFTHEEARTH
PARAMETER
(
CDI_KEY_SHAPEOFTHEEARTH
=
806
)
INTEGER
CDI_KEY_BACKGROUNDPROCESS
PARAMETER
(
CDI_KEY_BACKGROUNDPROCESS
=
807
)
INTEGER
cdiDefKeyInt
!
(
INTEGER
cdiID
,
!
INTEGER
varID
,
...
...
src/stream_gribapi.c
View file @
ca0eadcc
...
...
@@ -400,6 +400,38 @@ void gribapiGetString(grib_handle *gh, const char *key, char *string, size_t len
else
if
(
length
==
2
&&
memcmp
(
string
,
"~"
,
length
)
==
0
)
string
[
0
]
=
0
;
}
static
void
gribapiGetKeys
(
grib_handle
*
gh
,
int
varID
)
{
long
tablesVersion
=
0
;
if
(
grib_get_long
(
gh
,
"tablesVersion"
,
&
tablesVersion
)
==
0
)
varDefKeyInt
(
varID
,
CDI_KEY_TABLESVERSION
,
(
int
)
tablesVersion
);
long
localTablesVersion
=
0
;
if
(
grib_get_long
(
gh
,
"localTablesVersion"
,
&
localTablesVersion
)
==
0
)
varDefKeyInt
(
varID
,
CDI_KEY_LOCALTABLESVERSION
,
(
int
)
localTablesVersion
);
long
typeOfGeneratingProcess
=
0
;
if
(
grib_get_long
(
gh
,
"typeOfGeneratingProcess"
,
&
typeOfGeneratingProcess
)
==
0
)
varDefKeyInt
(
varID
,
CDI_KEY_TYPEOFGENERATINGPROCESS
,
(
int
)
typeOfGeneratingProcess
);
long
productDefinitionTemplate
=
0
;
if
(
grib_get_long
(
gh
,
"productDefinitionTemplateNumber"
,
&
productDefinitionTemplate
)
==
0
)
varDefKeyInt
(
varID
,
CDI_KEY_PRODUCTDEFINITIONTEMPLATE
,
(
int
)
productDefinitionTemplate
);
long
typeOfProcessedData
=
0
;
if
(
grib_get_long
(
gh
,
"typeOfProcessedData"
,
&
typeOfProcessedData
)
==
0
)
varDefKeyInt
(
varID
,
CDI_KEY_TYPEOFPROCESSEDDATA
,
(
int
)
typeOfProcessedData
);
long
shapeOfTheEarth
=
0
;
if
(
grib_get_long
(
gh
,
"shapeOfTheEarth"
,
&
shapeOfTheEarth
)
==
0
)
varDefKeyInt
(
varID
,
CDI_KEY_SHAPEOFTHEEARTH
,
(
int
)
shapeOfTheEarth
);
long
backgroundProcess
=
0
;
if
(
grib_get_long
(
gh
,
"backgroundProcess"
,
&
backgroundProcess
)
==
0
)
varDefKeyInt
(
varID
,
CDI_KEY_BACKGROUNDPROCESS
,
(
int
)
backgroundProcess
);
}
static
void
gribapiAddRecord
(
stream_t
*
streamptr
,
int
param
,
grib_handle
*
gh
,
size_t
recsize
,
off_t
position
,
int
datatype
,
int
comptype
,
const
char
*
varname
,
...
...
@@ -574,21 +606,7 @@ void gribapiAddRecord(stream_t *streamptr, int param, grib_handle *gh,
if
(
ens_index
>
0
)
varDefEnsembleInfo
(
varID
,
(
int
)
ens_index
,
(
int
)
ens_count
,
(
int
)
ens_forecast_type
);
long
tablesVersion
=
0
;
if
(
grib_get_long
(
gh
,
"tablesVersion"
,
&
tablesVersion
)
==
0
)
varDefKeyInt
(
varID
,
CDI_KEY_TABLESVERSION
,
(
int
)
tablesVersion
);
long
localTablesVersion
=
0
;
if
(
grib_get_long
(
gh
,
"localTablesVersion"
,
&
localTablesVersion
)
==
0
)
varDefKeyInt
(
varID
,
CDI_KEY_LOCALTABLESVERSION
,
(
int
)
localTablesVersion
);
long
typeOfGeneratingProcess
=
0
;
if
(
grib_get_long
(
gh
,
"typeOfGeneratingProcess"
,
&
typeOfGeneratingProcess
)
==
0
)
varDefKeyInt
(
varID
,
CDI_KEY_TYPEOFGENERATINGPROCESS
,
(
int
)
typeOfGeneratingProcess
);
long
productDefinitionTemplate
=
0
;
if
(
grib_get_long
(
gh
,
"productDefinitionTemplateNumber"
,
&
productDefinitionTemplate
)
==
0
)
varDefKeyInt
(
varID
,
CDI_KEY_PRODUCTDEFINITIONTEMPLATE
,
(
int
)
productDefinitionTemplate
);
gribapiGetKeys
(
gh
,
varID
);
if
(
lread_additional_keys
)
{
...
...
@@ -1861,9 +1879,8 @@ getGribApiCompTypeMsg(int comptype, size_t gridsize)
return
(
struct
gribApiMsg
){
.
msgLen
=
len
,
.
msg
=
mesg
};
}
static
void
gribapiDefGrid
(
int
editionNumber
,
grib_handle
*
gh
,
int
gridID
,
int
comptype
,
bool
lieee
,
int
datatype
,
size_t
nmiss
,
int
gcinit
)
void
gribapiDefGrid
(
int
editionNumber
,
grib_handle
*
gh
,
int
gridID
,
int
comptype
,
bool
lieee
,
int
datatype
,
size_t
nmiss
,
int
gcinit
,
int
shapeOfTheEarth
)
{
UNUSED
(
nmiss
);
bool
lrotated
=
false
;
...
...
@@ -1950,7 +1967,11 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
if
(
gcinit
)
return
;
if
(
editionNumber
==
2
)
GRIB_CHECK
(
my_grib_set_long
(
gh
,
"numberOfValues"
,
(
long
)
gridsize
),
0
);
if
(
editionNumber
==
2
)
{
GRIB_CHECK
(
my_grib_set_long
(
gh
,
"numberOfValues"
,
(
long
)
gridsize
),
0
);
GRIB_CHECK
(
my_grib_set_long
(
gh
,
"shapeOfTheEarth"
,
(
long
)
shapeOfTheEarth
),
0
);
}
switch
(
gridtype
)
{
...
...
@@ -3058,7 +3079,9 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
GRIB_CHECK
(
my_grib_set_long
(
gh
,
"bitsPerValue"
,
bitsPerValue
),
0
);
}
gribapiDefGrid
((
int
)
editionNumber
,
gh
,
gridID
,
comptype
,
lieee
,
datatype
,
nmiss
,
gc
->
init
);
int
shapeOfTheEarth
=
0
;
cdiInqKeyInt
(
vlistID
,
varID
,
CDI_KEY_SHAPEOFTHEEARTH
,
&
shapeOfTheEarth
);
gribapiDefGrid
((
int
)
editionNumber
,
gh
,
gridID
,
comptype
,
lieee
,
datatype
,
nmiss
,
gc
->
init
,
shapeOfTheEarth
);
gribapiDefLevel
((
int
)
editionNumber
,
gh
,
zaxisID
,
levelID
,
gc
->
init
,
productDefinitionTemplate
);
...
...
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