zaxis.c 48.8 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
  { /*  0 */ 0, "sfc",               "surface",                "",               ""},
  { /*  1 */ 0, "lev",               "generic",                "",               "level"},
  { /*  2 */ 2, "lev",               "hybrid",                 "",               "level"},
  { /*  3 */ 2, "lev",               "hybrid_half",            "",               "level"},
  { /*  4 */ 2, "lev",               "pressure",               "air_pressure",   "Pa"},
  { /*  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

typedef struct {
68
69
  char     dimname[CDI_MAX_NAME];
  char     vdimname[CDI_MAX_NAME];
Deike Kleberg's avatar
Deike Kleberg committed
70
71
72
73
  char     name[CDI_MAX_NAME];
  char     longname[CDI_MAX_NAME];
  char     stdname[CDI_MAX_NAME];
  char     units[CDI_MAX_NAME];
74
  char     psname[CDI_MAX_NAME];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
75
76
77
78
  double  *vals;
  double  *lbounds;
  double  *ubounds;
  double  *weights;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
79
  int      self;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
80
  int      prec;
81
  int      scalar;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
82
  int      type;
83
  int      ltype;    /* GRIB level type */
84
  int      ltype2;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
85
86
87
  int      size;
  int      direction;
  int      vctsize;
Thomas Jahns's avatar
Thomas Jahns committed
88
  unsigned positive;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
89
  double  *vct;
90
  int      number;   /* Reference number to a generalized Z-axis */
91
  int      nhlev;
92
  unsigned char uuid[CDI_UUID_SIZE];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
93
}
94
zaxis_t;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
95

96
static int    zaxisCompareP    (zaxis_t *z1, zaxis_t *z2);
Deike Kleberg's avatar
Deike Kleberg committed
97
98
static void   zaxisDestroyP    ( void * zaxisptr );
static void   zaxisPrintP      ( void * zaxisptr, FILE * fp );
99
100
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
101
static int    zaxisTxCode      ( void );
Uwe Schulzweida's avatar
Uwe Schulzweida committed
102

Thomas Jahns's avatar
Thomas Jahns committed
103
static const resOps zaxisOps = {
104
  (int (*)(void *, void *))zaxisCompareP,
105
106
107
108
109
  zaxisDestroyP,
  zaxisPrintP,
  zaxisGetPackSize,
  zaxisPack,
  zaxisTxCode
110
};
Uwe Schulzweida's avatar
Uwe Schulzweida committed
111

112
const resOps *getZaxisOps(void)
113
114
115
116
{
  return &zaxisOps;
}

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

119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
void zaxisGetTypeDescription(int zaxisType, int* outPositive, const char** outName, const char** outLongName, const char** outStdName, const char** outUnit)
{
  if(zaxisType < 0 || zaxisType >= CDI_NumZaxistype)
    {
      if(outPositive) *outPositive = 0;
      if(outName) *outName = NULL;
      if(outLongName) *outLongName = NULL;
      if(outStdName) *outStdName = NULL;
      if(outUnit) *outUnit = NULL;
    }
  else
    {
      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;
    }
}

139
static
140
void zaxisDefaultValue(zaxis_t *zaxisptr)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
141
{
142
  zaxisptr->self        = CDI_UNDEFID;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
143
144
  zaxisptr->name[0]     = 0;
  zaxisptr->longname[0] = 0;
Deike Kleberg's avatar
Deike Kleberg committed
145
  zaxisptr->stdname[0]  = 0;
146
147
  zaxisptr->dimname[0]  = 0;
  zaxisptr->vdimname[0] = 0;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
148
  zaxisptr->units[0]    = 0;
149
  zaxisptr->psname[0]   = 0;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
150
151
152
153
154
  zaxisptr->vals        = NULL;
  zaxisptr->ubounds     = NULL;
  zaxisptr->lbounds     = NULL;
  zaxisptr->weights     = NULL;
  zaxisptr->type        = CDI_UNDEFID;
155
  zaxisptr->ltype       = 0;
156
  zaxisptr->ltype2      = -1;
Deike Kleberg's avatar
Deike Kleberg committed
157
  zaxisptr->positive    = 0;
158
  zaxisptr->scalar      = 0;
Deike Kleberg's avatar
Deike Kleberg committed
159
  zaxisptr->direction   = 0;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
160
161
162
163
  zaxisptr->prec        = 0;
  zaxisptr->size        = 0;
  zaxisptr->vctsize     = 0;
  zaxisptr->vct         = NULL;
164
  zaxisptr->number      = 0;
165
  zaxisptr->nhlev       = 0;
Thomas Jahns's avatar
Thomas Jahns committed
166
  memset(zaxisptr->uuid, 0, CDI_UUID_SIZE);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
167
}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
168

