Commit d93a42b7 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Added function vlistDefVarIntKey() and vlistDefVarDblKey() to set GRIB_API Key/Value pairs

parent cde8b21e
2013-03-?? Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* Version 1.6.0 released
* using CGRIBEX library version 1.6.0
* using CGRIBEX library version 1.6.0
2013-02-18 Florian Prill <Florian.Prill@dwd.de>
* Added function vlistDefVarIntKey() and vlistDefVarDblKey() to set GRIB_API Key/Value pairs
2013-02-13 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
......@@ -9,7 +13,7 @@
2013-02-04 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* netCDF: ignore the attribute valid_range, if the data type is inconsitent
* netCDF: ignore the attribute valid_range, if the data type is inconsistent
* netCDF: added env IGNORE_VALID_RANGE to ignore the attribute valid_range
2013-01-31 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
......
CDI NEWS
--------
Version 1.6.0 (?? March 2013):
New functions:
* vlistDefVarIntKey(): Set an arbitrary keyword/integer value pair for GRIB API
* vlistDefVarDblKey(): Set an arbitrary keyword/double value pair for GRIB API
Fixed bugs:
* netCDF: ignore the attribute valid_range, if the data type is inconsistent
* global netCDF attribute "source" missing
Version 1.5.9 (17 December 2012):
New features:
......
......@@ -738,6 +738,24 @@ Define the code number of a Variable.
Define the data type of a Variable.
\section*{\tt \htmlref{vlistDefVarDblKey}{vlistDefVarDblKey}}
\begin{verbatim}
void vlistDefVarDblKey (int vlistID, int varID, const char *name, double value);
\end{verbatim}
Set an arbitrary keyword/double value pair for GRIB API.
\section*{\tt \htmlref{vlistDefVarIntKey}{vlistDefVarIntKey}}
\begin{verbatim}
void vlistDefVarIntKey (int vlistID, int varID, const char *name, int value);
\end{verbatim}
Set an arbitrary keyword/integer value pair for GRIB API.
\section*{\tt \htmlref{vlistDefVarLongname}{vlistDefVarLongname}}
\begin{verbatim}
......
......@@ -744,6 +744,26 @@ Define the code number of a Variable.
Define the data type of a Variable.
\section*{\tt \htmlref{vlistDefVarDblKey}{vlistDefVarDblKey}}
\begin{verbatim}
SUBROUTINE vlistDefVarDblKey (INTEGER vlistID, INTEGER varID, CHARACTER*(*) name,
DOUBLEPRECISION value)
\end{verbatim}
Set an arbitrary keyword/double value pair for GRIB API.
\section*{\tt \htmlref{vlistDefVarIntKey}{vlistDefVarIntKey}}
\begin{verbatim}
SUBROUTINE vlistDefVarIntKey (INTEGER vlistID, INTEGER varID, CHARACTER*(*) name,
INTEGER value)
\end{verbatim}
Set an arbitrary keyword/integer value pair for GRIB API.
\section*{\tt \htmlref{vlistDefVarLongname}{vlistDefVarLongname}}
\begin{verbatim}
......
......@@ -525,6 +525,15 @@ 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) */
/* ---------------------------------- */
/* 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);
/* VLIST attributes */
/* vlistInqNatts: Get number of variable attributes assigned to this variable */
......
......@@ -4,7 +4,7 @@
!
! Author:
! -------
! Uwe Schulzweida, MPI-MET, Hamburg, January 2013
! Uwe Schulzweida, MPI-MET, Hamburg, February 2013
!
INTEGER CDI_MAX_NAME
......@@ -1177,6 +1177,29 @@
! INTEGER forecast_type)
EXTERNAL vlistInqVarEnsemble
!
! ----------------------------------
!
!
! Local change: 2013-01-28, FP (DWD)
!
!
! ----------------------------------
!
! vlistDefVarIntKey
! (INTEGER vlistID,
! INTEGER varID,
! CHARACTER*(*) name,
! INTEGER value)
EXTERNAL vlistDefVarIntKey
! vlistDefVarDblKey
! (INTEGER vlistID,
! INTEGER varID,
! CHARACTER*(*) name,
! DOUBLEPRECISION value)
EXTERNAL vlistDefVarDblKey
!
! VLIST attributes
!
......
......@@ -248,6 +248,17 @@ 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) */
/* ---------------------------------- */
FCALLSCSUB4 (vlistDefVarIntKey, VLISTDEFVARINTKEY, vlistdefvarintkey, INT, INT, STRING, INT)
FCALLSCSUB4 (vlistDefVarDblKey, VLISTDEFVARDBLKEY, vlistdefvardblkey, INT, INT, STRING, DOUBLE)
/* VLIST attributes */
FCALLSCFUN3 (INT, vlistInqNatts, VLISTINQNATTS, vlistinqnatts, INT, INT, PINT)
......
......@@ -2990,6 +2990,27 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
gribapiDefLevel(editionNumber, gh, param, zaxisID, levelID, gc->init);
/* ---------------------------------- */
/* Local change: 2013-01-28, FP (DWD) */
/* ---------------------------------- */
vlist_t *vlistptr;
vlistptr = vlist_to_pointer(vlistID);
if (!gc->init) {
int i;
for (i=0; i<vlistptr->vars[varID].opt_grib_dbl_nentries; i++)
{
GRIB_CHECK(grib_set_double(gh, vlistptr->vars[varID].opt_grib_dbl_keyword[i],
vlistptr->vars[varID].opt_grib_dbl_val[i]), 0);
}
for (i=0; i<vlistptr->vars[varID].opt_grib_int_nentries; i++)
{
GRIB_CHECK(grib_set_long(gh, vlistptr->vars[varID].opt_grib_int_keyword[i],
vlistptr->vars[varID].opt_grib_int_val[i]), 0);
}
}
if ( nmiss > 0 )
{
GRIB_CHECK(grib_set_long(gh, "bitmapPresent", 1), 0);
......
......@@ -225,6 +225,16 @@ void vlistDestroy(int vlistID)
if ( vlistptr->vars[varID].ensdata ) free(vlistptr->vars[varID].ensdata);
int i;
for (i=0; i<vlistptr->vars[varID].opt_grib_int_nentries; i++) {
if ( vlistptr->vars[varID].opt_grib_int_keyword[i] )
free(vlistptr->vars[varID].opt_grib_int_keyword[i]);
}
for (i=0; i<vlistptr->vars[varID].opt_grib_dbl_nentries; i++) {
if ( vlistptr->vars[varID].opt_grib_dbl_keyword[i] )
free(vlistptr->vars[varID].opt_grib_dbl_keyword[i]);
}
vlistDelAtts(vlistID, varID);
}
......@@ -291,6 +301,26 @@ void vlistCopy(int vlistID2, int vlistID1)
vlistptr1->vars[varID].ensdata, sizeof(ensinfo_t));
}
/* ---------------------------------- */
/* Local change: 2013-01-28, FP (DWD) */
/* ---------------------------------- */
int i;
vlistptr2->vars[varID].opt_grib_int_nentries = vlistptr1->vars[varID].opt_grib_int_nentries;
for (i=0; i<vlistptr1->vars[varID].opt_grib_int_nentries; i++) {
if ( vlistptr1->vars[varID].opt_grib_int_keyword[i] ) {
vlistptr2->vars[varID].opt_grib_int_keyword[i] = strdupx(vlistptr1->vars[varID].opt_grib_int_keyword[i]);
vlistptr2->vars[varID].opt_grib_int_val[i] = vlistptr1->vars[varID].opt_grib_int_val[i];
}
}
vlistptr2->vars[varID].opt_grib_dbl_nentries = vlistptr1->vars[varID].opt_grib_dbl_nentries;
for (i=0; i<vlistptr1->vars[varID].opt_grib_dbl_nentries; i++) {
if ( vlistptr1->vars[varID].opt_grib_dbl_keyword[i] ) {
vlistptr2->vars[varID].opt_grib_dbl_keyword[i] = strdupx(vlistptr1->vars[varID].opt_grib_dbl_keyword[i]);
vlistptr2->vars[varID].opt_grib_dbl_val[i] = vlistptr1->vars[varID].opt_grib_dbl_val[i];
}
}
vlistptr2->vars[varID].atts.nelems = 0;
vlistCopyVarAtts(vlistID1, varID, vlistID2, varID);
......@@ -520,6 +550,26 @@ void vlistCopyFlag(int vlistID2, int vlistID1)
vlistptr1->vars[varID].ensdata, sizeof(ensinfo_t));
}
/* ---------------------------------- */
/* Local change: 2013-01-28, FP (DWD) */
/* ---------------------------------- */
int i;
vlistptr2->vars[varID].opt_grib_int_nentries = vlistptr1->vars[varID].opt_grib_int_nentries;
for (i=0; i<vlistptr1->vars[varID].opt_grib_int_nentries; i++) {
if ( vlistptr1->vars[varID].opt_grib_int_keyword[i] ) {
vlistptr2->vars[varID].opt_grib_int_keyword[i] = strdupx(vlistptr1->vars[varID].opt_grib_int_keyword[i]);
vlistptr2->vars[varID].opt_grib_int_val[i] = vlistptr1->vars[varID].opt_grib_int_val[i];
}
}
vlistptr2->vars[varID].opt_grib_dbl_nentries = vlistptr1->vars[varID].opt_grib_dbl_nentries;
for (i=0; i<vlistptr1->vars[varID].opt_grib_dbl_nentries; i++) {
if ( vlistptr1->vars[varID].opt_grib_dbl_keyword[i] ) {
vlistptr2->vars[varID].opt_grib_dbl_keyword[i] = strdupx(vlistptr1->vars[varID].opt_grib_dbl_keyword[i]);
vlistptr2->vars[varID].opt_grib_dbl_val[i] = vlistptr1->vars[varID].opt_grib_dbl_val[i];
}
}
vlistptr2->vars[varID2].atts.nelems = 0;
vlistCopyVarAtts(vlistID1, varID, vlistID2, varID2);
......@@ -719,6 +769,26 @@ void vlistCat(int vlistID2, int vlistID1)
memcpy(vlistptr2->vars[varID2].ensdata, vlistptr1->vars[varID].ensdata, sizeof(ensinfo_t));
}
/* ---------------------------------- */
/* Local change: 2013-01-28, FP (DWD) */
/* ---------------------------------- */
int i;
vlistptr2->vars[varID].opt_grib_int_nentries = vlistptr1->vars[varID].opt_grib_int_nentries;
for (i=0; i<vlistptr1->vars[varID].opt_grib_int_nentries; i++) {
if ( vlistptr1->vars[varID].opt_grib_int_keyword[i] ) {
vlistptr2->vars[varID].opt_grib_int_keyword[i] = strdupx(vlistptr1->vars[varID].opt_grib_int_keyword[i]);
vlistptr2->vars[varID].opt_grib_int_val[i] = vlistptr1->vars[varID].opt_grib_int_val[i];
}
}
vlistptr2->vars[varID].opt_grib_dbl_nentries = vlistptr1->vars[varID].opt_grib_dbl_nentries;
for (i=0; i<vlistptr1->vars[varID].opt_grib_dbl_nentries; i++) {
if ( vlistptr1->vars[varID].opt_grib_dbl_keyword[i] ) {
vlistptr2->vars[varID].opt_grib_dbl_keyword[i] = strdupx(vlistptr1->vars[varID].opt_grib_dbl_keyword[i]);
vlistptr2->vars[varID].opt_grib_dbl_val[i] = vlistptr1->vars[varID].opt_grib_dbl_val[i];
}
}
vlistptr2->vars[varID2].atts.nelems = 0;
vlistCopyVarAtts(vlistID1, varID, vlistID2, varID2);
......
......@@ -68,6 +68,13 @@ typedef struct
}
ensinfo_t;
/* ---------------------------------- */
/* Local change: 2013-01-28, FP (DWD) */
/* ---------------------------------- */
/* Length of optional keyword/value pair list */
#define MAX_OPT_GRIB_ENTRIES 50
typedef struct
{
......@@ -107,6 +114,18 @@ typedef struct
int decoSize;
deco_t *deco;
/* ---------------------------------- */
/* Local change: 2013-01-28, FP (DWD) */
/* ---------------------------------- */
/* (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];
}
var_t;
......
......@@ -63,6 +63,20 @@ void vlistvarInitEntry(int vlistID, int varID)
vlistptr->vars[varID].iorank = CDI_UNDEFID;
vlistptr->vars[varID].decoSize = 0;
vlistptr->vars[varID].deco = NULL;
/* ---------------------------------- */
/* Local change: 2013-01-28, FP (DWD) */
/* ---------------------------------- */
vlistptr->vars[varID].opt_grib_dbl_nentries = 0;
vlistptr->vars[varID].opt_grib_int_nentries = 0;
int i;
for (i=0; i<MAX_OPT_GRIB_ENTRIES; i++) {
vlistptr->vars[varID].opt_grib_dbl_val[i] = 0.0;
vlistptr->vars[varID].opt_grib_int_val[i] = 0;
vlistptr->vars[varID].opt_grib_int_keyword[i] = NULL;
vlistptr->vars[varID].opt_grib_dbl_keyword[i] = NULL;
} // for
}
static
......@@ -1798,6 +1812,42 @@ int vlistInqVarEnsemble( int vlistID, int varID, int *ensID, int *ensCount, int
return (status);
}
/* ---------------------------------- */
/* Local change: 2013-01-28, FP (DWD) */
/* ---------------------------------- */
/* vlistDefVarIntKey: Set an arbitrary keyword/integer value pair for GRIB API */
void vlistDefVarIntKey(int vlistID, int varID, const char *name, int value)
{
vlist_t *vlistptr;
vlistptr = vlist_to_pointer(vlistID);
int idx = vlistptr->vars[varID].opt_grib_int_nentries;
vlistptr->vars[varID].opt_grib_int_nentries++;
if ( idx >= MAX_OPT_GRIB_ENTRIES ) Error("Too many optional keyword/integer value pairs!");
vlistptr->vars[varID].opt_grib_int_val[idx] = value;
if ( name )
vlistptr->vars[varID].opt_grib_int_keyword[idx] = strdupx(name);
else
Error("Internal error!");
}
/* vlistDefVarDblKey: Set an arbitrary keyword/double value pair for GRIB API */
void vlistDefVarDblKey(int vlistID, int varID, const char *name, double value)
{
vlist_t *vlistptr;
vlistptr = vlist_to_pointer(vlistID);
int idx = vlistptr->vars[varID].opt_grib_dbl_nentries;
vlistptr->vars[varID].opt_grib_dbl_nentries++;
if ( idx >= MAX_OPT_GRIB_ENTRIES ) Error("Too many optional keyword/double value pairs!");
vlistptr->vars[varID].opt_grib_dbl_val[idx] = value;
if ( name )
vlistptr->vars[varID].opt_grib_dbl_keyword[idx] = strdupx(name);
else
Error("Internal error!");
}
void vlistDefVarDeco ( int vlistID, int varID, int decoSize, deco_t * deco )
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment