Commit 078c97bb authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

add env CDI_SORTNAME to sort netCDF names

parent 87d582ae
2009-??-?? Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* add env CDI_SORTNAME to sort netCDF names
* Version 1.3.2 released
2009-04-16 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* using GRIB library version 1.3.0
......
......@@ -169,7 +169,7 @@ void cdiPrintVersion(void);
void cdiDefMissval(double missval);
double cdiInqMissval(void);
int cdiDefGlobal(const char *string, int val);
void cdiDefGlobal(const char *string, int val);
/* STREAM control routines */
......
......@@ -4,7 +4,7 @@
!
! Author:
! -------
! Uwe Schulzweida, MPI-MET, Hamburg, January 2009
! Uwe Schulzweida, MPI-MET, Hamburg, April 2009
!
INTEGER CDI_UNDEFID
......@@ -186,10 +186,12 @@
PARAMETER (GRID_CURVILINEAR = 10)
INTEGER GRID_LCC
PARAMETER (GRID_LCC = 11)
INTEGER GRID_LCC2
PARAMETER (GRID_LCC2 = 12)
INTEGER GRID_LAEA
PARAMETER (GRID_LAEA = 12)
PARAMETER (GRID_LAEA = 13)
INTEGER GRID_SINUSOIDAL
PARAMETER (GRID_SINUSOIDAL = 13)
PARAMETER (GRID_SINUSOIDAL = 14)
!
! ZAXIS types
!
......@@ -248,21 +250,23 @@
PARAMETER (TUNIT_MONTH = 5)
INTEGER TUNIT_YEAR
PARAMETER (TUNIT_YEAR = 6)
INTEGER TUNIT_QUARTER
PARAMETER (TUNIT_QUARTER = 7)
!
! CALENDAR types
!
INTEGER CALENDAR_STANDARD
PARAMETER (CALENDAR_STANDARD = 0)
INTEGER CALENDAR_NONE
PARAMETER (CALENDAR_NONE = 1)
INTEGER CALENDAR_PROLEPTIC
PARAMETER (CALENDAR_PROLEPTIC = 1)
INTEGER CALENDAR_360DAYS
PARAMETER (CALENDAR_360DAYS = 2)
INTEGER CALENDAR_365DAYS
PARAMETER (CALENDAR_365DAYS = 3)
INTEGER CALENDAR_366DAYS
PARAMETER (CALENDAR_366DAYS = 4)
INTEGER CALENDAR_PROLEPTIC
PARAMETER (CALENDAR_PROLEPTIC = 5)
INTEGER CALENDAR_NONE
PARAMETER (CALENDAR_NONE = 5)
!
! CDI control routines
!
......@@ -287,7 +291,7 @@
DOUBLEPRECISION cdiInqMissval
EXTERNAL cdiInqMissval
INTEGER cdiDefGlobal
! cdiDefGlobal
! (CHARACTER*(*) string,
! INTEGER val)
EXTERNAL cdiDefGlobal
......@@ -1223,7 +1227,7 @@
EXTERNAL gridDefGMEni3
!
! Lambert Conformal Conic grid
! Lambert Conformal Conic grid (GRIB version)
!
! gridDefLCC
! (INTEGER gridID,
......@@ -1251,6 +1255,27 @@
! INTEGER scanflag)
EXTERNAL gridInqLCC
!
! Lambert Conformal Conic 2 grid (PROJ version)
!
! gridDefLcc2
! (INTEGER gridID,
! DOUBLEPRECISION earth_radius,
! DOUBLEPRECISION lon_0,
! DOUBLEPRECISION lat_0,
! DOUBLEPRECISION lat_1,
! DOUBLEPRECISION lat_2)
EXTERNAL gridDefLcc2
! gridInqLcc2
! (INTEGER gridID,
! DOUBLEPRECISION earth_radius,
! DOUBLEPRECISION lon_0,
! DOUBLEPRECISION lat_0,
! DOUBLEPRECISION lat_1,
! DOUBLEPRECISION lat_2)
EXTERNAL gridInqLcc2
!
! Lambert Azimuthal Equal Area grid
!
......
......@@ -57,7 +57,7 @@ FCALLSCFUN0 (STRING, cdiLibraryVersion, CDILIBRARYVERSION, cdilibraryversion)
FCALLSCSUB0 (cdiPrintVersion, CDIPRINTVERSION, cdiprintversion)
FCALLSCSUB1 (cdiDefMissval, CDIDEFMISSVAL, cdidefmissval, DOUBLE)
FCALLSCFUN0 (DOUBLE, cdiInqMissval, CDIINQMISSVAL, cdiinqmissval)
FCALLSCFUN2 (INT, cdiDefGlobal, CDIDEFGLOBAL, cdidefglobal, STRING, INT)
FCALLSCSUB2 (cdiDefGlobal, CDIDEFGLOBAL, cdidefglobal, STRING, INT)
/* STREAM control routines */
......@@ -259,11 +259,16 @@ FCALLSCSUB2 (gridDefGMEni2, GRIDDEFGMENI2, griddefgmeni2, INT, INT)
FCALLSCFUN1 (INT, gridInqGMEni3, GRIDINQGMENI3, gridinqgmeni3, INT)
FCALLSCSUB2 (gridDefGMEni3, GRIDDEFGMENI3, griddefgmeni3, INT, INT)
/* Lambert Conformal Conic grid */
/* Lambert Conformal Conic grid (GRIB version) */
FCALLSCSUB10 (gridDefLCC, GRIDDEFLCC, griddeflcc, INT, DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE, INT, INT)
FCALLSCSUB10 (gridInqLCC, GRIDINQLCC, gridinqlcc, INT, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PINT, PINT)
/* Lambert Conformal Conic 2 grid (PROJ version) */
FCALLSCSUB6 (gridDefLcc2, GRIDDEFLCC2, griddeflcc2, INT, DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE)
FCALLSCSUB6 (gridInqLcc2, GRIDINQLCC2, gridinqlcc2, INT, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE)
/* Lambert Azimuthal Equal Area grid */
FCALLSCSUB4 (gridDefLaea, GRIDDEFLAEA, griddeflaea, INT, DOUBLE, DOUBLE, DOUBLE)
......
......@@ -3456,15 +3456,18 @@ void cdfCreateRecords(int streamID, int tsID)
streamptr->tsteps[0].records,
nrecs*sizeof(RECORD));
recIDs = (int *) malloc(nvrecs*sizeof(int));
streamptr->tsteps[tsID].recIDs = recIDs;
vrecID = 0;
for ( recID = 0; recID < nrecs; recID++ )
if ( nvrecs )
{
varID = records[recID].varID;
if ( vlistInqVarTime(vlistID, varID) == TIME_VARIABLE )
recIDs = (int *) malloc(nvrecs*sizeof(int));
streamptr->tsteps[tsID].recIDs = recIDs;
vrecID = 0;
for ( recID = 0; recID < nrecs; recID++ )
{
recIDs[vrecID++] = recID;
varID = records[recID].varID;
if ( vlistInqVarTime(vlistID, varID) == TIME_VARIABLE )
{
recIDs[vrecID++] = recID;
}
}
}
}
......@@ -3632,6 +3635,23 @@ void printNCvars(NCVAR *ncvars, int nvars)
}
}
typedef struct
{
int ncvarid;
char name[128];
}
VarInfo;
static
int cmpvarname(const void *s1, const void *s2)
{
VarInfo *x = (VarInfo *) s1;
VarInfo *y = (VarInfo *) s2;
return (strcmp(x->name, y->name));
}
int cdfInqContents(int streamID)
{
......@@ -5327,6 +5347,31 @@ int cdfInqContents(int streamID)
if ( nvars == 0 )
return (CDI_EUFSTRUCT);
if ( streamptr->sortname )
{
int index;
VarInfo **varInfo;
varInfo = (VarInfo **) malloc(nvars*sizeof(VarInfo *));
varInfo[0] = (VarInfo *) malloc(nvars*sizeof(VarInfo));
for ( index = 1; index < nvars; index++ )
varInfo[index] = varInfo[0] + index;
for ( varID = 0; varID < nvars; varID++ )
{
ncvarid = varids[varID];
varInfo[varID]->ncvarid = ncvarid;
strcpy(varInfo[varID]->name, ncvars[ncvarid].name);
}
qsort(varInfo[0], nvars, sizeof(VarInfo), cmpvarname);
for ( varID = 0; varID < nvars; varID++ )
{
varids[varID] = varInfo[varID]->ncvarid;
}
free(varInfo[0]);
free(varInfo);
}
for ( varID1 = 0; varID1 < nvars; varID1++ )
{
ncvarid = varids[varID1];
......
......@@ -54,6 +54,7 @@ int CDI_Debug = 0; /* If set to 1, debugging */
int cdiDefaultLeveltype = -1;
static int cdiDataUnreduced = 0;
static int cdiSortName = 0;
long cdiGetenvInt(char *envName)
......@@ -111,12 +112,24 @@ void cdiInitialize(void)
value = cdiGetenvInt("CD_REGULARGRID");
if ( value >= 0 ) cdiDataUnreduced = (int) value;
value = cdiGetenvInt("CDI_REGULARGRID");
if ( value >= 0 ) cdiDataUnreduced = (int) value;
value = cdiGetenvInt("CDI_SORTNAME");
if ( value >= 0 ) cdiSortName = (int) value;
value = cdiGetenvInt("CD_LEVELTYPE");
if ( value >= 0 ) cdiDefaultLeveltype = (int) value;
value = cdiGetenvInt("CDI_LEVELTYPE");
if ( value >= 0 ) cdiDefaultLeveltype = (int) value;
envString = getenv("CD_MISSVAL");
if ( envString ) cdiDefaultMissval = atof(envString);
envString = getenv("CDI_MISSVAL");
if ( envString ) cdiDefaultMissval = atof(envString);
envString = getenv("NC_MISSING_VALUE");
if ( envString ) cdiNcMissingValue = atoi(envString);
......@@ -351,6 +364,7 @@ static void stream_init_entry(STREAM *streamptr)
streamptr->vct.ilevID = UNDEFID;
streamptr->vct.mlevID = UNDEFID;
streamptr->unreduced = cdiDataUnreduced;
streamptr->sortname = cdiSortName;
streamptr->ztype = COMPRESS_NONE;
streamptr->zlevel = 0;
......@@ -458,17 +472,22 @@ int streamSize(void)
}
int cdiDefGlobal(const char *string, int val)
void cdiDefGlobal(const char *string, int val)
{
int ret = 0;
static char func[] = "cdiDefGlobal";
if ( strcmp(string, "CD_REGULARGRID") == 0 )
if ( strcmp(string, "REGULARGRID") == 0 )
{
cdiDataUnreduced = val;
ret = 1;
}
return (ret);
else if ( strcmp(string, "SORTNAME") == 0 )
{
cdiSortName = val;
}
else
{
Warning(func, "Unsupported global key: %s", string);
}
}
......
......@@ -231,6 +231,7 @@ typedef struct {
int localatts;
VCT vct;
int unreduced;
int sortname;
int ztype;
int zlevel;
int curfile;
......
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