~javier-lopez/ubuntu/quantal/cdo/sru-1023329

« back to all changes in this revision

Viewing changes to libcdi/src/zaxis.c

  • Committer: Bazaar Package Importer
  • Author(s): Alastair McKinstry
  • Date: 2010-09-22 15:58:09 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20100922155809-u1d3vlmlqj02uxjt
Tags: 1.4.6.dfsg.1-1
New upstream release. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#if defined (HAVE_CONFIG_H)
 
2
#  include "config.h"
 
3
#endif
 
4
 
 
5
#include <string.h>
 
6
#include <math.h>
 
7
#include <float.h>
 
8
 
 
9
#include "dmemory.h"
 
10
 
 
11
#include "cdi.h"
 
12
#include "stream_int.h"
 
13
 
 
14
 
 
15
static struct {
 
16
  char *name;
 
17
  char *longname;
 
18
  char *units;
 
19
}
 
20
ZaxistypeEntry[] = {
 
21
  {"sfc",     "surface",                  ""},
 
22
  {"lev",     "generic",                  "level"},
 
23
  {"lev",     "hybrid",                   "level"},
 
24
  {"lev",     "hybrid_half",              "level"},
 
25
  {"lev",     "pressure",                 "Pa"},
 
26
  {"height",  "height",                   "m"},
 
27
  {"depth",   "depth_below_sea",          "m"},
 
28
  {"depth",   "depth_below_land",         "cm"},
 
29
  {"lev",     "isentropic",               "K"},
 
30
  {"lev",     "trajectory",               ""},
 
31
  {"alt",     "altitude",                 "m"},
 
32
  {"lev",     "sigma",                    "level"},
 
33
  {"lev",     "meansea",                  "level"},
 
34
};
 
35
 
 
36
static int CDI_MaxZaxistype = sizeof(ZaxistypeEntry) / sizeof(ZaxistypeEntry[0]);
 
37
 
 
38
 
 
39
#define  LevelDown  0
 
40
#define  LevelUp    1
 
41
 
 
42
typedef struct {
 
43
  char     name[256];
 
44
  char     longname[256];
 
45
  char     units[256];
 
46
  double  *vals;
 
47
  double  *lbounds;
 
48
  double  *ubounds;
 
49
  double  *weights;
 
50
  int      self;
 
51
  int      prec;
 
52
  int      type;
 
53
  int      ltype;    /* GRIB level type */
 
54
  int      size;
 
55
  int      direction;
 
56
  int      vctsize;
 
57
  double  *vct;
 
58
}
 
59
ZAXIS;
 
60
 
 
61
static int  ZAXIS_Debug = 0;   /* If set to 1, debugging */
 
62
 
 
63
static int _zaxis_max = MAX_ZAXES;
 
64
 
 
65
static void zaxis_initialize(void);
 
66
 
 
67
static int _zaxis_init = FALSE;
 
68
 
 
69
#if  defined  (HAVE_LIBPTHREAD)
 
70
#  include <pthread.h>
 
71
 
 
72
static pthread_once_t _zaxis_init_thread = PTHREAD_ONCE_INIT;
 
73
static pthread_mutex_t _zaxis_mutex;
 
74
 
 
75
#  define ZAXIS_LOCK           pthread_mutex_lock(&_zaxis_mutex);
 
76
#  define ZAXIS_UNLOCK         pthread_mutex_unlock(&_zaxis_mutex);
 
77
#  define ZAXIS_INIT                               \
 
78
   if ( _zaxis_init == FALSE ) pthread_once(&_zaxis_init_thread, zaxis_initialize);
 
79
 
 
80
#else
 
81
 
 
82
#  define ZAXIS_LOCK
 
83
#  define ZAXIS_UNLOCK
 
84
#  define ZAXIS_INIT                               \
 
85
   if ( _zaxis_init == FALSE ) zaxis_initialize();
 
86
 
 
87
#endif
 
88
 
 
89
 
 
90
typedef struct _zaxisPtrToIdx {
 
91
  int idx;
 
92
  ZAXIS *ptr;
 
93
  struct _zaxisPtrToIdx *next;
 
94
} zaxisPtrToIdx;
 
95
 
 
96
 
 
97
static zaxisPtrToIdx *_zaxisList  = NULL;
 
98
static zaxisPtrToIdx *_zaxisAvail = NULL;
 
99
 
 
100
 
 
101
static void zaxis_list_new(void)
 
102
{
 
103
  static const char *func = "zaxis_list_new";
 
104
 
 
105
  assert(_zaxisList == NULL);
 
106
 
 
107
  _zaxisList = (zaxisPtrToIdx *) malloc(_zaxis_max*sizeof(zaxisPtrToIdx));
 
108
}
 
109
 
 
110
 
 
111
static void zaxis_list_delete(void)
 
112
{
 
113
  static const char *func = "zaxis_list_delete";
 
114
 
 
115
  if ( _zaxisList ) free(_zaxisList);
 
116
}
 
117
 
 
118
 
 
119
static void zaxis_init_pointer(void)
 
120
{
 
121
  int  i;
 
122
  
 
123
  for ( i = 0; i < _zaxis_max; i++ )
 
124
    {
 
125
      _zaxisList[i].next = _zaxisList + i + 1;
 
126
      _zaxisList[i].idx  = i;
 
127
      _zaxisList[i].ptr  = 0;
 
128
    }
 
129
 
 
130
  _zaxisList[_zaxis_max-1].next = 0;
 
131
 
 
132
  _zaxisAvail = _zaxisList;
 
133
}
 
134
 
 
135
 
 
136
ZAXIS *zaxis_to_pointer(int idx)
 
137
{
 
138
  static const char *func = "zaxis_to_pointer";
 
139
  ZAXIS *zaxisptr = NULL;
 
140
 
 
141
  ZAXIS_INIT
 
142
 
 
143
  if ( idx >= 0 && idx < _zaxis_max )
 
144
    {
 
145
      ZAXIS_LOCK
 
146
 
 
147
      zaxisptr = _zaxisList[idx].ptr;
 
148
 
 
149
      ZAXIS_UNLOCK
 
150
    }
 
151
  else
 
152
    Error(func, "zaxis index %d undefined!", idx);
 
153
 
 
154
  return (zaxisptr);
 
155
}
 
156
 
 
157
 
 
158
/* Create an index from a pointer */
 
159
static int zaxis_from_pointer(ZAXIS *ptr)
 
