Commit 6ff70e26 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

new operator topo

parent 2db096e2
......@@ -5,6 +5,7 @@
* remaplib.sort_add: don't sort if num_links <= 1
* remaplib.remap_bi?: check that src_add is valid
* Remap: use REMAP_NON_GLOBAL only for gridsize > 1
* pstreamDefVlist: remove Read -> Write data-race on pstreamptr->vlistID
* Version 1.0.3 released
2006-09-18 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
......
......@@ -18,7 +18,8 @@
/*
This module contains the following operators:
Intgrid interpolate Interpolate
Intgrid interpolate PINGO grid interpolation
Intgrid intgridbil Bilinear grid interpolation
*/
......
......@@ -35,14 +35,18 @@
void *Vargen(void *argument)
{
static char func[] = "Vargen";
int RANDOM, CONST;
int RANDOM, CONST, TOPO;
int operatorID;
int streamID;
int nrecs;
int tsID, recID, varID, levelID;
int gridsize, i;
int vlistID;
int gridID, zaxisID, taxisID;
int gridID = -1, zaxisID, taxisID;
double etopo_scale = 3;
short etopo[] = {
#include "etopo.h"
};
const char *gridfile;
double rconst = 0.0;
double *array;
......@@ -51,24 +55,42 @@ void *Vargen(void *argument)
RANDOM = cdoOperatorAdd("random", 0, 0, "grid description file or name");
CONST = cdoOperatorAdd("const", 0, 0, "constant value, grid description file or name");
TOPO = cdoOperatorAdd("topo", 0, 0, "");
operatorID = cdoOperatorID();
operatorInputArg(cdoOperatorEnter(operatorID));
if ( operatorID == RANDOM )
{
operatorInputArg(cdoOperatorEnter(operatorID));
operatorCheckArgc(1);
gridfile = operatorArgv()[0];
gridID = cdoDefineGrid(gridfile);
}
else
else if ( operatorID == CONST )
{
operatorInputArg(cdoOperatorEnter(operatorID));
operatorCheckArgc(2);
rconst = atof(operatorArgv()[0]);
gridfile = operatorArgv()[1];
gridID = cdoDefineGrid(gridfile);
}
else if ( operatorID == TOPO )
{
int nlon, nlat, i;
double lon[720], lat[360];
nlon = 720;
nlat = 360;
gridID = gridCreate(GRID_LONLAT, nlon*nlat);
gridDefXsize(gridID, nlon);
gridDefYsize(gridID, nlat);
for ( i = 0; i < nlon; i++ ) lon[i] = -179.75 + i*0.5;
for ( i = 0; i < nlat; i++ ) lat[i] = -89.75 + i*0.5;
gridDefXvals(gridID, lon);
gridDefYvals(gridID, lat);
}
gridID = cdoDefineGrid(gridfile);
zaxisID = zaxisCreate(ZAXIS_SURFACE, 1);
......@@ -100,11 +122,16 @@ void *Vargen(void *argument)
for ( i = 0; i < gridsize; i++ )
array[i] = rand()/(RAND_MAX+1.0);
}
else
else if ( operatorID == CONST )
{
for ( i = 0; i < gridsize; i++ )
array[i] = rconst;
}
else if ( operatorID == TOPO )
{
for ( i = 0; i < gridsize; i++ )
array[i] = etopo[i]/etopo_scale;
}
streamWriteRecord(streamID, array, 0);
}
......
......@@ -129,6 +129,9 @@ void intgrid(FIELD *field1, FIELD *field2)
arrayOut = field2->ptr;
missval = field1->missval;
if ( ! (gridInqXvals(gridIDin, NULL) && gridInqYvals(gridIDin, NULL)) )
cdoAbort("Source grid has no values");
nlonIn = gridInqXsize(gridIDin);
nlatIn = gridInqYsize(gridIDin);
lonIn = (double *) malloc(nlonIn*sizeof(double));
......@@ -136,6 +139,9 @@ void intgrid(FIELD *field1, FIELD *field2)
gridInqXvals(gridIDin, lonIn);
gridInqYvals(gridIDin, latIn);
if ( ! (gridInqXvals(gridIDout, NULL) && gridInqYvals(gridIDout, NULL)) )
cdoAbort("Target grid has no values");
nlonOut = gridInqXsize(gridIDout);
nlatOut = gridInqYsize(gridIDout);
lonOut = (double *) malloc(nlonOut*sizeof(double));
......@@ -512,6 +518,12 @@ void interpolate(FIELD *field1, FIELD *field2)
lon = lon_array + 1;
lat = lat_array + 1;
if ( ! (gridInqXvals(gridIDi, NULL) && gridInqYvals(gridIDi, NULL)) )
cdoAbort("Source grid has no values");
if ( ! (gridInqXvals(gridIDo, NULL) && gridInqYvals(gridIDo, NULL)) )
cdoAbort("Target grid has no values");
gridInqXvals(gridIDi, lon);
gridInqYvals(gridIDi, lat);
......
......@@ -224,7 +224,7 @@ void *Zonstat(void *argument);
#define TrendOperators {"trend"}
#define TrmsOperators {"trms"}
#define VardupOperators {"vardup", "varmul"}
#define VargenOperators {"random", "const"}
#define VargenOperators {"random", "const", "topo"}
#define VarrmsOperators {"varrms"}
#define VertintOperators {"ml2pl", "ml2hl"}
#define VertstatOperators {"vertmin", "vertmax", "vertsum", "vertmean", "vertavg", "vertstd"}
......
......@@ -787,8 +787,6 @@ void pstreamDefVlist(int pstreamID, int vlistID)
pstreamptr = pstream_to_pointer(pstreamID);
pstreamptr->vlistID = vlistID;
#if defined (HAVE_LIBPTHREAD)
if ( pstreamptr->ispipe )
{
......
Supports Markdown
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