zaxis.c 47.6 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 "pio_util.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"
Uwe Schulzweida's avatar
Uwe Schulzweida committed
20

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


Uwe Schulzweida's avatar
Uwe Schulzweida committed
25
static struct {
26
  unsigned char positive;   // 1: up;  2: down
Uwe Schulzweida's avatar
Uwe Schulzweida committed
27
28
  char *name;
  char *longname;
Deike Kleberg's avatar
Deike Kleberg committed
29
  char *stdname;
30
  char *units;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
31
}
32
ZaxistypeEntry[] = {
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
  { /*  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",              "",               ""},
58
  { /* 25 */ 0, "height",            "generalized height",     "height",         ""},
Uwe Schulzweida's avatar
Uwe Schulzweida committed
59
60
};

61
62
static int CDI_MaxZaxistype = sizeof(ZaxistypeEntry) / sizeof(ZaxistypeEntry[0]);

Uwe Schulzweida's avatar
Uwe Schulzweida committed
63
64

typedef struct {
Deike Kleberg's avatar
Deike Kleberg committed
65
  unsigned char positive;
Deike Kleberg's avatar
Deike Kleberg committed
66
67
68
69
  char     name[CDI_MAX_NAME];
  char     longname[CDI_MAX_NAME];
  char     stdname[CDI_MAX_NAME];
  char     units[CDI_MAX_NAME];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
70
71
72
73
  double  *vals;
  double  *lbounds;
  double  *ubounds;
  double  *weights;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
74
  int      self;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
75
76
  int      prec;
  int      type;
77
  int      ltype;    /* GRIB level type */
Uwe Schulzweida's avatar
Uwe Schulzweida committed
78
79
80
81
  int      size;
  int      direction;
  int      vctsize;
  double  *vct;
82
  int      number;   /* Reference number to a generalized Z-axis */
83
  int      nhlev;
84
  char     uuid[17];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
85
}
86
zaxis_t;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
87

Deike Kleberg's avatar
Deike Kleberg committed
88
89
90
static int    zaxisCompareP    ( void * zaxisptr1, void * zaxisptr2 );
static void   zaxisDestroyP    ( void * zaxisptr );
static void   zaxisPrintP      ( void * zaxisptr, FILE * fp );
91
92
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
93
static int    zaxisTxCode      ( void );
Uwe Schulzweida's avatar
Uwe Schulzweida committed
94

95
resOps zaxisOps = { zaxisCompareP, zaxisDestroyP, zaxisPrintP
Deike Kleberg's avatar
Deike Kleberg committed
96
                    , zaxisGetPackSize, zaxisPack, zaxisTxCode
97
};
Uwe Schulzweida's avatar
Uwe Schulzweida committed
98

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

101
static
102
void zaxisDefaultValue ( zaxis_t *zaxisptr )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
103
{
104
  zaxisptr->self        = CDI_UNDEFID;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
105
106
  zaxisptr->name[0]     = 0;
  zaxisptr->longname[0] = 0;
Deike Kleberg's avatar
Deike Kleberg committed
107
  zaxisptr->stdname[0]  = 0;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
108
109
110
111
112
113
  zaxisptr->units[0]    = 0;
  zaxisptr->vals        = NULL;
  zaxisptr->ubounds     = NULL;
  zaxisptr->lbounds     = NULL;
  zaxisptr->weights     = NULL;
  zaxisptr->type        = CDI_UNDEFID;
114
  zaxisptr->ltype       = 0;
Deike Kleberg's avatar
Deike Kleberg committed
115
116
  zaxisptr->positive    = 0;
  zaxisptr->direction   = 0;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
117
118
119
120
  zaxisptr->prec        = 0;
  zaxisptr->size        = 0;
  zaxisptr->vctsize     = 0;
  zaxisptr->vct         = NULL;
121
  zaxisptr->number      = 0;
122
  zaxisptr->nhlev       = 0;
123
  zaxisptr->uuid[0]     = 0;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
124
}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
125