160
{
 
161
  static const char *func = "zaxis_from_pointer";
 
162
  int      idx = -1;
 
163
  zaxisPtrToIdx *newptr;
 
164
 
 
165
  if ( ptr )
 
166
    {
 
167
      ZAXIS_LOCK
 
168
 
 
169
      if ( _zaxisAvail )
 
170
        {
 
171
          newptr       = _zaxisAvail;
 
172
          _zaxisAvail  = _zaxisAvail->next;
 
173
          newptr->next = 0;
 
174
          idx          = newptr->idx;
 
175
          newptr->ptr  = ptr;
 
176
      
 
177
          if ( ZAXIS_Debug )
 
178
            Message(func, "Pointer %p has idx %d from zaxis list", ptr, idx);
 
179
        }
 
180
      else
 
181
        Warning(func, "Too many open zaxis (limit is %d)!", _zaxis_max);
 
182
 
 
183
      ZAXIS_UNLOCK
 
184
    }
 
185
  else
 
186
    Error(func, "Internal problem (pointer %p undefined)", ptr);
 
187
 
 
188
  return (idx);
 
189
}
 
190
 
 
191
 
 
192
static void zaxis_init_entry(ZAXIS *zaxisptr)
 
193
{
 
194
  zaxisptr->self        = zaxis_from_pointer(zaxisptr);
 
195
 
 
196
  zaxisptr->name[0]     = 0;
 
197
  zaxisptr->longname[0] = 0;
 
198
  zaxisptr->units[0]    = 0;
 
199
  zaxisptr->vals        = NULL;
 
200
  zaxisptr->ubounds     = NULL;
 
201
  zaxisptr->lbounds     = NULL;
 
202
  zaxisptr->weights     = NULL;
 
203
  zaxisptr->type        = CDI_UNDEFID;
 
204
  zaxisptr->ltype       = 0;
 
205
  zaxisptr->direction   = CDI_UNDEFID;
 
206
  zaxisptr->prec        = 0;
 
207
  zaxisptr->size        = 0;
 
208
  zaxisptr->vctsize     = 0;
 
209
  zaxisptr->vct         = NULL;
 
210
}
 
211
 
 
212
 
 
213
static ZAXIS *zaxis_new_entry(void)
 
214
{
 
215
  static const char *func = "zaxis_new_entry";
 
216
  ZAXIS *zaxisptr;
 
217
 
 
218
  zaxisptr = (ZAXIS *) malloc(sizeof(ZAXIS));
 
219
 
 
220
  if ( zaxisptr ) zaxis_init_entry(zaxisptr);
 
221
 
 
222
  return (zaxisptr);
 
223
}
 
224
 
 
225
 
 
226
static void zaxis_delete_entry(ZAXIS *zaxisptr)
 
227
{
 
228
  static const char *func = "zaxis_delete_entry";
 
229
  int idx;
 
230
 
 
231
  idx = zaxisptr->self;
 
232
 
 
233
  ZAXIS_LOCK
 
234
 
 
235
  free(zaxisptr);
 
236
 
 
237
  _zaxisList[idx].next = _zaxisAvail;
 
238
  _zaxisList[idx].ptr  = 0;
 
239
  _zaxisAvail          = &_zaxisList[idx];
 
240
 
 
241
  ZAXIS_UNLOCK
 
242
 
 
243
  if ( ZAXIS_Debug )
 
244
    Message(func, "Removed idx %d from zaxis list", idx);
 
245
}
 
246
 
 
247
 
 
248
static void zaxis_initialize(void)
 
249
{
 
250
  char *env;
 
251
 
 
252
#if  defined  (HAVE_LIBPTHREAD)
 
253
  /* initialize global API mutex lock */
 
254
  pthread_mutex_init(&_zaxis_mutex, NULL);
 
255
#endif
 
256
 
 
257
  env = getenv("ZAXIS_DEBUG");
 
258
  if ( env ) ZAXIS_Debug = atoi(env);
 
259
 
 
260
  zaxis_list_new();
 
261
  atexit(zaxis_list_delete);
 
262
 
 
263
  ZAXIS_LOCK
 
264
 
 
265
  zaxis_init_pointer();
 
266
 
 
267
  ZAXIS_UNLOCK
 
268
 
 
269
  _zaxis_init = TRUE;
 
270
}
 
271
 
 
272
 
 
273
static void zaxis_copy(ZAXIS *zaxisptr2, ZAXIS *zaxisptr1)
 
274
{
 
275
  int zaxisID2;
 
276
 
 
277
  zaxisID2 = zaxisptr2->self;
 
278
  memcpy(zaxisptr2, zaxisptr1, sizeof(ZAXIS));
 
279
  zaxisptr2->self = zaxisID2;
 
280
}
 
281
 
 
282
 
 
283
static void zaxis_check_ptr(const char *func, ZAXIS *zaxisptr)
 
284
{
 
285
  if ( zaxisptr == NULL )
 
286
    Error(func, "zaxis undefined!");
 
287
}
 
288
 
 
289
 
 
290
int zaxisSize(void)
 
291
{
 
292
  int zaxissize = 0;
 
293
  int i;
 
294
  
 
295
  ZAXIS_INIT
 
296
 
 
297
  ZAXIS_LOCK
 
298
 
 
299
  for ( i = 0; i < _zaxis_max; i++ )
 
300
    if ( _zaxisList[i].ptr ) zaxissize++;
 
301
 
 
302
  ZAXIS_UNLOCK
 
303
 
 
304
  return (zaxissize);
 
305
}
 
306
 
 
307
 
 
308
/*
 
309
@Function  zaxisCreate
 
310
@Title     Create a vertical Z-axis
 
311
 
 
312
@Prototype int zaxisCreate(int zaxistype, int size)
 
313
@Parameter
 
314
    @Item  zaxistype  The type of the Z-axis, one of the set of predefined CDI Z-axis types.
 
315
                      The valid CDI Z-axis types are @func{ZAXIS_GENERIC}, @func{ZAXIS_SURFACE},
 
316
                      @func{ZAXIS_HYBRID}, @func{ZAXIS_SIGMA}, @func{ZAXIS_PRESSURE}, @func{ZAXIS_HEIGHT},
 
317
                      @func{ZAXIS_DEPTH_BELOW_SEA} and @func{ZAXIS_DEPTH_BELOW_LAND}.
 
318
    @Item  size       Number of levels
 
319
 
 
320
@Description
 
321
The function @func{zaxisCreate} creates a vertical Z-axis.
 
322
 
 
323
@Result
 
324
@func{zaxisCreate} returns an identifier to the Z-axis.
 
325
 
 
326
@Example
 
327
Here is an example using @func{zaxisCreate} to create a pressure level Z-axis:
 
328
 
 
329
@Source
 
330
#include "cdi.h"
 
331
   ...
 
332
#define  NLEV    5
 
333
   ...
 
334
double levs[NLEV] = {101300, 92500, 85000, 50000, 20000};
 
335
int zaxisID;
 
336
   ...
 
337
zaxisID = zaxisCreate(ZAXIS_PRESSURE, NLEV);
 
338
zaxisDefLevels(zaxisID, levs);
 
339
   ...
 
340
@EndSource
 
341
@EndFunction
 
342
*/
 