169

170
static
171
zaxis_t *zaxisNewEntry(int id)
172
{
173
  zaxis_t *zaxisptr = (zaxis_t *) Malloc(sizeof(zaxis_t));
174
175

  zaxisDefaultValue ( zaxisptr );
176

177
  if ( id == CDI_UNDEFID )
178
179
180
181
182
183
    zaxisptr->self = reshPut(zaxisptr, &zaxisOps);
  else
    {
      zaxisptr->self = id;
      reshReplace(id, zaxisptr, &zaxisOps);
    }
184

185
  return zaxisptr;
186
187
}

188
189
static inline
zaxis_t *zaxisID2Ptr(int id)
190
191
192
193
194
{
  return (zaxis_t *)reshGetVal(id, &zaxisOps);
}


195
static
196
void zaxisInit(void)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
197
{
198
  static bool zaxisInitialized = false;
199
  if ( zaxisInitialized ) return;
200
  zaxisInitialized = true;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
201

202
  const char *env = getenv("ZAXIS_DEBUG");
203
  if ( env ) ZAXIS_Debug = atoi(env);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
204
205
}

206
207
static
void zaxis_copy(zaxis_t *zaxisptr2, zaxis_t *zaxisptr1)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
208
{
209
  int zaxisID2 = zaxisptr2->self;
210
  memcpy(zaxisptr2, zaxisptr1, sizeof(zaxis_t));
Uwe Schulzweida's avatar
Uwe Schulzweida committed
211
212
213
  zaxisptr2->self = zaxisID2;
}

214
unsigned cdiZaxisCount(void)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
215
{
216
  return reshCountType(&zaxisOps);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
217
218
}

219