126

127
static
128
zaxis_t *zaxisNewEntry(void)
129
{
130
131
132
133
134
  zaxis_t *zaxisptr;

  zaxisptr = (zaxis_t *) xmalloc(sizeof(zaxis_t));

  zaxisDefaultValue ( zaxisptr );
135
136

  zaxisptr->self = reshPut (( void * ) zaxisptr, &zaxisOps );
137
138

  return (zaxisptr);
139
140
}

141
static
142
void zaxisInit(void)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
143
{
144
145
  static int zaxisInitialized = 0;
  char *env;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
146

147
  if ( zaxisInitialized ) return;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
148

Thomas Jahns's avatar
Thomas Jahns committed
149
  zaxisInitialized = 1;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
150

151
152
  env = getenv("ZAXIS_DEBUG");
  if ( env ) ZAXIS_Debug = atoi(env);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
153
154
}

155
156
static
void zaxis_copy(zaxis_t *zaxisptr2, zaxis_t *zaxisptr1)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
157
158
159
160
{
  int zaxisID2;

  zaxisID2 = zaxisptr2->self;
161
  memcpy(zaxisptr2, zaxisptr1, sizeof(zaxis_t));
Uwe Schulzweida's avatar
Uwe Schulzweida committed
162
163
164
  zaxisptr2->self = zaxisID2;
}

