zaxis.c 51 KB
Newer Older
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1
2
3
4
5
6
7
8
9
10
11
#if defined (HAVE_CONFIG_H)
#  include "config.h"
#endif

#include <string.h>
#include <math.h>
#include <float.h>

#include "dmemory.h"

#include "cdi.h"
12
#include "cdi_cksum.h"
13
#include "cdi_int.h"
14
#include "cdi_uuid.h"
15
#include "resource_handle.h"
16
#include "resource_unpack.h"
17
#include "varscan.h"
Deike Kleberg's avatar
Deike Kleberg committed
18
#include "namespace.h"
19
#include "serialize.h"
20
#include "zaxis.h"
Uwe Schulzweida's avatar
Uwe Schulzweida committed
21

Deike Kleberg's avatar
Deike Kleberg committed
22
23
24
25
#define  LevelUp    1
#define  LevelDown  2


Thomas Jahns's avatar
Thomas Jahns committed
26
static const struct {
27
  unsigned char positive;   // 1: up;  2: down
Oliver Heidmann's avatar
Oliver Heidmann committed
28
29
30
31
  const char *name;
  const char *longname;
  const char *stdname;
  const char *units;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
32
}
33
ZaxistypeEntry[] = {
34
  { /*  0 */ 0, "sfc",               "surface",                "",               ""},
35
  { /*  1 */ 0, "lev",               "generic",                "",               ""},
36
37
  { /*  2 */ 2, "lev",               "hybrid",                 "",               "level"},
  { /*  3 */ 2, "lev",               "hybrid_half",            "",               "level"},
38
  { /*  4 */ 2, "plev",              "pressure",               "air_pressure",   "Pa"},
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
  { /*  5 */ 1, "height",            "height",                 "height",         "m"},
  { /*  6 */ 2, "depth",             "depth_below_sea",        "depth",          "m"},
  { /*  7 */ 2, "depth",             "depth_below_land",       "",               "cm"},
  { /*  8 */ 0, "lev",               "isentropic",             "",               "K"},
  { /*  9 */ 0, "lev",               "trajectory",             "",               ""},
  { /* 10 */ 1, "alt",               "altitude",               "",               "m"},
  { /* 11 */ 0, "lev",               "sigma",                  "",               "level"},
  { /* 12 */ 0, "lev",               "meansea",                "",               "level"},
  { /* 13 */ 0, "toa",               "top_of_atmosphere",      "",               ""},
  { /* 14 */ 0, "seabottom",         "sea_bottom",             "",               ""},
  { /* 15 */ 0, "atmosphere",        "atmosphere",             "",               ""},
  { /* 16 */ 0, "cloudbase",         "cloud_base",             "",               ""},
  { /* 17 */ 0, "cloudtop",          "cloud_top",              "",               ""},
  { /* 18 */ 0, "isotherm0",         "isotherm_zero",          "",               ""},
  { /* 19 */ 0, "snow",              "snow",                   "",               ""},
  { /* 20 */ 0, "lakebottom",        "lake_bottom",            "",               ""},
  { /* 21 */ 0, "sedimentbottom",    "sediment_bottom",        "",               ""},
  { /* 22 */ 0, "sedimentbottomta",  "sediment_bottom_ta",     "",               ""},
  { /* 23 */ 0, "sedimentbottomtw",  "sediment_bottom_tw",     "",               ""},
  { /* 24 */ 0, "mixlayer",          "mix_layer",              "",               ""},
59
  { /* 25 */ 0, "height",            "generalized_height",     "height",         ""},
Uwe Schulzweida's avatar
Uwe Schulzweida committed
60
61
};

62
enum {
63
  CDI_NumZaxistype = sizeof(ZaxistypeEntry) / sizeof(ZaxistypeEntry[0]),
64
};
65

Uwe Schulzweida's avatar
Uwe Schulzweida committed
66

67
static int    zaxisCompareP    (zaxis_t *z1, zaxis_t *z2);
Deike Kleberg's avatar
Deike Kleberg committed
68
69
static void   zaxisDestroyP    ( void * zaxisptr );
static void   zaxisPrintP      ( void * zaxisptr, FILE * fp );
70
71
static int    zaxisGetPackSize ( void * zaxisptr, void *context);
static void   zaxisPack        ( void * zaxisptr, void * buffer, int size, int *pos, void *context);
Deike Kleberg's avatar
Deike Kleberg committed
72
static int    zaxisTxCode      ( void );
Uwe Schulzweida's avatar
Uwe Schulzweida committed
73

Thomas Jahns's avatar
Thomas Jahns committed
74
static const resOps zaxisOps = {
75
  (int (*)(void *, void *))zaxisCompareP,
76
77
78
79
80
  zaxisDestroyP,
  zaxisPrintP,
  zaxisGetPackSize,
  zaxisPack,
  zaxisTxCode
81
};
Uwe Schulzweida's avatar
Uwe Schulzweida committed
82

83
const resOps *getZaxisOps(void)
84
85
86
87
{
  return &zaxisOps;
}

88
static int  ZAXIS_Debug = 0;   /* If set to 1, debugging */
Uwe Schulzweida's avatar
Uwe Schulzweida committed
89

