~ubuntu-branches/ubuntu/utopic/adios/utopic

« back to all changes in this revision

Viewing changes to src/common_adios.c

  • Committer: Package Import Robot
  • Author(s): Alastair McKinstry
  • Date: 2013-12-09 15:21:31 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20131209152131-jtd4fpmdv3xnunnm
Tags: 1.5.0-1
* New upstream.
* Standards-Version: 3.9.5
* Include latest config.{sub,guess} 
* New watch file.
* Create libadios-bin for binaries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* 
2
 
 * ADIOS is freely available under the terms of the BSD license described
3
 
 * in the COPYING file in the top level directory of this source distribution.
4
 
 *
5
 
 * Copyright (c) 2008 - 2009.  UT-BATTELLE, LLC. All rights reserved.
6
 
 */
7
 
 
8
 
#include <stdlib.h>
9
 
#include <math.h>
10
 
#include <string.h>
11
 
#include <unistd.h>
12
 
#include <stdint.h>
13
 
 
14
 
// xml parser
15
 
#include <mxml.h>
16
 
 
17
 
#include "common_adios.h"
18
 
#include "adios_transport_hooks.h"
19
 
#include "adios_bp_v1.h"
20
 
#include "adios_internals.h"
21
 
#include "adios_internals_mxml.h"
22
 
#include "buffer.h"
23
 
 
24
 
#ifdef DMALLOC
25
 
#include "dmalloc.h"
26
 
#endif
27
 
 
28
 
extern struct adios_transport_struct * adios_transports;
29
 
 
30
 
///////////////////////////////////////////////////////////////////////////////
31
 
int common_adios_init (const char * config)
32
 
{
33
 
    // parse the config file
34
 
    return adios_parse_config (config);
35
 
}
36
 
 
37
 
///////////////////////////////////////////////////////////////////////////////
38
 
// all XML file pieces will be provided by another series of calls
39
 
int common_adios_init_noxml ()
40
 
{
41
 
    return adios_local_config ();
42
 
}
43
 
 
44
 
///////////////////////////////////////////////////////////////////////////////
45
 
int common_adios_finalize (int mype)
46
 
{
47
 
    struct adios_method_list_struct * m;
48
 
 
49
 
    for (m = adios_get_methods (); m; m = m->next)
50
 
    {
51
 
        if (   m->method->m != ADIOS_METHOD_UNKNOWN
52
 
            && m->method->m != ADIOS_METHOD_NULL
53
 
            && adios_transports [m->method->m].adios_finalize_fn
54
 
           )
55
 
        {
56
 
            adios_transports [m->method->m].adios_finalize_fn (mype, m->method);
57
 
        }
58
 
    }
59
 
 
60
 
    adios_cleanup ();
61
 
 
62
 
    return 0;
63
 
}
64
 
 
65
 
///////////////////////////////////////////////////////////////////////////////
66
 
int common_adios_allocate_buffer (enum ADIOS_BUFFER_ALLOC_WHEN adios_buffer_alloc_when
67
 
                                 ,uint64_t buffer_size)
68
 
{
69
 
    adios_buffer_size_requested_set (buffer_size * 1024 * 1024);
70
 
    adios_buffer_alloc_when_set (adios_buffer_alloc_when);
71
 
 
72
 
    return adios_set_buffer_size ();
73
 
}
74
 
 
75
 
///////////////////////////////////////////////////////////////////////////////
76
 
int common_adios_open (int64_t * fd, const char * group_name
77
 
                ,const char * name, const char * file_mode, void * comm
78
 
               )
79
 