165
166
static
void zaxisCheckPtr(const char *caller, int zaxisID, zaxis_t *zaxisptr)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
167
168
{
  if ( zaxisptr == NULL )
169
    Errorc("zaxis %d undefined!", zaxisID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
170
171
}

172
#define  zaxis_check_ptr(zaxisID, zaxisptr)  zaxisCheckPtr(__func__, zaxisID, zaxisptr)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
173

Uwe Schulzweida's avatar
Uwe Schulzweida committed
174
int zaxisSize(void)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
175
{
176
  return reshCountType ( &zaxisOps );
Uwe Schulzweida's avatar
Uwe Schulzweida committed
177
178
179
180
}


/*
181
@Function  zaxisCreate
182
@Title     Create a vertical Z-axis
Uwe Schulzweida's avatar
Uwe Schulzweida committed
183

184
@Prototype int zaxisCreate(int zaxistype, int size)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
185
186
@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
187
                      The valid CDI Z-axis types are @func{ZAXIS_GENERIC}, @func{ZAXIS_SURFACE},
Uwe Schulzweida's avatar
Uwe Schulzweida committed
188
                      @func{ZAXIS_HYBRID}, @func{ZAXIS_SIGMA}, @func{ZAXIS_PRESSURE}, @func{ZAXIS_HEIGHT},
189
190
                      @func{ZAXIS_ISENTROPIC}, @func{ZAXIS_ALTITUDE}, @func{ZAXIS_MEANSEA}, @func{ZAXIS_TOA},
                      @func{ZAXIS_SEA_BOTTOM}, @func{ZAXIS_ATMOSPHERE}, @func{ZAXIS_CLOUD_BASE},
191
                      @func{ZAXIS_CLOUD_TOP}, @func{ZAXIS_ISOTHERM_ZERO}, @func{ZAXIS_SNOW},
192
193
                      @func{ZAXIS_LAKE_BOTTOM}, @func{ZAXIS_SEDIMENT_BOTTOM}, @func{ZAXIS_SEDIMENT_BOTTOM_TA},
                      @func{ZAXIS_SEDIMENT_BOTTOM_TW}, @func{ZAXIS_MIX_LAYER},
194
                      @func{ZAXIS_DEPTH_BELOW_SEA} and @func{ZAXIS_DEPTH_BELOW_LAND}.
Deike Kleberg's avatar
Deike Kleberg committed
195
    @Item  size       Number of levels.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
196
197

@Description
198
The function @func{zaxisCreate} creates a vertical Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
199
200

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

Uwe Schulzweida's avatar
Uwe Schulzweida committed
203
@Example
204
Here is an example using @func{zaxisCreate} to create a pressure level Z-axis:
Uwe Schulzweida's avatar
Uwe Schulzweida committed
205
206
207
208

@Source
#include "cdi.h"
   ...
209
#define  nlev    5
Uwe Schulzweida's avatar
Uwe Schulzweida committed
210
   ...
211
double levs[nlev] = {101300, 92500, 85000, 50000, 20000};
Uwe Schulzweida's avatar
Uwe Schulzweida committed
212
213
int zaxisID;
   ...
214
zaxisID = zaxisCreate(ZAXIS_PRESSURE, nlev);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
215
216
217
zaxisDefLevels(zaxisID, levs);
   ...
@EndSource
Uwe Schulzweida's avatar
Uwe Schulzweida committed
218
219
@EndFunction
*/
220
int zaxisCreate(int zaxistype, int size)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
221
222
223
224
{
  int ilev;
  int zaxisID;
  double *vals;
225
  zaxis_t *zaxisptr;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
226
227

  if ( CDI_Debug )
228
    Message("zaxistype: %d size: %d ", zaxistype, size);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
229

230
231
232
  zaxisInit ();

  zaxisptr = zaxisNewEntry();
Uwe Schulzweida's avatar
Uwe Schulzweida committed
233
234
235

  zaxisID = zaxisptr->self;

Uwe Schulzweida's avatar
Uwe Schulzweida committed
236
  zaxisptr->type = zaxistype;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
237
  zaxisptr->size = size;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
238

239
  if ( zaxistype > CDI_MaxZaxistype )
240
    Error("Internal problem! zaxistype > CDI_MaxZaxistype");
Uwe Schulzweida's avatar
Uwe Schulzweida committed
241

242
243
244
  zaxisDefName(zaxisID, ZaxistypeEntry[zaxistype].name);
  zaxisDefLongname(zaxisID, ZaxistypeEntry[zaxistype].longname);
  zaxisDefUnits(zaxisID, ZaxistypeEntry[zaxistype].units);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
245

Deike Kleberg's avatar
Deike Kleberg committed
246
247
248
249
250
  if ( *ZaxistypeEntry[zaxistype].stdname )
    strcpy(zaxisptr->stdname, ZaxistypeEntry[zaxistype].stdname);

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

Uwe Schulzweida's avatar
Uwe Schulzweida committed
251
252
253
254
255
  vals = (double *) malloc(size*sizeof(double));

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

Uwe Schulzweida's avatar
Uwe Schulzweida committed
256
  zaxisptr->vals = vals;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
257
258
259
260

  return (zaxisID);
}

261

262
void zaxisDestroyKernel( zaxis_t * zaxisptr )
263
264
265
{
  int id;

Deike Kleberg's avatar
Deike Kleberg committed
266
  xassert ( zaxisptr );
267
268
269

  id = zaxisptr->self;

270
  if ( zaxisptr->vals )    free ( zaxisptr->vals );
271
272
273
  if ( zaxisptr->lbounds ) free ( zaxisptr->lbounds );
  if ( zaxisptr->ubounds ) free ( zaxisptr->ubounds );
  if ( zaxisptr->weights ) free ( zaxisptr->weights );
274
  if ( zaxisptr->vct )     free ( zaxisptr->vct );
275
276
277

  free ( zaxisptr );

278
  reshRemove ( id, &zaxisOps );
279
280
}

281
282
283
284
285
286
/*
@Function  zaxisDestroy
@Title     Destroy a vertical Z-axis

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

@EndFunction
*/
void zaxisDestroy(int zaxisID)
{
293
  zaxis_t *zaxisptr;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
294

295
  zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );
296

297
  zaxisDestroyKernel ( zaxisptr );
298
299
300
}


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


308
char *zaxisNamePtr(int zaxistype)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
309
310
311
{
  char *name;

312
313
  if ( zaxistype >= 0 && zaxistype < CDI_MaxZaxistype )
    name = ZaxistypeEntry[zaxistype].longname;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
314
  else
315
    name = ZaxistypeEntry[ZAXIS_GENERIC].longname;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331

  return (name);
}


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

