Commit 35488c7d authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

dfDefVar: define attribute _FillValue if missval was defined

parent d6d45edd
2009-12-09 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* cdfDefVar: define attribute _FillValue if missval was defined (speed up)
2009-12-08 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de> 2009-12-08 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* allocate gribHandle for every grid/zaxis combination (speed up for writing GRIB2) * allocate gribHandle for every grid/zaxis combination (speed up for writing GRIB2)
......
...@@ -2552,6 +2552,7 @@ int cdfDefVar(int streamID, int varID) ...@@ -2552,6 +2552,7 @@ int cdfDefVar(int streamID, int varID)
int len; int len;
int timeID; int timeID;
int xtype; int xtype;
int gridtype;
int gridindex, zaxisindex; int gridindex, zaxisindex;
int tablenum; int tablenum;
int vlistID; int vlistID;
...@@ -2573,8 +2574,9 @@ int cdfDefVar(int streamID, int varID) ...@@ -2573,8 +2574,9 @@ int cdfDefVar(int streamID, int varID)
timeID = vlistInqVarTime(vlistID, varID); timeID = vlistInqVarTime(vlistID, varID);
code = vlistInqVarCode(vlistID, varID); code = vlistInqVarCode(vlistID, varID);
gridtype = gridInqType(gridID);
gridindex = vlistGridIndex(vlistID, gridID); gridindex = vlistGridIndex(vlistID, gridID);
if ( gridInqType(gridID) != GRID_TRAJECTORY ) if ( gridtype != GRID_TRAJECTORY )
{ {
xid = streamptr->xdimID[gridindex]; xid = streamptr->xdimID[gridindex];
yid = streamptr->ydimID[gridindex]; yid = streamptr->ydimID[gridindex];
...@@ -2761,14 +2763,12 @@ int cdfDefVar(int streamID, int varID) ...@@ -2761,14 +2763,12 @@ int cdfDefVar(int streamID, int varID)
cdf_put_att_int(fileID, ncvarid, "table", NC_INT, 1L, &tablenum); cdf_put_att_int(fileID, ncvarid, "table", NC_INT, 1L, &tablenum);
} }
if ( gridInqType(gridID) != GRID_GENERIC && if ( gridtype != GRID_GENERIC && gridtype != GRID_LONLAT &&
gridInqType(gridID) != GRID_LONLAT && gridtype != GRID_CURVILINEAR )
gridInqType(gridID) != GRID_CURVILINEAR )
{ {
len = strlen(gridNamePtr(gridInqType(gridID))); len = strlen(gridNamePtr(gridtype));
if ( len > 0 ) if ( len > 0 )
cdf_put_att_text(fileID, ncvarid, "grid_type", len, cdf_put_att_text(fileID, ncvarid, "grid_type", len, gridNamePtr(gridtype));
gridNamePtr(gridInqType(gridID)));
} }
if ( gridIsRotated(gridID) ) if ( gridIsRotated(gridID) )
...@@ -2777,30 +2777,26 @@ int cdfDefVar(int streamID, int varID) ...@@ -2777,30 +2777,26 @@ int cdfDefVar(int streamID, int varID)
cdf_put_att_text(fileID, ncvarid, "grid_mapping", strlen(mapping), mapping); cdf_put_att_text(fileID, ncvarid, "grid_mapping", strlen(mapping), mapping);
} }
if ( gridInqType(gridID) == GRID_SINUSOIDAL ) if ( gridtype == GRID_SINUSOIDAL )
{ {
char mapping[] = "sinusoidal"; char mapping[] = "sinusoidal";
cdf_put_att_text(fileID, ncvarid, "grid_mapping", strlen(mapping), mapping); cdf_put_att_text(fileID, ncvarid, "grid_mapping", strlen(mapping), mapping);
} }
else if ( gridtype == GRID_LAEA )
if ( gridInqType(gridID) == GRID_LAEA )
{ {
char mapping[] = "laea"; char mapping[] = "laea";
cdf_put_att_text(fileID, ncvarid, "grid_mapping", strlen(mapping), mapping); cdf_put_att_text(fileID, ncvarid, "grid_mapping", strlen(mapping), mapping);
} }
else if ( gridtype == GRID_LCC2 )
if ( gridInqType(gridID) == GRID_LCC2 )
{ {
char mapping[] = "Lambert_Conformal"; char mapping[] = "Lambert_Conformal";
cdf_put_att_text(fileID, ncvarid, "grid_mapping", strlen(mapping), mapping); cdf_put_att_text(fileID, ncvarid, "grid_mapping", strlen(mapping), mapping);
} }
else if ( gridtype == GRID_TRAJECTORY )
if ( gridInqType(gridID) == GRID_TRAJECTORY )
{ {
cdf_put_att_text(fileID, ncvarid, "coordinates", 9, "tlon tlat" ); cdf_put_att_text(fileID, ncvarid, "coordinates", 9, "tlon tlat" );
} }
else if ( gridtype == GRID_CELL || gridtype == GRID_CURVILINEAR )
if ( gridInqType(gridID) == GRID_CELL || gridInqType(gridID) == GRID_CURVILINEAR )
{ {
char coordinates[256] = ""; char coordinates[256] = "";
char cellarea[256] = "area: "; char cellarea[256] = "area: ";
...@@ -2832,8 +2828,7 @@ int cdfDefVar(int streamID, int varID) ...@@ -2832,8 +2828,7 @@ int cdfDefVar(int streamID, int varID)
cdf_put_att_text(fileID, ncvarid, "cell_measures", len, cellarea); cdf_put_att_text(fileID, ncvarid, "cell_measures", len, cellarea);
} }
} }
else if ( gridtype == GRID_SPECTRAL )
if ( gridInqType(gridID) == GRID_SPECTRAL )
{ {
int gridTruncation = gridInqTrunc(gridID); int gridTruncation = gridInqTrunc(gridID);
...@@ -2872,6 +2867,9 @@ int cdfDefVar(int streamID, int varID) ...@@ -2872,6 +2867,9 @@ int cdfDefVar(int streamID, int varID)
cdf_put_att_double(fileID, ncvarid, "scale_factor", (nc_type) astype, 1L, &scalefactor); cdf_put_att_double(fileID, ncvarid, "scale_factor", (nc_type) astype, 1L, &scalefactor);
} }
if ( vlistInqVarMissvalUsed(vlistID, varID) )
cdfDefMissval(streamID, varID, vlistInqVarDatatype(vlistID, varID));
streamptr->vars[varID].ncvarid = ncvarid; streamptr->vars[varID].ncvarid = ncvarid;
/* Attributes */ /* Attributes */
......
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