grid.c 121 KB
Newer Older
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1
2
3
4
5
#if defined (HAVE_CONFIG_H)
#  include "config.h"
#endif

#include <string.h>
6
#include <float.h>  /* FLT_EPSILON */
7
#include <limits.h> /* INT_MAX     */
8

Uwe Schulzweida's avatar
Uwe Schulzweida committed
9
10
#include "dmemory.h"
#include "cdi.h"
11
#include "cdi_cksum.h"
12
#include "cdi_int.h"
Uwe Schulzweida's avatar
Uwe Schulzweida committed
13
#include "grid.h"
14
#include "gaussgrid.h"
15
#include "resource_handle.h"
16
#include "resource_unpack.h"
17
#include "namespace.h"
18
#include "serialize.h"
19
20
21
22
#include "vlist.h"

#undef  UNDEFID
#define UNDEFID -1
Uwe Schulzweida's avatar
Uwe Schulzweida committed
23
24
25
26
27
28
29
30
31
32

#ifndef  RAD2DEG
#define  RAD2DEG  (180./M_PI)   /* conversion for rad to deg */
#endif

#ifndef  DEG2RAD
#define  DEG2RAD  (M_PI/180.)   /* conversion for deg to rad */
#endif


33
34
35
/* the value in the second pair of brackets must match the length of
 * the longest string (including terminating NUL) */
static const char Grids[][17] = {
36
37
38
39
40
41
42
43
44
  /*  0 */  "undefined",
  /*  1 */  "generic",
  /*  2 */  "gaussian",
  /*  3 */  "gaussian reduced",
  /*  4 */  "lonlat",
  /*  5 */  "spectral",
  /*  6 */  "fourier",
  /*  7 */  "gme",
  /*  8 */  "trajectory",
45
  /*  9 */  "unstructured",
46
47
  /* 10 */  "curvilinear",
  /* 11 */  "lcc",
48
49
50
  /* 12 */  "lcc2",
  /* 13 */  "laea",
  /* 14 */  "sinusoidal",
51
  /* 15 */  "projection",
Uwe Schulzweida's avatar
Uwe Schulzweida committed
52
53
54
};


55
56
57
static int    gridCompareP    ( void * gridptr1, void * gridptr2 );
static void   gridDestroyP    ( void * gridptr );
static void   gridPrintP      ( void * gridptr, FILE * fp );
58
static int    gridGetPackSize ( void * gridptr, void *context);
59
static void   gridPack        ( void * gridptr, void * buff, int size,
60
				int *position, void *context);
Deike Kleberg's avatar
minimal    
Deike Kleberg committed
61
static int    gridTxCode      ( void );
Uwe Schulzweida's avatar
Uwe Schulzweida committed
62

63
static const resOps gridOps = {
64
65
66
67
68
69
  gridCompareP,
  gridDestroyP,
  gridPrintP,
  gridGetPackSize,
  gridPack,
  gridTxCode
70
};
Uwe Schulzweida's avatar
Uwe Schulzweida committed
71

72
static int  GRID_Debug = 0;   /* If set to 1, debugging */
Uwe Schulzweida's avatar
Uwe Schulzweida committed
73

74
#define gridID2Ptr(gridID) (grid_t *)reshGetVal(gridID, &gridOps)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
75

Deike Kleberg's avatar
Deike Kleberg committed
76
void grid_init(grid_t *gridptr)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
77
{
78
  gridptr->self         = CDI_UNDEFID;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
79
  gridptr->type         = CDI_UNDEFID;
Deike Kleberg's avatar
Deike Kleberg committed
80
  gridptr->proj         = CDI_UNDEFID;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
81
  gridptr->mask         = NULL;
82
  gridptr->mask_gme     = NULL;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
83
84
85
86
87
88
89
  gridptr->xvals        = NULL;
  gridptr->yvals        = NULL;
  gridptr->area         = NULL;
  gridptr->xbounds      = NULL;
  gridptr->ybounds      = NULL;
  gridptr->rowlon       = NULL;
  gridptr->nrowlon      = 0;
90
91
  gridptr->xfirst       = 0.0;
  gridptr->xlast        = 0.0;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
92
  gridptr->xinc         = 0.0;
93
94
  gridptr->yfirst       = 0.0;
  gridptr->ylast        = 0.0;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
95
  gridptr->yinc         = 0.0;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
96
97
98
99
100
101
102
  gridptr->lcc_originLon = 0.0;
  gridptr->lcc_originLat = 0.0;
  gridptr->lcc_lonParY  = 0.0;
  gridptr->lcc_lat1     = 0.0;
  gridptr->lcc_lat2     = 0.0;
  gridptr->lcc_xinc     = 0.0;
  gridptr->lcc_yinc     = 0.0;
103
104
  gridptr->lcc_projflag = 0;
  gridptr->lcc_scanflag = 0;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
105
  gridptr->lcc_defined  = FALSE;
106
107
108
109
110
111
  gridptr->lcc2_lon_0   = 0.0;
  gridptr->lcc2_lat_0   = 0.0;
  gridptr->lcc2_lat_1   = 0.0;
  gridptr->lcc2_lat_2   = 0.0;
  gridptr->lcc2_a       = 0.0;
  gridptr->lcc2_defined = FALSE;
112
113
114
115
  gridptr->laea_lon_0   = 0.0;
  gridptr->laea_lat_0   = 0.0;
  gridptr->laea_a       = 0.0;
  gridptr->laea_defined = FALSE;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
116
117
118
119
120
121
  gridptr->trunc        = 0;
  gridptr->nvertex      = 0;
  gridptr->nd           = 0;
  gridptr->ni           = 0;
  gridptr->ni2          = 0;
  gridptr->ni3          = 0;
122
123
124
  gridptr->number       = 0;
  gridptr->position     = 0;
  gridptr->reference    = NULL;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
125
126
127
128
  gridptr->prec         = 0;
  gridptr->size         = 0;
  gridptr->xsize        = 0;
  gridptr->ysize        = 0;
129
  gridptr->np           = 0;
130
131
  gridptr->xdef         = 0;
  gridptr->ydef         = 0;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
132
  gridptr->isCyclic     = CDI_UNDEFID;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
133
134
135
136
137
  gridptr->isRotated    = FALSE;
  gridptr->xpole        = 0.0;
  gridptr->ypole        = 0.0;
  gridptr->angle        = 0.0;
  gridptr->locked       = FALSE;
138
  gridptr->lcomplex     = 0;
139
  gridptr->hasdims      = TRUE;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
140
141
142
143
144
145
146
147
  gridptr->xname[0]     = 0;
  gridptr->yname[0]     = 0;
  gridptr->xlongname[0] = 0;
  gridptr->ylongname[0] = 0;
  gridptr->xunits[0]    = 0;
  gridptr->yunits[0]    = 0;
  gridptr->xstdname[0]  = 0;
  gridptr->ystdname[0]  = 0;
Thomas Jahns's avatar
Thomas Jahns committed
148
  memset(gridptr->uuid, 0, CDI_UUID_SIZE);
Deike Kleberg's avatar
Deike Kleberg committed
149
  gridptr->name         = NULL;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
150
151
}