343
int zaxisCreate(int zaxistype, int size)
 
344
{
 
345
  static const char *func = "zaxisCreate";
 
346
  int ilev;
 
347
  int zaxisID;
 
348
  double *vals;
 
349
  ZAXIS *zaxisptr;
 
350
 
 
351
  if ( CDI_Debug )
 
352
    Message(func, "zaxistype: %d size: %d ", zaxistype, size);
 
353
 
 
354
  ZAXIS_INIT
 
355
 
 
356
  zaxisptr = zaxis_new_entry();
 
357
  if ( ! zaxisptr ) Error(func, "No memory");
 
358
 
 
359
  zaxisID = zaxisptr->self;
 
360
 
 
361
  zaxisptr->type = zaxistype;
 
362
  zaxisptr->size = size;
 
363
 
 
364
  if ( zaxistype > CDI_MaxZaxistype )
 
365
    Error(func, "Internal problem! zaxistype > CDI_MaxZaxistype");
 
366
 
 
367
  zaxisDefName(zaxisID, ZaxistypeEntry[zaxistype].name);
 
368
  zaxisDefLongname(zaxisID, ZaxistypeEntry[zaxistype].longname);
 
369
  zaxisDefUnits(zaxisID, ZaxistypeEntry[zaxistype].units);
 
370
 
 
371
  vals = (double *) malloc(size*sizeof(double));
 
372
 
 
373
  for ( ilev = 0; ilev < size; ilev++ )
 
374
    vals[ilev] = 0.0;
 
375
 
 
376
  zaxisptr->vals = vals;
 
377
 
 
378
  return (zaxisID);
 
379
}
 
380
 
 
381
 
 
382
/*
 
383
@Function  zaxisDestroy
 
384
@Title     Destroy a vertical Z-axis
 
385
 
 
386
@Prototype void zaxisDestroy(int zaxisID)
 
387
@Parameter
 
388
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate}
 
389
 
 
390
@EndFunction
 
391
*/
 
392
void zaxisDestroy(int zaxisID)
 
393
{
 
394
  ZAXIS *zaxisptr;
 
395
 
 
396
  zaxisptr = zaxis_to_pointer(zaxisID);
 
397
}
 
398
 
 
399
 
 
400
char *zaxisNamePtr(int zaxistype)
 
401
{
 
402
  char *name;
 
403
 
 
404
  if ( zaxistype >= 0 && zaxistype < CDI_MaxZaxistype )
 
405
    name = ZaxistypeEntry[zaxistype].longname;
 
406
  else
 
407
    name = ZaxistypeEntry[ZAXIS_GENERIC].longname;
 
408
 
 
409
  return (name);
 
410
}
 
411
 
 
412
 
 
413
void zaxisName(int zaxistype, char *zaxisname)
 
414
{
 
415
  strcpy(zaxisname, zaxisNamePtr(zaxistype));
 
416
}
 
417
 
 
418
 
 
419
/*
 
420
@Function  zaxisDefName
 
421
@Title     Define the name of a Z-axis
 
422
 
 
423
@Prototype void zaxisDefName(int zaxisID, const char *name)
 
424
@Parameter
 
425
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate}
 
426
    @Item  name     Name of the Z-axis
 
427
 
 
428
@Description
 
429
The function @func{zaxisDefName} defines the name of a Z-axis.
 
430
 
 
431
@EndFunction
 
432
*/
 
433
void zaxisDefName(int zaxisID, const char *name)
 
434
{
 
435
  ZAXIS *zaxisptr;
 
436
 
 
437
  zaxisptr = zaxis_to_pointer(zaxisID);
 
438
 
 
439
  if ( name )
 
440
    strcpy(zaxisptr->name, name);
 
441
}
 
442
 
 
443
 
 
444
/*
 
445
@Function  zaxisDefLongname
 
446
@Title     Define the longname of a Z-axis
 
447
 
 
448
@Prototype void zaxisDefLongname(int zaxisID, const char *longname)
 
449
@Parameter
 
450
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate}
 
451
    @Item  longname Longname of the Z-axis
 
452
 
 
453
@Description
 
454
The function @func{zaxisDefLongname} defines the longname of a Z-axis.
 
455
 
 
456
@EndFunction
 
457
*/
 
458
void zaxisDefLongname(int zaxisID, const char *longname)
 
459
{
 
460
  ZAXIS *zaxisptr;
 
461
 
 
462
  zaxisptr = zaxis_to_pointer(zaxisID);
 
463
 
 
464
  if ( longname )
 
465
    strcpy(zaxisptr->longname, longname);
 
466
}
 
467
 
 
468
 
 
469
/*
 
470
@Function  zaxisDefUnits
 
471
@Title     Define the units of a Z-axis
 
472
 
 
473
@Prototype void zaxisDefUnits(int zaxisID, const char *units)
 
474
@Parameter
 
475
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate}
 
476
    @Item  units    Units of the Z-axis
 
477
 
 
478
@Description
 
479
The function @func{zaxisDefUnits} defines the units of a Z-axis.
 
480
 
 
481
@EndFunction
 
482
*/
 
483
void zaxisDefUnits(int zaxisID, const char *units)
 
484
{
 
485
  ZAXIS *zaxisptr;
 
486
 
 
487
  zaxisptr = zaxis_to_pointer(zaxisID);
 
488
 
 
489
  if ( units )
 
490
    strcpy(zaxisptr->units, units);
 
491
}
 
492
 
 
493
 
 
494
/*
 
495
@Function  zaxisInqName
 
496
@Title     Get the name of a Z-axis
 
497
 
 
498
@Prototype void zaxisInqName(int zaxisID, char *name)
 
499
@Parameter
 
500
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate}
 
501
    @Item  name     Name of the Z-axis
 
502
 
 
503
@Description
 
504
The function @func{zaxisInqName} returns the name of a Z-axis.
 
505
 
 
506
@Result
 
507
@func{zaxisInqName} returns the name of the Z-axis to the parameter name.
 
508
 
 
509
@EndFunction
 
510
*/
 