/*
@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
332
333
    @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
334
335

@Description
336
The function @func{zaxisDefName} defines the name of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
337
338
339
340
341

@EndFunction
*/
void zaxisDefName(int zaxisID, const char *name)
{
342
  zaxis_t *zaxisptr;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
343

344
345
  if ( reshGetStatus ( zaxisID, &zaxisOps ) == CLOSED )
    {
346
      Warning("%s", "Operation not executed.");
347
348
349
      return;
    }

350
  zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );
Uwe Schulzweida's avatar
Uwe Schulzweida committed
351

352
353
  zaxis_check_ptr(zaxisID, zaxisptr);

Uwe Schulzweida's avatar
Uwe Schulzweida committed
354
  if ( name )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
355
    strcpy(zaxisptr->name, name);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
356
357
358
359
360
361
362
363
}

/*
@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
364
365
    @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
366
367

@Description
368
The function @func{zaxisDefLongname} defines the longname of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
369
370
371
372
373

@EndFunction
*/
void zaxisDefLongname(int zaxisID, const char *longname)
{
374
  zaxis_t *zaxisptr;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
375

376
377
  if ( reshGetStatus ( zaxisID, &zaxisOps ) == CLOSED )
    {
378
      Warning("%s", "Operation not executed.");
379
380
381
      return;
    }

382
  zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );
Uwe Schulzweida's avatar
Uwe Schulzweida committed
383

384
385
  zaxis_check_ptr(zaxisID, zaxisptr);

Uwe Schulzweida's avatar
Uwe Schulzweida committed
386
  if ( longname )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
387
    strcpy(zaxisptr->longname, longname);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
388
389
390
391
392
393
394
395
}

/*
@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
396
397
    @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
398
399

@Description
400
The function @func{zaxisDefUnits} defines the units of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
401
402
403
404
405

@EndFunction
*/
void zaxisDefUnits(int zaxisID, const char *units)
{
406
  zaxis_t *zaxisptr;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
407

408
409
  if ( reshGetStatus ( zaxisID, &zaxisOps ) == CLOSED )
    {
410
      Warning("%s", "Operation not executed.");
411
412
413
      return;
    }

414
  zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );
Uwe Schulzweida's avatar
Uwe Schulzweida committed
415

416
417
  zaxis_check_ptr(zaxisID, zaxisptr);

Uwe Schulzweida's avatar
Uwe Schulzweida committed
418
  if ( units )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
419
    strcpy(zaxisptr->units, units);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
420
421
422
423
424
425
426
427
}

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

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

@Description
434
The function @func{zaxisInqName} returns the name of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
435
436

@Result
437
@func{zaxisInqName} returns the name of the Z-axis to the parameter name.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
438
439
440
441
442

@EndFunction
*/
void zaxisInqName(int zaxisID, char *name)
{
443
  zaxis_t *zaxisptr;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
444

445
  zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );
Uwe Schulzweida's avatar
Uwe Schulzweida committed
446

447
448
  zaxis_check_ptr(zaxisID, zaxisptr);

Uwe Schulzweida's avatar
Uwe Schulzweida committed
449
  strcpy(name, zaxisptr->name);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
450
451
452
453
454
455
456
457
}

/*
@Function  zaxisInqLongname
@Title     Get the longname of a Z-axis

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

@Description
464
The function @func{zaxisInqLongname} returns the longname of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
465
466

@Result
467
@func{zaxisInqLongname} returns the longname of the Z-axis to the parameter longname.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
468
469
470
471
472

@EndFunction
*/
void zaxisInqLongname(int zaxisID, char *longname)
{
473
  zaxis_t *zaxisptr;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
474

475
  zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );
Uwe Schulzweida's avatar
Uwe Schulzweida committed
476

477
478
  zaxis_check_ptr(zaxisID, zaxisptr);