152

Deike Kleberg's avatar
Deike Kleberg committed
153
154
void grid_free(grid_t *gridptr)
{
155
156
157
158
159
160
161
162
163
164
  if ( gridptr->mask      ) Free(gridptr->mask);
  if ( gridptr->mask_gme  ) Free(gridptr->mask_gme);
  if ( gridptr->xvals     ) Free(gridptr->xvals);
  if ( gridptr->yvals     ) Free(gridptr->yvals);
  if ( gridptr->area      ) Free(gridptr->area);
  if ( gridptr->xbounds   ) Free(gridptr->xbounds);
  if ( gridptr->ybounds   ) Free(gridptr->ybounds);
  if ( gridptr->rowlon    ) Free(gridptr->rowlon);
  if ( gridptr->reference ) Free(gridptr->reference);
  if ( gridptr->name      ) Free(gridptr->name);
Deike Kleberg's avatar
Deike Kleberg committed
165
166
167
168

  grid_init(gridptr);
}

169
170
static grid_t *
gridNewEntry(cdiResH resH)
171
{
172
  grid_t *gridptr = (grid_t*) Malloc(sizeof(grid_t));
173
174
175
176
177
178
179
180
  grid_init(gridptr);
  if (resH == CDI_UNDEFID)
    gridptr->self = reshPut(gridptr, &gridOps);
  else
    {
      gridptr->self = resH;
      reshReplace(resH, gridptr, &gridOps);
    }
181
  return gridptr;
182
183
}

184
static
185
void gridInit (void)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
186
{
187
188
  static int gridInitialized = 0;
  char *env;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
189

190
  if ( gridInitialized ) return;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
191

Thomas Jahns's avatar
Thomas Jahns committed
192
  gridInitialized = 1;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
193

194
195
  env = getenv("GRID_DEBUG");
  if ( env ) GRID_Debug = atoi(env);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
196
197
}

198
199
static
void grid_copy(grid_t *gridptr2, grid_t *gridptr1)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
200
201
202
203
{
  int gridID2;

  gridID2 = gridptr2->self;
204
  memcpy(gridptr2, gridptr1, sizeof(grid_t));
Uwe Schulzweida's avatar
Uwe Schulzweida committed
205
206
207
  gridptr2->self = gridID2;
}

208
unsigned cdiGridCount(void)
Thomas Jahns's avatar
Thomas Jahns committed
209
{
210
  return reshCountType(&gridOps);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
211
212
}

213
214
// used also in CDO
void gridGenXvals(int xsize, double xfirst, double xlast, double xinc, double *xvals)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
215
{
216
  if ( (! (fabs(xinc) > 0)) && xsize > 1 )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
217
218
    {
      if ( xfirst >= xlast )
Thomas Jahns's avatar
Thomas Jahns committed
219
220
221
222
        {
          while ( xfirst >= xlast ) xlast += 360;
          xinc = (xlast-xfirst)/(xsize);
        }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
223
      else
Thomas Jahns's avatar
Thomas Jahns committed
224
225
226
        {
          xinc = (xlast-xfirst)/(xsize-1);
        }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
227
228
    }

229
  for ( int i = 0; i < xsize; ++i )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
230
231
232
    xvals[i] = xfirst + i*xinc;
}