{
80
 
    int64_t group_id = 0;
81
 
    struct adios_file_struct * fd_p = (struct adios_file_struct *)
82
 
                                  malloc (sizeof (struct adios_file_struct));
83
 
    struct adios_group_struct * g = 0;
84
 
    struct adios_method_list_struct * methods = 0;
85
 
    enum ADIOS_METHOD_MODE mode;
86
 
 
87
 
    adios_common_get_group (&group_id, group_name);
88
 
    g = (struct adios_group_struct *) group_id;
89
 
    methods = g->methods;
90
 
 
91
 
    if (!strcasecmp (file_mode, "r"))
92
 
        mode = adios_mode_read;
93
 
    else
94
 
        if (!strcasecmp (file_mode, "w"))
95
 
            mode = adios_mode_write;
96
 
        else
97
 
            if (!strcasecmp (file_mode, "a"))
98
 
                mode = adios_mode_append;
99
 
            else
100
 
                if (!strcasecmp (file_mode, "u"))
101
 
                    mode = adios_mode_update;
102
 
                else
103
 
                {
104
 
                    fprintf (stderr, "adios_open: unknown file mode: %s\n"
105
 
                            ,file_mode
106
 
                            );
107
 
 
108
 
                    *fd = 0;
109
 
 
110
 
                    return 1;
111
 
                }
112
 
 
113
 
    fd_p->name = strdup (name);
114
 
    fd_p->subfile_index = -1; // subfile index is by default -1
115
 
    fd_p->group = g;
116
 
    fd_p->mode = mode;
117
 
    fd_p->data_size = 0;
118
 
    fd_p->buffer = 0;
119
 
    fd_p->offset = 0;
120
 
    fd_p->bytes_written = 0;
121
 
    fd_p->buffer_size = 0;
122
 
    fd_p->vars_start = 0;
123
 
    fd_p->vars_written = 0;
124
 
    fd_p->write_size_bytes = 0;
125
 
    fd_p->base_offset = 0;
126
 
    fd_p->pg_start_in_file = 0;
127
 
 
128
 
    if (mode != adios_mode_read)
129
 
        g->time_index++;
130
 
 
131
 
    while (methods)
132
 
    {
133
 
        if (   methods->method->m != ADIOS_METHOD_UNKNOWN
134
 
            && methods->method->m != ADIOS_METHOD_NULL
135
 
            && adios_transports [methods->method->m].adios_open_fn
136
 
           )
137
 
        {
138
 
            adios_transports [methods->method->m].adios_open_fn
139
 
                                                 (fd_p, methods->method, comm);
140
 
        }
141
 
 
142
 
        methods = methods->next;
143
 
    }
144
 
 
145
 
    *fd = (int64_t) fd_p;
146
 
 
147
 
    return 0;
148
 
}
149
 
 
150
 
///////////////////////////////////////////////////////////////////////////////
151
 
int common_adios_group_size (int64_t fd_p
152
 
                     ,uint64_t data_size
153
 
                     ,uint64_t * total_size
154
 
                     )
155
 