Uwe Schulzweida's avatar
Uwe Schulzweida committed
479
  strcpy(longname, zaxisptr->longname);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
480
481
482
483
484
485
486
487
}

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

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

@Description
494
The function @func{zaxisInqUnits} returns the units of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
495
496

@Result
497
@func{zaxisInqUnits} returns the units of the Z-axis to the parameter units.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
498
499
500
501
502

@EndFunction
*/
void zaxisInqUnits(int zaxisID, char *units)
{
503
  zaxis_t *zaxisptr;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
504

505
  zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );
Uwe Schulzweida's avatar
Uwe Schulzweida committed
506

507
508
  zaxis_check_ptr(zaxisID, zaxisptr);

Uwe Schulzweida's avatar
Uwe Schulzweida committed
509
  strcpy(units, zaxisptr->units);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
510
511
512
}


Deike Kleberg's avatar
Deike Kleberg committed
513
514
515
516
517
518
519
520
521
522
523
524
void zaxisInqStdname(int zaxisID, char *stdname)
{
  zaxis_t *zaxisptr;

  zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );

  zaxis_check_ptr(zaxisID, zaxisptr);

  strcpy(stdname, zaxisptr->stdname);
}


Uwe Schulzweida's avatar
Uwe Schulzweida committed
525
526
void zaxisDefPrec(int zaxisID, int prec)
{
527
  zaxis_t *zaxisptr;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
528

529
530
  if ( reshGetStatus ( zaxisID, &zaxisOps ) == CLOSED )
    {
531
      Warning("%s", "Operation not executed.");
532
533
534
      return;
    }

535
  zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );
Uwe Schulzweida's avatar
Uwe Schulzweida committed
536

537
  zaxis_check_ptr(zaxisID, zaxisptr);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
538
539

  zaxisptr->prec = prec;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
540
541
542
543
544
}


int zaxisInqPrec(int zaxisID)
{
545
  zaxis_t *zaxisptr;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
546

547
  zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );
Uwe Schulzweida's avatar
Uwe Schulzweida committed
548

549
  zaxis_check_ptr(zaxisID, zaxisptr);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
550

Uwe Schulzweida's avatar
Uwe Schulzweida committed
551
  return (zaxisptr->prec);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
552
553
554
}


555
556
557
558
559
560
void zaxisDefPositive(int zaxisID, int positive)
{
  zaxis_t *zaxisptr;

  if ( reshGetStatus ( zaxisID, &zaxisOps ) == CLOSED )
    {
561
      Warning("%s", "Operation not executed.");
562
563
564
565
566
567
568
569
570
571
572
      return;
    }

  zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );

  zaxis_check_ptr(zaxisID, zaxisptr);

  zaxisptr->positive = positive;
}


Deike Kleberg's avatar
Deike Kleberg committed
573
574
575
576
577
578
579
580
581
582
583
584
int zaxisInqPositive(int zaxisID)
{
  zaxis_t *zaxisptr;

  zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );

  zaxis_check_ptr(zaxisID, zaxisptr);

  return (zaxisptr->positive);
}


585
586
void zaxisDefLtype(int zaxisID, int ltype)
{
587
  zaxis_t *zaxisptr;
588

589
590
  if ( reshGetStatus ( zaxisID, &zaxisOps ) == CLOSED )
    {
591
      Warning("%s", "Operation not executed.");
592
593
594
      return;
    }

595
  zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );
596

597
  zaxis_check_ptr(zaxisID, zaxisptr);
598
599
600
601
602
603
604

  zaxisptr->ltype = ltype;
}


int zaxisInqLtype(int zaxisID)
{
605
  zaxis_t *zaxisptr;
606

607
  zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );
608

609
  zaxis_check_ptr(zaxisID, zaxisptr);