233
234
static
void calc_gaussgrid(double *yvals, int ysize, double yfirst, double ylast)
235
{
236
  double *restrict yw = (double *) Malloc((size_t)ysize * sizeof(double));
237
  gaussaw(yvals, yw, (size_t)ysize);
238
  Free(yw);
239
  for (int i = 0; i < ysize; i++ )
240
241
242
243
    yvals[i] = asin(yvals[i])/M_PI*180.0;

  if ( yfirst < ylast && yfirst > -90.0 && ylast < 90.0 )
    {
244
245
      int yhsize = ysize/2;
      for (int i = 0; i < yhsize; i++ )
Thomas Jahns's avatar
Thomas Jahns committed
246
        {
247
          double ytmp = yvals[i];
Thomas Jahns's avatar
Thomas Jahns committed
248
249
250
          yvals[i] = yvals[ysize-i-1];
          yvals[ysize-i-1] = ytmp;
        }
251
252
253
    }
}

254
255
// used also in CDO
void gridGenYvals(int gridtype, int ysize, double yfirst, double ylast, double yinc, double *yvals)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
256
{
257
  const double deleps = 0.002;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
258
259
260
261

  if ( gridtype == GRID_GAUSSIAN || gridtype == GRID_GAUSSIAN_REDUCED )
    {
      if ( ysize > 2 )
Deike Kleberg's avatar
Deike Kleberg committed
262
263
264
265
266
267
	{
	  calc_gaussgrid(yvals, ysize, yfirst, ylast);

	  if ( ! (IS_EQUAL(yfirst, 0) && IS_EQUAL(ylast, 0)) )
	    if ( fabs(yvals[0] - yfirst) > deleps || fabs(yvals[ysize-1] - ylast) > deleps )
	      {
268
		double *restrict ytmp = NULL;
Deike Kleberg's avatar
Deike Kleberg committed
269
		int nstart, lfound = 0;
270
		int ny = (int) (180./fabs(ylast-yfirst)/(ysize-1) + 0.5);
Deike Kleberg's avatar
Deike Kleberg committed
271
272
273
		ny -= ny%2;
		if ( ny > ysize && ny < 4096 )
		  {
274
		    ytmp = (double *) Malloc((size_t)ny * sizeof (double));
Deike Kleberg's avatar
Deike Kleberg committed
275
		    calc_gaussgrid(ytmp, ny, yfirst, ylast);
276
                    int i;
Deike Kleberg's avatar
Deike Kleberg committed
277
278
279
280
281
		    for ( i = 0; i < (ny-ysize); i++ )
		      if ( fabs(ytmp[i] - yfirst) < deleps ) break;

		    nstart = i;

282
283
		    lfound = (nstart+ysize-1) < ny
                      && fabs(ytmp[nstart+ysize-1] - ylast) < deleps;
Deike Kleberg's avatar
Deike Kleberg committed
284
285
286
287
		  }

		if ( lfound )
		  {
288
		    for (int i = 0; i < ysize; i++) yvals[i] = ytmp[i+nstart];
Deike Kleberg's avatar
Deike Kleberg committed
289
290
291
292
		  }
		else
		  {
		    Warning("Cannot calculate gaussian latitudes for lat1 = %g latn = %g!", yfirst, ylast);
293
		    for (int i = 0; i < ysize; i++ ) yvals[i] = 0;
Deike Kleberg's avatar
Deike Kleberg committed
294
295
296
297
		    yvals[0] = yfirst;
		    yvals[ysize-1] = ylast;
		  }

298
		if ( ytmp ) Free(ytmp);
Deike Kleberg's avatar
Deike Kleberg committed
299
300
	      }
	}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
301
      else
Thomas Jahns's avatar
Thomas Jahns committed
302
303
304
305
        {
          yvals[0] = yfirst;
          yvals[ysize-1] = ylast;
        }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
306
307
308
309
    }
  /*     else if ( gridtype == GRID_LONLAT || gridtype == GRID_GENERIC ) */
  else
    {
310
      if ( (! (fabs(yinc) > 0)) && ysize > 1 )
Thomas Jahns's avatar
Thomas Jahns committed
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
        {
          if ( IS_EQUAL(yfirst, ylast) && IS_NOT_EQUAL(yfirst, 0) ) ylast *= -1;

          if ( yfirst > ylast )
            yinc = (yfirst-ylast)/(ysize-1);
          else if ( yfirst < ylast )
            yinc = (ylast-yfirst)/(ysize-1);
          else
            {
              if ( ysize%2 != 0 )
                {
                  yinc = 180.0/(ysize-1);
                  yfirst = -90;
                }
              else
                {
                  yinc = 180.0/ysize;
                  yfirst = -90 + yinc/2;
                }
            }
        }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
332
333
334

      if ( yfirst > ylast && yinc > 0 ) yinc = -yinc;

335
      for (int i = 0; i < ysize; i++ )
Thomas Jahns's avatar
Thomas Jahns committed
336
        yvals[i] = yfirst + i*yinc;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
337
338
339
    }
  /*
    else
340
    Error("unable to calculate values for %s grid!", gridNamePtr(gridtype));
Uwe Schulzweida's avatar
Uwe Schulzweida committed
341
342
343
344
  */
}