511
void zaxisInqName(int zaxisID, char *name)
 
512
{
 
513
  ZAXIS *zaxisptr;
 
514
 
 
515
  zaxisptr = zaxis_to_pointer(zaxisID);
 
516
 
 
517
  strcpy(name, zaxisptr->name);
 
518
}
 
519
 
 
520
 
 
521
/*
 
522
@Function  zaxisInqLongname
 
523
@Title     Get the longname of a Z-axis
 
524
 
 
525
@Prototype void zaxisInqLongname(int zaxisID, char *longname)
 
526
@Parameter
 
527
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate}
 
528
    @Item  longname Longname of the Z-axis
 
529
 
 
530
@Description
 
531
The function @func{zaxisInqLongname} returns the longname of a Z-axis.
 
532
 
 
533
@Result
 
534
@func{zaxisInqLongname} returns the longname of the Z-axis to the parameter longname.
 
535
 
 
536
@EndFunction
 
537
*/
 
538
void zaxisInqLongname(int zaxisID, char *longname)
 
539
{
 
540
  ZAXIS *zaxisptr;
 
541
 
 
542
  zaxisptr = zaxis_to_pointer(zaxisID);
 
543
 
 
544
  strcpy(longname, zaxisptr->longname);
 
545
}
 
546
 
 
547
 
 
548
/*
 
549
@Function  zaxisInqUnits
 
550
@Title     Get the units of a Z-axis
 
551
 
 
552
@Prototype void zaxisInqUnits(int zaxisID, char *units)
 
553
@Parameter
 
554
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate}
 
555
    @Item  units    Units of the Z-axis
 
556
 
 
557
@Description
 
558
The function @func{zaxisInqUnits} returns the units of a Z-axis.
 
559
 
 
560
@Result
 
561
@func{zaxisInqUnits} returns the units of the Z-axis to the parameter units.
 
562
 
 
563
@EndFunction
 
564
*/
 
565
void zaxisInqUnits(int zaxisID, char *units)
 
566
{
 
567
  ZAXIS *zaxisptr;
 
568
 
 
569
  zaxisptr = zaxis_to_pointer(zaxisID);
 
570
 
 
571
  strcpy(units, zaxisptr->units);
 
572
}
 
573
 
 
574
 
 
575
void zaxisDefPrec(int zaxisID, int prec)
 
576
{
 
577
  static const char *func = "zaxisDefPrec";
 
578
  ZAXIS *zaxisptr;
 
579
 
 
580
  zaxisptr = zaxis_to_pointer(zaxisID);
 
581
 
 
582
  zaxis_check_ptr(func, zaxisptr);
 
583
 
 
584
  zaxisptr->prec = prec;
 
585
}
 
586
 
 
587
 
 
588
int zaxisInqPrec(int zaxisID)
 
589
{
 
590
  static const char *func = "zaxisInqPrec";
 
591
  ZAXIS *zaxisptr;
 
592
 
 
593
  zaxisptr = zaxis_to_pointer(zaxisID);
 
594
 
 
595
  zaxis_check_ptr(func, zaxisptr);
 
596
 
 
597
  return (zaxisptr->prec);
 
598
}
 
599
 
 
600
 
 
601
void zaxisDefLtype(int zaxisID, int ltype)
 
602
{
 
603
  static const char *func = "zaxisDefLtype";
 
604
  ZAXIS *zaxisptr;
 
605
 
 
606
  zaxisptr = zaxis_to_pointer(zaxisID);
 
607
 
 
608
  zaxis_check_ptr(func, zaxisptr);
 
609
 
 
610
  zaxisptr->ltype = ltype;
 
611
}
 
612
 
 
613
 
 
614
int zaxisInqLtype(int zaxisID)
 
615
{
 
616
  static const char *func = "zaxisInqLtype";
 
617
  ZAXIS *zaxisptr;
 
618
 
 
619
  zaxisptr = zaxis_to_pointer(zaxisID);
 
620
 
 
621
  zaxis_check_ptr(func, zaxisptr);
 
622
 
 
623
  return (zaxisptr->ltype);
 
624
}
 
625
 
 
626
 
 
627
/*
 
628
@Function  zaxisDefLevels
 
629
@Title     Define the levels of a Z-axis
 
630
 
 
631
@Prototype void zaxisDefLevels(int zaxisID, const double *levels)
 
632
@Parameter
 
633
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate}
 
634
    @Item  levels   All levels of the Z-axis
 
635
 
 
636
@Description
 
637
The function @func{zaxisDefLevels} defines the levels of a Z-axis.
 
638
 
 
639
@EndFunction
 
640
*/
 
641
void zaxisDefLevels(int zaxisID, const double *levels)
 
642
{
 
643
  static const char *func = "zaxisDefLevels";
 
644
  int ilev;
 
645
  int size;
 
646
  double *vals;
 
647
  ZAXIS *zaxisptr;
 
648
 
 
649
  zaxisptr = zaxis_to_pointer(zaxisID);
 
650
 
 
651
  zaxis_check_ptr(func, zaxisptr);
 
652
 
 
653
  size = zaxisptr->size;
 
654
 
 
655
  vals = zaxisptr->vals;
 
656
 
 
657
  for ( ilev = 0; ilev < size; ilev++ )
 
658
    vals[ilev] = levels[ilev];
 
659
}
 
660
 
 
661
 
 
662
/*
 
663
@Function  zaxisDefLevel
 
664
@Title     Define one level of a Z-axis
 
665
 
 
666
@Prototype void zaxisDefLevel(int zaxisID, int levelID, double level)
 
667
@Parameter
 
668
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate}
 
669
    @Item  levelID  Level identifier
 
670
    @Item  level    Level
 
671
 
 
672
@Description
 
673
The function @func{zaxisDefLevel} defines one level of a Z-axis.
 
674
 
 
675
@EndFunction
 
676
*/
 
677
void zaxisDefLevel(int zaxisID, int levelID, double level)
 
678
{
 
679
  static const char *func = "zaxisDefLevel";
 
680
  ZAXIS *zaxisptr;
 
681
 
 
682
  zaxisptr = zaxis_to_pointer(zaxisID);
 
683
 
 
684
  zaxis_check_ptr(func, zaxisptr);
 
685
 
 
686
  if ( levelID >= 0 && levelID < zaxisptr->size )
 
687
    zaxisptr->vals[levelID] = level;
 
688
}
 