610
611
612
613

  return (zaxisptr->ltype);
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
614
615
616
617
/*
@Function  zaxisDefLevels
@Title     Define the levels of a Z-axis

Uwe Schulzweida's avatar
Uwe Schulzweida committed
618
@Prototype void zaxisDefLevels(int zaxisID, const double *levels)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
619
@Parameter
Deike Kleberg's avatar
Deike Kleberg committed
620
621
    @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
622
623

@Description
624
The function @func{zaxisDefLevels} defines the levels of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
625
626
627

@EndFunction
*/
Uwe Schulzweida's avatar
Uwe Schulzweida committed
628
void zaxisDefLevels(int zaxisID, const double *levels)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
629
630
631
632
{
  int ilev;
  int size;
  double *vals;
633
  zaxis_t *zaxisptr;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
634

635
636
  if ( reshGetStatus ( zaxisID, &zaxisOps ) == CLOSED )
    {
637
      Warning("%s", "Operation not executed.");
638
639
640
      return;
    }

641
  zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );
Uwe Schulzweida's avatar
Uwe Schulzweida committed
642

643
  zaxis_check_ptr(zaxisID, zaxisptr);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
644

Uwe Schulzweida's avatar
Uwe Schulzweida committed
645
646
647
  size = zaxisptr->size;

  vals = zaxisptr->vals;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
648
649
650
651
652
653
654
655
656
657
658

  for ( ilev = 0; ilev < size; ilev++ )
    vals[ilev] = levels[ilev];
}

/*
@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
659
660
661
    @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
662
663

@Description
664
The function @func{zaxisDefLevel} defines one level of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
665
666
667
668
669

@EndFunction
*/
void zaxisDefLevel(int zaxisID, int levelID, double level)
{
670
  zaxis_t *zaxisptr;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
671

672
673
  if ( reshGetStatus ( zaxisID, &zaxisOps ) == CLOSED )
    {
674
      Warning("%s", "Operation not executed.");
675
676
677
      return;
    }

678
  zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );
Uwe Schulzweida's avatar
Uwe Schulzweida committed
679

680
  zaxis_check_ptr(zaxisID, zaxisptr);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
681

Uwe Schulzweida's avatar
Uwe Schulzweida committed
682
683
  if ( levelID >= 0 && levelID < zaxisptr->size )
    zaxisptr->vals[levelID] = level;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
684
685
}

686
687
688
689
690
691
692

void zaxisDefNlevRef(int zaxisID, const int nhlev)
{
  zaxis_t *zaxisptr;

  if ( reshGetStatus ( zaxisID, &zaxisOps ) == CLOSED )
    {
693
      Warning("%s", "Operation not executed.");
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
      return;
    }

  zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );

  zaxis_check_ptr(zaxisID, zaxisptr);

  zaxisptr->nhlev = nhlev;
}


int zaxisInqNlevRef(int zaxisID)
{
  int nhlev = -1;
  zaxis_t *zaxisptr;

  zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );

  zaxis_check_ptr(zaxisID, zaxisptr);

  nhlev = zaxisptr->nhlev;

  return (nhlev);
}

719
/*
720
721
@Function  zaxisDefNumber
@Title     Define the reference number for a generalized Z-axis
722

723
@Prototype void zaxisDefNumber(int zaxisID, const int number)
724
725
@Parameter
    @Item  zaxisID     Z-axis ID, from a previous call to @fref{zaxisCreate}.
726
    @Item  number      Reference number for a generalized Z-axis.
727
728

@Description
729
The function @func{zaxisDefNumber} defines the reference number for a generalized Z-axis.
730
731
732

@EndFunction
*/
733
void zaxisDefNumber(int zaxisID, const int number)
734
735
736
{
  zaxis_t *zaxisptr;

737
  if ( reshGetStatus ( zaxisID, &zaxisOps ) == CLOSED )
738
    {
739
      Warning("%s", "Operation not executed.");
740
741
742
743
744
745
746
      return;
    }

  zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );

  zaxis_check_ptr(zaxisID, zaxisptr);

747
  zaxisptr->number = number;
748
749
}

