Commit 5efc8f2a authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Merge branch 'develop' of git.mpimet.mpg.de:libcdi into develop

parents 14499ed8 852c38d1
......@@ -2,6 +2,18 @@
* Version 1.9.3 released
2018-01-06 Uwe Schulzweida
* Removed CDI function vlistDefVarTimaccu()/vlistInqVarTimaccu().
2018-01-05 Uwe Schulzweida
* Replaced vlistDefVarEnsemble() by cdiDefKeyInt().
* Consistent test for GRIB2 shortName [patch from: Florian Prill]
* Added support for GRIB2 keys shapeOfTheEarth and typeOfProcessedData
* Replaced vlistDefVarProductDefinitionTemplate() by cdiDefKeyInt().
* Replaced vlistDefVarTypeOfGeneratingProcess() by cdiDefKeyInt().
2018-01-04 Uwe Schulzweida
* GRIB2: use typeOfSecondFixedSurface if present
......
......@@ -21,7 +21,6 @@ int main(void)
size_t nmiss;
int instID;
int i1,i2,i3;
size_t datasize = (size_t)nlon * (size_t)nlat;
data = (double *) malloc(datasize * sizeof (double));
......@@ -37,11 +36,18 @@ int main(void)
vlistID = vlistCreate();
varID = vlistDefVar(vlistID, gridID, zaxisID, TIME_VARYING);
int perturbationNumber = 1;
int numberOfForecastsInEnsemble = 2;
int typeOfEnsembleForecast = 3;
vlistDefVarEnsemble( vlistID, varID, 1, 2, 3);
vlistInqVarEnsemble( vlistID, varID, &i1,&i2,&i3);
cdiDefKeyInt(vlistID, varID, CDI_KEY_TYPEOFENSEMBLEFORECAST, typeOfEnsembleForecast);
cdiDefKeyInt(vlistID, varID, CDI_KEY_NUMBEROFFORECASTSINENSEMBLE, numberOfForecastsInEnsemble);
cdiDefKeyInt(vlistID, varID, CDI_KEY_PERTURBATIONNUMBER, perturbationNumber);
cdiInqKeyInt(vlistID, varID, CDI_KEY_PERTURBATIONNUMBER, &perturbationNumber);
cdiInqKeyInt(vlistID, varID, CDI_KEY_NUMBEROFFORECASTSINENSEMBLE, &numberOfForecastsInEnsemble);
cdiInqKeyInt(vlistID, varID, CDI_KEY_TYPEOFENSEMBLEFORECAST, &typeOfEnsembleForecast);
vlistDefInstitut( vlistID,instID );
......
......@@ -3,9 +3,6 @@
#include <stdbool.h>
void str_tolower(char *str);
bool str_is_equal(const char *vstr, const char *cstr);
int get_timeunit(size_t len, const char *ptu);
bool is_time_units(const char *timeunits);
......
......@@ -332,7 +332,6 @@ int cdfDefVar(stream_t *streamptr, int varID)
int dimorder[3];
size_t iax = 0;
char axis[5];
int ensID, ensCount, forecast_type;
int fileID = streamptr->fileID;
......@@ -750,15 +749,13 @@ int cdfDefVar(stream_t *streamptr, int varID)
}
}
if ( vlistInqVarEnsemble( vlistID, varID, &ensID, &ensCount, &forecast_type ) )
{
/* void cdf_put_att_int( int ncid, int varid, const char *name, nc_type xtype,
size_t len, const int *ip )
*/
cdf_put_att_int(fileID, ncvarid, "realization", NC_INT, 1, &ensID);
cdf_put_att_int(fileID, ncvarid, "ensemble_members", NC_INT, 1, &ensCount);
cdf_put_att_int(fileID, ncvarid, "forecast_init_type", NC_INT, 1, &forecast_type);
}
int perturbationNumber, numberOfForecastsInEnsemble, typeOfEnsembleForecast;
if ( cdiInqKeyInt(vlistID, varID, CDI_KEY_PERTURBATIONNUMBER, &perturbationNumber) == 0 )
cdf_put_att_int(fileID, ncvarid, "realization", NC_INT, 1, &perturbationNumber);
if ( cdiInqKeyInt(vlistID, varID, CDI_KEY_NUMBEROFFORECASTSINENSEMBLE, &numberOfForecastsInEnsemble) == 0 )
cdf_put_att_int(fileID, ncvarid, "ensemble_members", NC_INT, 1, &numberOfForecastsInEnsemble);
if ( cdiInqKeyInt(vlistID, varID, CDI_KEY_TYPEOFENSEMBLEFORECAST, &typeOfEnsembleForecast) == 0 )
cdf_put_att_int(fileID, ncvarid, "forecast_init_type", NC_INT, 1, &typeOfEnsembleForecast);
/* Attributes */
cdfDefineAttributes(vlistID, varID, fileID, ncvarid);
......
......@@ -662,14 +662,6 @@ double vlistInqVarAddoffset(int vlistID, int varID);
void vlistDefVarTimave(int vlistID, int varID, int timave);
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);
void vlistDefVarProductDefinitionTemplate(int vlistID, int varID, int productDefinitionTemplate);
int vlistInqVarProductDefinitionTemplate(int vlistID, int varID);
size_t vlistInqVarSize(int vlistID, int varID);
......@@ -682,10 +674,6 @@ int vlistFindLevel(int vlistID, int fvarID, int flevelID);
int vlistMergedVar(int vlistID, int varID);
int vlistMergedLevel(int vlistID, int varID, int levelID);
/* Ensemble info routines */
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);
/* cdiClearAdditionalKeys: Clear the list of additional GRIB keys. */
void cdiClearAdditionalKeys(void);
/* cdiDefAdditionalKey: Register an additional GRIB key which is read when file is opened. */
......@@ -809,9 +797,17 @@ int gridInqYIsc(int gridID);
/* gridInqYCvals: Get strings from Y-axis in case grid is of type GRID_CHARXY */
size_t gridInqYCvals(int gridID, char *ycvals[]);
// CDI var key values
#define CDI_KEY_TABLESVERSION 801 // GRIB2 tablesVersion
#define CDI_KEY_LOCALTABLESVERSION 802 // GRIB2 localTablesVersion
// CDI var keys
#define CDI_KEY_TABLESVERSION 801 // GRIB2 tablesVersion
#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
#define CDI_KEY_TYPEOFENSEMBLEFORECAST 808 // GRIB2 typeOfEnsembleForecast
#define CDI_KEY_NUMBEROFFORECASTSINENSEMBLE 809 // GRIB2 numberOfForecastsInEnsemble
#define CDI_KEY_PERTURBATIONNUMBER 810 // GRIB2 perturbationNumber
// cdiDefKeyInt: Define a CDI varianble integer value from a key
int cdiDefKeyInt(int cdiID, int varID, int key, int value);
......@@ -819,7 +815,7 @@ int cdiDefKeyInt(int cdiID, int varID, int key, int value);
// cdiInqKeyInt: Get a CDI variable integer value from a key
int cdiInqKeyInt(int cdiID, int varID, int key, int *value);
// CDI grid key values
// CDI grid keys
#define CDI_KEY_XNAME 901 // X-axis name
#define CDI_KEY_XDIMNAME 902 // X-axis dimension name
#define CDI_KEY_XLONGNAME 903 // X-axis longname
......@@ -832,7 +828,7 @@ int cdiInqKeyInt(int cdiID, int varID, int key, int *value);
#define CDI_KEY_MAPPING 921 // Grid mapping var name
#define CDI_KEY_MAPNAME 922 // Grid mapping name
// CDI zaxis key values
// CDI zaxis keys
#define CDI_KEY_NAME 941 // Z-axis name
#define CDI_KEY_DIMNAME 942 // Z-axis dimension name
#define CDI_KEY_LONGNAME 943 // Z-axis longname
......@@ -841,8 +837,6 @@ int cdiInqKeyInt(int cdiID, int varID, int key, int *value);
#define CDI_KEY_P0NAME 951 // Z-axis reference pressure name
#define CDI_KEY_P0VALUE 952 // Z-axis reference pressure in Pa
// CDI var key values
// cdiGridDefKeyStr: Define a CDI grid string value from a key
int cdiGridDefKeyStr(int gridID, int key, int size, const char *mesg);
......
! This file was automatically generated, don't edit!
!
! Fortran interface for CDI library version 1.9.2
! Fortran interface for CDI library version 1.9.3
!
! Author:
! -------
! Uwe Schulzweida, MPI-MET, Hamburg, November 2017
! Uwe Schulzweida, MPI-MET, Hamburg, January 2018
!
INTEGER CDI_MAX_NAME
......@@ -1248,39 +1248,6 @@
! INTEGER varID)
EXTERNAL vlistInqVarTimave
! vlistDefVarTimaccu
! (INTEGER vlistID,
! INTEGER varID,
! INTEGER timaccu)
EXTERNAL vlistDefVarTimaccu
INTEGER vlistInqVarTimaccu
! (INTEGER vlistID,
! INTEGER varID)
EXTERNAL vlistInqVarTimaccu
! vlistDefVarTypeOfGeneratingProcess
! (INTEGER vlistID,
! INTEGER varID,
! INTEGER typeOfGeneratingProcess)
EXTERNAL vlistDefVarTypeOfGeneratingProcess
INTEGER vlistInqVarTypeOfGeneratingProcess
! (INTEGER vlistID,
! INTEGER varID)
EXTERNAL vlistInqVarTypeOfGeneratingProcess
! vlistDefVarProductDefinitionTemplate
! (INTEGER vlistID,
! INTEGER varID,
! INTEGER productDefinitionTemplate)
EXTERNAL vlistDefVarProductDefinitionTemplate
INTEGER vlistInqVarProductDefinitionTemplate
! (INTEGER vlistID,
! INTEGER varID)
EXTERNAL vlistInqVarProductDefinitionTemplate
INTEGER vlistInqVarSize
! (INTEGER vlistID,
! INTEGER varID)
......@@ -1334,25 +1301,6 @@
! INTEGER levelID)
EXTERNAL vlistMergedLevel
!
! Ensemble info routines
!
! vlistDefVarEnsemble
! (INTEGER vlistID,
! INTEGER varID,
! INTEGER ensID,
! INTEGER ensCount,
! INTEGER forecast_type)
EXTERNAL vlistDefVarEnsemble
INTEGER vlistInqVarEnsemble
! (INTEGER vlistID,
! INTEGER varID,
! INTEGER ensID,
! INTEGER ensCount,
! INTEGER forecast_type)
EXTERNAL vlistInqVarEnsemble
! cdiClearAdditionalKeys
EXTERNAL cdiClearAdditionalKeys
......@@ -1603,9 +1551,40 @@
! (INTEGER gridID)
EXTERNAL gridInqYIsc
!
! CDI grid string key values
!
INTEGER CDI_KEY_TABLESVERSION
PARAMETER (CDI_KEY_TABLESVERSION = 801)
INTEGER CDI_KEY_LOCALTABLESVERSION
PARAMETER (CDI_KEY_LOCALTABLESVERSION = 802)
INTEGER CDI_KEY_TYPEOFGENERATINGPROCESS
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 CDI_KEY_TYPEOFENSEMBLEFORECAST
PARAMETER (CDI_KEY_TYPEOFENSEMBLEFORECAST = 808)
INTEGER CDI_KEY_NUMBEROFFORECASTSINENSEMBLE
PARAMETER (CDI_KEY_NUMBEROFFORECASTSINENSEMBLE = 809)
INTEGER CDI_KEY_PERTURBATIONNUMBER
PARAMETER (CDI_KEY_PERTURBATIONNUMBER = 810)
INTEGER cdiDefKeyInt
! (INTEGER cdiID,
! INTEGER varID,
! INTEGER key,
! INTEGER value)
EXTERNAL cdiDefKeyInt
INTEGER cdiInqKeyInt
! (INTEGER cdiID,
! INTEGER varID,
! INTEGER key,
! INTEGER value)
EXTERNAL cdiInqKeyInt
INTEGER CDI_KEY_XNAME
PARAMETER (CDI_KEY_XNAME = 901)
INTEGER CDI_KEY_XDIMNAME
......@@ -1628,9 +1607,6 @@
PARAMETER (CDI_KEY_MAPPING = 921)
INTEGER CDI_KEY_MAPNAME
PARAMETER (CDI_KEY_MAPNAME = 922)
!
! CDI zaxis string key values
!
INTEGER CDI_KEY_NAME
PARAMETER (CDI_KEY_NAME = 941)
INTEGER CDI_KEY_DIMNAME
......@@ -1659,6 +1635,20 @@
! CHARACTER*(*) mesg)
EXTERNAL cdiGridInqKeyStr
INTEGER cdiZaxisDefKeyStr
! (INTEGER zaxisID,
! INTEGER key,
! INTEGER size,
! CHARACTER*(*) mesg)
EXTERNAL cdiZaxisDefKeyStr
INTEGER cdiZaxisInqKeyStr
! (INTEGER zaxisID,
! INTEGER key,
! INTEGER size,
! CHARACTER*(*) mesg)
EXTERNAL cdiZaxisInqKeyStr
INTEGER cdiZaxisDefKeyFlt
! (INTEGER zaxisID,
! INTEGER key,
......@@ -2067,20 +2057,6 @@
! INTEGER*1(16) uuid)
EXTERNAL zaxisInqUUID
INTEGER cdiZaxisDefKeyStr
! (INTEGER zaxisID,
! INTEGER key,
! INTEGER size,
! CHARACTER*(*) mesg)
EXTERNAL cdiZaxisDefKeyStr
INTEGER cdiZaxisInqKeyStr
! (INTEGER zaxisID,
! INTEGER key,
! INTEGER size,
! CHARACTER*(*) mesg)
EXTERNAL cdiZaxisInqKeyStr
! zaxisDefName
! (INTEGER zaxisID,
! CHARACTER*(*) name_optional)
......
......@@ -360,12 +360,6 @@ FCALLSCSUB3 (vlistDefVarAddoffset, VLISTDEFVARADDOFFSET, vlistdefvaraddoffset, I
FCALLSCFUN2 (DOUBLE, vlistInqVarAddoffset, VLISTINQVARADDOFFSET, vlistinqvaraddoffset, INT, INT)
FCALLSCSUB3 (vlistDefVarTimave, VLISTDEFVARTIMAVE, vlistdefvartimave, INT, 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)
FCALLSCSUB3 (vlistDefVarProductDefinitionTemplate, VLISTDEFVARPRODUCTDEFINITIONTEMPLATE, vlistdefvarproductdefinitiontemplate, INT, INT, INT)
FCALLSCFUN2 (INT, vlistInqVarProductDefinitionTemplate, VLISTINQVARPRODUCTDEFINITIONTEMPLATE, vlistinqvarproductdefinitiontemplate, INT, INT)
static int vlistInqVarSize_fwrap(int vlistID, int varID)
{
size_t v;
......@@ -381,11 +375,6 @@ FCALLSCFUN2 (INT, vlistFindVar, VLISTFINDVAR, vlistfindvar, INT, INT)
FCALLSCFUN3 (INT, vlistFindLevel, VLISTFINDLEVEL, vlistfindlevel, INT, INT, INT)
FCALLSCFUN2 (INT, vlistMergedVar, VLISTMERGEDVAR, vlistmergedvar, INT, INT)
FCALLSCFUN3 (INT, vlistMergedLevel, VLISTMERGEDLEVEL, vlistmergedlevel, INT, INT, INT)
/* Ensemble info routines */
FCALLSCSUB5 (vlistDefVarEnsemble, VLISTDEFVARENSEMBLE, vlistdefvarensemble, INT, INT, INT, INT, INT)
FCALLSCFUN5 (INT, vlistInqVarEnsemble, VLISTINQVARENSEMBLE, vlistinqvarensemble, INT, INT, PINT, PINT, PINT)
FCALLSCSUB0 (cdiClearAdditionalKeys, CDICLEARADDITIONALKEYS, cdiclearadditionalkeys)
FCALLSCSUB1 (cdiDefAdditionalKey, CDIDEFADDITIONALKEY, cdidefadditionalkey, STRING)
FCALLSCSUB4 (vlistDefVarIntKey, VLISTDEFVARINTKEY, vlistdefvarintkey, INT, INT, STRING, INT)
......@@ -481,14 +470,12 @@ static int gridInqYvals_fwrap(int gridID, double yvals[])
}
FCALLSCFUN2 (INT, gridInqYvals_fwrap, GRIDINQYVALS, gridinqyvals, INT, DOUBLEV)
FCALLSCFUN1 (INT, gridInqYIsc, GRIDINQYISC, gridinqyisc, INT)
/* CDI grid string key values */
/* CDI zaxis string key values */
FCALLSCFUN4 (INT, cdiDefKeyInt, CDIDEFKEYINT, cdidefkeyint, INT, INT, INT, INT)
FCALLSCFUN4 (INT, cdiInqKeyInt, CDIINQKEYINT, cdiinqkeyint, INT, INT, INT, PINT)
FCALLSCFUN4 (INT, cdiGridDefKeyStr, CDIGRIDDEFKEYSTR, cdigriddefkeystr, INT, INT, INT, STRING)
FCALLSCFUN4 (INT, cdiGridInqKeyStr, CDIGRIDINQKEYSTR, cdigridinqkeystr, INT, INT, INT, PSTRING)
FCALLSCFUN4 (INT, cdiZaxisDefKeyStr, CDIZAXISDEFKEYSTR, cdizaxisdefkeystr, INT, INT, INT, STRING)
FCALLSCFUN4 (INT, cdiZaxisInqKeyStr, CDIZAXISINQKEYSTR, cdizaxisinqkeystr, INT, INT, INT, PSTRING)
FCALLSCFUN3 (INT, cdiZaxisDefKeyFlt, CDIZAXISDEFKEYFLT, cdizaxisdefkeyflt, INT, INT, DOUBLE)
FCALLSCFUN3 (INT, cdiZaxisInqKeyFlt, CDIZAXISINQKEYFLT, cdizaxisinqkeyflt, INT, INT, PDOUBLE)
FCALLSCSUB2 (gridDefXname, GRIDDEFXNAME, griddefxname, INT, STRING)
......@@ -604,8 +591,6 @@ FCALLSCSUB2 (zaxisDefNumber, ZAXISDEFNUMBER, zaxisdefnumber, INT, INT)
FCALLSCFUN1 (INT, zaxisInqNumber, ZAXISINQNUMBER, zaxisinqnumber, INT)
FCALLSCSUB2 (zaxisDefUUID, ZAXISDEFUUID, zaxisdefuuid, INT, PVOID)
FCALLSCSUB2 (zaxisInqUUID, ZAXISINQUUID, zaxisinquuid, INT, PVOID)
FCALLSCFUN4 (INT, cdiZaxisDefKeyStr, CDIZAXISDEFKEYSTR, cdizaxisdefkeystr, INT, INT, INT, STRING)
FCALLSCFUN4 (INT, cdiZaxisInqKeyStr, CDIZAXISINQKEYSTR, cdizaxisinqkeystr, INT, INT, INT, PSTRING)
FCALLSCSUB2 (zaxisDefName, ZAXISDEFNAME, zaxisdefname, INT, STRING)
FCALLSCSUB2 (zaxisInqName, ZAXISINQNAME, zaxisinqname, INT, PSTRING)
FCALLSCSUB2 (zaxisDefLongname, ZAXISDEFLONGNAME, zaxisdeflongname, INT, STRING)
......
......@@ -18,7 +18,7 @@
#include "cdf_config.h"
/* dummy use of unused parameters to silence compiler warnings */
#ifndef UNUSED
#ifndef UNUSED
#define UNUSED(x) (void)x
#endif
......@@ -38,6 +38,9 @@ char *strdup(const char *s);
*/
#endif
void str_tolower(char *str);
bool str_is_equal(const char *vstr, const char *cstr);
#ifndef M_PI
#define M_PI 3.14159265358979323846 /* pi */
#endif
......
#ifndef _GRID_H
#define _GRID_H
#ifndef GRID_H
#define GRID_H
#include "cdi.h"
#include <stdbool.h>
......
......@@ -15,7 +15,7 @@
#endif
//#include "config.h"
#define VERSION "1.9.2"
#define VERSION "1.9.3"
typedef struct
{
size_t naline;
......
......@@ -109,7 +109,9 @@ typedef struct {
char stdname[CDI_MAX_NAME];
char units[CDI_MAX_NAME];
char extra[CDI_MAX_NAME];
ensinfo_t *ensdata; /* Ensemble information */
int typeOfEnsembleForecast;
int numberOfForecastsInEnsemble;
int perturbationNumber;
}
ncvar_t;
......@@ -692,7 +694,9 @@ void init_ncvars(long nvars, ncvar_t *ncvars)
ncvars[ncvarid].lvalidrange = false;
ncvars[ncvarid].validrange[0] = VALIDMISS;
ncvars[ncvarid].validrange[1] = VALIDMISS;
ncvars[ncvarid].ensdata = NULL;
ncvars[ncvarid].typeOfEnsembleForecast = -1;
ncvars[ncvarid].numberOfForecastsInEnsemble = -1;
ncvars[ncvarid].perturbationNumber = -1;
memset(ncvars[ncvarid].name, 0, CDI_MAX_NAME);
memset(ncvars[ncvarid].longname, 0, CDI_MAX_NAME);
memset(ncvars[ncvarid].stdname, 0, CDI_MAX_NAME);
......@@ -1537,18 +1541,11 @@ void cdf_scan_var_attr(int nvars, ncvar_t *ncvars, ncdim_t *ncdims, int timedimi
strcmp(attname, "forecast_init_type") == 0) )
{
int temp;
if( ncvars[ncvarid].ensdata == NULL )
ncvars[ncvarid].ensdata = (ensinfo_t *) Malloc( sizeof( ensinfo_t ) );
cdfGetAttInt(ncid, ncvarid, attname, 1, &temp);
if( strcmp(attname, "realization") == 0 )
ncvars[ncvarid].ensdata->ens_index = temp;
else if( strcmp(attname, "ensemble_members") == 0 )
ncvars[ncvarid].ensdata->ens_count = temp;
else if( strcmp(attname, "forecast_init_type") == 0 )
ncvars[ncvarid].ensdata->forecast_init_type = temp;
if ( strcmp(attname, "realization") == 0 ) ncvars[ncvarid].perturbationNumber = temp;
else if ( strcmp(attname, "ensemble_members") == 0 ) ncvars[ncvarid].numberOfForecastsInEnsemble = temp;
else if ( strcmp(attname, "forecast_init_type") == 0 ) ncvars[ncvarid].typeOfEnsembleForecast = temp;
cdf_set_var(ncvars, ncvarid, TRUE);
}
......@@ -3180,13 +3177,11 @@ void cdf_define_all_vars(stream_t *streamptr, int vlistID, int instID, int model
printf("dimids: %d %d\n", i, dimids[i]);
printf("xdimid, ydimid %d %d\n", xdimid, ydimid);
*/
if ( ncvars[ncvarid].ensdata != NULL )
if ( ncvars[ncvarid].numberOfForecastsInEnsemble != -1 )
{
vlistDefVarEnsemble( vlistID, varID, ncvars[ncvarid].ensdata->ens_index,
ncvars[ncvarid].ensdata->ens_count,
ncvars[ncvarid].ensdata->forecast_init_type );
Free(ncvars[ncvarid].ensdata);
ncvars[ncvarid].ensdata = NULL;
cdiDefKeyInt(vlistID, varID, CDI_KEY_TYPEOFENSEMBLEFORECAST, ncvars[ncvarid].typeOfEnsembleForecast);
cdiDefKeyInt(vlistID, varID, CDI_KEY_NUMBEROFFORECASTSINENSEMBLE, ncvars[ncvarid].numberOfForecastsInEnsemble);
cdiDefKeyInt(vlistID, varID, CDI_KEY_PERTURBATIONNUMBER, ncvars[ncvarid].perturbationNumber);
}
if ( ncvars[ncvarid].extra[0] != 0 )
......
......@@ -2054,8 +2054,6 @@ void cgribexDefaultSec4(int *isec4)
static
void cgribexDefEnsembleVar(int *isec1, int vlistID, int varID)
{
int ensID, ensCount, forecast_type;
/* For Ensemble info */
//Put1Byte(isec1[36]); /* MPIM local GRIB use definition identifier */
......@@ -2064,16 +2062,21 @@ void cgribexDefEnsembleVar(int *isec1, int vlistID, int varID)
//Put2Byte(isec1[38]); /* individual ensemble member */
//Put2Byte(isec1[39]); /* number of forecasts in ensemble */
if ( vlistInqVarEnsemble(vlistID, varID, &ensID, &ensCount, &forecast_type) )
int perturbationNumber, numberOfForecastsInEnsemble, typeOfEnsembleForecast;
int r1 = cdiInqKeyInt(vlistID, varID, CDI_KEY_PERTURBATIONNUMBER, &perturbationNumber);
int r2 = cdiInqKeyInt(vlistID, varID, CDI_KEY_NUMBEROFFORECASTSINENSEMBLE, &numberOfForecastsInEnsemble);
int r3 = cdiInqKeyInt(vlistID, varID, CDI_KEY_TYPEOFENSEMBLEFORECAST, &typeOfEnsembleForecast);
if ( r1 == 0 && r2 == 0 && r3 == 0 )
{
if ( ISEC1_CenterID == 252 )
{
ISEC1_LocalFLag = 1;
isec1[36] = 1;
isec1[37] = forecast_type;
isec1[38] = ensID;
isec1[39] = ensCount;
isec1[37] = typeOfEnsembleForecast;
isec1[38] = perturbationNumber;
isec1[39] = numberOfForecastsInEnsemble;
}
}
}
......
......@@ -2,7 +2,7 @@
#include "config.h"
#endif
#ifdef HAVE_LIBGRIB_API
#ifdef HAVE_LIBGRIB_API
#include "dmemory.h"
#include "cdi.h"
#include "cdi_int.h"
......@@ -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 )
varDefTypeOfGeneratingProcess(varID, (int) typeOfGeneratingProcess);
long productDefinitionTemplate = 0;
if ( grib_get_long(gh, "productDefinitionTemplateNumber", &productDefinitionTemplate) == 0 )
varDefProductDefinitionTemplate(varID, (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);