{
156
 
    struct adios_file_struct * fd = (struct adios_file_struct *) fd_p;
157
 
    if (!fd)
158
 
    {
159
 
        fprintf (stderr, "Invalid handle passed to adios_group_size\n");
160
 
 
161
 
        return 1;
162
 
    }
163
 
    struct adios_method_list_struct * m = fd->group->methods;
164
 
    if (m && m->next == NULL && m->method->m == ADIOS_METHOD_NULL)
165
 
    {
166
 
        // nothing to do so just return
167
 
        fd->shared_buffer = adios_flag_no;
168
 
        fd->write_size_bytes = 0;
169
 
        fd->buffer = 0;
170
 
        *total_size = 0;
171
 
        return 0;
172
 
    }
173
 
 
174
 
    fd->write_size_bytes = data_size;
175
 
 
176
 
    uint64_t overhead = adios_calc_overhead_v1 (fd);
177
 
 
178
 
    *total_size = data_size + overhead;
179
 
 
180
 
    // try to reserve a buffer using the adios_method_buffer_alloc
181
 
    // if it does not give the correct amount, overflow.  Make sure
182
 
    // the amount given is big enough for the first part of the file.
183
 
 
184
 
    fd->write_size_bytes += overhead;
185
 
 
186
 
    uint64_t allocated = adios_method_buffer_alloc (fd->write_size_bytes);
187
 
    if (allocated != fd->write_size_bytes)
188
 
    {
189
 
        fd->shared_buffer = adios_flag_no;
190
 
 
191
 
        fprintf (stderr, "adios_group_size (%s): Not buffering. "
192
 
                         "needs: %llu available: %llu.\n"
193
 
                ,fd->group->name, fd->write_size_bytes, allocated
194
 
                );
195
 
    }
196
 
    else
197
 
    {
198
 
        fd->shared_buffer = adios_flag_yes;
199
 
    }
200
 
 
201
 
    // call each transport method to coordinate the write and handle
202
 
    // if an overflow is detected.
203
 
    // now tell each transport attached that it is being written
204
 
    while (m)
205
 
    {
206
 
        enum ADIOS_FLAG should_buffer = adios_flag_yes;
207
 
        if (   m->method->m != ADIOS_METHOD_UNKNOWN
208
 
            && m->method->m != ADIOS_METHOD_NULL
209
 
            && adios_transports [m->method->m].adios_should_buffer_fn
210
 
           )
211
 
        {
212
 
            should_buffer = adios_transports [m->method->m].
213
 
                                            adios_should_buffer_fn (fd
214
 
                                                                   ,m->method
215
 
                                                                   );
216
 
        }
217
 
 
218
 
        if (should_buffer == adios_flag_no)     // can't write directly since
219
 
            fd->shared_buffer = adios_flag_no;  // some might want to share
220
 
 
221
 
        m = m->next;
222
 
    }
223
 
 
224
 
    if (fd->shared_buffer == adios_flag_no)
225
 
    {
226
 
        adios_method_buffer_free (allocated);
227
 
        fd->buffer = 0;
228
 
        fd->offset = 0;
229
 
        fd->bytes_written = 0;
230
 
    }
231
 
    else
232
 
    {
233
 
        fd->buffer = malloc (fd->write_size_bytes);
234
 
        fd->buffer_size = fd->write_size_bytes;
235
 
        fd->offset = 0;
236
 
        fd->bytes_written = 0;
237
 
        if (!fd->buffer)
238
 
        {
239
 
            fprintf (stderr, "Cannot allocate %llu bytes for buffered output.\n",
240
 
                    fd->write_size_bytes);
241
 
 
242
 
            return 1;
243
 
        }
244
 
        else
245
 
        {
246
 
            // write the process group header
247
 
            adios_write_process_group_header_v1 (fd, *total_size);
248
 
 
249
 
            // setup for writing vars
250
 
            adios_write_open_vars_v1 (fd);
251
 
        }
252
 
    }
253
 
 
254
 
    // each var will be added to the buffer by the adios_write calls
255
 
    // attributes will be added by adios_close
256
 
 
257
 
    return 0;
258
 
}
259
 
 
260
 
///////////////////////////////////////////////////////////////////////////////
261
 
/* common_adios_write is just a partial implementation. It expects filled out
262
 
 * structures. This is because C and Fortran implementations of adios_write are 
263
 
 * different for some part and this is the common part.
264
 
 */
265
 
int common_adios_write (struct adios_file_struct * fd, struct adios_var_struct * v, void * var)
266
 