750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
/*
@Function  zaxisInqNumber
@Title     Get the reference number to a generalized Z-axis

@Prototype int zaxisInqNumber(int zaxisID)
@Parameter
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate}.

@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)
{
  int number = -1;
  zaxis_t *zaxisptr;

  zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );

  zaxis_check_ptr(zaxisID, zaxisptr);

  number = zaxisptr->number;

  return (number);
}

779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
/*
@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
*/
void zaxisDefUUID(int zaxisID, const char *uuid)
{
  zaxis_t *zaxisptr;

    if ( reshGetStatus ( zaxisID, &zaxisOps ) == CLOSED )
    {
799
      Warning("%s", "Operation not executed.");
800
801
802
803
804
805
806
      return;
    }

  zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );

  zaxis_check_ptr(zaxisID, zaxisptr);

807
  memcpy(zaxisptr->uuid, uuid, 16);
808
809
810
811
812
813

  return;
}

/*
@Function  zaxisInqUUID
814
@Title     Get the uuid to a generalized Z-axis
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834

@Prototype char *zaxisInqUUID(int zaxisID, char *uuid)
@Parameter
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate}.

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

@Result
@func{zaxisInqUUID} returns the UUID to a generalized Z-axis.
@EndFunction
*/
char *zaxisInqUUID(int zaxisID, char *uuid)
{
  zaxis_t *zaxisptr;

  zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );

  zaxis_check_ptr(zaxisID, zaxisptr);

835
  memcpy(uuid, zaxisptr->uuid, 16);
836
837
838
839

  return (uuid);
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
840
841
842
843
844
845
/*
@Function  zaxisInqLevel
@Title     Get one level of a Z-axis

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

@Description
850
The function @func{zaxisInqLevel} returns one level of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
851
852

@Result
853
@func{zaxisInqLevel} returns the level of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
854
855
856
857
858
@EndFunction
*/
double zaxisInqLevel(int zaxisID, int levelID)
{
  double level = 0;
859
  zaxis_t *zaxisptr;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
860

861
  zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );
Uwe Schulzweida's avatar
Uwe Schulzweida committed
862

863
  zaxis_check_ptr(zaxisID, zaxisptr);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
864

Uwe Schulzweida's avatar
Uwe Schulzweida committed
865
866
  if ( levelID >= 0 && levelID < zaxisptr->size )
    level = zaxisptr->vals[levelID];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
867
868
869
870
871
872
873

  return (level);
}

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

876
  zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );
Uwe Schulzweida's avatar
Uwe Schulzweida committed
877

878
  zaxis_check_ptr(zaxisID, zaxisptr);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
879

880
881
882
  if ( zaxisptr->lbounds )
    if ( index >= 0 && index < zaxisptr->size )
      level = zaxisptr->lbounds[index];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
883
884
885
886
887
888
889
890

  return (level);
}


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

893
  zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );
Uwe Schulzweida's avatar
Uwe Schulzweida committed
894

895
  zaxis_check_ptr(zaxisID, zaxisptr);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
896

897
898
899
  if ( zaxisptr->ubounds )
    if ( index >= 0 && index < zaxisptr->size )
      level = zaxisptr->ubounds[index];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
900
901
902
903
904
905
906

  return (level);
}


const double *zaxisInqLevelsPtr(int zaxisID)
{
907
  zaxis_t *zaxisptr;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
908

909
  zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );
Uwe Schulzweida's avatar
Uwe Schulzweida committed
910

911
912
  zaxis_check_ptr(zaxisID, zaxisptr);

Uwe Schulzweida's avatar
Uwe Schulzweida committed
913
  return ( zaxisptr->vals );
Uwe Schulzweida's avatar
Uwe Schulzweida committed
914
915
916
917
918
919
920
921
}

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

@Prototype void zaxisInqLevels(int zaxisID, double *levels)
@Parameter
Deike Kleberg's avatar
Deike Kleberg committed
922
923
924
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate}.
    @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
925

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