/*
345
@Function  gridCreate
346
@Title     Create a horizontal Grid
Uwe Schulzweida's avatar
Uwe Schulzweida committed
347

348
@Prototype int gridCreate(int gridtype, int size)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
349
350
@Parameter
    @Item  gridtype  The type of the grid, one of the set of predefined CDI grid types.
351
                     The valid CDI grid types are @func{GRID_GENERIC}, @func{GRID_GAUSSIAN},
Uwe Schulzweida's avatar
Uwe Schulzweida committed
352
                     @func{GRID_LONLAT}, @func{GRID_LCC}, @func{GRID_SPECTRAL},
353
                     @func{GRID_GME}, @func{GRID_CURVILINEAR} and @func{GRID_UNSTRUCTURED} and.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
354
355
356
    @Item  size      Number of gridpoints.

@Description
357
The function @func{gridCreate} creates a horizontal Grid.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
358
359

@Result
360
@func{gridCreate} returns an identifier to the Grid.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
361
362

@Example
363
Here is an example using @func{gridCreate} to create a regular lon/lat Grid:
Uwe Schulzweida's avatar
Uwe Schulzweida committed
364
365

@Source
Uwe Schulzweida's avatar
Uwe Schulzweida committed
366
367
#include "cdi.h"
   ...
368
369
#define  nlon  12
#define  nlat   6
Uwe Schulzweida's avatar
Uwe Schulzweida committed
370
   ...
371
372
double lons[nlon] = {0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330};
double lats[nlat] = {-75, -45, -15, 15, 45, 75};
Uwe Schulzweida's avatar
Uwe Schulzweida committed
373
374
int gridID;
   ...
375
376
377
gridID = gridCreate(GRID_LONLAT, nlon*nlat);
gridDefXsize(gridID, nlon);
gridDefYsize(gridID, nlat);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
378
379
380
381
gridDefXvals(gridID, lons);
gridDefYvals(gridID, lats);
   ...
@EndSource
Uwe Schulzweida's avatar
Uwe Schulzweida committed
382
383
@EndFunction
*/
384
int gridCreate(int gridtype, int size)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
385
{
386
  if ( CDI_Debug ) Message("gridtype=%s  size=%d", gridNamePtr(gridtype), size);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
387

388
  if ( size < 0 || size > INT_MAX ) Error("Grid size (%d) out of bounds (0 - %d)!", size, INT_MAX);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
389

390
  gridInit();
391

Uwe Schulzweida's avatar
Uwe Schulzweida committed
392
  grid_t *gridptr = gridNewEntry(CDI_UNDEFID);
393
  if ( ! gridptr ) Error("No memory");
Uwe Schulzweida's avatar
Uwe Schulzweida committed
394

Uwe Schulzweida's avatar
Uwe Schulzweida committed
395
  int gridID = gridptr->self;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
396

397
  if ( CDI_Debug ) Message("gridID: %d", gridID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
398
399
400
401
402

  gridptr->type = gridtype;
  gridptr->size = size;

  /*  if ( gridtype == GRID_GENERIC )     gridptr->xsize = size; */
403
404
  if ( gridtype == GRID_UNSTRUCTURED )  gridptr->xsize = size;
  if ( gridtype == GRID_CURVILINEAR  )  gridptr->nvertex = 4;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
405
406
407
408
409
410
411
412
413

  switch (gridtype)
    {
    case GRID_LONLAT:
    case GRID_GAUSSIAN:
    case GRID_GAUSSIAN_REDUCED:
    case GRID_CURVILINEAR:
    case GRID_TRAJECTORY:
      {
Thomas Jahns's avatar
Thomas Jahns committed
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
        if ( gridtype == GRID_TRAJECTORY )
          {
            gridDefXname(gridID, "tlon");
            gridDefYname(gridID, "tlat");
          }
        else
          {
            gridDefXname(gridID, "lon");
            gridDefYname(gridID, "lat");
          }
        gridDefXlongname(gridID, "longitude");
        gridDefYlongname(gridID, "latitude");

        /*
        if ( gridtype == GRID_CURVILINEAR )
          {
            strcpy(gridptr->xstdname, "grid_longitude");
            strcpy(gridptr->ystdname, "grid_latitude");
            gridDefXunits(gridID, "degrees");
            gridDefYunits(gridID, "degrees");
          }
        else
        */
          {
            strcpy(gridptr->xstdname, "longitude");
            strcpy(gridptr->ystdname, "latitude");
            gridDefXunits(gridID, "degrees_east");
            gridDefYunits(gridID, "degrees_north");
          }

        break;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
445
446
      }
    case GRID_GME:
447
    case GRID_UNSTRUCTURED:
448
      {
Thomas Jahns's avatar
Thomas Jahns committed
449
450
451
452
453
454
455
        gridDefXname(gridID, "lon");
        gridDefYname(gridID, "lat");
        strcpy(gridptr->xstdname, "longitude");
        strcpy(gridptr->ystdname, "latitude");
        gridDefXunits(gridID, "degrees_east");
        gridDefYunits(gridID, "degrees_north");
        break;
456
      }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
457
458
    case GRID_GENERIC:
      {
Thomas Jahns's avatar
Thomas Jahns committed
459
460
        gridDefXname(gridID, "x");
        gridDefYname(gridID, "y");
461
        /*
Thomas Jahns's avatar
Thomas Jahns committed
462
463
464
465
        strcpy(gridptr->xstdname, "grid_longitude");
        strcpy(gridptr->ystdname, "grid_latitude");
        gridDefXunits(gridID, "degrees");
        gridDefYunits(gridID, "degrees");
466
        */
Thomas Jahns's avatar
Thomas Jahns committed
467
        break;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
468
      }
469
    case GRID_LCC2:
470
    case GRID_SINUSOIDAL:
471
    case GRID_LAEA:
472
      {
Thomas Jahns's avatar
Thomas Jahns committed
473
474
475
476
477
478
479
        gridDefXname(gridID, "x");
        gridDefYname(gridID, "y");
        strcpy(gridptr->xstdname, "projection_x_coordinate");
        strcpy(gridptr->ystdname, "projection_y_coordinate");
        gridDefXunits(gridID, "m");
        gridDefYunits(gridID, "m");
        break;
480
      }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
481
482
483
484
485
    }

  return (gridID);
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
486
487
static
void gridDestroyKernel( grid_t * gridptr )
488
489
490
{
  int id;

Deike Kleberg's avatar
Deike Kleberg committed
491
  xassert ( gridptr );
492
493
494

  id = gridptr->self;

495
496
497
498
499
500
501
502
503
  if ( gridptr->mask      ) Free(gridptr->mask);
  if ( gridptr->mask_gme  ) Free(gridptr->mask_gme);
  if ( gridptr->xvals     ) Free(gridptr->xvals);
  if ( gridptr->yvals     ) Free(gridptr->yvals);
  if ( gridptr->area      ) Free(gridptr->area);
  if ( gridptr->xbounds   ) Free(gridptr->xbounds);
  if ( gridptr->ybounds   ) Free(gridptr->ybounds);
  if ( gridptr->rowlon    ) Free(gridptr->rowlon);
  if ( gridptr->reference ) Free(gridptr->reference);
504

Uwe Schulzweida's avatar
Uwe Schulzweida committed
505
  Free( gridptr );
506

507
  reshRemove ( id, &gridOps );
508
}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
509

510
511
512
513
514
515
/*
@Function  gridDestroy
@Title     Destroy a horizontal Grid

@Prototype void gridDestroy(int gridID)
@Parameter
Deike Kleberg's avatar
Deike Kleberg committed
516
    @Item  gridID   Grid ID, from a previous call to @fref{gridCreate}.
517
518
519
520
521

@EndFunction
*/
void gridDestroy(int gridID)
{
522
  grid_t *gridptr = gridID2Ptr(gridID);
523

524
  gridDestroyKernel ( gridptr );
525
526
}

527
void gridDestroyP ( void * gridptr )
528
{
529
  gridDestroyKernel (( grid_t * ) gridptr );
530
531
532
}


533
const char *gridNamePtr(int gridtype)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
534
{
535
  int size = (int) (sizeof(Grids)/sizeof(Grids[0]));
Uwe Schulzweida's avatar
Uwe Schulzweida committed
536

537
  const char *name = gridtype >= 0 && gridtype < size ? Grids[gridtype] : Grids[GRID_GENERIC];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553

  return (name);
}


void gridName(int gridtype, char *gridname)
{
  strcpy(gridname, gridNamePtr(gridtype));
}

/*
@Function  gridDefXname
@Title     Define the name of a X-axis

@Prototype void gridDefXname(int gridID, const char *name)
@Parameter
Deike Kleberg's avatar
Deike Kleberg committed
554
555
    @Item  gridID   Grid ID, from a previous call to @fref{gridCreate}.
    @Item  name     Name of the X-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
556
557

@Description
558
The function @func{gridDefXname} defines the name of a X-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
559
560
561

@EndFunction
*/
Uwe Schulzweida's avatar
Uwe Schulzweida committed
562
void gridDefXname(int gridID, const char *xname)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
563
{
564
  grid_t *gridptr = gridID2Ptr(gridID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
565

566
567
  if ( xname )
    {
568
569
      strncpy(gridptr->xname, xname, CDI_MAX_NAME);
      gridptr->xname[CDI_MAX_NAME - 1] = 0;
570
571
      reshSetStatus(gridID, &gridOps, RESH_DESYNC_IN_USE);
    }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
572
573
574
575
576
577
578
579
}

/*
@Function  gridDefXlongname
@Title     Define the longname of a X-axis

@Prototype void gridDefXlongname(int gridID, const char *longname)
@Parameter
Deike Kleberg's avatar
Deike Kleberg committed
580
581
    @Item  gridID   Grid ID, from a previous call to @fref{gridCreate}.
    @Item  longname Longname of the X-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
582
583

@Description
584
The function @func{gridDefXlongname} defines the longname of a X-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
585
586
587

@EndFunction
*/
Uwe Schulzweida's avatar
Uwe Schulzweida committed
588
void gridDefXlongname(int gridID, const char *xlongname)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
589
{
590
  grid_t *gridptr = gridID2Ptr(gridID);
591
592
  if ( xlongname )
    {
593
594
      strncpy(gridptr->xlongname, xlongname, CDI_MAX_NAME);
      gridptr->xlongname[CDI_MAX_NAME - 1] = 0;
595
596
      reshSetStatus(gridID, &gridOps, RESH_DESYNC_IN_USE);
    }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
597
598
599
600
601
602
603
604
}

/*
@Function  gridDefXunits
@Title     Define the units of a X-axis

@Prototype void gridDefXunits(int gridID, const char *units)
@Parameter
Deike Kleberg's avatar
Deike Kleberg committed
605
606
    @Item  gridID   Grid ID, from a previous call to @fref{gridCreate}.
    @Item  units    Units of the X-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
607
608

@Description
609
The function @func{gridDefXunits} defines the units of a X-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
610
611
612

@EndFunction
*/
Uwe Schulzweida's avatar
Uwe Schulzweida committed
613
void gridDefXunits(int gridID, const char *xunits)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
614
{
615
  grid_t *gridptr = gridID2Ptr(gridID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
616

617
618
  if ( xunits )
    {
619
620
      strncpy(gridptr->xunits, xunits, CDI_MAX_NAME);
      gridptr->xunits[CDI_MAX_NAME - 1] = 0;
621
622
      reshSetStatus(gridID, &gridOps, RESH_DESYNC_IN_USE);
    }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
623
624
625
626
627
628
629
630
}

/*
@Function  gridDefYname
@Title     Define the name of a Y-axis

@Prototype void gridDefYname(int gridID, const char *name)
@Parameter
Deike Kleberg's avatar
Deike Kleberg committed
631
632
    @Item  gridID   Grid ID, from a previous call to @fref{gridCreate}.
    @Item  name     Name of the Y-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
633
634

@Description
635
The function @func{gridDefYname} defines the name of a Y-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
636
637
638

@EndFunction
*/
Uwe Schulzweida's avatar
Uwe Schulzweida committed
639
void gridDefYname(int gridID, const char *yname)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
640
{
641
  grid_t *gridptr = gridID2Ptr(gridID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
642

643
644
  if ( yname )
    {
645
646
      strncpy(gridptr->yname, yname, CDI_MAX_NAME);
      gridptr->yname[CDI_MAX_NAME - 1] = 0;
647
648
      reshSetStatus(gridID, &gridOps, RESH_DESYNC_IN_USE);
    }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
649
650
651
652
653
654
655
656
}

/*
@Function  gridDefYlongname
@Title     Define the longname of a Y-axis

@Prototype void gridDefYlongname(int gridID, const char *longname)
@Parameter
Deike Kleberg's avatar
Deike Kleberg committed
657
658
    @Item  gridID   Grid ID, from a previous call to @fref{gridCreate}.
    @Item  longname Longname of the Y-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
659
660

@Description
661
The function @func{gridDefYlongname} defines the longname of a Y-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
662
663
664

@EndFunction
*/
Uwe Schulzweida's avatar
Uwe Schulzweida committed
665
void gridDefYlongname(int gridID, const char *ylongname)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
666
{
667
  grid_t *gridptr = gridID2Ptr(gridID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
668

669
670
  if ( ylongname )
    {
671
672
      strncpy(gridptr->ylongname, ylongname, CDI_MAX_NAME);
      gridptr->ylongname[CDI_MAX_NAME - 1] = 0;
673
674
      reshSetStatus(gridID, &gridOps, RESH_DESYNC_IN_USE);
    }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
675
676
677
678
679
680
681
682
}

/*
@Function  gridDefYunits
@Title     Define the units of a Y-axis

@Prototype void gridDefYunits(int gridID, const char *units)
@Parameter
Deike Kleberg's avatar
Deike Kleberg committed
683
684
    @Item  gridID   Grid ID, from a previous call to @fref{gridCreate}.
    @Item  units    Units of the Y-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
685
686

@Description
687
The function @func{gridDefYunits} defines the units of a Y-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
688
689
690

@EndFunction
*/
Uwe Schulzweida's avatar
Uwe Schulzweida committed
691
void gridDefYunits(int gridID, const char *yunits)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
692
{
693
  grid_t *gridptr = gridID2Ptr(gridID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
694

695
696
  if ( yunits )
    {
697
698
      strncpy(gridptr->yunits, yunits, CDI_MAX_NAME);
      gridptr->yunits[CDI_MAX_NAME - 1] = 0;
699
700
      reshSetStatus(gridID, &gridOps, RESH_DESYNC_IN_USE);
    }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
701
702
703
704
705
706
}

/*
@Function  gridInqXname
@Title     Get the name of a X-axis

Deike Kleberg's avatar
Deike Kleberg committed
707
@Prototype void gridInqXname(int gridID, char *name)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
708
@Parameter
Uwe Schulzweida's avatar
Uwe Schulzweida committed
709
710
    @Item  gridID   Grid ID, from a previous call to @fref{gridCreate} or @fref{vlistInqVarGrid}.
    @Item  name     Name of the X-axis. The caller must allocate space for the
Deike Kleberg's avatar
Deike Kleberg committed
711
                    returned string. The maximum possible length, in characters, of
712
                    the string is given by the predefined constant @func{CDI_MAX_NAME}.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
713
714

@Description
715
The function @func{gridInqXname} returns the name of a X-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
716
717

@Result
718
@func{gridInqXname} returns the name of the X-axis to the parameter name.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
719
720
721
722
723

@EndFunction
*/
void gridInqXname(int gridID, char *xname)
{
724
  grid_t *gridptr = gridID2Ptr(gridID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
725
726
727
728
729
730
731
732

  strcpy(xname, gridptr->xname);
}

/*
@Function  gridInqXlongname
@Title     Get the longname of a X-axis

Deike Kleberg's avatar
Deike Kleberg committed
733
@Prototype void gridInqXlongname(int gridID, char *longname)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
734
@Parameter
Uwe Schulzweida's avatar
Uwe Schulzweida committed
735
736
    @Item  gridID   Grid ID, from a previous call to @fref{gridCreate} or @fref{vlistInqVarGrid}.
    @Item  longname Longname of the X-axis. The caller must allocate space for the
Deike Kleberg's avatar
Deike Kleberg committed
737
                    returned string. The maximum possible length, in characters, of
738
                    the string is given by the predefined constant @func{CDI_MAX_NAME}.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
739
740

@Description
741
The function @func{gridInqXlongname} returns the longname of a X-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
742
743

@Result
744
@func{gridInqXlongname} returns the longname of the X-axis to the parameter longname.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
745
746
747
748
749

@EndFunction
*/
void gridInqXlongname(int gridID, char *xlongname)
{
750
  grid_t *gridptr = gridID2Ptr(gridID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
751
752
753
754
755
756
757
758

  strcpy(xlongname, gridptr->xlongname);
}

/*
@Function  gridInqXunits
@Title     Get the units of a X-axis

Deike Kleberg's avatar
Deike Kleberg committed
759
@Prototype void gridInqXunits(int gridID, char *units)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
760
@Parameter
Uwe Schulzweida's avatar
Uwe Schulzweida committed
761
762
    @Item  gridID   Grid ID, from a previous call to @fref{gridCreate} or @fref{vlistInqVarGrid}.
    @Item  units    Units of the X-axis. The caller must allocate space for the
Deike Kleberg's avatar
Deike Kleberg committed
763
                    returned string. The maximum possible length, in characters, of
764
                    the string is given by the predefined constant @func{CDI_MAX_NAME}.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
765
766

@Description
767
The function @func{gridInqXunits} returns the units of a X-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
768
769

@Result
770
@func{gridInqXunits} returns the units of the X-axis to the parameter units.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
771
772
773
774
775

@EndFunction
*/
void gridInqXunits(int gridID, char *xunits)
{
776
  grid_t *gridptr = gridID2Ptr(gridID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
777
778
779
780
781
782
783

  strcpy(xunits, gridptr->xunits);
}


void gridInqXstdname(int gridID, char *xstdname)
{
784
  grid_t *gridptr = gridID2Ptr(gridID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
785
786
787
788
789
790
791
792

  strcpy(xstdname, gridptr->xstdname);
}

/*
@Function  gridInqYname
@Title     Get the name of a Y-axis

Deike Kleberg's avatar
Deike Kleberg committed
793
@Prototype void gridInqYname(int gridID, char *name)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
794
@Parameter
Uwe Schulzweida's avatar
Uwe Schulzweida committed
795
796
    @Item  gridID   Grid ID, from a previous call to @fref{gridCreate} or @fref{vlistInqVarGrid}.
    @Item  name     Name of the Y-axis. The caller must allocate space for the
Deike Kleberg's avatar
Deike Kleberg committed
797
                    returned string. The maximum possible length, in characters, of
798
                    the string is given by the predefined constant @func{CDI_MAX_NAME}.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
799
800

@Description
801
The function @func{gridInqYname} returns the name of a Y-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
802
803

@Result
804
@func{gridInqYname} returns the name of the Y-axis to the parameter name.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
805
806
807
808
809

@EndFunction
*/
void gridInqYname(int gridID, char *yname)
{
810
  grid_t *gridptr = gridID2Ptr(gridID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
811
812
813
814
815
816
817
818

  strcpy(yname, gridptr->yname);
}

/*
@Function  gridInqYlongname
@Title     Get the longname of a Y-axis

Deike Kleberg's avatar
Deike Kleberg committed
819
@Prototype void gridInqXlongname(int gridID, char *longname)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
820
@Parameter
Uwe Schulzweida's avatar
Uwe Schulzweida committed
821
822
    @Item  gridID   Grid ID, from a previous call to @fref{gridCreate} or @fref{vlistInqVarGrid}.
    @Item  longname Longname of the Y-axis. The caller must allocate space for the
Deike Kleberg's avatar
Deike Kleberg committed
823
                    returned string. The maximum possible length, in characters, of
824
                    the string is given by the predefined constant @func{CDI_MAX_NAME}.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
825
826

@Description
827
The function @func{gridInqYlongname} returns the longname of a Y-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
828
829

@Result
830
@func{gridInqYlongname} returns the longname of the Y-axis to the parameter longname.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
831
832
833
834
835

@EndFunction
*/
void gridInqYlongname(int gridID, char *ylongname)
{
836
  grid_t *gridptr = gridID2Ptr(gridID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
837
838
839
840
841
842
843
844

  strcpy(ylongname, gridptr->ylongname);
}

/*
@Function  gridInqYunits
@Title     Get the units of a Y-axis

Deike Kleberg's avatar
Deike Kleberg committed
845
@Prototype void gridInqYunits(int gridID, char *units)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
846
@Parameter
Uwe Schulzweida's avatar
Uwe Schulzweida committed
847
848
    @Item  gridID   Grid ID, from a previous call to @fref{gridCreate} or @fref{vlistInqVarGrid}.
    @Item  units    Units of the Y-axis. The caller must allocate space for the
Deike Kleberg's avatar
Deike Kleberg committed
849
                    returned string. The maximum possible length, in characters, of
850
                    the string is given by the predefined constant @func{CDI_MAX_NAME}.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
851
852

@Description
853
The function @func{gridInqYunits} returns the units of a Y-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
854
855

@Result
856
@func{gridInqYunits} returns the units of the Y-axis to the parameter units.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
857
858
859
860
861

@EndFunction
*/
void gridInqYunits(int gridID, char *yunits)
{
862
  grid_t *gridptr = gridID2Ptr(gridID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
863
864
865
866
867
868

  strcpy(yunits, gridptr->yunits);
}

void gridInqYstdname(int gridID, char *ystdname)
{
869
  grid_t *gridptr = gridID2Ptr(gridID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
870
871
872
873
874
875
876
877
878
879

  strcpy(ystdname, gridptr->ystdname);
}

/*
@Function  gridInqType
@Title     Get the type of a Grid

@Prototype int gridInqType(int gridID)
@Parameter
Uwe Schulzweida's avatar
Uwe Schulzweida committed
880
    @Item  gridID   Grid ID, from a previous call to @fref{gridCreate} or @fref{vlistInqVarGrid}.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
881
882

@Description
883
The function @func{gridInqType} returns the type of a Grid.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
884
885

@Result
886
@func{gridInqType} returns the type of the grid,
Uwe Schulzweida's avatar
Uwe Schulzweida committed
887
one of the set of predefined CDI grid types.
888
The valid CDI grid types are @func{GRID_GENERIC}, @func{GRID_GAUSSIAN},
Uwe Schulzweida's avatar
Uwe Schulzweida committed
889
@func{GRID_LONLAT}, @func{GRID_LCC}, @func{GRID_SPECTRAL}, @func{GRID_GME},
890
@func{GRID_CURVILINEAR} and @func{GRID_UNSTRUCTURED}.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
891
892
893
894
895

@EndFunction
*/
int gridInqType(int gridID)
{
896
  grid_t *gridptr = gridID2Ptr(gridID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
897
898
899
900
901
902
903
904
905
906
907

  return (gridptr->type);
}


/*
@Function  gridInqSize
@Title     Get the size of a Grid

@Prototype int gridInqSize(int gridID)
@Parameter
Uwe Schulzweida's avatar
Uwe Schulzweida committed
908
    @Item  gridID   Grid ID, from a previous call to @fref{gridCreate} or @fref{vlistInqVarGrid}.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
909
910

@Description
911
The function @func{gridInqSize} returns the size of a Grid.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
912
913

@Result
914
@func{gridInqSize} returns the number of grid points of a Grid.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
915
916
917
918
919

@EndFunction
*/
int gridInqSize(int gridID)
{
920
  grid_t *gridptr = gridID2Ptr(gridID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
921

Uwe Schulzweida's avatar
Uwe Schulzweida committed
922
  int size = gridptr->size;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
923
924
925
926
927
928
929
930
931

  if ( ! size )
    {
      int xsize, ysize;

      xsize = gridptr->xsize;
      ysize = gridptr->ysize;

      if ( ysize )
Thomas Jahns's avatar
Thomas Jahns committed
932
        size = xsize *ysize;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
933
      else
Thomas Jahns's avatar
Thomas Jahns committed
934
        size = xsize;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
935

Thomas Jahns's avatar
Thomas Jahns committed
936
      gridptr->size = size;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
937
938
939
940
941
    }

  return (size);
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
942
943
static
int nsp2trunc(int nsp)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
944
945
946
947
948
949
950
{
  /*  nsp = (trunc+1)*(trunc+1)              */
  /*      => trunc^2 + 3*trunc - (x-2) = 0   */
  /*                                         */
  /*  with:  y^2 + p*y + q = 0               */
  /*         y = -p/2 +- sqrt((p/2)^2 - q)   */
  /*         p = 3 and q = - (x-2)           */
951
  int trunc = (int) (sqrt(nsp*4 + 1.) - 3) / 2;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
952
953
954
955
956
957
  return (trunc);
}


int gridInqTrunc(int gridID)
{
958
  grid_t *gridptr = gridID2Ptr(gridID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
959
960
961
962

  if ( gridptr->trunc == 0 )
    {
      if ( gridptr->type == GRID_SPECTRAL )
Thomas Jahns's avatar
Thomas Jahns committed
963
        gridptr->trunc = nsp2trunc(gridptr->size);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
964
965
      /*
      else if      ( gridptr->type == GRID_GAUSSIAN )
Thomas Jahns's avatar
Thomas Jahns committed
966
        gridptr->trunc = nlat2trunc(gridptr->ysize);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
967
968
969
970
971
972
      */
    }

  return (gridptr->trunc);
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
973

Uwe Schulzweida's avatar
Uwe Schulzweida committed
974
975
void gridDefTrunc(int gridID, int trunc)
{
976
  grid_t *gridptr = gridID2Ptr(gridID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
977

978
979
980
981
982
  if (gridptr->trunc != trunc)
    {
      reshSetStatus(gridID, &gridOps, RESH_DESYNC_IN_USE);
      gridptr->trunc = trunc;
    }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
983
984
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
985
986
987
988
989
990
/*
@Function  gridDefXsize
@Title     Define the number of values of a X-axis

@Prototype void gridDefXsize(int gridID, int xsize)
@Parameter
Deike Kleberg's avatar
Deike Kleberg committed
991
992
    @Item  gridID   Grid ID, from a previous call to @fref{gridCreate}.
    @Item  xsize    Number of values of a X-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
993
994

@Description
995
The function @func{gridDefXsize} defines the number of values of a X-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
996
997
998

@EndFunction
*/
Uwe Schulzweida's avatar
Uwe Schulzweida committed
999
1000
void gridDefXsize(int gridID, int xsize)
{
For faster browsing, not all history is shown. View entire blame