{
267
 
    struct adios_method_list_struct * m = fd->group->methods;
268
 
 
269
 
    if (fd->shared_buffer == adios_flag_yes)
270
 
    {
271
 
        // var payload sent for sizing information
272
 
        adios_write_var_header_v1 (fd, v);
273
 
 
274
 
        // write payload
275
 
        adios_write_var_payload_v1 (fd, v);
276
 
    }
277
 
 
278
 
    // now tell each transport attached that it is being written
279
 
    while (m)
280
 
    {
281
 
        if (   m->method->m != ADIOS_METHOD_UNKNOWN
282
 
            && m->method->m != ADIOS_METHOD_NULL
283
 
            && adios_transports [m->method->m].adios_write_fn
284
 
           )
285
 
        {
286
 
            adios_transports [m->method->m].adios_write_fn
287
 
                                   (fd, v, var, m->method);
288
 
        }
289
 
 
290
 
        m = m->next;
291
 
    }
292
 
 
293
 
    if (v->dimensions)
294
 
    {
295
 
        v->data = 0;
296
 
    }
297
 
 
298
 
    return 0;
299
 
}
300
 
 
301
 
///////////////////////////////////////////////////////////////////////////////
302
 
int common_adios_get_write_buffer (int64_t fd_p, const char * name
303
 
                           ,uint64_t * size
304
 
                           ,void ** buffer
305
 
                           )
306
 
{
307
 
    struct adios_file_struct * fd = (struct adios_file_struct *) fd_p;
308
 
    if (!fd)
309
 
    {
310
 
        fprintf (stderr, "Invalid handle passed to adios_get_write_buffer\n");
311
 
 
312
 
        return 1;
313
 
    }
314
 
    struct adios_var_struct * v = fd->group->vars;
315
 
    struct adios_method_list_struct * m = fd->group->methods;
316
 
 
317
 
    v = adios_find_var_by_name (v, name, fd->group->all_unique_var_names);
318
 
 
319
 
    if (!v)
320
 
    {
321
 
        fprintf (stderr
322
 
                ,"Bad var name (ignored): '%s' (%c%c%c)\n"
323
 
                ,name, name[0], name[1], name[2]
324
 
                );
325
 
 
326
 
        return 1;
327
 
    }
328
 
 
329
 
    if (fd->mode == adios_mode_read)
330
 
    {
331
 
        fprintf (stderr, "write attempted on %s in %s.  This was opened for"
332
 
                         " read\n"
333
 
                ,name , fd->name
334
 
                );
335
 
 
336
 
        return 1;
337
 
    }
338
 
 
339
 
    // since we are only getting one buffer, get it from the first
340
 
    // transport method that can provide it.
341
 
    while (m)
342
 
    {
343
 
        if (   m->method->m != ADIOS_METHOD_UNKNOWN
344
 
            && m->method->m != ADIOS_METHOD_NULL
345
 
            && adios_transports [m->method->m].adios_get_write_buffer_fn
346
 
           )
347
 
        {
348
 
            adios_transports [m->method->m].adios_get_write_buffer_fn
349
 
                                (fd, v, size, buffer, m->method);
350
 
            m = 0;
351
 
        }
352
 
        else
353
 
            m = m->next;
354
 
    }
355
 
 
356
 
    return 0;
357
 
}
358
 
 
359
 
///////////////////////////////////////////////////////////////////////////////
360
 
int common_adios_read (int64_t fd_p, const char * name, void * buffer
361
 
               ,uint64_t buffer_size
362
 
               )
363
 