220
221
222
223
224
static int
zaxisCreate_(int zaxistype, int size, int id)
{
  zaxis_t *zaxisptr = zaxisNewEntry(id);

225
  xassert(size >= 0);
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
  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;

242
  double *vals = zaxisptr->vals
243
    = (double *) Malloc((size_t)size * sizeof(double));
244
245
246
247
248
249
250

  for ( int ilev = 0; ilev < size; ilev++ )
    vals[ilev] = 0.0;

  return zaxisID;
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
251
/*
252
@Function  zaxisCreate
253
@Title     Create a vertical Z-axis
Uwe Schulzweida's avatar
Uwe Schulzweida committed
254

255
@Prototype int zaxisCreate(int zaxistype, int size)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
256
257
@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
258
                      The valid CDI Z-axis types are @func{ZAXIS_GENERIC}, @func{ZAXIS_SURFACE},
Uwe Schulzweida's avatar
Uwe Schulzweida committed
259
                      @func{ZAXIS_HYBRID}, @func{ZAXIS_SIGMA}, @func{ZAXIS_PRESSURE}, @func{ZAXIS_HEIGHT},
260
261
                      @func{ZAXIS_ISENTROPIC}, @func{ZAXIS_ALTITUDE}, @func{ZAXIS_MEANSEA}, @func{ZAXIS_TOA},
                      @func{ZAXIS_SEA_BOTTOM}, @func{ZAXIS_ATMOSPHERE}, @func{ZAXIS_CLOUD_BASE},
262
                      @func{ZAXIS_CLOUD_TOP}, @func{ZAXIS_ISOTHERM_ZERO}, @func{ZAXIS_SNOW},
263
264
                      @func{ZAXIS_LAKE_BOTTOM}, @func{ZAXIS_SEDIMENT_BOTTOM}, @func{ZAXIS_SEDIMENT_BOTTOM_TA},
                      @func{ZAXIS_SEDIMENT_BOTTOM_TW}, @func{ZAXIS_MIX_LAYER},
265
                      @func{ZAXIS_DEPTH_BELOW_SEA} and @func{ZAXIS_DEPTH_BELOW_LAND}.
Deike Kleberg's avatar
Deike Kleberg committed
266
    @Item  size       Number of levels.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
267
268

@Description
269
The function @func{zaxisCreate} creates a vertical Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
270
271

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

Uwe Schulzweida's avatar
Uwe Schulzweida committed
274
@Example
275
Here is an example using @func{zaxisCreate} to create a pressure level Z-axis:
Uwe Schulzweida's avatar
Uwe Schulzweida committed
276
277
278
279

@Source
#include "cdi.h"
   ...
280
#define  nlev    5
Uwe Schulzweida's avatar
Uwe Schulzweida committed
281
   ...
282
double levs[nlev] = {101300, 92500, 85000, 50000, 20000};
Uwe Schulzweida's avatar
Uwe Schulzweida committed
283
284
int zaxisID;
   ...
285
zaxisID = zaxisCreate(ZAXIS_PRESSURE, nlev);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
286
287
288
zaxisDefLevels(zaxisID, levs);
   ...
@EndSource
Uwe Schulzweida's avatar
Uwe Schulzweida committed
289
290
@EndFunction
*/
291
int zaxisCreate(int zaxistype, int size)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
292
{
293
  if ( CDI_Debug ) Message("zaxistype: %d size: %d ", zaxistype, size);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
294

295
296
  zaxisInit ();
  return zaxisCreate_(zaxistype, size, CDI_UNDEFID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
297
298
}

299

300
static void zaxisDestroyKernel( zaxis_t * zaxisptr )
301
{
Deike Kleberg's avatar
Deike Kleberg committed
302
  xassert ( zaxisptr );
303

304
  int id = zaxisptr->self;
305

Uwe Schulzweida's avatar
Uwe Schulzweida committed
306
307
308
309
310
  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 );
311

Uwe Schulzweida's avatar
Uwe Schulzweida committed
312
  Free( zaxisptr );
313

314
  reshRemove ( id, &zaxisOps );
315
316
}

317
318
319
320
321
322
/*
@Function  zaxisDestroy
@Title     Destroy a vertical Z-axis

@Prototype void zaxisDestroy(int zaxisID)
@Parameter
Deike Kleberg's avatar
Deike Kleberg committed
323
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate}.
324
325
326
327
328

@EndFunction
*/
void zaxisDestroy(int zaxisID)
{
329
  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
330
  zaxisDestroyKernel(zaxisptr);
331
332
333
}


334
static
335
void zaxisDestroyP(void *zaxisptr)
336
{
337
  zaxisDestroyKernel((zaxis_t *) zaxisptr);
338
339
340
}


Oliver Heidmann's avatar
Oliver Heidmann committed
341
const char *zaxisNamePtr(int zaxistype)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
342
{
Oliver Heidmann's avatar
Oliver Heidmann committed
343
  const char *name = (zaxistype >= 0 && zaxistype < CDI_NumZaxistype)
344
345
    ? ZaxistypeEntry[zaxistype].longname
    : ZaxistypeEntry[ZAXIS_GENERIC].longname;
346
  return name;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
347
348
349
350
351
352
353
354
}


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

355
356
357
static inline
void zaxisSetString(char *zaxisstrname, const char *name, size_t len)
{
358
  if ( len >= CDI_MAX_NAME ) len = CDI_MAX_NAME-1;
359
  strncpy(zaxisstrname, name, len);
360
  zaxisstrname[len] = 0;
361
362
363
364
365
}

static inline
void zaxisGetString(char *name, const char *zaxisstrname, size_t len)
{
366
  if ( len >= CDI_MAX_NAME ) len = CDI_MAX_NAME-1;
367
  strncpy(name, zaxisstrname, len);
368
  name[len] = 0;
369
370
371
}

static
372
void *zaxis_key_to_ptr(zaxis_t *zaxisptr, int key)
373
{
374
  void *keyptr = NULL;
375
376
377

  switch (key)
    {
378
379
380
381
382
    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;
383
    case CDI_KEY_PSNAME:    keyptr = (void*)zaxisptr->psname; break;
384
385
    }

386
  return keyptr;
387
388
389
}

/*
390
@Function  cdiZaxisDefKeyStr
391
392
@Title     Define a CDI Z-axis string value from a key

393
@Prototype int cdiZaxisDefKeyStr(int zaxisID, int key, int size, const char *mesg)
394
395
396
397
398
399
400
@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
401
The function @func{cdiZaxisDefKeyStr} defines a CDI Z-axis string value from a key.
402
403

@Result
404
@func{cdiZaxisDefKeyStr} returns 0 if OK and integer value on error.
405
406
407

@EndFunction
*/
408
int cdiZaxisDefKeyStr(int zaxisID, int key, int size, const char *mesg)
409
{
410
  if ( size < 1 || mesg == NULL || *mesg == 0 ) return -1;
411
412
413

  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);

414
  char *keyptr = (char*)zaxis_key_to_ptr(zaxisptr, key);
415
  if ( keyptr == NULL)
416
417
418
419
420
    {
      Warning("CDI zaxis string key %d not supported!", key);
      return -1;
    }

421
  zaxisSetString(keyptr, mesg, (size_t)size);
422
423
424
425
426
427
  reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);

  return 0;
}