90
void zaxisGetTypeDescription(int zaxisType, int *outPositive, const char **outName, const char **outLongName, const char **outStdName, const char **outUnit)
91
{
92
  if ( zaxisType < 0 || zaxisType >= CDI_NumZaxistype )
93
    {
94
95
96
97
98
      if (outPositive) *outPositive = 0;
      if (outName) *outName = NULL;
      if (outLongName) *outLongName = NULL;
      if (outStdName) *outStdName = NULL;
      if (outUnit) *outUnit = NULL;
99
100
101
    }
  else
    {
102
103
104
105
106
      if (outPositive) *outPositive = ZaxistypeEntry[zaxisType].positive;
      if (outName) *outName = ZaxistypeEntry[zaxisType].name;
      if (outLongName) *outLongName = ZaxistypeEntry[zaxisType].longname;
      if (outStdName) *outStdName = ZaxistypeEntry[zaxisType].stdname;
      if (outUnit) *outUnit = ZaxistypeEntry[zaxisType].units;
107
108
109
    }
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
110
111
112
113
114
115

zaxis_t *zaxis_to_pointer(int id)
{
  return (zaxis_t *)reshGetVal(id, &zaxisOps);
}

116
static
Uwe Schulzweida's avatar
Uwe Schulzweida committed
117
void zaxis_init(zaxis_t *zaxisptr)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
118
{
119
120
121
122
123
124
125
126
  zaxisptr->self          = CDI_UNDEFID;
  zaxisptr->name[0]       = 0;
  zaxisptr->longname[0]   = 0;
  zaxisptr->stdname[0]    = 0;
  zaxisptr->dimname[0]    = 0;
  zaxisptr->vdimname[0]   = 0;
  zaxisptr->units[0]      = 0;
  zaxisptr->psname[0]     = 0;
127
128
  zaxisptr->p0name[0]     = 0;
  zaxisptr->p0value.defined = false;
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
  zaxisptr->vals          = NULL;
  zaxisptr->ubounds       = NULL;
  zaxisptr->lbounds       = NULL;
  zaxisptr->weights       = NULL;
  zaxisptr->type          = CDI_UNDEFID;
  zaxisptr->ltype         = 0;
  zaxisptr->ltype2        = -1;
  zaxisptr->positive      = 0;
  zaxisptr->scalar        = 0;
  zaxisptr->direction     = 0;
  zaxisptr->prec          = 0;
  zaxisptr->size          = 0;
  zaxisptr->vctsize       = 0;
  zaxisptr->vct           = NULL;
  zaxisptr->number        = 0;
  zaxisptr->nhlev         = 0;
Thomas Jahns's avatar
Thomas Jahns committed
145
  memset(zaxisptr->uuid, 0, CDI_UUID_SIZE);
146
147
  zaxisptr->atts.nalloc   = MAX_ATTRIBUTES;
  zaxisptr->atts.nelems   = 0;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
148
}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
149

150
static
151
zaxis_t *zaxisNewEntry(int id)
152
{
153
  zaxis_t *zaxisptr = (zaxis_t *) Malloc(sizeof(zaxis_t));
Uwe Schulzweida's avatar
Uwe Schulzweida committed
154
  zaxis_init(zaxisptr);
155

156
  if ( id == CDI_UNDEFID )
157
158
159
160
161
162
    zaxisptr->self = reshPut(zaxisptr, &zaxisOps);
  else
    {
      zaxisptr->self = id;
      reshReplace(id, zaxisptr, &zaxisOps);
    }
163

164
  return zaxisptr;
165
166
}

167
static
168
void zaxisInit(void)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
169
{
170
  static bool zaxisInitialized = false;
171
  if ( zaxisInitialized ) return;
172
  zaxisInitialized = true;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
173

174
  const char *env = getenv("ZAXIS_DEBUG");
175
  if ( env ) ZAXIS_Debug = atoi(env);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
176
177
}

178
179
static
void zaxis_copy(zaxis_t *zaxisptr2, zaxis_t *zaxisptr1)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
180
{
181
  int zaxisID2 = zaxisptr2->self;
182
  memcpy(zaxisptr2, zaxisptr1, sizeof(zaxis_t));
Uwe Schulzweida's avatar
Uwe Schulzweida committed
183
184
185
  zaxisptr2->self = zaxisID2;
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
186

187
unsigned cdiZaxisCount(void)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
188
{
189
  return reshCountType(&zaxisOps);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
190
191
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
192
193
static
int zaxisCreate_(int zaxistype, int size, int id)
194
195
196
{
  zaxis_t *zaxisptr = zaxisNewEntry(id);

197
  xassert(size >= 0);
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
  zaxisptr->type = zaxistype;
  zaxisptr->size = size;

  if ( zaxistype >= CDI_NumZaxistype || zaxistype < 0 )
    Error("Internal problem! zaxistype > CDI_MaxZaxistype");

  int zaxisID = zaxisptr->self;
  zaxisDefName(zaxisID, ZaxistypeEntry[zaxistype].name);
  zaxisDefLongname(zaxisID, ZaxistypeEntry[zaxistype].longname);
  zaxisDefUnits(zaxisID, ZaxistypeEntry[zaxistype].units);

  if ( *ZaxistypeEntry[zaxistype].stdname )
    strcpy(zaxisptr->stdname, ZaxistypeEntry[zaxistype].stdname);

  zaxisptr->positive = ZaxistypeEntry[zaxistype].positive;

  return zaxisID;
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
217
/*
218
@Function  zaxisCreate
219
@Title     Create a vertical Z-axis
Uwe Schulzweida's avatar
Uwe Schulzweida committed
220

221
@Prototype int zaxisCreate(int zaxistype, int size)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
222
223
@Parameter
    @Item  zaxistype  The type of the Z-axis, one of the set of predefined CDI Z-axis types.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
224
                      The valid CDI Z-axis types are @func{ZAXIS_GENERIC}, @func{ZAXIS_SURFACE},
Uwe Schulzweida's avatar
Uwe Schulzweida committed
225
                      @func{ZAXIS_HYBRID}, @func{ZAXIS_SIGMA}, @func{ZAXIS_PRESSURE}, @func{ZAXIS_HEIGHT},
226
227
                      @func{ZAXIS_ISENTROPIC}, @func{ZAXIS_ALTITUDE}, @func{ZAXIS_MEANSEA}, @func{ZAXIS_TOA},
                      @func{ZAXIS_SEA_BOTTOM}, @func{ZAXIS_ATMOSPHERE}, @func{ZAXIS_CLOUD_BASE},
228
                      @func{ZAXIS_CLOUD_TOP}, @func{ZAXIS_ISOTHERM_ZERO}, @func{ZAXIS_SNOW},
229
230
                      @func{ZAXIS_LAKE_BOTTOM}, @func{ZAXIS_SEDIMENT_BOTTOM}, @func{ZAXIS_SEDIMENT_BOTTOM_TA},
                      @func{ZAXIS_SEDIMENT_BOTTOM_TW}, @func{ZAXIS_MIX_LAYER},
231
                      @func{ZAXIS_DEPTH_BELOW_SEA} and @func{ZAXIS_DEPTH_BELOW_LAND}.
Deike Kleberg's avatar
Deike Kleberg committed
232
    @Item  size       Number of levels.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
233
234

@Description
235
The function @func{zaxisCreate} creates a vertical Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
236
237

@Result
238
@func{zaxisCreate} returns an identifier to the Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
239

Uwe Schulzweida's avatar
Uwe Schulzweida committed
240
@Example
241
Here is an example using @func{zaxisCreate} to create a pressure level Z-axis:
Uwe Schulzweida's avatar
Uwe Schulzweida committed
242
243
244
245

@Source
#include "cdi.h"
   ...
246
#define  nlev    5
Uwe Schulzweida's avatar
Uwe Schulzweida committed
247
   ...
248
double levs[nlev] = {101300, 92500, 85000, 50000, 20000};
Uwe Schulzweida's avatar
Uwe Schulzweida committed
249
250
int zaxisID;
   ...
251
zaxisID = zaxisCreate(ZAXIS_PRESSURE, nlev);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
252
253
254
zaxisDefLevels(zaxisID, levs);
   ...
@EndSource
Uwe Schulzweida's avatar
Uwe Schulzweida committed
255
256
@EndFunction
*/
257
int zaxisCreate(int zaxistype, int size)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
258
{
259
  if ( CDI_Debug ) Message("zaxistype: %d size: %d ", zaxistype, size);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
260

Uwe Schulzweida's avatar
Uwe Schulzweida committed
261
262
  zaxisInit();

263
  return zaxisCreate_(zaxistype, size, CDI_UNDEFID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
264
265
}

266
267
static
void zaxisDestroyKernel( zaxis_t * zaxisptr )
268
{
Deike Kleberg's avatar
Deike Kleberg committed
269
  xassert ( zaxisptr );
270

271
  int id = zaxisptr->self;
272

Uwe Schulzweida's avatar
Uwe Schulzweida committed
273
274
275
276
277
  if ( zaxisptr->vals )    Free( zaxisptr->vals );
  if ( zaxisptr->lbounds ) Free( zaxisptr->lbounds );
  if ( zaxisptr->ubounds ) Free( zaxisptr->ubounds );
  if ( zaxisptr->weights ) Free( zaxisptr->weights );
  if ( zaxisptr->vct )     Free( zaxisptr->vct );
278

Uwe Schulzweida's avatar
Uwe Schulzweida committed
279
  Free( zaxisptr );
280

281
  reshRemove ( id, &zaxisOps );
282
283
}

284
285
286
287
288
289
/*
@Function  zaxisDestroy
@Title     Destroy a vertical Z-axis

@Prototype void zaxisDestroy(int zaxisID)
@Parameter
Deike Kleberg's avatar
Deike Kleberg committed
290
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate}.
291
292
293
294
295

@EndFunction
*/
void zaxisDestroy(int zaxisID)
{
296
  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
297
  zaxisDestroyKernel(zaxisptr);
298
299
300
}


301
static
302
void zaxisDestroyP(void *zaxisptr)
303
{
304
  zaxisDestroyKernel((zaxis_t *) zaxisptr);
305
306
307
}


Oliver Heidmann's avatar
Oliver Heidmann committed
308
const char *zaxisNamePtr(int zaxistype)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
309
{
Oliver Heidmann's avatar
Oliver Heidmann committed
310
  const char *name = (zaxistype >= 0 && zaxistype < CDI_NumZaxistype)
311
312
    ? ZaxistypeEntry[zaxistype].longname
    : ZaxistypeEntry[ZAXIS_GENERIC].longname;
313
  return name;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
314
315
316
317
318
319
320
321
}


void zaxisName(int zaxistype, char *zaxisname)
{
  strcpy(zaxisname, zaxisNamePtr(zaxistype));
}

322
323
324
static inline
void zaxisSetString(char *zaxisstrname, const char *name, size_t len)
{
325
  if ( len > CDI_MAX_NAME ) len = CDI_MAX_NAME;
326
  strncpy(zaxisstrname, name, len);
327
  zaxisstrname[len-1] = 0;
328
329
330
331
332
}

static inline
void zaxisGetString(char *name, const char *zaxisstrname, size_t len)
{
333
334
335
336
337
  size_t slen = strlen(zaxisstrname)+1;
  if ( slen > len ) slen = len;
  if ( slen > CDI_MAX_NAME ) slen = CDI_MAX_NAME;
  strncpy(name, zaxisstrname, slen);
  name[slen-1] = 0;
338
339
340
}

static
341
void *zaxis_key_to_ptr(zaxis_t *zaxisptr, int key)
342
{
343
  void *keyptr = NULL;
344
345
346

  switch (key)
    {
347
348
349
350
351
    case CDI_KEY_NAME:      keyptr = (void*)zaxisptr->name; break;
    case CDI_KEY_LONGNAME:  keyptr = (void*)zaxisptr->longname; break;
    case CDI_KEY_UNITS:     keyptr = (void*)zaxisptr->units; break;
    case CDI_KEY_DIMNAME:   keyptr = (void*)zaxisptr->dimname; break;
    case CDI_KEY_VDIMNAME:  keyptr = (void*)zaxisptr->vdimname; break;
352
    case CDI_KEY_PSNAME:    keyptr = (void*)zaxisptr->psname; break;
353
354
    case CDI_KEY_P0NAME:    keyptr = (void*)zaxisptr->p0name; break;
    case CDI_KEY_P0VALUE:   keyptr = (void*)&zaxisptr->p0value; break;
355
356
    }

357
  return keyptr;
358
359
360
}

/*
361
@Function  cdiZaxisDefKeyStr
362
363
@Title     Define a CDI Z-axis string value from a key

364
@Prototype int cdiZaxisDefKeyStr(int zaxisID, int key, int size, const char *mesg)
365
366
367
368
369
370
371
@Parameter
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate}.
    @Item  key      The key to be searched
    @Item  size     The allocated length of the string on input
    @Item  mesg     The address of a string where the data will be read

@Description
372
The function @func{cdiZaxisDefKeyStr} defines a CDI Z-axis string value from a key.
373
374

@Result
375
@func{cdiZaxisDefKeyStr} returns 0 if OK and integer value on error.
376
377
378

@EndFunction
*/
379
int cdiZaxisDefKeyStr(int zaxisID, int key, int size, const char *mesg)
380
{
381
  if ( size < 1 || mesg == NULL || *mesg == 0 ) return -1;
382

383
  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
384

385
  char *keyptr = (char*)zaxis_key_to_ptr(zaxisptr, key);
386
  if ( keyptr == NULL)
387
388
389
390
391
    {
      Warning("CDI zaxis string key %d not supported!", key);
      return -1;
    }

392
  zaxisSetString(keyptr, mesg, (size_t)size);
393
394
395
396
397
398
  reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);

  return 0;
}

/*
399
@Function  cdiZaxisInqKeyStr
400
401
@Title     Get a CDI Z-axis string value from a key

402
@Prototype int cdiZaxisInqKeyStr(int zaxisID, int key, int size, char *mesg)
403
404
405
406
407
408
409
410
411
412
@Parameter
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate}.
    @Item  key      The key to be searched.
    @Item  size     The allocated length of the string on input.
    @Item  mesg     The address of a string where the data will be retrieved.
                    The caller must allocate space for the returned string.
                    The maximum possible length, in characters, of the string
                    is given by the predefined constant @func{CDI_MAX_NAME}.

@Description
413
The function @func{cdiZaxisInqKeyStr} return a CDI Z-axis string value from a key.
414
415

@Result
416
@func{cdiZaxisInqKeyStr} returns 0 if OK and integer value on error.
417
418
419

@EndFunction
*/
420
int cdiZaxisInqKeyStr(int zaxisID, int key, int size, char *mesg)
421
{
422
  if ( size < 1 || mesg == NULL ) return -1;
423

424
  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
425
  const char *keyptr = (const char*)zaxis_key_to_ptr(zaxisptr, key);
426
  if ( keyptr == NULL)
427
428
429
430
431
    {
      Warning("CDI zaxis string key %d not supported!", key);
      return -1;
    }

432
  zaxisGetString(mesg, keyptr, (size_t)size);
433
434
435
436

  return 0;
}

437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509

/*
@Function  cdiZaxisDefKeyFlt
@Title     Define a CDI Z-axis floating point value from a key

@Prototype int cdiZaxisDefKeyFlt(int zaxisID, int key, double value)
@Parameter
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate}.
    @Item  key      The key to be searched
    @Item  value    A double where the data will be read

@Description
The function @func{cdiZaxisDefKeyFlt} defines a CDI Z-axis double value from a key.

@Result
@func{cdiZaxisDefKeyFlt} returns 0 if OK and integer value on error.

@EndFunction
*/
int cdiZaxisDefKeyFlt(int zaxisID, int key, double value)
{
  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);

  zkey_double_t *keyptr = (zkey_double_t*)zaxis_key_to_ptr(zaxisptr, key);
  if ( keyptr == NULL)
    {
      Warning("CDI zaxis double key %d not supported!", key);
      return -1;
    }

  keyptr->value = value;
  keyptr->defined = true;

  reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);

  return 0;
}

/*
@Function  cdiZaxisInqKeyFlt
@Title     Get a CDI Z-axis floating point value from a key

@Prototype int cdiZaxisInqKeyFlt(int zaxisID, int key, double *value)
@Parameter
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate}.
    @Item  key      The key to be searched.
    @Item value     The address of a double where the data will be retrieved.

@Description
The function @func{cdiZaxisInqKeyFlt} return a CDI Z-axis double value from a key.

@Result
@func{cdiZaxisInqKeyFlt} returns 0 if OK and integer value on error.

@EndFunction
*/
int cdiZaxisInqKeyFlt(int zaxisID, int key, double *value)
{
  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
  zkey_double_t *keyptr = (zkey_double_t*)zaxis_key_to_ptr(zaxisptr, key);
  if ( keyptr == NULL)
    {
      Warning("CDI zaxis double key %d not supported!", key);
      return -1;
    }

  if ( !keyptr->defined ) return 1;

  *value = keyptr->value;

  return 0;
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
510
511
512
513
514
515
/*
@Function  zaxisDefName
@Title     Define the name of a Z-axis

@Prototype void zaxisDefName(int zaxisID, const char *name)
@Parameter
Deike Kleberg's avatar
Deike Kleberg committed
516
517
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate}.
    @Item  name     Name of the Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
518
519

@Description
520
The function @func{zaxisDefName} defines the name of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
521
522
523
524
525

@EndFunction
*/
void zaxisDefName(int zaxisID, const char *name)
{
526
  (void)cdiZaxisDefKeyStr(zaxisID, CDI_KEY_NAME, CDI_MAX_NAME, name);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
527
528
529
530
531
532
533
534
}

/*
@Function  zaxisDefLongname
@Title     Define the longname of a Z-axis

@Prototype void zaxisDefLongname(int zaxisID, const char *longname)
@Parameter
Deike Kleberg's avatar
Deike Kleberg committed
535
536
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate}.
    @Item  longname Longname of the Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
537
538

@Description
539
The function @func{zaxisDefLongname} defines the longname of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
540
541
542
543
544

@EndFunction
*/
void zaxisDefLongname(int zaxisID, const char *longname)
{
545
  (void)cdiZaxisDefKeyStr(zaxisID, CDI_KEY_LONGNAME, CDI_MAX_NAME, longname);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
546
547
548
549
550
551
552
553
}

/*
@Function  zaxisDefUnits
@Title     Define the units of a Z-axis

@Prototype void zaxisDefUnits(int zaxisID, const char *units)
@Parameter
Deike Kleberg's avatar
Deike Kleberg committed
554
555
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate}.
    @Item  units    Units of the Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
556
557

@Description
558
The function @func{zaxisDefUnits} defines the units of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
559
560
561
562
563

@EndFunction
*/
void zaxisDefUnits(int zaxisID, const char *units)
{
564
  (void)cdiZaxisDefKeyStr(zaxisID, CDI_KEY_UNITS, CDI_MAX_NAME, units);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
565
566
567
568
569
570
571
572
}

/*
@Function  zaxisInqName
@Title     Get the name of a Z-axis

@Prototype void zaxisInqName(int zaxisID, char *name)
@Parameter
Uwe Schulzweida's avatar
Uwe Schulzweida committed
573
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate} or @fref{vlistInqVarZaxis}.
Deike Kleberg's avatar
Deike Kleberg committed
574
    @Item  name     Name of the Z-axis. The caller must allocate space for the
Deike Kleberg's avatar
Deike Kleberg committed
575
                    returned string. The maximum possible length, in characters, of
576
                    the string is given by the predefined constant @func{CDI_MAX_NAME}.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
577
578

@Description
579
The function @func{zaxisInqName} returns the name of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
580
581

@Result
582
@func{zaxisInqName} returns the name of the Z-axis to the parameter name.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
583
584
585
586
587

@EndFunction
*/
void zaxisInqName(int zaxisID, char *name)
{
588
  (void)cdiZaxisInqKeyStr(zaxisID, CDI_KEY_NAME, CDI_MAX_NAME, name);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
589
590
}

591
592
const char *zaxisInqNamePtr(int zaxisID)
{
593
  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
594
595
596
  return zaxisptr->name;
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
597
598
599
600
601
602
/*
@Function  zaxisInqLongname
@Title     Get the longname of a Z-axis

@Prototype void zaxisInqLongname(int zaxisID, char *longname)
@Parameter
Uwe Schulzweida's avatar
Uwe Schulzweida committed
603
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate} or @fref{vlistInqVarZaxis}.
Deike Kleberg's avatar
Deike Kleberg committed
604
    @Item  longname Longname of the Z-axis. The caller must allocate space for the
Deike Kleberg's avatar
Deike Kleberg committed
605
                    returned string. The maximum possible length, in characters, of
606
                    the string is given by the predefined constant @func{CDI_MAX_NAME}.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
607
608

@Description
609
The function @func{zaxisInqLongname} returns the longname of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
610
611

@Result
612
@func{zaxisInqLongname} returns the longname of the Z-axis to the parameter longname.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
613
614
615
616
617

@EndFunction
*/
void zaxisInqLongname(int zaxisID, char *longname)
{
618
  (void)cdiZaxisInqKeyStr(zaxisID, CDI_KEY_LONGNAME, CDI_MAX_NAME, longname);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
619
620
621
622
623
624
625
626
}

/*
@Function  zaxisInqUnits
@Title     Get the units of a Z-axis

@Prototype void zaxisInqUnits(int zaxisID, char *units)
@Parameter
Uwe Schulzweida's avatar
Uwe Schulzweida committed
627
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate} or @fref{vlistInqVarZaxis}.
Deike Kleberg's avatar
Deike Kleberg committed
628
    @Item  units    Units of the Z-axis. The caller must allocate space for the
Deike Kleberg's avatar
Deike Kleberg committed
629
                    returned string. The maximum possible length, in characters, of
630
                    the string is given by the predefined constant @func{CDI_MAX_NAME}.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
631
632

@Description
633
The function @func{zaxisInqUnits} returns the units of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
634
635

@Result
636
@func{zaxisInqUnits} returns the units of the Z-axis to the parameter units.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
637
638
639
640
641

@EndFunction
*/
void zaxisInqUnits(int zaxisID, char *units)
{
642
  (void)cdiZaxisInqKeyStr(zaxisID, CDI_KEY_UNITS, CDI_MAX_NAME, units);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
643
644
645
}


Deike Kleberg's avatar
Deike Kleberg committed
646
647
void zaxisInqStdname(int zaxisID, char *stdname)
{
Uwe Schulzweida's avatar
Uwe Schulzweida committed
648
649
650
651
652
653
  if ( stdname )
    {
      stdname[0] = 0;
      zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
      if ( zaxisptr->stdname ) strcpy(stdname, zaxisptr->stdname);
    }
Deike Kleberg's avatar
Deike Kleberg committed
654
655
656
}


Uwe Schulzweida's avatar
Uwe Schulzweida committed
657
658
void zaxisDefPrec(int zaxisID, int prec)
{
659
  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
660

Uwe Schulzweida's avatar
Uwe Schulzweida committed
661
  if ( zaxisptr->prec != prec )
662
663
664
665
    {
      zaxisptr->prec = prec;
      reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
    }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
666
667
668
669
670
}


int zaxisInqPrec(int zaxisID)
{
671
  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
672
  return zaxisptr->prec;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
673
674
675
}


676
677
void zaxisDefPositive(int zaxisID, int positive)
{
678
  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
679

Uwe Schulzweida's avatar
Uwe Schulzweida committed
680
  if ( zaxisptr->positive != (unsigned)positive )
681
    {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
682
      zaxisptr->positive = (unsigned)positive;
683
684
      reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
    }
685
686
687
}


Deike Kleberg's avatar
Deike Kleberg committed
688
689
int zaxisInqPositive(int zaxisID)
{
690
  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
Thomas Jahns's avatar
Thomas Jahns committed
691
  return (int)zaxisptr->positive;
Deike Kleberg's avatar
Deike Kleberg committed
692
693
694
}


695
696
void zaxisDefScalar(int zaxisID)
{
697
  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
698
699
700
701
702
703
704

  zaxisptr->scalar = 1;
  reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
}

int zaxisInqScalar(int zaxisID)
{
705
  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
706
707
708
709
  return zaxisptr->scalar;
}


710
711
void zaxisDefLtype(int zaxisID, int ltype)
{
712
  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
713

714
715
716
717
718
  if (zaxisptr->ltype != ltype)
    {
      zaxisptr->ltype = ltype;
      reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
    }
719
720
721
722
723
}


int zaxisInqLtype(int zaxisID)
{
724
  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
725
  return zaxisptr->ltype;
726
727
}

728
729
730

void zaxisDefLtype2(int zaxisID, int ltype2)
{
731
  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
732

Uwe Schulzweida's avatar
Uwe Schulzweida committed
733
  if ( zaxisptr->ltype2 != ltype2 )
734
735
736
737
738
739
740
741
742
    {
      zaxisptr->ltype2 = ltype2;
      reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
    }
}


int zaxisInqLtype2(int zaxisID)
{
743
  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
744
  return zaxisptr->ltype2;
745
746
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
747
748
749
750
/*
@Function  zaxisDefLevels
@Title     Define the levels of a Z-axis

Uwe Schulzweida's avatar
Uwe Schulzweida committed
751
@Prototype void zaxisDefLevels(int zaxisID, const double *levels)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
752
@Parameter
Deike Kleberg's avatar
Deike Kleberg committed
753
754
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate}.
    @Item  levels   All levels of the Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
755
756

@Description
757
The function @func{zaxisDefLevels} defines the levels of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
758
759
760

@EndFunction
*/
Uwe Schulzweida's avatar
Uwe Schulzweida committed
761
void zaxisDefLevels(int zaxisID, const double *levels)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
762
{
763
  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
764
765
  size_t size = (size_t)zaxisptr->size;

766
767
768
769
  if ( levels )
    {
      if ( zaxisptr->vals == NULL )
        zaxisptr->vals = (double*) Malloc(size*sizeof(double));
Uwe Schulzweida's avatar
Uwe Schulzweida committed
770

771
      double *vals = zaxisptr->vals;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
772

773
774
      for ( size_t ilev = 0; ilev < size; ++ilev )
        vals[ilev] = levels[ilev];
775

776
777
      reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
    }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
778
779
780
781
782
783
784
785
}

/*
@Function  zaxisDefLevel
@Title     Define one level of a Z-axis

@Prototype void zaxisDefLevel(int zaxisID, int levelID, double level)
@Parameter
Deike Kleberg's avatar
Deike Kleberg committed
786
787
788
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate}.
    @Item  levelID  Level identifier.
    @Item  level    Level.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
789
790

@Description
791
The function @func{zaxisDefLevel} defines one level of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
792
793
794
795
796

@EndFunction
*/
void zaxisDefLevel(int zaxisID, int levelID, double level)
{
797
  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
798
799
800
801
802
803
  int size = zaxisptr->size;

  if ( zaxisptr->vals == NULL )
    zaxisptr->vals = (double*) Malloc((size_t)size*sizeof(double));

  if ( levelID >= 0 && levelID < size )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
804
    zaxisptr->vals[levelID] = level;
805

806
  reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
807
808
}

809
810
811

void zaxisDefNlevRef(int zaxisID, const int nhlev)
{
812
  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
813
814
815
816
817
  if (zaxisptr->nhlev != nhlev)
    {
      zaxisptr->nhlev = nhlev;
      reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
    }
818
819
820
821
822
}


int zaxisInqNlevRef(int zaxisID)
{
823
  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
824
  return zaxisptr->nhlev;
825
826
}

827
/*
828
829
@Function  zaxisDefNumber
@Title     Define the reference number for a generalized Z-axis
830

831
@Prototype void zaxisDefNumber(int zaxisID, const int number)
832
833
@Parameter
    @Item  zaxisID     Z-axis ID, from a previous call to @fref{zaxisCreate}.
834
    @Item  number      Reference number for a generalized Z-axis.
835
836

@Description
837
The function @func{zaxisDefNumber} defines the reference number for a generalized Z-axis.
838
839
840

@EndFunction
*/
841
void zaxisDefNumber(int zaxisID, const int number)
842
{
843
  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
844
845
846
847
848
  if (zaxisptr->number != number)
    {
      zaxisptr->number = number;
      reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
    }
849
850
}

851
852
853
854
855
856
/*
@Function  zaxisInqNumber
@Title     Get the reference number to a generalized Z-axis

@Prototype int zaxisInqNumber(int zaxisID)
@Parameter
Uwe Schulzweida's avatar
Uwe Schulzweida committed
857
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate} or @fref{vlistInqVarZaxis}.
858
859
860
861
862
863
864
865
866
867

@Description
The function @func{zaxisInqNumber} returns the reference number to a generalized Z-axis.

@Result
@func{zaxisInqNumber} returns the reference number to a generalized Z-axis.
@EndFunction
*/
int zaxisInqNumber(int zaxisID)
{
868
  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
869
  return zaxisptr->number;
870
871
}

872
873
874
875
876
877
878
879
880
881
882
883
884
885
/*
@Function  zaxisDefUUID
@Title     Define the UUID for a genralized Z-axis

@Prototype void zaxisDefUUID(int zaxisID, const char *uuid)
@Parameter
    @Item  zaxisID     Z-axis ID, from a previous call to @fref{zaxisCreate}.
    @Item  uuid        UUID for a generalized Z-axis.

@Description
The function @func{zaxisDefUUID} defines the UUID for a generalized  Z-axis.

@EndFunction
*/
886
void zaxisDefUUID(int zaxisID, const unsigned char uuid[CDI_UUID_SIZE])
887
{
888
  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
889
  memcpy(zaxisptr->uuid, uuid, CDI_UUID_SIZE);
890
  reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
891
892
893
894
}

/*
@Function  zaxisInqUUID
895
@Title     Get the uuid to a generalized Z-axis
896

897
@Prototype void zaxisInqUUID(int zaxisID, char *uuid)
898
@Parameter
Uwe Schulzweida's avatar
Uwe Schulzweida committed
899
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate} or @fref{vlistInqVarZaxis}.
900
    @Item uuid A user supplied buffer of at least 16 bytes.
901
902
903
904
905

@Description
The function @func{zaxisInqUUID} returns the UUID to a generalized Z-axis.

@Result
906
@func{zaxisInqUUID} returns the UUID to a generalized Z-axis to the parameter uuid.
907
908
@EndFunction
*/
909
void zaxisInqUUID(int zaxisID, unsigned char uuid[CDI_UUID_SIZE])
910
{
911
  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
912
  memcpy(uuid, zaxisptr->uuid, CDI_UUID_SIZE);
913
914
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
915
916
917
918
919
920
/*
@Function  zaxisInqLevel
@Title     Get one level of a Z-axis

@Prototype double zaxisInqLevel(int zaxisID, int levelID)
@Parameter
Uwe Schulzweida's avatar
Uwe Schulzweida committed
921
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate} or @fref{vlistInqVarZaxis}.
Deike Kleberg's avatar
Deike Kleberg committed
922
    @Item  levelID  Level index (range: 0 to nlevel-1).
Uwe Schulzweida's avatar
Uwe Schulzweida committed
923
924

@Description
925
The function @func{zaxisInqLevel} returns one level of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
926
927

@Result
928
@func{zaxisInqLevel} returns the level of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
929
930
931
932
@EndFunction
*/
double zaxisInqLevel(int zaxisID, int levelID)
{
933
  double level = 0;
934
  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
935

936
  if ( zaxisptr->vals && levelID >= 0 && levelID < zaxisptr->size )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
937
    level = zaxisptr->vals[levelID];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
938

939
  return level;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
940
941
}

942

943
double zaxisInqLbound(int zaxisID, int levelID)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
944
{
945
  double level = 0;
946
  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
947

948
949
  if ( zaxisptr->lbounds && levelID >= 0 && levelID < zaxisptr->size )
    level = zaxisptr->lbounds[levelID];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
950

951
  return level;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
952
953
954
}


955
double zaxisInqUbound(int zaxisID, int levelID)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
956
{
957
  double level = 0;
958
  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
959

960
961
962
  if ( zaxisptr->ubounds && levelID >= 0 && levelID < zaxisptr->size )
    level = zaxisptr->ubounds[levelID];

963
  return level;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
964
965
966
967
968
}


const double *zaxisInqLevelsPtr(int zaxisID)
{
969
  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
970
  return zaxisptr->vals;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
971
972
973
974
975
976
977
978
}

/*
@Function  zaxisInqLevels
@Title     Get all levels of a Z-axis

@Prototype void zaxisInqLevels(int zaxisID, double *levels)
@Parameter
Uwe Schulzweida's avatar
Uwe Schulzweida committed
979
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate} or @fref{vlistInqVarZaxis}.
Deike Kleberg's avatar
Deike Kleberg committed
980
981
    @Item  levels   Pointer to the location into which the levels are read.
                    The caller must allocate space for the returned values.
Deike Kleberg's avatar
Deike Kleberg committed
982

Uwe Schulzweida's avatar
Uwe Schulzweida committed
983
@Description
984
The function @func{zaxisInqLevels} returns all levels of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
985
986

@Result
987
@func{zaxisInqLevels} saves all levels to the parameter @func{levels}.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
988
989
@EndFunction
*/
990
int zaxisInqLevels(int zaxisID, double *levels)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
991
{
992
  int size = 0;
993
  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
994
995
996
997
998
999
1000
1001
1002
1003
1004

  if ( zaxisptr->vals )
    {
      size = zaxisptr->size;

      if ( levels )
        for ( int i = 0; i < size; i++ )
          levels[i] = zaxisptr->vals[i];
    }

  return size;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1005
1006
1007
1008
1009
1010
}


int zaxisInqLbounds(int zaxisID, double *lbounds)
{
  int size = 0;
1011
  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1012

Uwe Schulzweida's avatar
Uwe Schulzweida committed
1013
  if ( zaxisptr->lbounds )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1014
    {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1015
      size = zaxisptr->size;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1016
1017

      if ( lbounds )
1018
1019
        for ( int i = 0; i < size; i++ )
          lbounds[i] = zaxisptr->lbounds[i];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1020
1021
    }

1022
  return size;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1023
1024
1025
1026
1027
1028
}


int zaxisInqUbounds(int zaxisID, double *ubounds)
{
  int size = 0;
1029
  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1030

Uwe Schulzweida's avatar
Uwe Schulzweida committed
1031
  if ( zaxisptr->ubounds )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1032
    {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1033
      size = zaxisptr->size;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1034
1035

      if ( ubounds )
1036
1037
        for ( int i = 0; i < size; i++ )
          ubounds[i] = zaxisptr->ubounds[i];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1038
1039
    }