vlist_att.c 15.9 KB
Newer Older
1
2
3
4
#ifdef HAVE_CONFIG_H
#  include "config.h"
#endif

5
6
7
8
#include <stdio.h>
#include <string.h>
#include <assert.h>

9
10
11
12
#ifdef USE_MPI
#include <mpi.h>
#endif

13
14
15
16
17
#include "dmemory.h"

#include "cdi.h"
#include "stream_int.h"
#include "vlist.h"
18
#include "pio_util.h"
19
20


Uwe Schulzweida's avatar
Uwe Schulzweida committed
21
static
Uwe Schulzweida's avatar
Uwe Schulzweida committed
22
cdi_atts_t *get_attsp(vlist_t *vlistptr, int varID)
23
{
Uwe Schulzweida's avatar
Uwe Schulzweida committed
24
  cdi_atts_t *attsp = NULL;
25
26
27
28
29
30
31

  if ( varID == CDI_GLOBAL )
    {
      attsp = &vlistptr->atts;
    }
  else
    {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
32
33
      if ( varID >= 0 && varID < vlistptr->nvars )
	attsp = &(vlistptr->vars[varID].atts);
34
35
36
37
38
    }

  return (attsp);
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
39
static
Uwe Schulzweida's avatar
Uwe Schulzweida committed
40
cdi_att_t *find_att(cdi_atts_t *attsp, const char *name)
41
{
Uwe Schulzweida's avatar
Uwe Schulzweida committed
42
  cdi_att_t *attp;
43
  size_t attid;
44
45
46
47
48
49
50
51
  size_t slen;

  assert(attsp != NULL);

  if ( attsp->nelems == 0 ) return NULL;

  slen = strlen(name);

52
  for ( attid = 0; attid < attsp->nelems; attid++ )
53
    {
54
55
      attp = &(attsp->value[attid]);
      if ( attp->namesz == slen )
56
	if ( memcmp(attp->name, name, slen) == 0)
57
	  {
58
	    return (attp); /* Normal return */
59
60
61
62
63
64
	  }
    }

  return (NULL);
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
65
static
Uwe Schulzweida's avatar
Uwe Schulzweida committed
66
cdi_att_t *new_att(cdi_atts_t *attsp, const char *name)
67
{
Uwe Schulzweida's avatar
Uwe Schulzweida committed
68
  cdi_att_t *attp;
69
70
71
72
73
74
75
  size_t slen;

  assert(attsp != NULL);
  assert(name  != NULL);

  if ( attsp->nelems == attsp->nalloc ) return (NULL);

76
  attp = &(attsp->value[attsp->nelems]);
77
78
79
80
  attsp->nelems++;

  slen = strlen(name);

81
82
83
  attp->name = (char *) malloc(slen+1);
  memcpy(attp->name, name, slen+1);
  attp->namesz = slen;
84
  attp->xvalue = NULL;
85

86
  return (attp);
87
88
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
89
static
90
void fill_att(cdi_att_t *attp, int indtype, int exdtype, size_t nelems, size_t xsz, const void *xvalue)
91
{
92
  assert(attp != NULL);
93

94
  attp->xsz = xsz;
95
96
97
  attp->indtype = indtype;
  attp->exdtype = exdtype;
  attp->nelems  = nelems;
98

99
100
  if ( xsz > 0 )
    {
101
      attp->xvalue = xrealloc(attp->xvalue, xsz);
102
103
      memcpy(attp->xvalue, xvalue, xsz);
    }
104
105
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
@Function  vlistInqNatts
@Title     Get number of variable attributes

@Prototype int vlistInqNatts(int vlistID, int varID, int *nattsp)
@Parameter
    @Item  vlistID  Variable list ID, from a previous call to @fref{vlistCreate}
    @Item  varID    Variable identifier, or CDI_GLOBAL for a global attribute
    @Item  nattsp   Pointer to location for returned number of variable attributes

@Description
The function @func{vlistInqNatts} gets the number of variable attributes assigned to this variable.

@EndFunction
*/
121
122
123
int vlistInqNatts(int vlistID, int varID, int *nattsp)
{
  int status = CDI_NOERR;
124
  vlist_t *vlistptr;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
125
  cdi_atts_t *attsp;
126
127
128
129

  vlistptr = vlist_to_pointer(vlistID);
  
  attsp = get_attsp(vlistptr, varID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
130
  assert(attsp != NULL);
131
132
133
134
135
136

  *nattsp = attsp->nelems;

  return (status);
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
@Function  vlistInqAtt
@Title     Get information about an attribute

@Prototype int vlistInqAtt(int vlistID, int varID, int attnum, char *name, int *typep, int *lenp)
@Parameter
    @Item  vlistID  Variable list ID, from a previous call to @fref{vlistCreate}
    @Item  varID    Variable identifier, or CDI_GLOBAL for a global attribute
    @Item  attnum   Attribute number (from 0 to natts-1)
    @Item  name     Pointer to the location for the returned attribute name
    @Item  typep    Pointer to location for returned attribute type
    @Item  lenp     Pointer to location for returned attribute number

@Description
151
The function @func{vlistInqAtt} gets information about an attribute.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
152
153
154

@EndFunction
*/
155
int vlistInqAtt(int vlistID, int varID, int attnum, char *name, int *typep, int *lenp)
156
157
{
  int status = CDI_NOERR;
158
  vlist_t *vlistptr;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
159
160
  cdi_att_t *attp = NULL;
  cdi_atts_t *attsp;
161
162
163
164
165
166

  assert(name != NULL);

  vlistptr = vlist_to_pointer(vlistID);

  attsp = get_attsp(vlistptr, varID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
167
  assert(attsp != NULL);
168

169
170
  if ( attnum >= 0 && attnum < (int)attsp->nelems )
    attp = &(attsp->value[attnum]);
171

172
  if ( attp != NULL ) /* name in use */
173
    {
174
      memcpy(name, attp->name, attp->namesz+1);
175
      *typep  = attp->exdtype;
176
      *lenp   = attp->nelems;
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
    }
  else
    {
      name[0] =  0;
      *typep  = -1;
      *lenp   =  0;
    }

  return (status);
}


int vlistDelAtts(int vlistID, int varID)
{
  int status = CDI_NOERR;
192
  vlist_t *vlistptr;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
193
194
  cdi_att_t *attp = NULL;
  cdi_atts_t *attsp;
195
  int attid;
196
197
198
199

  vlistptr = vlist_to_pointer(vlistID);

  attsp = get_attsp(vlistptr, varID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
200
  assert(attsp != NULL);
201

202
  for ( attid = 0; attid < (int)attsp->nelems; attid++ )
203
    {
204
205
206
      attp = &(attsp->value[attid]);
      if ( attp->name   ) free(attp->name);
      if ( attp->xvalue ) free(attp->xvalue);
207
208
209
210
211
212
213
214
    }

  attsp->nelems = 0;

  return (status);
}


215
int vlistDelAtt(int vlistID, int varID, const char *name)
216
217
218
{
  int status = CDI_NOERR;

219
  fprintf(stderr, "vlistDelAtt not implemented!\n");
220
221
222
223

  return (status);
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
224
static
225
int vlist_def_att(int indtype, int exdtype, int vlistID, int varID, const char *name, size_t len, size_t xsz, const void *xp)
226
227
{
  int status = CDI_NOERR;
228
  vlist_t *vlistptr;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
229
230
  cdi_att_t *attp;
  cdi_atts_t *attsp;
231
232
233
234
235
236
237
238
239

  if ( len != 0 && xp == NULL ) /* Null arg */
    {
      return (CDI_EINVAL);
    }

  vlistptr = vlist_to_pointer(vlistID);

  attsp = get_attsp(vlistptr, varID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
240
  assert(attsp != NULL);
241

242
  attp = find_att(attsp, name);
243
244
  if ( attp == NULL )
    attp = new_att(attsp, name);
245

246
  if ( attp != NULL )
247
    fill_att(attp, indtype, exdtype, len, xsz, xp);
248
  
249
250
251
  return (status);
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
252
static
253
int vlist_inq_att(int indtype, int vlistID, int varID, const char *name, size_t mxsz, void *xp)
254
255
{
  int status = CDI_NOERR;
256
  vlist_t *vlistptr;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
257
258
  cdi_att_t *attp;
  cdi_atts_t *attsp;
259
260
261
262
263
264
265
266
267
268
  size_t xsz;

  if ( mxsz != 0 && xp == NULL ) /* Null arg */
    {
      return (CDI_EINVAL);
    }

  vlistptr = vlist_to_pointer(vlistID);

  attsp = get_attsp(vlistptr, varID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
269
  assert(attsp != NULL);
270

271
272
  attp = find_att(attsp, name);
  if ( attp != NULL ) /* name in use */
273
    {
274
275
276
277
278
279
280
281
282
283
284
      if ( attp->indtype == indtype )
	{
	  xsz = attp->xsz;
	  if ( mxsz < xsz ) xsz = mxsz;
	  if ( xsz > 0 )
	    memcpy(xp, attp->xvalue, xsz);
	}
      else
	{
	  Warning("Attribute %s has wrong data type!", name);
	}
285
286
287
    }
  else
    {
288
      Warning("Internal problem, attribute %s not found!", name);
289
290
291
292
293
294
295
296
297
    }

  return (status);
}


int vlistCopyVarAtts(int vlistID1, int varID_1, int vlistID2, int varID_2)
{
  int status = CDI_NOERR;
298
  vlist_t *vlistptr1;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
299
300
  cdi_att_t *attp = NULL;
  cdi_atts_t *attsp1;
301
  int attid;
302
303
304
305

  vlistptr1 = vlist_to_pointer(vlistID1);

  attsp1 = get_attsp(vlistptr1, varID_1);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
306
  assert(attsp1 != NULL);
307

308
  for ( attid = 0; attid < (int)attsp1->nelems; attid++ )
309
    {
310
      attp = &(attsp1->value[attid]);
311
      vlist_def_att(attp->indtype, attp->exdtype, vlistID2, varID_2, attp->name, attp->nelems, attp->xsz, attp->xvalue);
312
313
314
315
316
    }

  return (status);
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
317
318
319
320
/*
@Function  vlistDefAttInt
@Title     Define an integer attribute

321
@Prototype int vlistDefAttInt(int vlistID, int varID, const char *name, int type, int len, const int *ip)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
322
323
324
325
326

@Parameter
    @Item  vlistID  Variable list ID, from a previous call to @fref{vlistCreate}
    @Item  varID    Variable identifier, or CDI_GLOBAL for a global attribute
    @Item  name     Attribute name
327
    @Item  type     External data type (DATATYPE_INT16 or DATATYPE_INT32)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
328
329
330
331
332
333
334
335
    @Item  len      Number of values provided for the attribute
    @Item  ip       Pointer to one or more integer values

@Description
The function @func{vlistDefAttInt} defines an integer attribute.

@EndFunction
*/
336
int vlistDefAttInt(int vlistID, int varID, const char *name, int type, int len, const int *ip)
337
338
339
{
  int status;

340
  status = vlist_def_att(DATATYPE_INT, type, vlistID, varID, name, (size_t) len, len*sizeof(int), (const void *) ip);
341
342
343
344

  return (status);
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
345
346
347
348
/*
@Function  vlistDefAttFlt
@Title     Define a floating point attribute

349
@Prototype int vlistDefAttFlt(int vlistID, int varID, const char *name, int type, int len, const double *dp)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
350
351
352
353
354

@Parameter
    @Item  vlistID  Variable list ID, from a previous call to @fref{vlistCreate}
    @Item  varID    Variable identifier, or CDI_GLOBAL for a global attribute
    @Item  name     Attribute name
355
    @Item  type     External data type (DATATYPE_FLT32 or DATATYPE_FLT64)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
356
357
358
359
360
361
362
363
    @Item  len      Number of values provided for the attribute
    @Item  dp       Pointer to one or more floating point values

@Description
The function @func{vlistDefAttFlt} defines a floating point attribute.

@EndFunction
*/
364
int vlistDefAttFlt(int vlistID, int varID, const char *name, int type, int len, const double *dp)
365
366
367
{
  int status;

368
  status = vlist_def_att(DATATYPE_FLT, type, vlistID, varID, name, (size_t) len, len*sizeof(double), (const void *) dp);
369
370
371
372

  return (status);
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
/*
@Function  vlistDefAttTxt
@Title     Define a text attribute

@Prototype int vlistDefAttTxt(int vlistID, int varID, const char *name, int len, const char *tp)

@Parameter
    @Item  vlistID  Variable list ID, from a previous call to @fref{vlistCreate}
    @Item  varID    Variable identifier, or CDI_GLOBAL for a global attribute
    @Item  name     Attribute name
    @Item  len      Number of values provided for the attribute
    @Item  tp       Pointer to one or more character values

@Description
The function @func{vlistDefAttTxt} defines a text attribute.

@EndFunction
*/
391
int vlistDefAttTxt(int vlistID, int varID, const char *name, int len, const char *tp)
392
393
394
{
  int status;

395
  status = vlist_def_att(DATATYPE_TXT, DATATYPE_TXT, vlistID, varID, name, (size_t) len, len*sizeof(char), (const void *) tp);
396
397
398
399

  return (status);
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
400
401
402
403
404
405
406
407
408
409
410
/*
@Function  vlistInqAttInt
@Title     Get the value(s) of an integer attribute

@Prototype int vlistInqAttInt(int vlistID, int varID, const char *name, int mlen, int *ip)
@Parameter
    @Item  vlistID  Variable list ID, from a previous call to @fref{vlistCreate}
    @Item  varID    Variable identifier, or CDI_GLOBAL for a global attribute
    @Item  name     Attribute name
    @Item  mlen     Number of allocated values provided for the attribute
    @Item  ip       Pointer location for returned integer attribute value(s)
411

Uwe Schulzweida's avatar
Uwe Schulzweida committed
412
413
414
415
416
@Description
The function @func{vlistInqAttInt} gets the values(s) of an integer attribute.

@EndFunction
*/
417
int vlistInqAttInt(int vlistID, int varID, const char *name, int mlen, int *ip)
418
419
420
{
  int status = CDI_NOERR;

421
  status = vlist_inq_att(DATATYPE_INT, vlistID, varID, name, mlen*sizeof(int), (void *) ip);
422
423
424
425

  return (CDI_NOERR);
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
/*
@Function  vlistInqAttFlt
@Title     Get the value(s) of a floating point attribute

@Prototype int vlistInqAttFlt(int vlistID, int varID, const char *name, int mlen, int *dp)
@Parameter
    @Item  vlistID  Variable list ID, from a previous call to @fref{vlistCreate}
    @Item  varID    Variable identifier, or CDI_GLOBAL for a global attribute
    @Item  name     Attribute name
    @Item  mlen     Number of allocated values provided for the attribute
    @Item  dp       Pointer location for returned floating point attribute value(s)

@Description
The function @func{vlistInqAttFlt} gets the values(s) of a floating point attribute.

@EndFunction
*/
443
int vlistInqAttFlt(int vlistID, int varID, const char *name, int mlen, double *dp)
444
445
446
{
  int status = CDI_NOERR;

447
  status = vlist_inq_att(DATATYPE_FLT, vlistID, varID, name, mlen*sizeof(double), (void *) dp);
448
449
450
451

  return (status);
}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
/*
@Function  vlistInqAttTxt
@Title     Get the value(s) of a text attribute

@Prototype int vlistInqAttTxt(int vlistID, int varID, const char *name, int mlen, int *tp)
@Parameter
    @Item  vlistID  Variable list ID, from a previous call to @fref{vlistCreate}
    @Item  varID    Variable identifier, or CDI_GLOBAL for a global attribute
    @Item  name     Attribute name
    @Item  mlen     Number of allocated values provided for the attribute
    @Item  tp       Pointer location for returned text attribute value(s)

@Description
The function @func{vlistInqAttTxt} gets the values(s) of a text attribute.

@EndFunction
*/
469
int vlistInqAttTxt(int vlistID, int varID, const char *name, int mlen, char *tp)
470
471
472
{
  int status = CDI_NOERR;

473
  status = vlist_inq_att(DATATYPE_TXT, vlistID, varID, name, mlen*sizeof(char), (void *) tp);
474
475
476

  return (status);
}
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640


#ifdef USE_MPI

enum {
  vlist_att_nints = 4,          /* namesz, exdtype, indtype, nelems */
};

static int
vlistAttGetSize(vlist_t *vlistptr, int varID, int attnum, MPI_Comm comm)
{
  int txsize = 0, txinc;
  cdi_atts_t *attsp;
  cdi_att_t *attp;

  assert(attsp = get_attsp(vlistptr, varID));
  assert(attnum >= 0 && attnum < (int)attsp->nelems);
  attp = &(attsp->value[attnum]);
  xmpi(MPI_Pack_size(vlist_att_nints, MPI_INT, comm, &txsize));
  xmpi(MPI_Pack_size(attp->namesz, MPI_CHAR, comm, &txinc));
  txsize += txinc;
  switch (attp->exdtype)
  {
  case DATATYPE_FLT:
    xmpi(MPI_Pack_size((int)attp->nelems, MPI_DOUBLE, comm, &txinc));
    break;
  case DATATYPE_INT:
    xmpi(MPI_Pack_size((int)attp->nelems, MPI_INT, comm, &txinc));
    break;
  case DATATYPE_TXT:
    xmpi(MPI_Pack_size((int)attp->nelems, MPI_CHAR, comm, &txinc));
    break;
  default:
    fprintf(stderr, "Unknown datatype encountered in attribute %s: %d\n",
            attp->name, attp->exdtype);
    xabort("");
  }
  txsize += txinc;
  return txsize;
}

int
vlistAttsGetSize(vlist_t *p, int varID, MPI_Comm comm)
{
  int numAtts, i;
  int txsize;
  cdi_atts_t *attsp = get_attsp(p, varID);
  numAtts = attsp->nelems;
  xmpi(MPI_Pack_size(1, MPI_INT, comm, &txsize));
  for (i = 0; i < numAtts; ++i)
  {
    txsize += vlistAttGetSize(p, varID, i, comm);
  }
  return txsize;
}

static int
vlistAttPack(vlist_t *vlistptr, int varID, int attnum,
             void * buf, int size, int *position, MPI_Comm comm)
{
  cdi_atts_t *attsp;
  cdi_att_t *attp;
  int tempbuf[vlist_att_nints];
  MPI_Datatype attVMPIDt;

  assert(attsp = get_attsp(vlistptr, varID));
  assert(attnum >= 0 && attnum < (int)attsp->nelems);
  attp = &(attsp->value[attnum]);
  tempbuf[0] = attp->namesz;
  tempbuf[1] = attp->exdtype;
  tempbuf[2] = attp->indtype;
  tempbuf[3] = attp->nelems;
  xmpi(MPI_Pack(tempbuf, vlist_att_nints, MPI_INT, buf, size, position, comm));
  xmpi(MPI_Pack(attp->name, attp->namesz, MPI_CHAR, buf, size, position, comm));
  switch (attp->indtype)
  {
  case DATATYPE_FLT:
    attVMPIDt = MPI_DOUBLE;
    break;
  case DATATYPE_INT:
    attVMPIDt = MPI_INT;
    break;
  case DATATYPE_TXT:
    attVMPIDt = MPI_CHAR;
    break;
  default:
    fprintf(stderr, "Unknown datatype encountered in attribute %s: %d\n",
            attp->name, attp->indtype);
    xabort("");
  }
  xmpi(MPI_Pack(attp->xvalue, (int)attp->nelems, attVMPIDt,
                buf, size, position, comm));
}

void
vlistAttsPack(vlist_t *p, int varID,
              void * buf, int size, int *position, MPI_Comm comm)
{
  int numAtts, i;
  cdi_atts_t *attsp = get_attsp(p, varID);
  numAtts = attsp->nelems;
  xmpi(MPI_Pack(&numAtts, 1, MPI_INT, buf, size, position, comm));
  for (i = 0; i < numAtts; ++i)
  {
    vlistAttPack(p, varID, i, buf, size, position, comm);
  }
}

static int
vlistAttUnpack(int vlistID, int varID,
               void * buf, int size, int *position, MPI_Comm comm)
{
  char *attName;
  int tempbuf[vlist_att_nints];
  MPI_Datatype attVMPIDt;
  int elemSize;
  void *attData;

  xmpi(MPI_Unpack(buf, size, position,
                  tempbuf, vlist_att_nints, MPI_INT, comm));
  attName = xmalloc(tempbuf[0] + 1);
  xmpi(MPI_Unpack(buf, size, position, attName, tempbuf[0], MPI_CHAR, comm));
  switch (tempbuf[2])
  {
  case DATATYPE_FLT:
    attVMPIDt = MPI_DOUBLE;
    elemSize = sizeof(double);
    break;
  case DATATYPE_INT:
    attVMPIDt = MPI_INT;
    elemSize = sizeof(int);
    break;
  case DATATYPE_TXT:
    attVMPIDt = MPI_CHAR;
    elemSize = 1;
    break;
  default:
    fprintf(stderr, "Unknown datatype encountered in attribute %s: %d\n",
            attName, tempbuf[2]);
    xabort("");
  }
  attData = xmalloc(elemSize * tempbuf[3]);
  xmpi(MPI_Unpack(buf, size, position, attData, tempbuf[3], attVMPIDt, comm));
  vlist_def_att(tempbuf[2], tempbuf[1], vlistID, varID, attName,
                tempbuf[3], tempbuf[3] * elemSize, attData);
  free(attName);
  free(attData);
}

void
vlistAttsUnpack(int vlistID, int varID,
              void * buf, int size, int *position, MPI_Comm comm)
{
  int numAtts, i;
  xmpi(MPI_Unpack(buf, size, position, &numAtts, 1, MPI_INT, comm));
  for (i = 0; i < numAtts; ++i)
  {
    vlistAttUnpack(vlistID, varID, buf, size, position, comm);
  }
}



#endif