/*
428
@Function  cdiZaxisInqKeyStr
429
430
@Title     Get a CDI Z-axis string value from a key

431
@Prototype int cdiZaxisInqKeyStr(int zaxisID, int key, int size, char *mesg)
432
433
434
435
436
437
438
439
440
441
@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
442
The function @func{cdiZaxisInqKeyStr} return a CDI Z-axis string value from a key.
443
444

@Result
445
@func{cdiZaxisInqKeyStr} returns 0 if OK and integer value on error.
446
447
448

@EndFunction
*/
449
int cdiZaxisInqKeyStr(int zaxisID, int key, int size, char *mesg)
450
{
451
  if ( size < 1 || mesg == NULL ) return -1;
452
453

  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
454
  const char *keyptr = (const char*)zaxis_key_to_ptr(zaxisptr, key);
455
  if ( keyptr == NULL)
456
457
458
459
460
    {
      Warning("CDI zaxis string key %d not supported!", key);
      return -1;
    }

461
  zaxisGetString(mesg, keyptr, (size_t)size);
462
463
464
465

  return 0;
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
466
467
468
469
470
471
/*
@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
472
473
    @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
474
475

@Description
476
The function @func{zaxisDefName} defines the name of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
477
478
479
480
481

@EndFunction
*/
void zaxisDefName(int zaxisID, const char *name)
{
482
  (void)cdiZaxisDefKeyStr(zaxisID, CDI_KEY_NAME, CDI_MAX_NAME, name);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
483
484
485
486
487
488
489
490
}

/*
@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
491
492
    @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
493
494

@Description
495
The function @func{zaxisDefLongname} defines the longname of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
496
497
498
499
500

@EndFunction
*/
void zaxisDefLongname(int zaxisID, const char *longname)
{
501
  (void)cdiZaxisDefKeyStr(zaxisID, CDI_KEY_LONGNAME, CDI_MAX_NAME, longname);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
502
503
504
505
506
507
508
509
}

/*
@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
510
511
    @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
512
513

@Description
514
The function @func{zaxisDefUnits} defines the units of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
515
516
517
518
519

@EndFunction
*/
void zaxisDefUnits(int zaxisID, const char *units)
{
520
  (void)cdiZaxisDefKeyStr(zaxisID, CDI_KEY_UNITS, CDI_MAX_NAME, units);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
521
522
523
524
525
526
527
528
}

/*
@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
529
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate} or @fref{vlistInqVarZaxis}.
Deike Kleberg's avatar
Deike Kleberg committed
530
    @Item  name     Name of the Z-axis. The caller must allocate space for the
Deike Kleberg's avatar
Deike Kleberg committed
531
                    returned string. The maximum possible length, in characters, of
532
                    the string is given by the predefined constant @func{CDI_MAX_NAME}.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
533
534

@Description
535
The function @func{zaxisInqName} returns the name of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
536
537

@Result
538
@func{zaxisInqName} returns the name of the Z-axis to the parameter name.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
539
540
541
542
543

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

547
548
549
550
551
552
const char *zaxisInqNamePtr(int zaxisID)
{
  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
  return zaxisptr->name;
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
553
554
555
556
557
558
/*
@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
559
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate} or @fref{vlistInqVarZaxis}.
Deike Kleberg's avatar
Deike Kleberg committed
560
    @Item  longname Longname of the Z-axis. The caller must allocate space for the
Deike Kleberg's avatar
Deike Kleberg committed
561
                    returned string. The maximum possible length, in characters, of
562
                    the string is given by the predefined constant @func{CDI_MAX_NAME}.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
563
564

@Description
565
The function @func{zaxisInqLongname} returns the longname of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
566
567

@Result
568
@func{zaxisInqLongname} returns the longname of the Z-axis to the parameter longname.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
569
570
571
572
573

@EndFunction
*/
void zaxisInqLongname(int zaxisID, char *longname)
{
574
  (void)cdiZaxisInqKeyStr(zaxisID, CDI_KEY_LONGNAME, CDI_MAX_NAME, longname);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
575
576
577
578
579
580
581
582
}

/*
@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
583
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate} or @fref{vlistInqVarZaxis}.
Deike Kleberg's avatar
Deike Kleberg committed
584
    @Item  units    Units of the Z-axis. The caller must allocate space for the
Deike Kleberg's avatar
Deike Kleberg committed
585
                    returned string. The maximum possible length, in characters, of
586
                    the string is given by the predefined constant @func{CDI_MAX_NAME}.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
587
588

@Description
589
The function @func{zaxisInqUnits} returns the units of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
590
591

@Result
592
@func{zaxisInqUnits} returns the units of the Z-axis to the parameter units.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
593
594
595
596
597

@EndFunction
*/
void zaxisInqUnits(int zaxisID, char *units)
{
598
  (void)cdiZaxisInqKeyStr(zaxisID, CDI_KEY_UNITS, CDI_MAX_NAME, units);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
599
600
601
}


Deike Kleberg's avatar
Deike Kleberg committed
602
603
void zaxisInqStdname(int zaxisID, char *stdname)
{
604
  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
Deike Kleberg's avatar
Deike Kleberg committed
605
606
607
608
  strcpy(stdname, zaxisptr->stdname);
}


609
610
611
612
613
614
615
void zaxisInqPsName(int zaxisID, char *psname)
{
  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
  strcpy(psname, zaxisptr->psname);
}


Uwe Schulzweida's avatar
Uwe Schulzweida committed
616
617
void zaxisDefPrec(int zaxisID, int prec)
{
618
  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
619

620
621
622
623
624
  if (zaxisptr->prec != prec)
    {
      zaxisptr->prec = prec;
      reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
    }
Uwe Schulzweida's avatar
Uwe Schulzweida committed
625
626
627
628
629
}


int zaxisInqPrec(int zaxisID)
{
630
  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
631
  return zaxisptr->prec;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
632
633
634
}


635
636
void zaxisDefPositive(int zaxisID, int positive)
{
637
  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
638

Uwe Schulzweida's avatar
Uwe Schulzweida committed
639
  if ( zaxisptr->positive != (unsigned)positive )
640
    {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
641
      zaxisptr->positive = (unsigned)positive;
642
643
      reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
    }
644
645
646
}


Deike Kleberg's avatar
Deike Kleberg committed
647
648
int zaxisInqPositive(int zaxisID)
{
649
  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
Thomas Jahns's avatar
Thomas Jahns committed
650
  return (int)zaxisptr->positive;
Deike Kleberg's avatar
Deike Kleberg committed
651
652
653
}


654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
void zaxisDefScalar(int zaxisID)
{
  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);

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

int zaxisInqScalar(int zaxisID)
{
  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
  return zaxisptr->scalar;
}


669
670
void zaxisDefLtype(int zaxisID, int ltype)
{
671
  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
672

673
674
675
676
677
  if (zaxisptr->ltype != ltype)
    {
      zaxisptr->ltype = ltype;
      reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
    }
678
679
680
681
682
}


int zaxisInqLtype(int zaxisID)
{
683
  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
684
  return zaxisptr->ltype;
685
686
}

687
688
689

void zaxisDefLtype2(int zaxisID, int ltype2)
{
690
  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
691
692
693
694
695
696
697
698
699
700
701

  if (zaxisptr->ltype2 != ltype2)
    {
      zaxisptr->ltype2 = ltype2;
      reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
    }
}


int zaxisInqLtype2(int zaxisID)
{
702
  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
703
  return zaxisptr->ltype2;
704
705
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
706
707
708
709
/*
@Function  zaxisDefLevels
@Title     Define the levels of a Z-axis

Uwe Schulzweida's avatar
Uwe Schulzweida committed
710
@Prototype void zaxisDefLevels(int zaxisID, const double *levels)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
711
@Parameter
Deike Kleberg's avatar
Deike Kleberg committed
712
713
    @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
714
715

@Description
716
The function @func{zaxisDefLevels} defines the levels of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
717
718
719

@EndFunction
*/
Uwe Schulzweida's avatar
Uwe Schulzweida committed
720
void zaxisDefLevels(int zaxisID, const double *levels)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
721
{
722
  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
723

724
725
  int size = zaxisptr->size;
  double *vals = zaxisptr->vals;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
726

727
  for (int ilev = 0; ilev < size; ilev++ )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
728
    vals[ilev] = levels[ilev];
729

730
  reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
731
732
733
734
735
736
737
738
}

/*
@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
739
740
741
    @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
742
743

@Description
744
The function @func{zaxisDefLevel} defines one level of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
745
746
747
748
749

@EndFunction
*/
void zaxisDefLevel(int zaxisID, int levelID, double level)
{
750
  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
751
752
  if ( levelID >= 0 && levelID < zaxisptr->size )
    zaxisptr->vals[levelID] = level;
753
  reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
754
755
}

756
757
758

void zaxisDefNlevRef(int zaxisID, const int nhlev)
{
759
  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
760
761
762
763
764
  if (zaxisptr->nhlev != nhlev)
    {
      zaxisptr->nhlev = nhlev;
      reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
    }
765
766
767
768
769
}


int zaxisInqNlevRef(int zaxisID)
{
770
  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
771
  return zaxisptr->nhlev;
772
773
}

774
/*
775
776
@Function  zaxisDefNumber
@Title     Define the reference number for a generalized Z-axis
777

778
@Prototype void zaxisDefNumber(int zaxisID, const int number)
779
780
@Parameter
    @Item  zaxisID     Z-axis ID, from a previous call to @fref{zaxisCreate}.
781
    @Item  number      Reference number for a generalized Z-axis.
782
783

@Description
784
The function @func{zaxisDefNumber} defines the reference number for a generalized Z-axis.
785
786
787

@EndFunction
*/
788
void zaxisDefNumber(int zaxisID, const int number)
789
{
790
  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
791
792
793
794
795
  if (zaxisptr->number != number)
    {
      zaxisptr->number = number;
      reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
    }
796
797
}

798
799
800
801
802
803
/*
@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
804
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate} or @fref{vlistInqVarZaxis}.
805
806
807
808
809
810
811
812
813
814

@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)
{
815
  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
816
  return zaxisptr->number;
817
818
}

819
820
821
822
823
824
825
826
827
828
829
830
831
832
/*
@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
*/
833
void zaxisDefUUID(int zaxisID, const unsigned char uuid[CDI_UUID_SIZE])
834
{
835
  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
836
  memcpy(zaxisptr->uuid, uuid, CDI_UUID_SIZE);
837
  reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
838
839
840
841
}

/*
@Function  zaxisInqUUID
842
@Title     Get the uuid to a generalized Z-axis
843

844
@Prototype void zaxisInqUUID(int zaxisID, char *uuid)
845
@Parameter
Uwe Schulzweida's avatar
Uwe Schulzweida committed
846
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate} or @fref{vlistInqVarZaxis}.
847
    @Item uuid A user supplied buffer of at least 16 bytes.
848
849
850
851
852

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

@Result
853
@func{zaxisInqUUID} returns the UUID to a generalized Z-axis to the parameter uuid.
854
855
@EndFunction
*/
856
void zaxisInqUUID(int zaxisID, unsigned char uuid[CDI_UUID_SIZE])
857
{
858
  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
859
  memcpy(uuid, zaxisptr->uuid, CDI_UUID_SIZE);
860
861
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
862
863
864
865
866
867
/*
@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
868
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate} or @fref{vlistInqVarZaxis}.
Deike Kleberg's avatar
Deike Kleberg committed
869
    @Item  levelID  Level index (range: 0 to nlevel-1).
Uwe Schulzweida's avatar
Uwe Schulzweida committed
870
871

@Description
872
The function @func{zaxisInqLevel} returns one level of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
873
874

@Result
875
@func{zaxisInqLevel} returns the level of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
876
877
878
879
880
@EndFunction
*/
double zaxisInqLevel(int zaxisID, int levelID)
{
  double level = 0;
881
  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
882

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

886
  return level;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
887
888
889
890
891
}

double zaxisInqLbound(int zaxisID, int index)
{
  double level = 0;
892
  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
893

894
  if ( zaxisptr->lbounds && ( index >= 0 && index < zaxisptr->size ) )
895
      level = zaxisptr->lbounds[index];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
896

897
  return level;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
898
899
900
901
902
903
}


double zaxisInqUbound(int zaxisID, int index)
{
  double level = 0;
904
  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
905

906
907
908
  if ( zaxisptr->ubounds && ( index >= 0 && index < zaxisptr->size ) )
    level = zaxisptr->ubounds[index];
  return level;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
909
910
911
912
913
}


const double *zaxisInqLevelsPtr(int zaxisID)
{
914
  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
915
  return zaxisptr->vals;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
916
917
918
919
920
921
922
923
}

/*
@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
924
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate} or @fref{vlistInqVarZaxis}.
Deike Kleberg's avatar
Deike Kleberg committed
925
926
    @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
927

Uwe Schulzweida's avatar
Uwe Schulzweida committed
928
@Description
929
The function @func{zaxisInqLevels} returns all levels of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
930
931

@Result
932
@func{zaxisInqLevels} saves all levels to the parameter @func{levels}.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
933
934
935
936
@EndFunction
*/
void zaxisInqLevels(int zaxisID, double *levels)
{
937
  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
Thomas Jahns's avatar
Thomas Jahns committed
938
939
  int size = zaxisptr->size;
  for (int i = 0; i < size; i++ )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
940
    levels[i] =  zaxisptr->vals[i];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
941
942
943
944
945
946
}


int zaxisInqLbounds(int zaxisID, double *lbounds)
{
  int size = 0;
947
  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
948

Uwe Schulzweida's avatar
Uwe Schulzweida committed
949
  if ( zaxisptr->lbounds )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
950
    {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
951
      size = zaxisptr->size;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
952
953

      if ( lbounds )
Thomas Jahns's avatar
Thomas Jahns committed
954
        for (int i = 0; i < size; i++ )
Thomas Jahns's avatar
Thomas Jahns committed
955
          lbounds[i] =  zaxisptr->lbounds[i];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
956
957
    }

958
  return size;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
959
960
961
962
963
964
}


int zaxisInqUbounds(int zaxisID, double *ubounds)
{
  int size = 0;
965
  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
966

Uwe Schulzweida's avatar
Uwe Schulzweida committed
967
  if ( zaxisptr->ubounds )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
968
    {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
969
      size = zaxisptr->size;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
970
971

      if ( ubounds )
Thomas Jahns's avatar
Thomas Jahns committed
972
        for (int i = 0; i < size; i++ )
Thomas Jahns's avatar
Thomas Jahns committed
973
          ubounds[i] =  zaxisptr->ubounds[i];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
974
975
    }

976
  return size;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
977
978
979
980
981
982
}


int zaxisInqWeights(int zaxisID, double *weights)
{
  int size = 0;
983
  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
984

Uwe Schulzweida's avatar
Uwe Schulzweida committed
985
  if ( zaxisptr->weights )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
986
    {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
987
      size = zaxisptr->size;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
988
989

      if ( weights )
Thomas Jahns's avatar
Thomas Jahns committed
990
        for ( int i = 0; i < size; i++ )
Thomas Jahns's avatar
Thomas Jahns committed
991
          weights[i] =  zaxisptr->weights[i];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
992
993
    }

994
  return size;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
995
996
997
998
999
1000
}


int zaxisInqLevelID(int zaxisID, double level)
{
  int levelID = CDI_UNDEFID;