689
 
 
690
 
 
691
/*
 
692
@Function  zaxisInqLevel
 
693
@Title     Get one level of a Z-axis
 
694
 
 
695
@Prototype double zaxisInqLevel(int zaxisID, int levelID)
 
696
@Parameter
 
697
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate}
 
698
    @Item  levelID  Level index (range: 0 to nlevel-1)
 
699
 
 
700
@Description
 
701
The function @func{zaxisInqLevel} returns one level of a Z-axis.
 
702
 
 
703
@Result
 
704
@func{zaxisInqLevel} returns the level of a Z-axis.
 
705
@EndFunction
 
706
*/
 
707
double zaxisInqLevel(int zaxisID, int levelID)
 
708
{
 
709
  static const char *func = "zaxisInqLevel";
 
710
  double level = 0;
 
711
  ZAXIS *zaxisptr;
 
712
 
 
713
  zaxisptr = zaxis_to_pointer(zaxisID);
 
714
 
 
715
  zaxis_check_ptr(func, zaxisptr);
 
716
 
 
717
  if ( levelID >= 0 && levelID < zaxisptr->size )
 
718
    level = zaxisptr->vals[levelID];
 
719
 
 
720
  return (level);
 
721
}
 
722
 
 
723
 
 
724
double zaxisInqLbound(int zaxisID, int index)
 
725
{
 
726
  static const char *func = "zaxisInqLbound";
 
727
  double level = 0;
 
728
  ZAXIS *zaxisptr;
 
729
 
 
730
  zaxisptr = zaxis_to_pointer(zaxisID);
 
731
 
 
732
  zaxis_check_ptr(func, zaxisptr);
 
733
 
 
734
  if ( zaxisptr->lbounds )
 
735
    if ( index >= 0 && index < zaxisptr->size )
 
736
      level = zaxisptr->lbounds[index];
 
737
 
 
738
  return (level);
 
739
}
 
740
 
 
741
 
 
742
double zaxisInqUbound(int zaxisID, int index)
 
743
{
 
744
  static const char *func = "zaxisInqUbound";
 
745
  double level = 0;
 
746
  ZAXIS *zaxisptr;
 
747
 
 
748
  zaxisptr = zaxis_to_pointer(zaxisID);
 
749
 
 
750
  zaxis_check_ptr(func, zaxisptr);
 
751
 
 
752
  if ( zaxisptr->ubounds )
 
753
    if ( index >= 0 && index < zaxisptr->size )
 
754
      level = zaxisptr->ubounds[index];
 
755
 
 
756
  return (level);
 
757
}
 
758
 
 
759
 
 
760
const double *zaxisInqLevelsPtr(int zaxisID)
 
761
{
 
762
  ZAXIS *zaxisptr;
 
763
 
 
764
  zaxisptr = zaxis_to_pointer(zaxisID);
 
765
 
 
766
  return ( zaxisptr->vals );
 
767
}
 
768
 
 
769
 
 
770
/*
 
771
@Function  zaxisInqLevels
 
772
@Title     Get all levels of a Z-axis
 
773
 
 
774
@Prototype void zaxisInqLevels(int zaxisID, double *levels)
 
775
@Parameter
 
776
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate}
 
777
    @Item  levels   Levels of the Z-axis
 
778
    
 
779
@Description
 
780
The function @func{zaxisInqLevels} returns all levels of a Z-axis.
 
781
 
 
782
@Result
 
783
@func{zaxisInqLevels} saves all levels to the parameter @func{levels}.
 
784
@EndFunction
 
785
*/
 
786
void zaxisInqLevels(int zaxisID, double *levels)
 
787
{
 
788
  static const char *func = "zaxisInqLevels";
 
789
  int size;
 
790
  int i;
 
791
  ZAXIS *zaxisptr;
 
792
 
 
793
  zaxisptr = zaxis_to_pointer(zaxisID);
 
794
 
 
795
  zaxis_check_ptr(func, zaxisptr);
 
796
 
 
797
  size = zaxisptr->size;
 
798
  for ( i = 0; i < size; i++ )
 
799
    levels[i] =  zaxisptr->vals[i];
 
800
}
 
801
 
 
802
 
 
803
int zaxisInqLbounds(int zaxisID, double *lbounds)
 
804
{
 
805
  static const char *func = "zaxisInqLbounds";
 
806
  int size = 0;
 
807
  int i;
 
808
  ZAXIS *zaxisptr;
 
809
 
 
810
  zaxisptr = zaxis_to_pointer(zaxisID);
 
811
 
 
812
  zaxis_check_ptr(func, zaxisptr);
 
813
 
 
814
  if ( zaxisptr->lbounds )
 
815
    {
 
816
      size = zaxisptr->size;
 
817
 
 
818
      if ( lbounds )
 
819
        for ( i = 0; i < size; i++ )
 
820
          lbounds[i] =  zaxisptr->lbounds[i];
 
821
    }
 
822
 
 
823
  return (size);
 
824
}
 
825
 
 
826
 
 
827
int zaxisInqUbounds(int zaxisID, double *ubounds)
 
828
{
 
829
  static const char *func = "zaxisInqUbounds";
 
830
  int size = 0;
 
831
  int i;
 
832
  ZAXIS *zaxisptr;
 
833
 
 
834
  zaxisptr = zaxis_to_pointer(zaxisID);
 
835
 
 
836
  zaxis_check_ptr(func, zaxisptr);
 
837
 
 
838
  if ( zaxisptr->ubounds )
 
839
    {
 
840
      size = zaxisptr->size;
 
841
 
 
842
      if ( ubounds )
 
843
        for ( i = 0; i < size; i++ )
 
844
          ubounds[i] =  zaxisptr->ubounds[i];
 
845
    }
 
846
 
 
847
  return (size);
 
848
}
 
849
 
 
850
 
 
851
int zaxisInqWeights(int zaxisID, double *weights)
 
852
{
 
853
  static const char *func = "zaxisInqWeights";
 
854
  int size = 0;
 
855
  int i;
 
856
  ZAXIS *zaxisptr;
 
857
 
 
858
  zaxisptr = zaxis_to_pointer(zaxisID);
 
859
 
 
860
  zaxis_check_ptr(func, zaxisptr);
 
861
 
 
862
  if ( zaxisptr->weights )
 
863
    {
 
864
      size = zaxisptr->size;
 
865
 
 
866
      if ( weights )
 
867
        for ( i = 0; i < size; i++ )
 
868
          weights[i] =  zaxisptr->weights[i];
 
869
    }
 
870
 
 
871
  return (size);
 
872
}
 