{
364
 
    struct adios_file_struct * fd = (struct adios_file_struct *) fd_p;
365
 
    if (!fd)
366
 
    {
367
 
        fprintf (stderr, "Invalid handle passed to adios_read\n");
368
 
 
369
 
        return 1;
370
 
    }
371
 
    struct adios_var_struct * v;
372
 
    struct adios_method_list_struct * m = fd->group->methods;
373
 
 
374
 
    if (m && m->next == NULL && m->method->m == ADIOS_METHOD_NULL)
375
 
    {
376
 
        // nothing to do so just return
377
 
        return 0;
378
 
    }
379
 
 
380
 
    if (!(fd->mode == adios_mode_read))
381
 
    {
382
 
        fprintf (stderr, "read attempted on %s which was opened for write\n"
383
 
                ,fd->name
384
 
                );
385
 
 
386
 
        return 1;
387
 
    }
388
 
 
389
 
    v = adios_find_var_by_name (fd->group->vars, name
390
 
                               ,fd->group->all_unique_var_names
391
 
                               );
392
 
    if (v)
393
 
    {
394
 
        // since can only read from one place into the buffer,
395
 
        // read from the first transport method that can
396
 
        while (m)
397
 
        {
398
 
            if (   m->method->m != ADIOS_METHOD_UNKNOWN
399
 
                && m->method->m != ADIOS_METHOD_NULL
400
 
                && adios_transports [m->method->m].adios_read_fn
401
 
               )
402
 
            {
403
 
                adios_transports [m->method->m].adios_read_fn
404
 
                                     (fd, v, buffer, buffer_size, m->method);
405
 
                m = 0;
406
 
            }
407
 
            else
408
 
                m = m->next;
409
 
        }
410
 
    }
411
 
    else
412
 
    {
413
 
        fprintf (stderr, "var %s in file %s not found on read\n"
414
 
                ,name, fd->name
415
 
                );
416
 
 
417
 
        return 1;
418
 
    }
419
 
 
420
 
    return 0;
421
 
}
422
 
 
423
 
///////////////////////////////////////////////////////////////////////////////
424
 
int common_adios_set_path (int64_t fd_p, const char * path)
425
 
{
426
 
    struct adios_file_struct * fd = (struct adios_file_struct *) fd_p;
427
 
    if (!fd)
428
 
    {
429
 
        fprintf (stderr, "Invalid handle passed to adios_set_path\n");
430
 
 
431
 
        return 1;
432
 
    }
433
 
    struct adios_group_struct * t = fd->group;
434
 
    struct adios_var_struct * v = t->vars;
435
 
    struct adios_attribute_struct * a = t->attributes;
436
 
 
437
 
    while (v)
438
 
    {
439
 
        if (v->path)
440
 
        {
441
 
            free (v->path);
442
 
        }
443
 
 
444
 
        v->path = strdup (path);
445
 
 
446
 
        v = v->next;
447
 
    }
448
 
 
449
 
    while (a)
450
 
    {
451
 
        if (a->path)
452
 
        {
453
 
            free (a->path);
454
 
        }
455
 
 
456
 
        a->path = strdup (path);
457
 
 
458
 
        a = a->next;
459
 
    }
460
 
 
461
 
    return 0;
462
 
}
463
 
 
464
 
///////////////////////////////////////////////////////////////////////////////
465
 
int common_adios_set_path_var (int64_t fd_p, const char * path
466
 
                       ,const char * name
467
 
                       )
468
 
{
469
 
    struct adios_file_struct * fd = (struct adios_file_struct *) fd_p;
470
 
    if (!fd)
471
 
    {
472
 
        fprintf (stderr, "Invalid handle passed to adios_set_path_var\n");
473
 
 
474
 
        return 1;
475
 
    }
476
 
    struct adios_group_struct * t = fd->group;
477
 
    struct adios_var_struct * v = t->vars;
478
 
 
479
 
    // check for vars and then attributes
480
 
    v = adios_find_var_by_name (t->vars, name, fd->group->all_unique_var_names);
481
 
 
482
 
    if (v)
483
 
    {
484
 
        if (v->path)
485
 
        {
486
 
            free (v->path);
487
 
        }
488
 
 
489
 
        v->path = strdup (path);
490
 
    }
491
 
    else
492
 
    {
493
 
        fprintf (stderr, "adios_set_path_var (path=%s, var=%s): var not found\n"
494
 
                ,path, name
495
 
                );
496
 
 
497
 
        return 1;
498
 
    }
499
 
 
500
 
    return 0;
501
 
}
502
 
 
503
 
///////////////////////////////////////////////////////////////////////////////
504
 
// hint that we reached the end of an iteration (for asynchronous pacing)
505
 