@Result
930
@func{zaxisInqLevels} saves all levels to the parameter @func{levels}.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
931
932
933
934
935
936
@EndFunction
*/
void zaxisInqLevels(int zaxisID, double *levels)
{
  int size;
  int i;
937
  zaxis_t *zaxisptr;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
938

939
  zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );
Uwe Schulzweida's avatar
Uwe Schulzweida committed
940

941
  zaxis_check_ptr(zaxisID, zaxisptr);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
942
943

  size = zaxisptr->size;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
944
  for ( i = 0; i < size; i++ )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
945
    levels[i] =  zaxisptr->vals[i];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
946
947
948
949
950
951
952
}


int zaxisInqLbounds(int zaxisID, double *lbounds)
{
  int size = 0;
  int i;
953
  zaxis_t *zaxisptr;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
954

955
  zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );
Uwe Schulzweida's avatar
Uwe Schulzweida committed
956

957
  zaxis_check_ptr(zaxisID, zaxisptr);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
958

Uwe Schulzweida's avatar
Uwe Schulzweida committed
959
  if ( zaxisptr->lbounds )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
960
    {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
961
      size = zaxisptr->size;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
962
963

      if ( lbounds )
Thomas Jahns's avatar
Thomas Jahns committed
964
965
        for ( i = 0; i < size; i++ )
          lbounds[i] =  zaxisptr->lbounds[i];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
966
967
968
969
970
971
972
973
974
975
    }

  return (size);
}


int zaxisInqUbounds(int zaxisID, double *ubounds)
{
  int size = 0;
  int i;
976
  zaxis_t *zaxisptr;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
977

978
  zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );
Uwe Schulzweida's avatar
Uwe Schulzweida committed
979

980
  zaxis_check_ptr(zaxisID, zaxisptr);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
981
982

  if ( zaxisptr->ubounds )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
983
    {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
984
      size = zaxisptr->size;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
985
986

      if ( ubounds )
Thomas Jahns's avatar
Thomas Jahns committed
987
988
        for ( i = 0; i < size; i++ )
          ubounds[i] =  zaxisptr->ubounds[i];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
989
990
991
992
993
994
995
996
997
998
    }

  return (size);
}


int zaxisInqWeights(int zaxisID, double *weights)
{
  int size = 0;
  int i;
999
  zaxis_t *zaxisptr;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1000

1001
  zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1002

1003
  zaxis_check_ptr(zaxisID, zaxisptr);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1004

Uwe Schulzweida's avatar
Uwe Schulzweida committed
1005
  if ( zaxisptr->weights )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1006
    {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1007
      size = zaxisptr->size;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1008
1009

      if ( weights )
Thomas Jahns's avatar
Thomas Jahns committed
1010
1011
        for ( i = 0; i < size; i++ )
          weights[i] =  zaxisptr->weights[i];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
    }

  return (size);
}


int zaxisInqLevelID(int zaxisID, double level)
{
  int size;
  int levelID = CDI_UNDEFID;
  int i;
1023
  zaxis_t *zaxisptr;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1024

1025
  zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1026

1027
  zaxis_check_ptr(zaxisID, zaxisptr);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1028

Uwe Schulzweida's avatar
Uwe Schulzweida committed
1029
  size = zaxisptr->size;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1030
  for ( i = 0; i < size; i++ )
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1031
    if ( fabs(level-zaxisptr->vals[i]) < DBL_EPSILON ) break;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043

  if ( i < size ) levelID = i;

  return (levelID);
}

/*
@Function  zaxisInqType
@Title     Get the type of a Z-axis

@Prototype int zaxisInqType(int zaxisID)
@Parameter
Deike Kleberg's avatar
Deike Kleberg committed
1044
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate}.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1045
1046

@Description
1047
The function @func{zaxisInqType} returns the type of a Z-axis.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1048
1049

@Result
1050
@func{zaxisInqType} returns the type of the Z-axis,
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1051
one of the set of predefined CDI Z-axis types.