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
c0e91f25
Commit
c0e91f25
authored
Mar 13, 2013
by
Uwe Schulzweida
Browse files
Read arbitrary GRIB keys
parent
db166e0e
Changes
9
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
c0e91f25
...
...
@@ -3,6 +3,10 @@
* Version 1.6.0 released
* using CGRIBEX library version 1.6.0
2013-03-13 Florian Prill <Florian.Prill@dwd.de>
* Read arbitrary GRIB keys [Feature #3267]
2013-03-13 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* GRIB: added support for time step unit: seconds (Bug #3352)
...
...
doc/tex/c_quick_ref.tex
View file @
c0e91f25
...
...
@@ -939,6 +939,24 @@ Get the name of a Variable.
Get the parameter number of a Variable.
\section*
{
\tt
\htmlref
{
vlistInqVarRawBegin
}{
vlistInqVarRawBegin
}}
\begin{verbatim}
void vlistInqVarRawBegin (int streamID, int varID);
\end{verbatim}
Open GRIB record to retrieve raw meta-data in subsequent calls.
\section*
{
\tt
\htmlref
{
vlistInqVarRawEnd
}{
vlistInqVarRawEnd
}}
\begin{verbatim}
void vlistInqVarRawEnd (int streamID);
\end{verbatim}
Free previously opened GRIB record.
\section*
{
\tt
\htmlref
{
vlistInqVarStdname
}{
vlistInqVarStdname
}}
\begin{verbatim}
...
...
doc/tex/f_quick_ref.tex
View file @
c0e91f25
...
...
@@ -955,6 +955,24 @@ Get the name of a Variable.
Get the parameter number of a Variable.
\section*
{
\tt
\htmlref
{
vlistInqVarRawBegin
}{
vlistInqVarRawBegin
}}
\begin{verbatim}
SUBROUTINE vlistInqVarRawBegin (INTEGER streamID, INTEGER varID)
\end{verbatim}
Open GRIB record to retrieve raw meta-data in subsequent calls.
\section*
{
\tt
\htmlref
{
vlistInqVarRawEnd
}{
vlistInqVarRawEnd
}}
\begin{verbatim}
SUBROUTINE vlistInqVarRawEnd (INTEGER streamID)
\end{verbatim}
Free previously opened GRIB record.
\section*
{
\tt
\htmlref
{
vlistInqVarStdname
}{
vlistInqVarStdname
}}
\begin{verbatim}
...
...
src/cdi.h
View file @
c0e91f25
...
...
@@ -537,6 +537,20 @@ void vlistDefVarIntKey(int vlistID, int varID, const char *name, int value);
/* vlistDefVarDblKey: Set an arbitrary keyword/double value pair for GRIB API */
void
vlistDefVarDblKey
(
int
vlistID
,
int
varID
,
const
char
*
name
,
double
value
);
/* ---------------------------------- */
/* Local change: 2013-02-18, FP (DWD) */
/* ---------------------------------- */
/* vlistInqVarRawBegin: Open GRIB record to retrieve raw meta-data in subsequent calls */
void
vlistInqVarRawBegin
(
int
streamID
,
int
varID
);
/* vlistInqVarDblKey: raw access to GRIB meta-data */
double
vlistInqVarDblKey
(
int
streamID
,
const
char
*
name
);
/* vlistInqVarIntKey: raw access to GRIB meta-data */
int
vlistInqVarIntKey
(
int
streamID
,
const
char
*
name
);
/* vlistInqVarRawEnd: Free previously opened GRIB record */
void
vlistInqVarRawEnd
(
int
streamID
);
/* VLIST attributes */
/* vlistInqNatts: Get number of variable attributes assigned to this variable */
...
...
src/cdi.inc
View file @
c0e91f25
...
...
@@ -1206,6 +1206,24 @@
!
DOUBLEPRECISION
value
)
EXTERNAL
vlistDefVarDblKey
!
!
----------------------------------
!
!
!
Local
change
:
2013
-
02
-
18
,
FP
(
DWD
)
!
!
!
----------------------------------
!
!
vlistInqVarRawBegin
!
(
INTEGER
streamID
,
!
INTEGER
varID
)
EXTERNAL
vlistInqVarRawBegin
!
vlistInqVarRawEnd
!
(
INTEGER
streamID
)
EXTERNAL
vlistInqVarRawEnd
!
!
VLIST
attributes
!
...
...
src/cdiFortran.c
View file @
c0e91f25
...
...
@@ -259,6 +259,17 @@ FCALLSCFUN5 (INT, vlistInqVarEnsemble, VLISTINQVARENSEMBLE, vlistinqvarensemble,
FCALLSCSUB4
(
vlistDefVarIntKey
,
VLISTDEFVARINTKEY
,
vlistdefvarintkey
,
INT
,
INT
,
STRING
,
INT
)
FCALLSCSUB4
(
vlistDefVarDblKey
,
VLISTDEFVARDBLKEY
,
vlistdefvardblkey
,
INT
,
INT
,
STRING
,
DOUBLE
)
/* ---------------------------------- */
/* Local change: 2013-02-18, FP (DWD) */
/* ---------------------------------- */
FCALLSCSUB2
(
vlistInqVarRawBegin
,
VLISTINQVARRAWBEGIN
,
vlistinqvarrawbegin
,
INT
,
INT
)
FCALLSCSUB1
(
vlistInqVarRawEnd
,
VLISTINQVARRAWEND
,
vlistinqvarrawend
,
INT
)
/* VLIST attributes */
FCALLSCFUN3
(
INT
,
vlistInqNatts
,
VLISTINQNATTS
,
vlistinqnatts
,
INT
,
INT
,
PINT
)
...
...
src/stream_grb.c
View file @
c0e91f25
...
...
@@ -348,7 +348,7 @@ void grbReadVarDP(stream_t * streamptr, int varID, double *data, int *nmiss)
missval
=
vlistInqVarMissval
(
vlistID
,
varID
);
grbDecode
(
filetype
,
gribbuffer
,
recsize
,
&
data
[
levelID
*
gridsize
],
gridsize
,
grbDecode
(
filetype
,
gribbuffer
,
recsize
,
&
data
[
levelID
*
gridsize
],
gridsize
,
streamptr
->
unreduced
,
&
imiss
,
&
zip
,
missval
);
*
nmiss
+=
imiss
;
...
...
src/stream_int.h
View file @
c0e91f25
...
...
@@ -251,6 +251,12 @@ typedef struct {
void
*
gribContainers
;
#endif
int
vlistIDorig
;
/* ---------------------------------- */
/* Local change: 2013-02-18, FP (DWD) */
/* ---------------------------------- */
void
*
gh
;
// grib handle
}
stream_t
;
...
...
src/vlist_var.c
View file @
c0e91f25
...
...
@@ -674,7 +674,7 @@ void vlistInqVarStdname(int vlistID, int varID, char *stdname)
if
(
vlistptr
->
vars
[
varID
].
stdname
==
NULL
)
{
stdname
[
0
]
=
'\0'
;
}
}
else
strcpy
(
stdname
,
vlistptr
->
vars
[
varID
].
stdname
);
...
...
@@ -689,7 +689,7 @@ void vlistInqVarStdname(int vlistID, int varID, char *stdname)
@Parameter
@Item vlistID Variable list ID, from a previous call to @fref{vlistCreate}.
@Item varID Variable identifier.
@Item units Units of the variable. The caller must allocate space for the
@Item units Units of the variable. The caller must allocate space for the
returned string. The maximum possible length, in characters, of
the string is given by the predefined constant @func{CDI_MAX_NAME}.
...
...
@@ -1848,6 +1848,74 @@ void vlistDefVarDblKey(int vlistID, int varID, const char *name, double value)
Error
(
"Internal error!"
);
}
#if defined (HAVE_LIBGRIB_API)
# include "file.h"
# include "grib_api.h"
#endif
/* vlistInqVarRawBegin: Open GRIB record to retrieve raw meta-data in subsequent calls */
void
vlistInqVarRawBegin
(
int
streamID
,
int
varID
)
{
#if defined (HAVE_LIBGRIB_API)
stream_t
*
streamptr
;
int
recID
,
tsID
,
fileID
;
long
recpos
,
recsize
;
streamptr
=
stream_to_pointer
(
streamID
);
stream_check_ptr
(
__func__
,
streamptr
);
fileID
=
streamInqFileID
(
streamID
);
tsID
=
streamptr
->
curTsID
;
// determine record ID for varID in current time step
for
(
recID
=
0
;
(
recID
<
streamptr
->
tsteps
[
0
].
nrecs
)
&&
(
varID
!=
streamptr
->
tsteps
[
tsID
].
records
[
recID
].
varID
);
recID
++
);
recpos
=
streamptr
->
tsteps
[
tsID
].
records
[
recID
].
position
;
recsize
=
streamptr
->
tsteps
[
tsID
].
records
[
recID
].
size
;
fileSetPos
(
fileID
,
recpos
,
SEEK_SET
);
fileRead
(
fileID
,
streamptr
->
record
->
buffer
,
(
size_t
)
recsize
);
streamptr
->
gh
=
(
void
*
)
grib_handle_new_from_message
(
NULL
,
(
void
*
)
streamptr
->
record
->
buffer
,
recsize
);
#endif
}
/* vlistInqVarDblKey: raw access to GRIB meta-data */
double
vlistInqVarDblKey
(
int
streamID
,
const
char
*
name
)
{
double
value
=
0
;
#if defined (HAVE_LIBGRIB_API)
stream_t
*
streamptr
=
stream_to_pointer
(
streamID
);
stream_check_ptr
(
__func__
,
streamptr
);
GRIB_CHECK
(
grib_get_double
((
grib_handle
*
)
streamptr
->
gh
,
name
,
&
value
),
0
);
#endif
return
value
;
}
/* vlistInqVarIntKey: raw access to GRIB meta-data */
int
vlistInqVarIntKey
(
int
streamID
,
const
char
*
name
)
{
long
int
value
=
0
;
#if defined (HAVE_LIBGRIB_API)
stream_t
*
streamptr
=
stream_to_pointer
(
streamID
);
stream_check_ptr
(
__func__
,
streamptr
);
GRIB_CHECK
(
grib_get_long
((
grib_handle
*
)
streamptr
->
gh
,
name
,
&
value
),
0
);
#endif
return
(
int
)
value
;
}
/* vlistInqVarRawEnd: Free previously opened GRIB record */
void
vlistInqVarRawEnd
(
int
streamID
)
{
#if defined (HAVE_LIBGRIB_API)
stream_t
*
streamptr
=
stream_to_pointer
(
streamID
);
stream_check_ptr
(
__func__
,
streamptr
);
grib_handle_delete
((
grib_handle
*
)
streamptr
->
gh
);
#endif
}
void
vlistDefVarDeco
(
int
vlistID
,
int
varID
,
int
decoSize
,
deco_t
*
deco
)
{
...
...
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