873
 
 
874
 
 
875
int zaxisInqLevelID(int zaxisID, double level)
 
876
{
 
877
  static const char *func = "zaxisInqLevelID";
 
878
  int size;
 
879
  int levelID = CDI_UNDEFID;
 
880
  int i;
 
881
  ZAXIS *zaxisptr;
 
882
 
 
883
  zaxisptr = zaxis_to_pointer(zaxisID);
 
884
 
 
885
  zaxis_check_ptr(func, zaxisptr);
 
886
 
 
887
  size = zaxisptr->size;
 
888
  for ( i = 0; i < size; i++ )
 
889
    if ( fabs(level-zaxisptr->vals[i]) < DBL_EPSILON ) break;
 
890
 
 
891
  if ( i < size ) levelID = i;
 
892
 
 
893
  return (levelID);
 
894
}
 
895
 
 
896
 
 
897
/*
 
898
@Function  zaxisInqType
 
899
@Title     Get the type of a Z-axis
 
900
 
 
901
@Prototype int zaxisInqType(int zaxisID)
 
902
@Parameter
 
903
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate}
 
904
 
 
905
@Description
 
906
The function @func{zaxisInqType} returns the type of a Z-axis.
 
907
 
 
908
@Result
 
909
@func{zaxisInqType} returns the type of the Z-axis,
 
910
one of the set of predefined CDI Z-axis types.
 
911
The valid CDI Z-axis types are @func{ZAXIS_GENERIC}, @func{ZAXIS_SURFACE},
 
912
@func{ZAXIS_HYBRID}, @func{ZAXIS_SIGMA}, @func{ZAXIS_PRESSURE}, @func{ZAXIS_HEIGHT},
 
913
@func{ZAXIS_DEPTH_BELOW_SEA} and @func{ZAXIS_DEPTH_BELOW_LAND}.
 
914
 
 
915
@EndFunction
 
916
*/
 
917
int zaxisInqType(int zaxisID)
 
918
{
 
919
  static const char *func = "zaxisInqType";
 
920
  ZAXIS *zaxisptr;
 
921
 
 
922
  zaxisptr = zaxis_to_pointer(zaxisID);
 
923
 
 
924
  zaxis_check_ptr(func, zaxisptr);
 
925
 
 
926
  return (zaxisptr->type);
 
927
}
 
928
 
 
929
 
 
930
/*
 
931
@Function  zaxisInqSize
 
932
@Title     Get the size of a Z-axis
 
933
 
 
934
@Prototype int zaxisInqSize(int zaxisID)
 
935
@Parameter
 
936
    @Item  zaxisID  Z-axis ID, from a previous call to @fref{zaxisCreate}
 
937
 
 
938
@Description
 
939
The function @func{zaxisInqSize} returns the size of a Z-axis.
 
940
 
 
941
@Result
 
942
@func{zaxisInqSize} returns the number of levels of a Z-axis.
 
943
 
 
944
@EndFunction
 
945
*/
 
946
int zaxisInqSize(int zaxisID)
 
947
{
 
948
  static const char *func = "zaxisInqSize";
 
949
  int size = 1;
 
950
  ZAXIS *zaxisptr;
 
951
 
 
952
  zaxisptr = zaxis_to_pointer(zaxisID);
 
953
 
 
954
  zaxis_check_ptr(func, zaxisptr);
 
955
 
 
956
  size = zaxisptr->size;
 
957
 
 
958
  return (size);
 
959
}
 
960
 
 
961
 
 
962
void cdiCheckZaxis(int zaxisID)
 
963
{
 
964
  static const char *func = "cdiCheckZaxis";
 
965
  int size, i, found;
 
966
  ZAXIS *zaxisptr;
 
967
 
 
968
  zaxisptr = zaxis_to_pointer(zaxisID);
 
969
  
 
970
  zaxis_check_ptr(func, zaxisptr);
 
971
 
 
972
  if ( zaxisInqType(zaxisID) == ZAXIS_GENERIC )
 
973
    {
 
974
      size = zaxisptr->size;
 
975
      if ( size > 1 )
 
976
        {
 
977
          /* check direction */
 
978
          if ( zaxisptr->direction == CDI_UNDEFID )
 
979
            {
 
980
              found = 0;
 
981
              for ( i = 1; i < size; i++ )
 
982
                if ( zaxisptr->vals[i] > zaxisptr->vals[i-1] )
 
983
                  found++;
 
984
              if ( found == size-1 )
 
985
                {
 
986
                  zaxisptr->direction = LevelUp;
 
987
                }
 
988
              else
 
989
                {
 
990
                  found = 0;
 
991
                  for ( i = 1; i < size; i++ )
 
992
                    if ( zaxisptr->vals[i] < zaxisptr->vals[i-1] )
 
993
                      found++;
 
994
                  if ( found == size-1 )
 
995
                    {
 
996
                      zaxisptr->direction = LevelDown;
 
997
                    }
 
998
                }
 
999
            }
 
1000
          /* check consistent */
 
1001
          if ( zaxisptr->direction == CDI_UNDEFID )
 
1002
            {
 
1003
              Warning(func, "direction undefined for zaxisID %d", zaxisID);
 
1004
            }
 
1005
        }
 
1006
    }
 
1007
}
 
1008
 
 
1009
 
 
1010
void zaxisDefVct(int zaxisID, int size, const double *vct)
 
1011
{
 
1012
  static const char *func = "zaxisDefVct";
 
1013
  ZAXIS *zaxisptr;
 
1014
 
 
1015
  zaxisptr = zaxis_to_pointer(zaxisID);
 
1016
 
 
1017
  zaxis_check_ptr(func, zaxisptr);
 
1018
 
 
1019
  if ( zaxisptr->vct == 0 )
 
1020
    {
 
1021
      zaxisptr->vctsize = size;
 
1022
      zaxisptr->vct = (double *) malloc(size*sizeof(double));
 
1023
      memcpy(zaxisptr->vct, vct, size*sizeof(double));
 
1024
    }
 
1025
  else
 
1026
    if ( zaxisptr->vctsize != size )
 
1027
      Warning(func, "VCT was already defined");
 
1028
}
 
1029
 
 
1030
 
 
1031
int zaxisInqVctSize(int zaxisID)
 
