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

netcdf: added support for GRID_FOURIER

parent c3f4b06e
2011-07-14 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* netcdf: added support for GRID_FOURIER (fourier coefficients)
2011-07-12 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* Version 1.5.1 released
......
......@@ -160,7 +160,7 @@ void printGridInfo(int vlistID)
double xfirst = 0.0, xlast = 0.0;
double yfirst = 0.0, ylast = 0.0;
double xinc = 0.0, yinc = 0.0;
yfirst = gridInqYval(gridID, 0);
ylast = gridInqYval(gridID, ysize-1);
yinc = gridInqYinc(gridID);
......@@ -207,7 +207,7 @@ void printGridInfo(int vlistID)
fprintf(stdout, " %s", yunits);
fprintf(stdout, "\n");
}
if ( gridIsRotated(gridID) )
{
double lonpole, latpole, angle;
......@@ -219,7 +219,7 @@ void printGridInfo(int vlistID)
if ( angle > 0 ) fprintf(stdout, " angle = %.9g", angle);
fprintf(stdout, "\n");
}
if ( gridInqXbounds(gridID, NULL) || gridInqYbounds(gridID, NULL) )
{
fprintf(stdout, "%*s", nbyte0, "");
......@@ -229,7 +229,7 @@ void printGridInfo(int vlistID)
if ( gridInqMask(gridID, NULL) ) fprintf(stdout, " mask");
fprintf(stdout, "\n");
}
if ( gridtype == GRID_LAEA )
{
double a, lon_0, lat_0;
......@@ -237,7 +237,7 @@ void printGridInfo(int vlistID)
fprintf(stdout, "%*s", nbyte0, "");
fprintf(stdout, "projpar : a = %g lon_0 = %g lat_0 = %g\n", a, lon_0, lat_0);
}
if ( gridtype == GRID_LCC2 )
{
double a, lon_0, lat_0, lat_1, lat_2;
......@@ -249,11 +249,15 @@ void printGridInfo(int vlistID)
}
else if ( gridtype == GRID_SPECTRAL )
{
fprintf(stdout, "size : dim = %d truncation = %d spc = %d\n",
fprintf(stdout, "size : dim = %d truncation = %d nsp = %d\n",
gridsize, trunc, gridsize/2);
fprintf(stdout, "%*s", nbyte0, "");
fprintf(stdout, " complexPacking = %d\n", gridInqComplexPacking(gridID));
}
else if ( gridtype == GRID_FOURIER )
{
fprintf(stdout, "size : dim = %d nfc = %d\n", gridsize, gridsize/2);
}
else if ( gridtype == GRID_GME )
{
int ni, nd;
......@@ -314,7 +318,7 @@ void printGridInfo(int vlistID)
fprintf(stdout, "\n");
fprintf(stdout, "%*s", nbyte0, "");
fprintf(stdout, "%-9s : min = %.9g max = %.9g %s\n", yname, yfirst, ylast, yunits);
free(xvals);
free(yvals);
}
......@@ -332,11 +336,11 @@ void printGridInfo(int vlistID)
fprintf(stdout, "North Pole\n");
else
fprintf(stdout, "South Pole\n");
fprintf(stdout, "%*s", nbyte0, "");
fprintf(stdout, "%*s", nbyte0, "");
fprintf(stdout, " originLon = %g originLat = %g lonParY = %g\n",
originLon, originLat, lonParY);
fprintf(stdout, "%*s", nbyte0, "");
fprintf(stdout, " lat1 = %g lat2 = %g xinc = %g m yinc = %g m\n",
fprintf(stdout, "%*s", nbyte0, "");
fprintf(stdout, " lat1 = %g lat2 = %g xinc = %g m yinc = %g m\n",
lat1, lat2, xincm, yincm);
}
else /* if ( gridtype == GRID_GENERIC ) */
......@@ -348,7 +352,7 @@ void printGridInfo(int vlistID)
fprintf(stdout, "size : dim = %d nx = %d ny = %d\n", gridsize, xsize, ysize);
if ( gridIsCircular(gridID) )
{
fprintf(stdout, "%*s", nbyte0, "");
fprintf(stdout, "%*s", nbyte0, "");
fprintf(stdout, "longitude : circular\n");
}
}
......@@ -373,12 +377,3 @@ void printGridInfo(int vlistID)
}
}
}
/*
* Local Variables:
* c-file-style: "Java"
* c-basic-offset: 2
* indent-tabs-mode: nil
* show-trailing-whitespace: t
* require-trailing-newline: t
* End:
*/
......@@ -809,6 +809,7 @@ enable_dependency_tracking
with_gnu_ld
with_sysroot
enable_libtool_lock
with_gnu_ld
enable_largefile
with_threads
with_zlib
......@@ -838,16 +839,25 @@ LDFLAGS
LIBS
CPPFLAGS
CPP
CPPFLAGS
FC
FCFLAGS
LDFLAGS
LIBS
FPP
FPPFLAGS
F77
FFLAGS
LDFLAGS
LIBS
CXX
CXXFLAGS
LDFLAGS
LIBS
CPPFLAGS
CCC
CXXCPP
CPPFLAGS
FCMODEXT'
 
 
......
......@@ -2620,6 +2620,10 @@ int gridGenerate(grid_t grid)
if ( grid.lcomplex ) gridDefComplexPacking(gridID, 1);
break;
}
case GRID_FOURIER:
{
break;
}
case GRID_GME:
{
gridDefGMEnd(gridID, grid.nd);
......@@ -3448,6 +3452,10 @@ void gridPrint(int gridID, int opt)
fprintf(fp, "complexpacking = %d\n", gridInqComplexPacking(gridID));
break;
}
case GRID_FOURIER:
{
break;
}
case GRID_GME:
{
fprintf(fp, "ni = %d\n", gridInqGMEni(gridID));
......
......@@ -966,7 +966,7 @@ void cdfDefTimestep(int streamID, int tsID)
static
void cdfDefComplex(int streamID, int gridID)
{
char axisname[] = "complex";
char axisname[] = "nc2";
int index;
int dimID = UNDEFID;
int gridID0, gridtype0, gridindex;
......@@ -989,7 +989,7 @@ void cdfDefComplex(int streamID, int gridID)
{
gridID0 = vlistGrid(vlistID, index);
gridtype0 = gridInqType(gridID0);
if ( gridtype0 == GRID_SPECTRAL )
if ( gridtype0 == GRID_SPECTRAL || gridtype0 == GRID_FOURIER )
{
dimID = streamptr->xdimID[index];
break;
......@@ -1016,12 +1016,12 @@ void cdfDefComplex(int streamID, int gridID)
#if defined (HAVE_LIBNETCDF)
static
void cdfDefSpc(int streamID, int gridID)
void cdfDefSP(int streamID, int gridID)
{
/*
char longname[] = "Spherical harmonic coefficient";
*/
char axisname[5] = "spcX";
char axisname[5] = "nspX";
int index, iz = 0;
int gridID0, gridtype0, gridindex;
int dimID = UNDEFID;
......@@ -1055,7 +1055,68 @@ void cdfDefSpc(int streamID, int gridID)
break;
}
else
iz++;
iz++;
}
}
}
if ( dimID == UNDEFID )
{
if ( iz == 0 ) axisname[3] = '\0';
else sprintf(&axisname[3], "%1d", iz+1);
if ( streamptr->ncmode == 2 ) cdf_redef(fileID);
cdf_def_dim(fileID, axisname, dimlen, &dimID);
cdf_enddef(fileID);
streamptr->ncmode = 2;
}
gridindex = vlistGridIndex(vlistID, gridID);
streamptr->ydimID[gridindex] = dimID;
}
#endif
#if defined (HAVE_LIBNETCDF)
static
void cdfDefFC(int streamID, int gridID)
{
char axisname[5] = "nfcX";
int index, iz = 0;
int gridID0, gridtype0, gridindex;
int dimID = UNDEFID;
int ngrids;
int fileID;
int dimlen, dimlen0;
int vlistID;
stream_t *streamptr;
streamptr = stream_to_pointer(streamID);
vlistID = streamInqVlist(streamID);
fileID = streamInqFileID(streamID);
ngrids = vlistNgrids(vlistID);
dimlen = gridInqSize(gridID)/2;
for ( index = 0; index < ngrids; index++ )
{
if ( streamptr->ydimID[index] != UNDEFID )
{
gridID0 = vlistGrid(vlistID, index);
gridtype0 = gridInqType(gridID0);
if ( gridtype0 == GRID_FOURIER )
{
dimlen0 = gridInqSize(gridID0)/2;
if ( dimlen == dimlen0 )
{
dimID = streamptr->ydimID[index];
break;
}
else
iz++;
}
}
}
......@@ -2528,7 +2589,7 @@ void cdfDefGrid(int streamID, int gridID)
if ( gridIsRotated(gridID) ) cdfDefPole(streamID, gridID);
}
else if ( gridtype == GRID_CURVILINEAR )
{
{
cdfDefCurvilinear(streamID, gridID);
}
else if ( gridtype == GRID_UNSTRUCTURED )
......@@ -2542,7 +2603,12 @@ void cdfDefGrid(int streamID, int gridID)
else if ( gridtype == GRID_SPECTRAL )
{
cdfDefComplex(streamID, gridID);
cdfDefSpc(streamID, gridID);
cdfDefSP(streamID, gridID);
}
else if ( gridtype == GRID_FOURIER )
{
cdfDefComplex(streamID, gridID);
cdfDefFC(streamID, gridID);
}
else if ( gridtype == GRID_TRAJECTORY )
{
......@@ -2902,6 +2968,12 @@ int cdfDefVar(int streamID, int varID)
cdf_put_att_text(fileID, ncvarid, "axis", iax, axis);
cdf_put_att_int(fileID, ncvarid, "truncation", NC_INT, 1L, &gridTruncation);
}
else if ( gridtype == GRID_FOURIER )
{
axis[iax++] = '-';
axis[iax++] = '-';
cdf_put_att_text(fileID, ncvarid, "axis", iax, axis);
}
/* if ( xtype == NC_BYTE || xtype == NC_SHORT || xtype == NC_INT ) */
{
......@@ -4318,6 +4390,8 @@ void scanVarAttributes(int fileID, int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
ncvars[ncvarid].gridtype = GRID_GAUSSIAN;
else if ( strncmp(attstring, "spectral", 8) == 0 )
ncvars[ncvarid].gridtype = GRID_SPECTRAL;
else if ( strncmp(attstring, "fourier", 7) == 0 )
ncvars[ncvarid].gridtype = GRID_FOURIER;
else if ( strcmp(attstring, "trajectory") == 0 )
ncvars[ncvarid].gridtype = GRID_TRAJECTORY;
else if ( strcmp(attstring, "generic") == 0 )
......@@ -5297,6 +5371,11 @@ void define_all_grids(stream_t *streamptr, int fileID, int vlistID, ncdim_t *ncd
grid.lcomplex = 1;
break;
}
case GRID_FOURIER:
{
grid.size = size;
break;
}
case GRID_TRAJECTORY:
{
grid.size = 1;
......
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