Commit 127b980f authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

more gribapi stuff

parent 82f1823d
......@@ -9,7 +9,7 @@ The following different Grid types are available:
\item[{\large\tt GRID\_GENERIC }] Generic user defined grid
\item[{\large\tt GRID\_GAUSSIAN }] Gaussian latitude/longitude grid
\item[{\large\tt GRID\_LONLAT }] Equidistant longitude/latitude grid
\item[{\large\tt GRID\_LAMBERT }] Lambert conformal grid
\item[{\large\tt GRID\_LCC }] Lambert conformal conic grid
\item[{\large\tt GRID\_SPECTRAL }] Spherical harmonic coefficients
\item[{\large\tt GRID\_GME }] Icosahedral-hexagonal GME grid
\item[{\large\tt GRID\_CURVILINEAR}] Curvilinear grid
......
......@@ -2,7 +2,7 @@
This section describes how to build the {\CDI} library from the sources on a UNIX system.
{\CDI} is using the GNU configure and build system to compile the source code.
The only requirement is a working ANSI C compiler.
The only requirement is a working ANSI C99 compiler.
First go to the \href{http://www.mpimet.mpg.de/cdi}{\tt download} page
({\tt http://www.mpimet.mpg.de/cdi}) to get the latest distribution,
......
......@@ -5,32 +5,28 @@
/* Level Types */
#define GRIBAPI_LTYPE_SURFACE 1
#define GRIBAPI_LTYPE_99 99
#define GRIBAPI_LTYPE_ISOBARIC 100
#define GRIBAPI_LTYPE_MEANSEA 102
#define GRIBAPI_LTYPE_ALTITUDE 103
#define GRIBAPI_LTYPE_HEIGHT 105
#define GRIBAPI_LTYPE_SIGMA 107
#define GRIBAPI_LTYPE_HYBRID 109
#define GRIBAPI_LTYPE_HYBRID_LAYER 110
#define GRIBAPI_LTYPE_LANDDEPTH 111
#define GRIBAPI_LTYPE_LANDDEPTH_LAYER 112
#define GRIBAPI_LTYPE_ISENTROPIC 113
#define GRIBAPI_LTYPE_MEANSEA 101
#define GRIBAPI_LTYPE_ALTITUDE 102
#define GRIBAPI_LTYPE_HEIGHT 103
#define GRIBAPI_LTYPE_SIGMA 104
#define GRIBAPI_LTYPE_HYBRID 105
#define GRIBAPI_LTYPE_LANDDEPTH 106
#define GRIBAPI_LTYPE_ISENTROPIC 107
#define GRIBAPI_LTYPE_SEADEPTH 160
#define GRIBAPI_LTYPE_99_MARGIN 1000
/*
* Data representation type (Grid Type)
*/
#define GRIBAPI_GTYPE_LATLON 0 /* latitude/longitude */
#define GRIBAPI_GTYPE_LATLON_ROT 10 /* rotated latitude/longitude */
#define GRIBAPI_GTYPE_LATLON_STR 20 /* stretched latitude/longitude */
#define GRIBAPI_GTYPE_LATLON_ROTSTR 30 /* rotated and stretched latitude/longitude */
#define GRIBAPI_GTYPE_LATLON_ROT 1 /* rotated latitude/longitude */
#define GRIBAPI_GTYPE_LATLON_STR 2 /* stretched latitude/longitude */
#define GRIBAPI_GTYPE_LATLON_ROTSTR 3 /* rotated and stretched latitude/longitude */
#define GRIBAPI_GTYPE_GAUSSIAN 40 /* gaussian grid */
#define GRIBAPI_GTYPE_GAUSSIAN_ROT 14 /* rotated gaussian grid */
#define GRIBAPI_GTYPE_GAUSSIAN_STR 24 /* stretched gaussian grid */
#define GRIBAPI_GTYPE_GAUSSIAN_ROTSTR 34 /* rotated and stretched gaussian grid */
#define GRIBAPI_GTYPE_LCC 3 /* Lambert conformal */
#define GRIBAPI_GTYPE_GAUSSIAN_ROT 41 /* rotated gaussian grid */
#define GRIBAPI_GTYPE_GAUSSIAN_STR 42 /* stretched gaussian grid */
#define GRIBAPI_GTYPE_GAUSSIAN_ROTSTR 43 /* rotated and stretched gaussian grid */
#define GRIBAPI_GTYPE_LCC 30 /* Lambert conformal */
#define GRIBAPI_GTYPE_SPECTRAL 50 /* spherical harmonics */
#define GRIBAPI_GTYPE_GME 192 /* hexagonal GME grid */
......
......@@ -5030,20 +5030,28 @@ int cdfInqContents(int streamID)
}
if ( ncvars[xvarid].ndims > 2 || ncvars[yvarid].ndims > 2 )
{
Warning(func, "Unsupported grid structure for variable %s (grid dims > 2)!",
ncvars[ncvarid].name);
ncvars[ncvarid].xvarid = UNDEFID;
ncvars[ncvarid].yvarid = UNDEFID;
xvarid = UNDEFID;
yvarid = UNDEFID;
{
if ( ncvars[xvarid].ndims == 3 && ncvars[xvarid].dimids[0] == timedimid &&
ncvars[yvarid].ndims == 3 && ncvars[yvarid].dimids[0] == timedimid )
{
}
else
{
Warning(func, "Unsupported grid structure for variable %s (grid dims > 2)!",
ncvars[ncvarid].name);
ncvars[ncvarid].xvarid = UNDEFID;
ncvars[ncvarid].yvarid = UNDEFID;
xvarid = UNDEFID;
yvarid = UNDEFID;
}
}
}
if ( xvarid != UNDEFID )
{
islon = ncvars[xvarid].islon;
if ( ncvars[xvarid].ndims == 2 )
ndims = ncvars[xvarid].ndims;
if ( ndims == 2 || ndims == 3 )
{
ncvars[ncvarid].gridtype = GRID_CURVILINEAR;
size = xsize*ysize;
......@@ -5051,9 +5059,9 @@ int cdfInqContents(int streamID)
{
int dimid;
size_t dimsize1, dimsize2;
dimid = ncvars[xvarid].dimids[0];
dimid = ncvars[xvarid].dimids[ndims-2];
cdf_inq_dimlen(fileID, dimid, &dimsize1);
dimid = ncvars[xvarid].dimids[1];
dimid = ncvars[xvarid].dimids[ndims-1];
cdf_inq_dimlen(fileID, dimid, &dimsize2);
if ( dimsize1*dimsize2 != size )
{
......@@ -5108,7 +5116,8 @@ int cdfInqContents(int streamID)
if ( yvarid != UNDEFID )
{
islat = ncvars[yvarid].islat;
if ( ncvars[yvarid].ndims == 2 )
ndims = ncvars[yvarid].ndims;
if ( ndims == 2 || ndims == 3 )
{
ncvars[ncvarid].gridtype = GRID_CURVILINEAR;
size = xsize*ysize;
......@@ -5116,9 +5125,9 @@ int cdfInqContents(int streamID)
{
int dimid;
size_t dimsize1, dimsize2;
dimid = ncvars[xvarid].dimids[0];
dimid = ncvars[xvarid].dimids[ndims-2];
cdf_inq_dimlen(fileID, dimid, &dimsize1);
dimid = ncvars[xvarid].dimids[1];
dimid = ncvars[xvarid].dimids[ndims-1];
cdf_inq_dimlen(fileID, dimid, &dimsize2);
if ( dimsize1*dimsize2 != size )
{
......
......@@ -202,6 +202,7 @@ int cgribexGetTimeUnit(int *isec1)
return (timeunit);
}
/*
int cgribexInqRecord(int streamID, int *varID, int *levelID)
{
static char func[] = "cgribexInqRecord";
......@@ -209,15 +210,15 @@ int cgribexInqRecord(int streamID, int *varID, int *levelID)
int fileID;
void *gribbuffer;
int iret = 0, iword = 0;
int isec4size = 0;
int isec0[2], isec1[4096], isec2[4096], isec3[2], isec4[512];
double fsec2[512], fsec3[2], *fsec4 = NULL;
int gridID = -1, zaxisID = -1;
int gridtype;
int gribsize;
size_t readsize;
int vlistID;
stream_t *streamptr;
int isec4size = 0;
int isec0[2], isec1[4096], isec2[4096], isec3[2], isec4[512];
double fsec2[512], fsec3[2], *fsec4 = NULL;
streamptr = stream_to_pointer(streamID);
......@@ -233,6 +234,7 @@ int cgribexInqRecord(int streamID, int *varID, int *levelID)
if ( gribsize == 0 ) return (0);
gribbuffer = streamptr->record->buffer;
printf("size = %d\n", streamptr->record->buffersize);
gribbuffer = realloc(gribbuffer, gribsize);
streamptr->record->buffer = gribbuffer;
......@@ -302,6 +304,7 @@ int cgribexInqRecord(int streamID, int *varID, int *levelID)
return (status);
}
*/
static
void cgribexAddRecord(int streamID, int code, int *isec1, int *isec2, double *fsec2,
......
#ifndef _STREAM_CGRIBEX_H
#define _STREAM_CGRIBEX_H
int cgribexInqRecord(int streamID, int *varID, int *levelID);
void cgribexScanTimestep1(int streamID);
int cgribexScanTimestep2(int streamID);
int cgribexScanTimestep(int streamID);
......
......@@ -13,7 +13,7 @@
#include "file.h"
#include "cgribex.h" /* gribZip gribGetZip gribGinfo */
/*
int grbInqRecord(int streamID, int *varID, int *levelID)
{
int status;
......@@ -22,7 +22,7 @@ int grbInqRecord(int streamID, int *varID, int *levelID)
return (status);
}
*/
int grbDefRecord(int streamID)
{
......
This diff is collapsed.
#ifndef _STREAM_GRIBAPI_H
#define _STREAM_GRIBAPI_H
int gribapiInqRecord(int streamID, int *varID, int *levelID);
void gribapiScanTimestep1(int streamID);
int gribapiScanTimestep2(int streamID);
int gribapiScanTimestep(int streamID);
......
......@@ -311,6 +311,7 @@ void streamReadRecord(int streamID, double *data, int *nmiss)
{
#if defined (HAVE_LIBGRIB)
case FILETYPE_GRB:
case FILETYPE_GRB2:
{
status = grbReadRecord(streamID, data, nmiss);
break;
......
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