int common_adios_end_iteration ()
506
 
{
507
 
    struct adios_method_list_struct * m;
508
 
 
509
 
    for (m = adios_get_methods (); m; m = m->next)
510
 
    {
511
 
        if (   m->method->m != ADIOS_METHOD_UNKNOWN
512
 
            && m->method->m != ADIOS_METHOD_NULL
513
 
            && adios_transports [m->method->m].adios_end_iteration_fn
514
 
           )
515
 
        {
516
 
            adios_transports [m->method->m].adios_end_iteration_fn
517
 
                                                (m->method);
518
 
        }
519
 
    }
520
 
 
521
 
    return 0;
522
 
}
523
 
 
524
 
///////////////////////////////////////////////////////////////////////////////
525
 
// hint to start communicating
526
 
int common_adios_start_calculation ()
527
 
{
528
 
    struct adios_method_list_struct * m;
529
 
 
530
 
    for (m = adios_get_methods (); m; m = m->next)
531
 
    {
532
 
        if (   m->method->m != ADIOS_METHOD_UNKNOWN
533
 
            && m->method->m != ADIOS_METHOD_NULL
534
 
            && adios_transports [m->method->m].adios_start_calculation_fn
535
 
           )
536
 
        {
537
 
            adios_transports [m->method->m].adios_start_calculation_fn
538
 
                                                  (m->method);
539
 
        }
540
 
    }
541
 
 
542
 
    return 0;
543
 
}
544
 
 
545
 
///////////////////////////////////////////////////////////////////////////////
546
 
// hint to stop communicating
547
 
int common_adios_stop_calculation ()
548
 
{
549
 
    struct adios_method_list_struct * m;
550
 
 
551
 
    for (m = adios_get_methods (); m; m = m->next)
552
 
    {
553
 
        if (   m->method->m != ADIOS_METHOD_UNKNOWN
554
 
            && m->method->m != ADIOS_METHOD_NULL
555
 
            && adios_transports [m->method->m].adios_stop_calculation_fn
556
 
           )
557
 
        {
558
 
            adios_transports [m->method->m].adios_stop_calculation_fn
559
 
                                                   (m->method);
560
 
        }
561
 
    }
562
 
 
563
 
    return 0;
564
 
}
565
 
 
566
 
///////////////////////////////////////////////////////////////////////////////
567
 
int common_adios_close (int64_t fd_p)
568
 