1032
{
 
1033
  static const char *func = "zaxisInqVctSize";
 
1034
  ZAXIS *zaxisptr;
 
1035
 
 
1036
  zaxisptr = zaxis_to_pointer(zaxisID);
 
1037
 
 
1038
  zaxis_check_ptr(func, zaxisptr);
 
1039
 
 
1040
  return (zaxisptr->vctsize);
 
1041
}
 
1042
 
 
1043
 
 
1044
const double *zaxisInqVctPtr(int zaxisID)
 
1045
{
 
1046
  static const char *func = "zaxisInqVctPtr";
 
1047
  ZAXIS *zaxisptr;
 
1048
 
 
1049
  zaxisptr = zaxis_to_pointer(zaxisID);
 
1050
 
 
1051
  zaxis_check_ptr(func, zaxisptr);
 
1052
 
 
1053
  return (zaxisptr->vct);
 
1054
}
 
1055
 
 
1056
 
 
1057
void zaxisDefLbounds(int zaxisID, const double *lbounds)
 
1058
{
 
1059
  static const char *func = "zaxisDefLbounds";
 
1060
  size_t size;
 
1061
  ZAXIS *zaxisptr;
 
1062
 
 
1063
  zaxisptr = zaxis_to_pointer(zaxisID);
 
1064
 
 
1065
  zaxis_check_ptr(func, zaxisptr);
 
1066
 
 
1067
  size = zaxisptr->size;
 
1068
  
 
1069
  if ( CDI_Debug )
 
1070
    if ( zaxisptr->lbounds != NULL )
 
1071
      Warning(func, "Lower bounds already defined for zaxisID = %d", zaxisID);
 
1072
 
 
1073
  if ( zaxisptr->lbounds == NULL )
 
1074
    zaxisptr->lbounds = (double *) malloc(size*sizeof(double));
 
1075
 
 
1076
  memcpy(zaxisptr->lbounds, lbounds, size*sizeof(double));
 
1077
}
 
1078
 
 
1079
 
 
1080
void zaxisDefUbounds(int zaxisID, const double *ubounds)
 
1081
{
 
1082
  static const char *func = "zaxisDefUbounds";
 
1083
  size_t size;
 
1084
  ZAXIS *zaxisptr;
 
1085
 
 
1086
  zaxisptr = zaxis_to_pointer(zaxisID);
 
1087
 
 
1088
  zaxis_check_ptr(func, zaxisptr);
 
1089
 
 
1090
  size = zaxisptr->size;
 
1091
 
 
1092
  if ( CDI_Debug )
 
1093
    if ( zaxisptr->ubounds != NULL )
 
1094
      Warning(func, "Upper bounds already defined for zaxisID = %d", zaxisID);
 
1095
 
 
1096
  if ( zaxisptr->ubounds == NULL )
 
1097
    zaxisptr->ubounds = (double *) malloc(size*sizeof(double));
 
1098
 
 
1099
  memcpy(zaxisptr->ubounds, ubounds, size*sizeof(double));
 
1100
}
 
1101
 
 
1102
 
 
1103
void zaxisDefWeights(int zaxisID, const double *weights)
 
1104
{
 
1105
  static const char *func = "zaxisDefWeights";
 
1106
  size_t size;
 
1107
  ZAXIS *zaxisptr;
 
1108
 
 
1109
  zaxisptr = zaxis_to_pointer(zaxisID);
 
1110
 
 
1111
  zaxis_check_ptr(func, zaxisptr);
 
1112
 
 
1113
  size = zaxisptr->size;
 
1114
 
 
1115
  if ( CDI_Debug )
 
1116
    if ( zaxisptr->weights != NULL )
 
1117
      Warning(func, "Weights already defined for zaxisID = %d", zaxisID);
 
1118
 
 
1119
  if ( zaxisptr->weights == NULL )
 
1120
    zaxisptr->weights = (double *) malloc(size*sizeof(double));
 
1121
 
 
1122
  memcpy(zaxisptr->weights, weights, size*sizeof(double));
 
1123
}
 
1124
 
 
1125
 
 
1126
void zaxisChangeType(int zaxisID, int zaxistype)
 
1127
{
 
1128
  static const char *func = "zaxisChangeType";
 
1129
  ZAXIS *zaxisptr;
 
1130
 
 
1131
  zaxisptr = zaxis_to_pointer(zaxisID);
 
1132
 
 
1133
  zaxis_check_ptr(func, zaxisptr);
 
1134
 
 
1135
  Message(func, "Changed zaxis type from %s to %s\n",
 
1136
          zaxisNamePtr(zaxisptr->type),
 
1137
          zaxisNamePtr(zaxistype));
 
1138
  
 
1139
  zaxisptr->type = zaxistype;
 
1140
}
 
1141
 
 
1142
 
 
1143
void zaxisResize(int zaxisID, int size)
 
1144
{
 
1145
  static const char *func = "zaxisResize";
 
1146
  ZAXIS *zaxisptr;
 
1147
 
 
1148
  zaxisptr = zaxis_to_pointer(zaxisID);
 
1149
 
 
1150
  zaxis_check_ptr(func, zaxisptr);
 
1151
 
 
1152
  zaxisptr->size = size;
 
1153
 
 
1154
  if ( zaxisptr->vals )
 
1155
    zaxisptr->vals = (double *) realloc(zaxisptr->vals, size*sizeof(double));
 
1156
}
 
1157
 
 
1158
 
 
1159
int zaxisDuplicate(int zaxisID)
 
