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
168404d8
Commit
168404d8
authored
Apr 26, 2013
by
Uwe Schulzweida
Browse files
added patch from Florian Prill: Lesen von Nicht-Standard GRIB-Keys
parent
2fd55278
Changes
15
Hide whitespace changes
Inline
Side-by-side
configure
View file @
168404d8
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.68 for cdi 1.6.1rc
1
.
# Generated by GNU Autoconf 2.68 for cdi 1.6.1rc
2
.
#
# Report bugs to <http://code.zmaw.de/projects/cdi>.
#
...
...
@@ -570,8 +570,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='cdi'
PACKAGE_TARNAME='cdi'
PACKAGE_VERSION='1.6.1rc
1
'
PACKAGE_STRING='cdi 1.6.1rc
1
'
PACKAGE_VERSION='1.6.1rc
2
'
PACKAGE_STRING='cdi 1.6.1rc
2
'
PACKAGE_BUGREPORT='http://code.zmaw.de/projects/cdi'
PACKAGE_URL=''
...
...
@@ -1403,7 +1403,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures cdi 1.6.1rc
1
to adapt to many kinds of systems.
\`configure' configures cdi 1.6.1rc
2
to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
...
...
@@ -1473,7 +1473,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of cdi 1.6.1rc
1
:";;
short | recursive ) echo "Configuration of cdi 1.6.1rc
2
:";;
esac
cat <<\_ACEOF
...
...
@@ -1630,7 +1630,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
cdi configure 1.6.1rc
1
cdi configure 1.6.1rc
2
generated by GNU Autoconf 2.68
Copyright (C) 2010 Free Software Foundation, Inc.
...
...
@@ -2391,7 +2391,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by cdi $as_me 1.6.1rc
1
, which was
It was created by cdi $as_me 1.6.1rc
2
, which was
generated by GNU Autoconf 2.68. Invocation command line was
$ $0 $@
...
...
@@ -3323,7 +3323,7 @@ fi
# Define the identity of the package.
PACKAGE='cdi'
VERSION='1.6.1rc
1
'
VERSION='1.6.1rc
2
'
cat >>confdefs.h <<_ACEOF
...
...
@@ -27424,7 +27424,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by cdi $as_me 1.6.1rc
1
, which was
This file was extended by cdi $as_me 1.6.1rc
2
, which was
generated by GNU Autoconf 2.68. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
...
...
@@ -27490,7 +27490,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
cdi config.status 1.6.1rc
1
cdi config.status 1.6.1rc
2
configured by $0, generated by GNU Autoconf 2.68,
with options \\"\$ac_cs_config\\"
...
...
configure.ac
View file @
168404d8
# Process this file with autoconf to produce a configure script.
AC_INIT([cdi], [1.6.1rc
1
], [http://code.zmaw.de/projects/cdi])
AC_INIT([cdi], [1.6.1rc
2
], [http://code.zmaw.de/projects/cdi])
echo "configuring ${PACKAGE_NAME} ${PACKAGE_VERSION}"
...
...
doc/tex/c_quick_ref.tex
View file @
168404d8
...
...
@@ -4,6 +4,15 @@
This appendix provide a brief listing of the C language bindings of the
CDI library routines:
\section*
{
\tt
\htmlref
{
cdiDefAdditionalKey
}{
cdiDefAdditionalKey
}}
\begin{verbatim}
void cdiDefAdditionalKey (const char *string);
\end{verbatim}
Register an additional GRIB key which is read when file is opened..
\section*
{
\tt
\htmlref
{
gridCreate
}{
gridCreate
}}
\begin{verbatim}
...
...
@@ -916,7 +925,7 @@ Get the data type of a Variable.
\section*
{
\tt
\htmlref
{
vlistInqVarDblKey
}{
vlistInqVarDblKey
}}
\begin{verbatim}
double vlistInqVarDblKey (int
stream
ID, const char *name);
double vlistInqVarDblKey (int
vlistID, int var
ID, const char *name);
\end{verbatim}
raw access to GRIB meta-data.
...
...
@@ -934,7 +943,7 @@ Get extra information of a Variable.
\section*
{
\tt
\htmlref
{
vlistInqVarIntKey
}{
vlistInqVarIntKey
}}
\begin{verbatim}
int vlistInqVarIntKey (int
stream
ID, const char *name);
int vlistInqVarIntKey (int
vlistID, int var
ID, const char *name);
\end{verbatim}
raw access to GRIB meta-data.
...
...
@@ -976,24 +985,6 @@ 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 @
168404d8
...
...
@@ -4,6 +4,15 @@
This appendix provide a brief listing of the Fortran language bindings of the
CDI library routines:
\section*
{
\tt
\htmlref
{
cdiDefAdditionalKey
}{
cdiDefAdditionalKey
}}
\begin{verbatim}
SUBROUTINE cdiDefAdditionalKey (CHARACTER*(*) string)
\end{verbatim}
Register an additional GRIB key which is read when file is opened..
\section*
{
\tt
\htmlref
{
gridCreate
}{
gridCreate
}}
\begin{verbatim}
...
...
@@ -930,7 +939,8 @@ Get the data type of a Variable.
\section*
{
\tt
\htmlref
{
vlistInqVarDblKey
}{
vlistInqVarDblKey
}}
\begin{verbatim}
DOUBLEPRECISION FUNCTION vlistInqVarDblKey (INTEGER streamID, CHARACTER*(*) name)
DOUBLEPRECISION FUNCTION vlistInqVarDblKey (INTEGER vlistID, INTEGER varID,
CHARACTER*(*) name)
\end{verbatim}
raw access to GRIB meta-data.
...
...
@@ -948,7 +958,8 @@ Get extra information of a Variable.
\section*
{
\tt
\htmlref
{
vlistInqVarIntKey
}{
vlistInqVarIntKey
}}
\begin{verbatim}
INTEGER FUNCTION vlistInqVarIntKey (INTEGER streamID, CHARACTER*(*) name)
INTEGER FUNCTION vlistInqVarIntKey (INTEGER vlistID, INTEGER varID,
CHARACTER*(*) name)
\end{verbatim}
raw access to GRIB meta-data.
...
...
@@ -991,24 +1002,6 @@ 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 @
168404d8
...
...
@@ -534,27 +534,22 @@ int vlistMergedLevel(int vlistID, int varID, int levelID);
void
vlistDefVarEnsemble
(
int
vlistID
,
int
varID
,
int
ensID
,
int
ensCount
,
int
forecast_type
);
int
vlistInqVarEnsemble
(
int
vlistID
,
int
varID
,
int
*
ensID
,
int
*
ensCount
,
int
*
forecast_type
);
/* ---------------------------------- */
/* Local change: 2013-01-28, FP (DWD) */
/* ---------------------------------- */
/* cdiClearAdditionalKeys: Clear the list of additional GRIB keys. */
void
cdiClearAdditionalKeys
();
/* cdiDefAdditionalKey: Register an additional GRIB key which is read when file is opened. */
void
cdiDefAdditionalKey
(
const
char
*
string
);
/* vlistDefVarIntKey: Set an arbitrary keyword/integer value pair for GRIB API */
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
);
/* vlistHasVarKey: returns 1 if meta-data key was read, 0 otherwise. */
int
vlistHasVarKey
(
int
vlistID
,
int
varID
,
const
char
*
name
);
/* vlistInqVarDblKey: raw access to GRIB meta-data */
double
vlistInqVarDblKey
(
int
stream
ID
,
const
char
*
name
);
double
vlistInqVarDblKey
(
int
vlistID
,
int
var
ID
,
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
);
int
vlistInqVarIntKey
(
int
vlistID
,
int
varID
,
const
char
*
name
);
/* VLIST attributes */
...
...
src/cdi.inc
View file @
168404d8
!
This
file
was
automatically
generated
,
don
'
t
edit
!
!
!
Fortran
interface
for
CDI
library
version
1.6.1
rc
1
!
Fortran
interface
for
CDI
library
version
1.6.1
rc
2
!
!
Author
:
!
-------
...
...
@@ -1195,15 +1195,10 @@
!
INTEGER
forecast_type
)
EXTERNAL
vlistInqVarEnsemble
!
!
----------------------------------
!
!
!
Local
change
:
2013
-
01
-
28
,
FP
(
DWD
)
!
!
!
----------------------------------
!
!
cdiDefAdditionalKey
!
(
CHARACTER
*
(
*
)
string
)
EXTERNAL
cdiDefAdditionalKey
!
vlistDefVarIntKey
!
(
INTEGER
vlistID
,
!
INTEGER
varID
,
...
...
@@ -1218,34 +1213,18 @@
!
DOUBLEPRECISION
value
)
EXTERNAL
vlistDefVarDblKey
!
!
----------------------------------
!
!
!
Local
change
:
2013
-
02
-
18
,
FP
(
DWD
)
!
!
!
----------------------------------
!
!
vlistInqVarRawBegin
!
(
INTEGER
streamID
,
!
INTEGER
varID
)
EXTERNAL
vlistInqVarRawBegin
DOUBLEPRECISION
vlistInqVarDblKey
!
(
INTEGER
streamID
,
!
(
INTEGER
vlistID
,
!
INTEGER
varID
,
!
CHARACTER
*
(
*
)
name
)
EXTERNAL
vlistInqVarDblKey
INTEGER
vlistInqVarIntKey
!
(
INTEGER
streamID
,
!
(
INTEGER
vlistID
,
!
INTEGER
varID
,
!
CHARACTER
*
(
*
)
name
)
EXTERNAL
vlistInqVarIntKey
!
vlistInqVarRawEnd
!
(
INTEGER
streamID
)
EXTERNAL
vlistInqVarRawEnd
!
!
VLIST
attributes
!
...
...
src/cdiFortran.c
View file @
168404d8
...
...
@@ -15,7 +15,7 @@
#endif
#if ! defined (_CDIFORTRAN_H)
# include "cdi
F
ortran.h"
# include "cdi
f
ortran.h"
#endif
...
...
@@ -253,30 +253,11 @@ FCALLSCFUN3 (INT, vlistMergedLevel, VLISTMERGEDLEVEL, vlistmergedlevel, INT, INT
FCALLSCSUB5
(
vlistDefVarEnsemble
,
VLISTDEFVARENSEMBLE
,
vlistdefvarensemble
,
INT
,
INT
,
INT
,
INT
,
INT
)
FCALLSCFUN5
(
INT
,
vlistInqVarEnsemble
,
VLISTINQVARENSEMBLE
,
vlistinqvarensemble
,
INT
,
INT
,
PINT
,
PINT
,
PINT
)
/* ---------------------------------- */
/* Local change: 2013-01-28, FP (DWD) */
/* ---------------------------------- */
FCALLSCSUB1
(
cdiDefAdditionalKey
,
CDIDEFADDITIONALKEY
,
cdidefadditionalkey
,
STRING
)
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
)
FCALLSCFUN2
(
DOUBLE
,
vlistInqVarDblKey
,
VLISTINQVARDBLKEY
,
vlistinqvardblkey
,
INT
,
STRING
)
FCALLSCFUN2
(
INT
,
vlistInqVarIntKey
,
VLISTINQVARINTKEY
,
vlistinqvarintkey
,
INT
,
STRING
)
FCALLSCSUB1
(
vlistInqVarRawEnd
,
VLISTINQVARRAWEND
,
vlistinqvarrawend
,
INT
)
FCALLSCFUN3
(
DOUBLE
,
vlistInqVarDblKey
,
VLISTINQVARDBLKEY
,
vlistinqvardblkey
,
INT
,
INT
,
STRING
)
FCALLSCFUN3
(
INT
,
vlistInqVarIntKey
,
VLISTINQVARINTKEY
,
vlistinqvarintkey
,
INT
,
INT
,
STRING
)
/* VLIST attributes */
...
...
src/stream_grb.c
View file @
168404d8
...
...
@@ -123,16 +123,23 @@ int grbDefRecord(stream_t * streamptr)
static
int
grbDecode
(
int
filetype
,
unsigned
char
*
gribbuffer
,
int
gribsize
,
double
*
data
,
int
gridsize
,
int
unreduced
,
int
*
nmiss
,
int
*
zip
,
double
missval
)
int
unreduced
,
int
*
nmiss
,
int
*
zip
,
double
missval
,
int
vlistID
,
int
varID
)
{
int
status
=
0
;
#if defined (HAVE_LIBCGRIBEX)
if
(
filetype
==
FILETYPE_GRB
)
status
=
cgribexDecode
(
gribbuffer
,
gribsize
,
data
,
gridsize
,
unreduced
,
nmiss
,
zip
,
missval
);
{
extern
int
cdiNAdditionalGRIBKeys
;
if
(
cdiNAdditionalGRIBKeys
>
0
)
Error
(
"CGRIBEX decode does not support reading of additional GRIB keys!"
);
status
=
cgribexDecode
(
gribbuffer
,
gribsize
,
data
,
gridsize
,
unreduced
,
nmiss
,
zip
,
missval
);
}
else
#endif
status
=
gribapiDecode
(
gribbuffer
,
gribsize
,
data
,
gridsize
,
unreduced
,
nmiss
,
zip
,
missval
);
{
status
=
gribapiDecode
(
gribbuffer
,
gribsize
,
data
,
gridsize
,
unreduced
,
nmiss
,
zip
,
missval
,
vlistID
,
varID
);
}
return
(
status
);
}
...
...
@@ -176,7 +183,7 @@ int grbReadRecord(stream_t * streamptr, double *data, int *nmiss)
missval
=
vlistInqVarMissval
(
vlistID
,
varID
);
grbDecode
(
filetype
,
gribbuffer
,
recsize
,
data
,
gridsize
,
streamptr
->
unreduced
,
nmiss
,
&
zip
,
missval
);
grbDecode
(
filetype
,
gribbuffer
,
recsize
,
data
,
gridsize
,
streamptr
->
unreduced
,
nmiss
,
&
zip
,
missval
,
vlistID
,
varID
);
streamptr
->
tsteps
[
tsID
].
records
[
recID
].
zip
=
zip
;
...
...
@@ -349,7 +356,7 @@ void grbReadVarDP(stream_t * streamptr, int varID, double *data, int *nmiss)
missval
=
vlistInqVarMissval
(
vlistID
,
varID
);
grbDecode
(
filetype
,
gribbuffer
,
recsize
,
&
data
[
levelID
*
gridsize
],
gridsize
,
streamptr
->
unreduced
,
&
imiss
,
&
zip
,
missval
);
streamptr
->
unreduced
,
&
imiss
,
&
zip
,
missval
,
vlistID
,
varID
);
*
nmiss
+=
imiss
;
...
...
@@ -403,7 +410,7 @@ void grbReadVarSliceDP(stream_t * streamptr, int varID, int levelID, double *dat
missval
=
vlistInqVarMissval
(
vlistID
,
varID
);
grbDecode
(
filetype
,
gribbuffer
,
recsize
,
data
,
gridsize
,
streamptr
->
unreduced
,
nmiss
,
&
zip
,
missval
);
grbDecode
(
filetype
,
gribbuffer
,
recsize
,
data
,
gridsize
,
streamptr
->
unreduced
,
nmiss
,
&
zip
,
missval
,
vlistID
,
varID
);
fileSetPos
(
fileID
,
currentfilepos
,
SEEK_SET
);
...
...
src/stream_gribapi.c
View file @
168404d8
...
...
@@ -923,6 +923,27 @@ 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
);
int
i
;
long
lval
;
double
dval
;
/* we read the additional keys for the first variable record only. */
int
linitial_field
=
(
varOptGribNentries
(
varID
)
==
0
);
for
(
i
=
0
;
i
<
cdiNAdditionalGRIBKeys
;
i
++
)
{
if
(
linitial_field
)
{
if
(
grib_get_long
(
gh
,
cdiAdditionalGRIBKeys
[
i
],
&
lval
)
==
0
)
varDefOptGribInt
(
varID
,
lval
,
cdiAdditionalGRIBKeys
[
i
]);
}
if
(
linitial_field
)
{
if
(
grib_get_double
(
gh
,
cdiAdditionalGRIBKeys
[
i
],
&
dval
)
==
0
)
varDefOptGribInt
(
varID
,
dval
,
cdiAdditionalGRIBKeys
[
i
]);
}
/* note: if the key is not defined, we do not throw an error! */
}
if
(
varInqInst
(
varID
)
==
CDI_UNDEFID
)
{
...
...
@@ -1881,7 +1902,7 @@ int gribapiScanTimestep(stream_t * streamptr)
int
gribapiDecode
(
unsigned
char
*
gribbuffer
,
int
gribsize
,
double
*
data
,
int
gridsize
,
int
unreduced
,
int
*
nmiss
,
int
*
zip
,
double
missval
)
int
unreduced
,
int
*
nmiss
,
int
*
zip
,
double
missval
,
int
vlistID
,
int
varID
)
{
int
status
=
0
;
#if defined (HAVE_LIBGRIB_API)
...
...
@@ -2534,7 +2555,8 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int ljpeg, i
GRIB_CHECK
(
grib_set_long
(
gh
,
"numberOfGridUsed"
,
gridInqNumber
(
gridID
)),
0
);
GRIB_CHECK
(
grib_set_long
(
gh
,
"numberOfGridInReference"
,
gridInqPosition
(
gridID
)),
0
);
len
=
16
;
GRIB_CHECK
(
grib_set_bytes
(
gh
,
"uuidOfHGrid"
,
(
unsigned
char
*
)
gridInqUUID
(
gridID
,
uuid
),
&
len
),
0
);
if
(
grib_set_bytes
(
gh
,
"uuidOfHGrid"
,
(
unsigned
char
*
)
gridInqUUID
(
gridID
,
uuid
),
&
len
)
!=
0
)
Warning
(
"Can't write UUID!"
);
}
break
;
...
...
@@ -2933,7 +2955,8 @@ void gribapiDefLevel(int editionNumber, grib_handle *gh, int param, int zaxisID,
GRIB_CHECK
(
grib_set_double
(
gh
,
"nlev"
,
(
double
)
zaxisInqSize
(
zaxisID
)),
0
);
GRIB_CHECK
(
grib_set_double
(
gh
,
"numberOfVGridUsed"
,
(
double
)
reference
),
0
);
len
=
16
;
GRIB_CHECK
(
grib_set_bytes
(
gh
,
"uuidOfVGrid"
,
(
unsigned
char
*
)
zaxisInqUUID
(
zaxisID
,
uuid
),
&
len
),
0
);
if
(
grib_set_bytes
(
gh
,
"uuidOfVGrid"
,
(
unsigned
char
*
)
zaxisInqUUID
(
zaxisID
,
uuid
),
&
len
)
!=
0
)
Warning
(
"Can't write UUID!"
);
GRIB_CHECK
(
grib_set_double
(
gh
,
"level"
,
level
),
0
);
}
...
...
src/stream_gribapi.h
View file @
168404d8
...
...
@@ -6,7 +6,7 @@ int gribapiScanTimestep2(stream_t * streamptr);
int
gribapiScanTimestep
(
stream_t
*
streamptr
);
int
gribapiDecode
(
unsigned
char
*
gribbuffer
,
int
gribsize
,
double
*
data
,
int
gridsize
,
int
unreduced
,
int
*
nmiss
,
int
*
zip
,
double
missval
);
int
unreduced
,
int
*
nmiss
,
int
*
zip
,
double
missval
,
int
vlistID
,
int
varID
);
size_t
gribapiEncode
(
int
varID
,
int
levelID
,
int
vlistID
,
int
gridID
,
int
zaxisID
,
int
vdate
,
int
vtime
,
int
tsteptype
,
int
numavg
,
...
...
src/varscan.c
View file @
168404d8
...
...
@@ -63,6 +63,14 @@ typedef struct
char
*
longname
;
char
*
units
;
ensinfo_t
*
ensdata
;
/* (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
];
/* (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
];
}
vartable_t
;
...
...
@@ -249,7 +257,11 @@ int paramNewEntry(int param)
}
for
(
i
=
0
;
i
<
varTablesize
;
i
++
)
vartable
[
i
].
param
=
UNDEF_PARAM
;
{
vartable
[
i
].
param
=
UNDEF_PARAM
;
vartable
[
i
].
opt_grib_int_nentries
=
0
;
vartable
[
i
].
opt_grib_dbl_nentries
=
0
;
}
}
else
{
...
...
@@ -276,7 +288,11 @@ int paramNewEntry(int param)
varID
=
varTablesize
/
2
;
for
(
i
=
varID
;
i
<
varTablesize
;
i
++
)
vartable
[
i
].
param
=
UNDEF_PARAM
;
{
vartable
[
i
].
param
=
UNDEF_PARAM
;
vartable
[
i
].
opt_grib_int_nentries
=
0
;
vartable
[
i
].
opt_grib_dbl_nentries
=
0
;
}
}
paramInitEntry
(
varID
,
param
);
...
...
@@ -946,6 +962,36 @@ void varDefEnsembleInfo(int varID, int ens_idx, int ens_count, int forecast_type
vartable
[
varID
].
ensdata
->
forecast_init_type
=
forecast_type
;
}
void
varDefOptGribInt
(
int
varID
,
long
lval
,
const
char
*
keyword
)
{
int
idx
=
vartable
[
varID
].
opt_grib_int_nentries
;
vartable
[
varID
].
opt_grib_int_nentries
++
;
if
(
idx
>=
MAX_OPT_GRIB_ENTRIES
)
Error
(
"Too many optional keyword/integer value pairs!"
);
vartable
[
varID
].
opt_grib_int_val
[
idx
]
=
(
int
)
lval
;
vartable
[
varID
].
opt_grib_int_keyword
[
idx
]
=
strdupx
(
keyword
);
}
void
varDefOptGribDbl
(
int
varID
,
double
dval
,
const
char
*
keyword
)
{
int
idx
=
vartable
[
varID
].
opt_grib_int_nentries
;
vartable
[
varID
].
opt_grib_int_nentries
++
;
if
(
idx
>=
MAX_OPT_GRIB_ENTRIES
)
Error
(
"Too many optional keyword/integer value pairs!"
);
vartable
[
varID
].
opt_grib_dbl_val
[
idx
]
=
dval
;
vartable
[
varID
].
opt_grib_dbl_keyword
[
idx
]
=
strdupx
(
keyword
);
}
int
varOptGribNentries
(
int
varID
)
{
int
nentries
=
0
;
nentries
=
vartable
[
varID
].
opt_grib_int_nentries
+
vartable
[
varID
].
opt_grib_dbl_nentries
;
return
(
nentries
);
}
/*
* Local Variables:
* c-file-style: "Java"
...
...
src/varscan.h
View file @
168404d8
...
...
@@ -29,6 +29,10 @@ void varDefTable(int varID, int tableID);
int
varInqTable
(
int
varID
);
void
varDefEnsembleInfo
(
int
varID
,
int
ens_idx
,
int
ens_count
,
int
forecast_type
);
void
varDefOptGribInt
(
int
varID
,
long
lval
,
const
char
*
keyword
);
void
varDefOptGribDbl
(
int
varID
,
double
dval
,
const
char
*
keyword
);
int
varOptGribNentries
(
int
varID
);
int
zaxisCompare
(
int
zaxisID
,
int
zaxistype
,
int
nlevels
,
int
lbounds
,
double
*
levels
,
char
*
longname
,
char
*
units
,
int
ltype
);
#endif
...
...
src/vlist.c
View file @
168404d8
...
...
@@ -15,6 +15,12 @@
#include "vlist_att.h"
#include "pio_rpc.h"
/* list of additional GRIB2 keywords which are read by the open process */
int
cdiNAdditionalGRIBKeys
=
0
;
char
*
cdiAdditionalGRIBKeys
[
MAX_OPT_GRIB_ENTRIES
];
extern
void
zaxisGetIndexList
(
int
,
int
*
);
static
int
VLIST_Debug
=
0
;
...
...
src/vlist.h
View file @
168404d8
...
...
@@ -178,6 +178,10 @@ void vlistDefVarValidrange(int vlistID, int varID, const double *validrange);
/* vlistInqVarValidrange: Get the valid range of a Variable */
int
vlistInqVarValidrange
(
int
vlistID
,
int
varID
,
double
*
validrange
);
extern
int
cdiNAdditionalGRIBKeys
;
extern
char
*
cdiAdditionalGRIBKeys
[];
#endif
/* _VLIST_H */
/*
* Local Variables:
...
...
src/vlist_var.c
View file @
168404d8
...
...
@@ -1935,67 +1935,83 @@ void vlistDefVarDblKey(int vlistID, int varID, const char *name, double value)
# 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
;
/* cdiClearAdditionalKeys: Clears the list of additional GRIB keys. */
void
cdiClearAdditionalKeys
()
{
int
i
;
for
(
i
=
0
;
i
<
cdiNAdditionalGRIBKeys
;
i
++
)
free
(
cdiAdditionalGRIBKeys
[
i
]);
cdiNAdditionalGRIBKeys
=
0
;
}
// 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
;
/* cdiDefAdditionalKey: Register an additional GRIB key which is read when file is opened. */
void
cdiDefAdditionalKey
(
const
char
*
name
)
{
#if defined (HAVE_LIBGRIB_API)
int
idx
=
cdiNAdditionalGRIBKeys
;
cdiNAdditionalGRIBKeys
++
;
if
(
idx
>=
MAX_OPT_GRIB_ENTRIES
)
Error
(
"Too many additional keywords!"
);
if
(
name
)
cdiAdditionalGRIBKeys
[
idx
]
=
strdupx
(
name
);
else
Error
(
"Internal error!"
);
#endif
}
fileSetPos
(
fileID
,
recpos
,
SEEK_SET
);
fileRead
(
fileID
,
streamptr
->
record
->
buffer