{
569
 
    struct adios_file_struct * fd = (struct adios_file_struct *) fd_p;
570
 
    if (!fd)
571
 
    {
572
 
        fprintf (stderr, "Invalid handle passed to adios_close\n");
573
 
 
574
 
        return 1;
575
 
    }
576
 
    struct adios_method_list_struct * m = fd->group->methods;
577
 
    if (m && m->next == NULL && m->method->m == ADIOS_METHOD_NULL)
578
 
    {
579
 
        // nothing to do so just return
580
 
        return 0;
581
 
    }
582
 
 
583
 
    struct adios_attribute_struct * a = fd->group->attributes;
584
 
    struct adios_var_struct * v = fd->group->vars;
585
 
 
586
 
    if (fd->shared_buffer == adios_flag_yes)
587
 
    {
588
 
        adios_write_close_vars_v1 (fd);
589
 
 
590
 
        adios_write_open_attributes_v1 (fd);
591
 
 
592
 
        while (a)
593
 
        {
594
 
            adios_write_attribute_v1 (fd, a);
595
 
 
596
 
            a = a->next;
597
 
        }
598
 
 
599
 
        adios_write_close_attributes_v1 (fd);
600
 
    }
601
 
 
602
 
    // in order to get the index assembled, we need to do it in the
603
 
    // transport once we have collected all of the pieces
604
 
 
605
 
    // now tell all of the transports to write the buffer during close
606
 
    for (;m; m = m->next)
607
 
    {
608
 
        if (   m->method->m != ADIOS_METHOD_UNKNOWN
609
 
            && m->method->m != ADIOS_METHOD_NULL
610
 
            && adios_transports [m->method->m].adios_close_fn
611
 
           )
612
 
        {
613
 
            adios_transports [m->method->m].adios_close_fn
614
 
                                 (fd, m->method);
615
 
        }
616
 
    }
617
 
 
618
 
    if (fd->shared_buffer == adios_flag_yes)
619
 
    {
620
 
        adios_method_buffer_free (fd->write_size_bytes);
621
 
        free (fd->buffer);
622
 
        fd->buffer_size = 0;
623
 
        fd->buffer = 0;
624
 
        fd->offset = 0;
625
 
    }
626
 
 
627
 
    while (v)
628
 
    {
629
 
        v->write_offset = 0;
630
 
        if (v->data)
631
 
        {
632
 
            free (v->data);
633
 
            v->data = 0;
634
 
        }
635
 
 
636
 
        v = v->next;
637
 
    }
638
 
 
639
 
    while (fd->group->vars_written)
640
 
    {
641
 
        if (fd->group->vars_written->name)
642
 
            free (fd->group->vars_written->name);
643
 
        if (fd->group->vars_written->path)
644
 
            free (fd->group->vars_written->path);
645
 
 
646
 
        while (fd->group->vars_written->dimensions)
647
 
        {
648
 
            struct adios_dimension_struct * dimensions
649
 
                            = fd->group->vars_written->dimensions->next;
650
 
 
651
 
            free (fd->group->vars_written->dimensions);
652
 
            fd->group->vars_written->dimensions = dimensions;
653
 
        }
654
 
 
655
 
                // NCSU - Clear stat
656
 
        if (fd->group->vars_written->stats)
657
 
                {
658
 
            uint8_t j = 0, idx = 0;
659
 
            uint8_t c = 0, count = adios_get_stat_set_count(fd->group->vars_written->type);
660
 
 
661
 
            for (c = 0; c < count; c ++)
662
 
            {
663
 
                while (fd->group->vars_written->bitmap >> j)
664
 
                {
665
 
                    if ((fd->group->vars_written->bitmap >> j) & 1)
666
 
                    {
667
 
                        if (j == adios_statistic_hist)
668
 
                        {
669
 
                            struct adios_hist_struct * hist = (struct adios_hist_struct *) (fd->group->vars_written->stats[c][idx].data);
670
 
                            free (hist->breaks);
671
 
                            free (hist->frequencies);
672
 
                            free (hist);
673
 
                        }
674
 
                        else
675
 
                            free (fd->group->vars_written->stats[c][idx].data);
676
 
 
677
 
                        idx ++;
678
 
                    }
679
 
                    j ++;
680
 
                }
681
 
                free (fd->group->vars_written->stats[c]);
682
 
            }
683
 
            free (fd->group->vars_written->stats);
684
 
                }
685
 
        if (fd->group->vars_written->data)
686
 
            free (fd->group->vars_written->data);
687
 
 
688
 
        v = fd->group->vars_written->next;
689
 
        free (fd->group->vars_written);
690
 
        fd->group->vars_written = v;
691
 
    }
692
 
 
693
 
    if (fd->name)
694
 
    {
695
 
        free (fd->name);
696
 
        fd->name = 0;
697
 
    }
698
 
 
699
 
    free ((void *) fd_p);
700
 
 
701
 
    return 0;
702
 
}
703
 
 
704
 
//////////////////////////////////////////////////////////////////////////////
705
 
// Methods normally only called by the XML parser
706
 
//////////////////////////////////////////////////////////////////////////////
707
 
 
708
 
// adios_common_declare_group is in adios_internals.c
709
 
// adios_common_define_var is in adios_internals.c
710
 
// adios_common_define_attribute is in adios_internals.c
711
 
// adios_common_select_method is in adios_internals.c