1160
{
 
1161
  static const char *func = "zaxisDuplicate";
 
1162
  int zaxisIDnew;
 
1163
  int zaxistype, zaxissize;
 
1164
  int size;
 
1165
  ZAXIS *zaxisptr, *zaxisptrnew;
 
1166
 
 
1167
  zaxisptr = zaxis_to_pointer(zaxisID);
 
1168
 
 
1169
  zaxistype = zaxisInqType(zaxisID);
 
1170
  zaxissize = zaxisInqSize(zaxisID);
 
1171
 
 
1172
  zaxisIDnew = zaxisCreate(zaxistype, zaxissize);
 
1173
  zaxisptrnew = zaxis_to_pointer(zaxisIDnew);
 
1174
 
 
1175
  zaxis_copy(zaxisptrnew, zaxisptr);
 
1176
 
 
1177
  strcpy(zaxisptrnew->name, zaxisptr->name);
 
1178
  strcpy(zaxisptrnew->longname, zaxisptr->longname);
 
1179
  strcpy(zaxisptrnew->units, zaxisptr->units);
 
1180
 
 
1181
  if ( zaxisptr->vals != NULL )
 
1182
    {
 
1183
      size = zaxissize;
 
1184
 
 
1185
      zaxisptrnew->vals = (double *) malloc(size*sizeof(double));
 
1186
      memcpy(zaxisptrnew->vals, zaxisptr->vals, size*sizeof(double));
 
1187
    }
 
1188
 
 
1189
  if ( zaxisptr->lbounds )
 
1190
    {
 
1191
      size = zaxissize;
 
1192
 
 
1193
      zaxisptrnew->lbounds = (double *) malloc(size*sizeof(double));
 
1194
      memcpy(zaxisptrnew->lbounds, zaxisptr->lbounds, size*sizeof(double));
 
1195
    }
 
1196
 
 
1197
  if ( zaxisptr->ubounds )
 
1198
    {
 
1199
      size = zaxissize;
 
1200
 
 
1201
      zaxisptrnew->ubounds = (double *) malloc(size*sizeof(double));
 
1202
      memcpy(zaxisptrnew->ubounds, zaxisptr->ubounds, size*sizeof(double));
 
1203
    }
 
1204
 
 
1205
  if ( zaxisptr->vct != NULL )
 
1206
    {
 
1207
      size = zaxisptr->vctsize;
 
1208
 
 
1209
      if ( size )
 
1210
        {
 
1211
          zaxisptrnew->vctsize = size;
 
1212
          zaxisptrnew->vct = (double *) malloc(size*sizeof(double));
 
1213
          memcpy(zaxisptrnew->vct, zaxisptr->vct, size*sizeof(double));
 
1214
        }
 
1215
    }
 
1216
 
 
1217
  return (zaxisIDnew);
 
1218
}
 
1219
 
 
1220
 
 
1221
void zaxisPrint(int zaxisID)
 
1222
{
 
1223
  FILE *fp = stdout;
 
1224
  int type;
 
1225
  int nlevels, levelID;
 
1226
  int nbyte0, nbyte;
 
1227
  double level;
 
1228
  ZAXIS *zaxisptr;
 
1229
 
 
1230
  zaxisptr = zaxis_to_pointer(zaxisID);
 
1231
 
 
1232
  type    = zaxisInqType(zaxisID);
 
1233
  nlevels = zaxisInqSize(zaxisID);
 
1234
 
 
1235
  nbyte0 = 0;
 
1236
  fprintf(fp, "#\n");
 
1237
  fprintf(fp, "# zaxisID %d\n", zaxisID);
 
1238
  fprintf(fp, "#\n");
 
1239
  fprintf(fp, "zaxistype = %s\n", zaxisNamePtr(type));
 
1240
  fprintf(fp, "size      = %d\n", nlevels);
 
1241
  if ( zaxisptr->name[0]     ) fprintf(fp, "name      = %s\n", zaxisptr->name);
 
1242
  if ( zaxisptr->longname[0] ) fprintf(fp, "longname  = %s\n", zaxisptr->longname);
 
1243
  if ( zaxisptr->units[0]    ) fprintf(fp, "units     = %s\n", zaxisptr->units);
 
1244
 
 
1245
  nbyte0 = fprintf(fp, "levels    = ");
 
1246
  nbyte = nbyte0;
 
1247
  for ( levelID = 0; levelID < nlevels; levelID++ )
 
1248
    {
 
1249
      if ( nbyte > 80 )
 
1250
        {
 
1251
          fprintf(stdout, "\n");
 
1252
          fprintf(stdout, "%*s", nbyte0, "");
 
1253
          nbyte = nbyte0;
 
1254
        }
 
1255
      level = zaxisInqLevel(zaxisID, levelID);
 
1256
      nbyte += fprintf(stdout, "%.9g ", level);
 
1257
    }
 
1258
  fprintf(stdout, "\n");
 
1259
 
 
1260
  if ( zaxisptr->lbounds && zaxisptr->ubounds )
 
1261
    {
 
1262
      double level1, level2;
 
1263
      nbyte = nbyte0;
 
1264
      nbyte0 = fprintf(stdout, "%32s = ", "bounds");
 
1265
      for ( levelID = 0; levelID < nlevels; levelID++ )
 
1266
        {
 
1267
          if ( nbyte > 80 )
 
1268
            {
 
1269
              fprintf(stdout, "\n");
 
1270
              fprintf(stdout, "%*s", nbyte0, "");
 
1271
              nbyte = nbyte0;
 
1272
            }
 
1273
          level1 = zaxisInqLbound(zaxisID, levelID);
 
1274
          level2 = zaxisInqUbound(zaxisID, levelID);
 
1275
          nbyte += fprintf(stdout, "%.9g-%.9g ", level1, level2);
 
1276
        }
 
1277
      fprintf(stdout, "\n");
 
1278
    }
 
1279
 
 
1280
  if ( type == ZAXIS_HYBRID || type == ZAXIS_HYBRID_HALF )
 
1281
    {
 
1282
      int i;
 
1283
      int vctsize;
 
1284
      const double *vct;
 
1285
 
 
1286
      vctsize = zaxisInqVctSize(zaxisID);
 
1287
      vct     = zaxisInqVctPtr(zaxisID);
 
1288
      fprintf(stdout, "vctsize   = %d\n", vctsize);
 
1289
      if ( vctsize )
 
1290
        {
 
1291
          nbyte0 = fprintf(stdout, "vct       = ");
 
1292
          nbyte = nbyte0;
 
1293
          for ( i = 0; i < vctsize; i++ )
 
1294
            {
 
1295
              if ( nbyte > 70 || i == vctsize/2 )
 
1296
                {
 
1297
                  fprintf(stdout, "\n%*s", nbyte0, "");
 
1298
                  nbyte = nbyte0;
 
1299
                }
 
1300
              nbyte += fprintf(stdout, "%.9g ", vct[i]);
 
1301
            }
 
1302
          fprintf(stdout, "\n");
 
1303
          /*
 
1304
          nbyte0 = fprintf(stdout, "vct_b     = ");
 
1305
          nbyte  = nbyte0;
 
1306
          for ( i = 0; i < vctsize/2; i++ )
 
1307
            {
 
1308
              if ( nbyte > 70 )
 
1309
                {
 
1310
                  fprintf(stdout, "\n%*s", nbyte0, "");
 
1311
                  nbyte = nbyte0;
 
1312
                }
 
1313
              nbyte += fprintf(stdout, "%.9g ", vct[vctsize/2+i]);
 
1314
            }
 
1315
          fprintf(stdout, "\n");
 
1316
          */
 
1317
        }
 
1318
    }
 
1319
}