~ubuntu-branches/debian/stretch/adios/stretch

« back to all changes in this revision

Viewing changes to src/core/adios_internals.c

  • Committer: Package Import Robot
  • Author(s): Alastair McKinstry
  • Date: 2014-06-16 23:06:38 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20140616230638-5a0z7ylxx8i0edrg
Tags: 1.7.0-1
* New upstream release.
* Add adios.pc pkgconfig file. adios_config now uses this.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
#include "adios_transforms_hooks.h"
35
35
#include "adios_transforms_read.h"
36
36
#include "adios_transforms_write.h"
 
37
#include "adios_transforms_specparse.h"
37
38
 
38
39
struct adios_method_list_struct * adios_methods = 0;
39
40
struct adios_group_list_struct * adios_groups = 0;
80
81
struct adios_var_struct * adios_find_var_by_name (struct adios_group_struct * g,
81
82
                                                  const char * fullpath)
82
83
{
83
 
    struct adios_var_struct * var = NULL;
84
 
 
85
 
    if (!fullpath) {
86
 
        return NULL;
87
 
    }
88
 
 
89
84
    // Find variable in the hash table
90
 
    var = (struct adios_var_struct *)
 
85
    return  (struct adios_var_struct *)
91
86
            g->hashtbl_vars->get (g->hashtbl_vars, fullpath);
92
 
 
93
 
    return var;
94
87
}
95
88
 
96
89
/*
205
198
}
206
199
 
207
200
struct adios_var_struct * adios_find_var_by_id (struct adios_var_struct * root
208
 
        ,uint16_t id
 
201
        ,uint32_t id
209
202
        )
210
203
{
211
204
    while (root)
221
214
 
222
215
struct adios_attribute_struct * adios_find_attribute_by_id
223
216
(struct adios_attribute_struct * root
224
 
 ,uint16_t id
 
217
 ,uint32_t id
225
218
 )
226
219
{
227
220
    while (root)
698
691
 
699
692
                                return 1;
700
693
                            }
 
694
                        default:
 
695
                                return 1;
701
696
                    }
702
697
                }
703
698
            }
789
784
 
790
785
                                return 1;
791
786
                            }
 
787
                        default:
 
788
                                return 1;
792
789
                    }
793
790
                }
794
791
            }
1256
1253
 
1257
1254
void adios_append_attribute (struct adios_attribute_struct ** root
1258
1255
        ,struct adios_attribute_struct * attribute
1259
 
        ,uint16_t id
 
1256
        ,uint32_t id
1260
1257
        )
1261
1258
{
1262
1259
    while (root)
1297
1294
    g->member_count = 0; // will be set in adios_append_group
1298
1295
    g->vars = NULL;
1299
1296
    g->vars_tail = NULL;
1300
 
    g->hashtbl_vars = qhashtbl(100);
 
1297
    g->hashtbl_vars = qhashtbl(500);
1301
1298
    g->vars_written = NULL;
1302
1299
    g->vars_written_tail = NULL;
1303
1300
    g->attributes = NULL;
1327
1324
 
1328
1325
    if (!root)
1329
1326
    {
1330
 
        adios_error (err_unspecified, "Err in adios_common_free_group()\n");
 
1327
        adios_error (err_unspecified, "Err in adios_common_free_group(): no groups left\n");
1331
1328
        return -1;
1332
1329
    }
1333
1330
    while (root && root->group->id != g->id)
1339
1336
    if (!root)
1340
1337
    {
1341
1338
        // Didn't find the group
1342
 
        adios_error (err_unspecified, "Err in adios_common_free_group()\n");
 
1339
        adios_error (err_unspecified, "Err in adios_common_free_group(): did not find requested group\n");
1343
1340
        return -1;
1344
1341
    }
1345
1342
 
1346
1343
    // old_root->root->root next
1347
 
    if (old_root == adios_groups)
 
1344
    if (root == adios_groups)
1348
1345
    {
1349
1346
        adios_groups =  root->next;
1350
1347
    }
1503
1500
        , const char * bin_count
1504
1501
        )
1505
1502
{
1506
 
    struct adios_var_struct * root = g->vars, * var;
 
1503
    struct adios_var_struct * var;
1507
1504
 
1508
1505
    var = adios_find_var_by_name (g, var_name);
1509
1506
 
1655
1652
        ,const char * dimensions
1656
1653
        ,const char * global_dimensions
1657
1654
        ,const char * local_offsets
1658
 
        ,char *transform_type_str // NCSU ALACRITY-ADIOS
1659
1655
        )
1660
1656
{
1661
1657
    struct adios_group_struct * t = (struct adios_group_struct *) group_id;
1664
1660
    char * dim_temp;
1665
1661
    char * g_dim_temp;
1666
1662
    char * lo_dim_temp;
1667
 
    enum ADIOS_FLAG flag;
1668
1663
    uint8_t i;
1669
1664
    if (dimensions)
1670
1665
        dim_temp = strdup (dimensions);
1701
1696
    v->stats = 0;
1702
1697
    v->bitmap = 0;
1703
1698
 
1704
 
    // NCSU ALACRITY-ADIOS - Initialize transform metadata
 
1699
    // NCSU ALACRITY-ADIOS - Initialize transform metadata (set to 'none')
1705
1700
    adios_transform_init_transform_var(v);
1706
1701
 
1707
1702
    // Q.L. - Check whether stats are disabled or not
1805
1800
    if (lo_dim_temp)
1806
1801
        free (lo_dim_temp);
1807
1802
 
 
1803
    v->id = ++t->member_count;
 
1804
    adios_append_var (t, v);
 
1805
 
 
1806
    return (int64_t)v;
 
1807
}
 
1808
 
 
1809
/* Set the transformation method for a variable. Only one transformation will work for each variable */
 
1810
int adios_common_set_transform (int64_t var_id, const char *transform_type_str)
 
1811
{
 
1812
    struct adios_var_struct * v = (struct adios_var_struct *)var_id;
 
1813
    assert (v);
1808
1814
    // NCSU ALACRITY-ADIOS - parse transform type string, and call the transform layer to
1809
1815
    //   set up the variable as needed
1810
 
    struct adios_transform_spec *transform_spec = adios_transform_parse_spec(transform_type_str);
 
1816
    struct adios_transform_spec *transform_spec = adios_transform_parse_spec(transform_type_str, v->transform_spec);
1811
1817
    if (transform_spec->transform_type == adios_transform_unknown) {
1812
 
        log_error("Unknown transform type \"%s\" specified for variable \"%s\", ignoring it...\n",
 
1818
        adios_error(err_invalid_transform_type, 
 
1819
                  "Unknown transform type \"%s\" specified for variable \"%s\", ignoring it...\n",
1813
1820
                  transform_spec->transform_type_str, v->name);
1814
1821
        transform_spec->transform_type = adios_transform_none;
1815
1822
    }
1816
1823
 
1817
1824
    // This function sets the transform_type field. It does nothing if transform_type is none.
1818
1825
    // Note: ownership of the transform_spec struct is given to this function
1819
 
    v = adios_transform_define_var(t, v, transform_spec);
1820
 
 
1821
 
    v->id = ++t->member_count;
1822
 
    adios_append_var (t, v);
1823
 
 
1824
 
    return (int64_t)v;
 
1826
    v = adios_transform_define_var(v, transform_spec);
 
1827
    return adios_errno;
1825
1828
}
1826
1829
 
 
1830
 
1827
1831
void adios_common_get_group (int64_t * group_id, const char * name)
1828
1832
{
1829
1833
    struct adios_group_list_struct * g = adios_get_groups ();
1959
1963
    struct adios_dimension_struct * d = v->dimensions;
1960
1964
 
1961
1965
    overhead += 8; // length of var entry
1962
 
    overhead += 2; // member id
 
1966
    overhead += 4; // member id
1963
1967
    overhead += 2; // length of name
1964
1968
    overhead += strlen (v->name); // name
1965
1969
    overhead += 2; // length of path
1981
1985
        }
1982
1986
        else
1983
1987
        {
1984
 
            overhead += 2; // member id
 
1988
            overhead += 4; // member id
1985
1989
        }
1986
1990
 
1987
1991
        overhead += 1; // var flag
1994
1998
        }
1995
1999
        else
1996
2000
        {
1997
 
            overhead += 2; // member id
 
2001
            overhead += 4; // member id
1998
2002
        }
1999
2003
 
2000
2004
        overhead += 1; // var flag
2007
2011
        }
2008
2012
        else
2009
2013
        {
2010
 
            overhead += 2; // member id
 
2014
            overhead += 4; // member id
2011
2015
        }
2012
2016
 
2013
2017
        d = d->next;
2022
2026
    uint32_t overhead = 0;
2023
2027
 
2024
2028
    overhead += 4; // attribute length
2025
 
    overhead += 2; // member id
 
2029
    overhead += 4; // member id
2026
2030
    overhead += 2; // length of name
2027
2031
    overhead += strlen (a->name); // name
2028
2032
    overhead += 2; // length of path
2029
2033
    overhead += strlen (a->path); // path
2030
2034
    overhead += 1; // var flag
2031
2035
    if (a->var)
2032
 
        overhead += 2; // var member id
 
2036
        overhead += 4; // var member id
2033
2037
    else
2034
2038
    {
2035
2039
        overhead += 1; // datatype
2051
2055
    overhead += 1; // host language flag
2052
2056
    overhead += 2; // length of group name
2053
2057
    overhead += strlen (fd->group->name); // group name
2054
 
    overhead += 2; // coordination var id
 
2058
    overhead += 4; // coordination var id
2055
2059
    overhead += 2; // length of time index name
2056
2060
    overhead += ((fd->group->time_index_name)
2057
2061
            ? strlen (fd->group->time_index_name)
2070
2074
        m = m->next;
2071
2075
    }
2072
2076
 
2073
 
    overhead += 2; // count of vars
 
2077
    overhead += 4; // count of vars
2074
2078
    overhead += 8; // length of vars section
2075
2079
 
2076
2080
    while (v)
2080
2084
        v = v->next;
2081
2085
    }
2082
2086
 
2083
 
    overhead += 2; // attributes count
 
2087
    overhead += 4; // attributes count
2084
2088
    overhead += 8; // attributes length
2085
2089
 
2086
2090
    while (a)
2102
2106
    uint8_t flag;
2103
2107
    struct adios_var_struct * var;
2104
2108
    uint16_t len;
2105
 
    char * temp;
2106
2109
 
2107
2110
    buffer_write (&fd->buffer, &fd->buffer_size, &fd->offset, &total_size, 8);
2108
2111
 
2117
2120
    var = adios_find_var_by_name (g, g->group_by);
2118
2121
    if (var)
2119
2122
    {
2120
 
        buffer_write (&fd->buffer, &fd->buffer_size, &fd->offset, &var->id, 2);
 
2123
        buffer_write (&fd->buffer, &fd->buffer_size, &fd->offset, &var->id, 4);
2121
2124
    }
2122
2125
    else
2123
2126
    {
2124
 
        uint16_t i = 0;
2125
 
        buffer_write (&fd->buffer, &fd->buffer_size, &fd->offset, &i, 2);
 
2127
        uint32_t i = 0;
 
2128
        buffer_write (&fd->buffer, &fd->buffer_size, &fd->offset, &i, 4);
2126
2129
    }
2127
2130
 
2128
2131
    len = ((g->time_index_name) ? strlen (g->time_index_name) : 0);
2202
2205
        ,struct adios_index_var_struct_v1 * item
2203
2206
        )
2204
2207
{
2205
 
    struct adios_index_var_struct_v1 * root = index->vars_root;
2206
2208
    struct adios_index_var_struct_v1 * olditem;
2207
2209
 
2208
2210
    olditem = (struct adios_index_var_struct_v1 *)
2408
2410
        )
2409
2411
{
2410
2412
    struct adios_index_process_group_struct_v1 * p2 = 0, * p1_temp, * p2_temp, * p2_temp_prev;
2411
 
    struct adios_index_var_struct_v1 * v2 = 0, * v1_temp, * v2_temp, * v2_temp_prev;
2412
 
    struct adios_index_attribute_struct_v1 * a2 = 0, * a1_temp, * a2_temp, * a2_temp_prev;
 
2413
    struct adios_index_var_struct_v1 * v1_temp;
2413
2414
    int i, j;
2414
2415
 
2415
2416
    while (*p1)
2677
2678
    index->attrs_root = NULL;
2678
2679
    index->attrs_tail = NULL;
2679
2680
    if (alloc_hashtables) {
2680
 
        index->hashtbl_vars  = qhashtbl(100);
 
2681
        index->hashtbl_vars  = qhashtbl(500);
2681
2682
        //index->hashtbl_attrs = qhashtbl(100);
2682
2683
        index->hashtbl_attrs = NULL; // not used yet
2683
2684
    } else {
2698
2699
        index->hashtbl_vars->free  (index->hashtbl_vars);
2699
2700
    if (index->hashtbl_attrs)
2700
2701
        index->hashtbl_attrs->free (index->hashtbl_attrs);
 
2702
    free(index);
2701
2703
}
2702
2704
 
2703
2705
void adios_clear_index_v1 (struct adios_index_struct_v1 * index)
2783
2785
        case adios_string:
2784
2786
        case adios_complex:
2785
2787
        case adios_double_complex:
 
2788
        default:
2786
2789
            adios_error (err_unspecified,
2787
2790
                    "Cannot convert type %s to integer for var %s\n",
2788
2791
                    adios_type_to_string_int (type), parent_name);
2984
2987
 
2985
2988
                break;
2986
2989
            }
 
2990
        default:
 
2991
            {
 
2992
                adios_error (err_unspecified, "Reached unexpected branch in %s:%s:%d\n",
 
2993
                        __FILE__,__func__, __LINE__);
 
2994
            }
2987
2995
    }
2988
2996
 
2989
2997
    /* Insert new variable into the copy list */
3185
3193
    struct adios_attribute_struct * a = g->attributes;
3186
3194
    struct adios_index_process_group_struct_v1 * g_item;
3187
3195
 
3188
 
    uint64_t process_group_count = 0;
3189
 
 
3190
3196
    g_item = (struct adios_index_process_group_struct_v1 *)
3191
3197
        malloc (sizeof (struct adios_index_process_group_struct_v1));
3192
3198
    g_item->group_name = (g->name ? strdup (g->name) : 0L);
3365
3371
 
3366
3372
                        break;
3367
3373
                    }
 
3374
                default:
 
3375
                    {
 
3376
                        adios_error (err_unspecified, "Reached unexpected branch in %s:%s:%d\n",
 
3377
                                __FILE__,__func__, __LINE__);
 
3378
                    }
3368
3379
            }
3369
3380
            v_index->next = 0;
3370
3381
 
3443
3454
        )
3444
3455
{
3445
3456
    uint64_t groups_count = 0;
3446
 
    uint16_t vars_count = 0;
3447
 
    uint16_t attrs_count = 0;
 
3457
    uint32_t vars_count = 0;
 
3458
    uint32_t attrs_count = 0;
3448
3459
 
3449
3460
    uint64_t index_size = 0;
3450
3461
    uint64_t pg_index_start = index_start;
3540
3551
    vars_index_start = buffer_offset_start + index_start;
3541
3552
    index_size = 0;
3542
3553
 
3543
 
    *buffer_offset += (2 + 8); // save space for count and size
 
3554
    *buffer_offset += (4 + 8); // save space for count and size
3544
3555
 
3545
3556
    while (vars_root)
3546
3557
    {
3554
3565
 
3555
3566
        *buffer_offset += 4; // save space for var length
3556
3567
 
3557
 
        buffer_write (buffer, buffer_size, buffer_offset, &vars_root->id, 2);
3558
 
        index_size += 2;
3559
 
        var_size += 2;
 
3568
        buffer_write (buffer, buffer_size, buffer_offset, &vars_root->id, 4);
 
3569
        index_size += 4;
 
3570
        var_size += 4;
3560
3571
 
3561
3572
        len = strlen (vars_root->group_name);
3562
3573
        buffer_write (buffer, buffer_size, buffer_offset, &len, 2);
3899
3910
                        characteristic_set_length += size;
3900
3911
                    }
3901
3912
                    break;
 
3913
                default:
 
3914
                    {
 
3915
                        adios_error (err_unspecified, "Reached unexpected branch in %s:%s:%d\n",
 
3916
                                __FILE__,__func__, __LINE__);
 
3917
                    }
3902
3918
            }
3903
3919
            // characteristics count/size prefix
3904
3920
            buffer_write (buffer, buffer_size, &characteristic_set_start
3917
3933
    log_debug ("%s: wrote %d variables into the var-index buffer\n", __func__, vars_count);
3918
3934
 
3919
3935
    // vars index count/size prefix
3920
 
    buffer_write (buffer, buffer_size, &buffer_offset_start, &vars_count, 2);
 
3936
    buffer_write (buffer, buffer_size, &buffer_offset_start, &vars_count, 4);
3921
3937
    buffer_write (buffer, buffer_size, &buffer_offset_start, &index_size, 8);
3922
3938
 
3923
3939
    buffer_offset_start = *buffer_offset; // save to write the attrs_count/size
3924
3940
    attrs_index_start = buffer_offset_start + index_start;
3925
3941
    index_size = 0;
3926
3942
 
3927
 
    *buffer_offset += (2 + 8); // save space for count and size
 
3943
    *buffer_offset += (4 + 8); // save space for count and size
3928
3944
 
3929
3945
    while (attrs_root)
3930
3946
    {
3938
3954
 
3939
3955
        *buffer_offset += 4; // save space for attr length
3940
3956
 
3941
 
        buffer_write (buffer, buffer_size, buffer_offset, &attrs_root->id, 2);
3942
 
        index_size += 2;
3943
 
        attr_size += 2;
 
3957
        buffer_write (buffer, buffer_size, buffer_offset, &attrs_root->id, 4);
 
3958
        index_size += 4;
 
3959
        attr_size += 4;
3944
3960
 
3945
3961
        len = strlen (attrs_root->group_name);
3946
3962
        buffer_write (buffer, buffer_size, buffer_offset, &len, 2);
4098
4114
                attr_size += 1;
4099
4115
                characteristic_set_length += 1;
4100
4116
                buffer_write (buffer, buffer_size, buffer_offset
4101
 
                        ,&attrs_root->characteristics [i].var_id, 2
 
4117
                        ,&attrs_root->characteristics [i].var_id, 4
4102
4118
                        );
4103
 
                index_size += 2;
4104
 
                attr_size += 2;
4105
 
                characteristic_set_length += 2;
 
4119
                index_size += 4;
 
4120
                attr_size += 4;
 
4121
                characteristic_set_length += 4;
4106
4122
            }
4107
4123
 
4108
4124
            // characteristics count/size prefix
4120
4136
    }
4121
4137
 
4122
4138
    // attrs index count/size prefix
4123
 
    buffer_write (buffer, buffer_size, &buffer_offset_start, &attrs_count, 2);
 
4139
    buffer_write (buffer, buffer_size, &buffer_offset_start, &attrs_count, 4);
4124
4140
    buffer_write (buffer, buffer_size, &buffer_offset_start, &index_size, 8);
4125
4141
 
4126
4142
 
4167
4183
    else
4168
4184
        test = 0;
4169
4185
 
4170
 
    test += 1;   // first data storage version
 
4186
    // version number 1 byte, endiness 1 byte,
 
4187
    // the rest is user-defined options 2 bytes
 
4188
    test += ADIOS_VERSION_BP_FORMAT;   // file format version
4171
4189
    // For the new read API to be able to read back older file format,
4172
4190
    // set this flag
4173
4191
    test |= ADIOS_VERSION_HAVE_TIME_INDEX_CHARACTERISTIC;
4194
4212
 
4195
4213
    // version number 1 byte, endiness 1 byte,
4196
4214
    // the rest is user-defined options 2 bytes
4197
 
    test += 1;   // master index file version
 
4215
    test += ADIOS_VERSION_BP_FORMAT;   // file format version
4198
4216
    // For the new read API to be able to read back older file format,
4199
4217
    // set this flag
4200
4218
    test |= ADIOS_VERSION_HAVE_TIME_INDEX_CHARACTERISTIC | flag;
4221
4239
    }
4222
4240
    else   // it is a var
4223
4241
    {
4224
 
        size += 2;  // size of var ID
 
4242
        size += 4;  // size of var ID
4225
4243
    }
4226
4244
 
4227
4245
    size += 1; // var (y or n)
4235
4253
    }
4236
4254
    else
4237
4255
    {
4238
 
        size += 2;  // size of var ID
 
4256
        size += 4;  // size of var ID
4239
4257
    }
4240
4258
 
4241
4259
    size += 1; // var (y or n)
4249
4267
    }
4250
4268
    else
4251
4269
    {
4252
 
        size += 2;  // size of var ID
 
4270
        size += 4;  // size of var ID
4253
4271
    }
4254
4272
 
4255
4273
    return size;
4275
4293
        )
4276
4294
{
4277
4295
    uint64_t size = 0;
4278
 
    uint16_t id;
 
4296
    uint32_t id;
4279
4297
    uint8_t var;
4280
4298
 
4281
4299
    if (    dimension->dimension.var == NULL
4302
4320
        var = 'y';
4303
4321
        buffer_write (&fd->buffer, &fd->buffer_size, &fd->offset, &var, 1);
4304
4322
        size += 1;
4305
 
        buffer_write (&fd->buffer, &fd->buffer_size, &fd->offset, &id, 2);
4306
 
        size += 2;
 
4323
        buffer_write (&fd->buffer, &fd->buffer_size, &fd->offset, &id, 4);
 
4324
        size += 4;
4307
4325
    }
4308
4326
 
4309
4327
    if (    dimension->global_dimension.var == NULL
4330
4348
        var = 'y';
4331
4349
        buffer_write (&fd->buffer, &fd->buffer_size, &fd->offset, &var, 1);
4332
4350
        size += 1;
4333
 
        buffer_write (&fd->buffer, &fd->buffer_size, &fd->offset, &id, 2);
4334
 
        size += 2;
 
4351
        buffer_write (&fd->buffer, &fd->buffer_size, &fd->offset, &id, 4);
 
4352
        size += 4;
4335
4353
    }
4336
4354
 
4337
4355
    if (    dimension->local_offset.var == NULL
4358
4376
        var = 'y';
4359
4377
        buffer_write (&fd->buffer, &fd->buffer_size, &fd->offset, &var, 1);
4360
4378
        size += 1;
4361
 
        buffer_write (&fd->buffer, &fd->buffer_size, &fd->offset, &id, 2);
4362
 
        size += 2;
 
4379
        buffer_write (&fd->buffer, &fd->buffer_size, &fd->offset, &id, 4);
 
4380
        size += 4;
4363
4381
    }
4364
4382
 
4365
4383
    return size;
4440
4458
        )
4441
4459
{
4442
4460
    uint8_t flag;
4443
 
    uint64_t size;
4444
4461
    uint16_t len;
4445
4462
    uint8_t characteristic_set_count = 0;
4446
4463
    uint32_t characteristic_set_length = 0;
4452
4469
 
4453
4470
    // depending on if it is an array or not, generate a different
4454
4471
    // additional set of characteristics
4455
 
    size = adios_get_type_size (v->type, v->data);
4456
4472
 
4457
4473
    switch (v->type)
4458
4474
    {
4608
4624
 
4609
4625
        case adios_string:
4610
4626
            break;
 
4627
        default:
 
4628
            break;
4611
4629
    }
4612
4630
    // characteristics count/size prefix
4613
4631
    buffer_write (&fd->buffer, &fd->buffer_size, &characteristic_set_start
4628
4646
    enum ADIOS_DATATYPES original_var_type = adios_transform_get_var_original_type_var(var);
4629
4647
 
4630
4648
    if (var->transform_type != adios_transform_none) {
4631
 
        total_size = adios_transform_get_pre_transform_var_size (fd->group, var);
 
4649
        total_size = adios_transform_get_pre_transform_var_size (var);
4632
4650
    } else {
4633
 
        total_size = adios_get_var_size (var, fd->group, var->data);
 
4651
        total_size = adios_get_var_size (var, var->data);
4634
4652
    }
4635
4653
 
4636
4654
    if (var->bitmap == 0)
4642
4660
#if 1
4643
4661
#define HIST(a) \
4644
4662
    { \
4645
 
        int j = 0, low, high, mid; \
 
4663
        int low, high, mid; \
4646
4664
        low=0; \
4647
4665
        high=hist->num_breaks - 1; \
4648
4666
        if (hist->breaks[low] > a) \
4845
4863
            */
4846
4864
 
4847
4865
            *cnt_r = *cnt_i = *cnt_m = 0;
4848
 
            *min_r = *min_i = *min_m = INFINITY;
4849
 
            *max_r = *max_i = *max_m = -INFINITY;
 
4866
            *min_r = *min_i = *min_m = HUGE_VAL;
 
4867
            *max_r = *max_i = *max_m = -HUGE_VAL;
4850
4868
            *sum_r = *sum_i = *sum_m = 0;
4851
4869
            *sum_square_r = *sum_square_i = *sum_square_m = 0;
4852
4870
 
4975
4993
            cnt_i = (uint32_t *) stats[2][map[adios_statistic_cnt]].data;
4976
4994
 
4977
4995
            *cnt_r = *cnt_i = *cnt_m = 0;
4978
 
            *min_r = *min_i = *min_m = INFINITY;
4979
 
            *max_r = *max_i = *max_m = -INFINITY;
 
4996
            *min_r = *min_i = *min_m = HUGE_VAL;
 
4997
            *max_r = *max_i = *max_m = -HUGE_VAL;
4980
4998
            *sum_r = *sum_i = *sum_m = 0;
4981
4999
            *sum_square_r = *sum_square_i = *sum_square_m = 0;
4982
5000
 
4983
5001
            while ((size * sizeof(double)) < total_size)
4984
5002
            {
4985
 
                long double magnitude = sqrt((long double) data [size] * data [size] + (long double) data[size + 1] * data[size + 1]);
 
5003
                magnitude = sqrt((long double) data [size] * data [size] + 
 
5004
                                 (long double) data[size + 1] * data[size + 1]);
4986
5005
 
4987
5006
                // Both real and imaginary parts have to be finite, else skip calculating the characteristic
4988
5007
                if ( isnan(data [size]) || !isfinite(data [size]) || isnan(data[size + 1]) || !isfinite(data[size + 1]) ) {
5051
5070
 
5052
5071
        default:
5053
5072
        {
5054
 
            uint64_t data = adios_unknown;
5055
5073
            var->stats = 0;
5056
5074
 
5057
5075
            return 0;
5073
5091
    fd->offset += 8;              // save space for the size
5074
5092
    total_size += 8;              // makes final parsing easier
5075
5093
 
5076
 
    buffer_write (&fd->buffer, &fd->buffer_size, &fd->offset, &v->id, 2);
5077
 
    total_size += 2;
 
5094
    buffer_write (&fd->buffer, &fd->buffer_size, &fd->offset, &v->id, 4);
 
5095
    total_size += 4;
5078
5096
 
5079
5097
    len = strlen (v->name);
5080
5098
    buffer_write (&fd->buffer, &fd->buffer_size, &fd->offset, &len, 2);
5104
5122
    // adios_generate_var_characteristics_v1 (fd, v);
5105
5123
    total_size += adios_write_var_characteristics_v1 (fd, v);
5106
5124
 
5107
 
    total_size += adios_get_var_size (v, fd->group, v->data); // payload
 
5125
    total_size += adios_get_var_size (v, v->data); // payload
5108
5126
 
5109
5127
    buffer_write (&fd->buffer, &fd->buffer_size, &start, &total_size, 8);
5110
5128
 
5123
5141
    uint64_t size;
5124
5142
 
5125
5143
    // write payload
5126
 
    size = adios_get_var_size (var, fd->group, var->data);
 
5144
    size = adios_get_var_size (var, var->data);
5127
5145
    buffer_write (&fd->buffer, &fd->buffer_size, &fd->offset, var->data, size);
5128
5146
 
5129
5147
    if (fd->bytes_written < fd->offset)
5146
5164
    a->write_offset = fd->offset + fd->base_offset; // save offset in file
5147
5165
    fd->offset += 4;
5148
5166
 
5149
 
    buffer_write (&fd->buffer, &fd->buffer_size, &fd->offset, &a->id, 2);
5150
 
    size += 2;
 
5167
    buffer_write (&fd->buffer, &fd->buffer_size, &fd->offset, &a->id, 4);
 
5168
    size += 4;
5151
5169
 
5152
5170
    len = strlen (a->name);
5153
5171
    buffer_write (&fd->buffer, &fd->buffer_size, &fd->offset, &len, 2);
5170
5188
    if (a->var)
5171
5189
    {
5172
5190
        buffer_write (&fd->buffer, &fd->buffer_size, &fd->offset
5173
 
                ,&a->var->id, 2
 
5191
                ,&a->var->id, 4
5174
5192
                );
5175
 
        size += 2;
 
5193
        size += 4;
5176
5194
    }
5177
5195
    else
5178
5196
    {
5208
5226
    // it is now setup to write the vars and then the attrs on close
5209
5227
    fd->vars_start = fd->offset;
5210
5228
 
5211
 
    fd->offset += (2 + 8); // (count + size)
 
5229
    fd->offset += (4 + 8); // (count + size)
5212
5230
 
5213
5231
    if (fd->bytes_written < fd->offset)
5214
5232
        fd->bytes_written = fd->offset;
5220
5238
{
5221
5239
    // close the var area (count and total size) and write the attributes
5222
5240
    uint64_t size = fd->offset - fd->vars_start;
5223
 
    buffer_write (&fd->buffer, &fd->buffer_size, &fd->vars_start, &fd->vars_written, 2);
 
5241
    buffer_write (&fd->buffer, &fd->buffer_size, &fd->vars_start, &fd->vars_written, 4);
5224
5242
 
5225
5243
    buffer_write (&fd->buffer, &fd->buffer_size, &fd->vars_start, &size, 8);
5226
5244
 
5230
5248
int adios_write_open_attributes_v1 (struct adios_file_struct * fd)
5231
5249
{
5232
5250
    fd->vars_start = fd->offset;   // save the start of attr area for size
5233
 
    fd->offset += (2 + 8);         // space to write the count and size
 
5251
    fd->offset += (4 + 8);         // space to write the count and size
5234
5252
    fd->vars_written = 0;
5235
5253
 
5236
5254
    if (fd->bytes_written < fd->offset)
5243
5261
{
5244
5262
    // write attribute count and total size
5245
5263
    uint64_t size = fd->offset - fd->vars_start;
5246
 
    buffer_write (&fd->buffer, &fd->buffer_size, &fd->vars_start, &fd->vars_written, 2);
 
5264
    buffer_write (&fd->buffer, &fd->buffer_size, &fd->vars_start, &fd->vars_written, 4);
5247
5265
 
5248
5266
    buffer_write (&fd->buffer, &fd->buffer_size, &fd->vars_start, &size, 8);
5249
5267
 
5307
5325
// TODO: Factor out "var", since needed because of adios_multiply_dimensions, which needs
5308
5326
//       it only for debugging output.
5309
5327
uint64_t adios_get_dimension_space_size (struct adios_var_struct *var
5310
 
                                        ,struct adios_dimension_struct * d
5311
 
                                        ,struct adios_group_struct * group) {
 
5328
                                        ,struct adios_dimension_struct * d) {
5312
5329
    uint64_t size = 1;
5313
5330
    while (d)
5314
5331
    {
5393
5410
}
5394
5411
 
5395
5412
// NCSU ALACRITY-ADIOS: Refactored to call the above dimension space compute code
5396
 
uint64_t adios_get_var_size (struct adios_var_struct * var
5397
 
        ,struct adios_group_struct * group, void * data
5398
 
        )
 
5413
uint64_t adios_get_var_size (struct adios_var_struct * var, void * data)
5399
5414
{
5400
5415
    uint64_t size = adios_get_type_size (var->type, data);
5401
5416
    if (var->dimensions)
5402
 
        size *= adios_get_dimension_space_size(var, var->dimensions, group);
 
5417
        size *= adios_get_dimension_space_size(var, var->dimensions);
5403
5418
 
5404
5419
    return size;
5405
5420
}
5560
5575
    return list_rem_next (queue, NULL, data);
5561
5576
}
5562
5577
 
 
5578
 
5563
5579
// Functions for non-XML API fo ADIOS Schema some of which are also called from functions in adios_internals_mxml.c
5564
 
int adios_define_schema_version(struct adios_group_struct * new_group, char * schema_version){
5565
 
    int64_t      p_new_group = (int64_t) new_group;
 
5580
int adios_common_define_schema_version (struct adios_group_struct * new_group, char * schema_version)
 
5581
{
 
5582
    int64_t p_new_group = (int64_t) new_group;
5566
5583
 
5567
5584
    if (strcasecmp (schema_version,"")){
5568
5585
        char * ver;// copy version
5569
5586
        char * d;  // dot location
5570
5587
        char * ptr_end;
5571
5588
        ver = strdup (schema_version);
5572
 
        char * schema_version_major;
5573
 
        char * schema_version_minor;
5574
5589
        char * schema_version_major_att_nam;
5575
5590
        char * schema_version_minor_att_nam;
5576
5591
        d = strtok (ver, ".");
5577
5592
        int counter = 0; // counter
5578
 
        //int slength = 0;
 
5593
 
5579
5594
        while (d)
5580
5595
        {
5581
5596
            int slength = 0;
5589
5604
                    slength = slength + strlen("version_major") + 1;
5590
5605
                    schema_version_major_att_nam = malloc (slength);
5591
5606
                    strcpy(schema_version_major_att_nam,"adios_schema/version_major");
5592
 
                    //schema_version_major = strdup(d);
5593
5607
                    adios_common_define_attribute (p_new_group,schema_version_major_att_nam,"/",adios_string,d,"");
5594
5608
                }else if (counter == 1){
5595
5609
                    slength = slength + strlen("version_minor") + 1;
5596
5610
                    schema_version_minor_att_nam = malloc (slength);
5597
5611
                    strcpy(schema_version_minor_att_nam,"adios_schema/version_minor");
5598
 
                    //schema_version_minor = strdup(d);
5599
5612
                    adios_common_define_attribute (p_new_group,schema_version_minor_att_nam,"/",adios_string,d,"");
5600
5613
                }
5601
5614
            }
5610
5623
    return 0;
5611
5624
}
5612
5625
 
 
5626
 
5613
5627
// Parse mesh time series (single file for multiple time steps or
5614
5628
// multiple files for time steps, basename + timeformat + extension)
5615
 
int adios_define_mesh_timeSeriesFormat (const char * timeseries
5616
 
        ,struct adios_group_struct * new_group
5617
 
        ,const char * name
5618
 
        )
 
5629
int adios_common_define_mesh_timeSeriesFormat (const char * timeseries,
 
5630
                                               struct adios_group_struct * new_group,
 
5631
                                               const char * name
 
5632
                                              )
5619
5633
{
5620
5634
    char * d1;                     // save of strdup
5621
 
    int64_t      p_new_group = (int64_t) new_group;
 
5635
    int64_t p_new_group = (int64_t) new_group;
5622
5636
    char * format_att_nam = 0;     // extension format .xxxx att name
5623
5637
    char * format_att_val = 0;     // extension format att value
5624
5638
 
5626
5640
    // The number indicates how to write the time steps. Ex: 4 ==>
5627
5641
    // varname.XXXX.png where XXXX is the time step padded with 0s
5628
5642
    // We do not fail if this is not given as variables all have nsteps
5629
 
    if (!timeseries){
 
5643
    if (!timeseries || !strcmp(timeseries,"")){
5630
5644
        return 1;
5631
5645
    }
5632
5646
 
5633
5647
    char * ptr_end;
5634
5648
    d1 = strdup (timeseries);
5635
 
    if (strtod (d1, &ptr_end)){
 
5649
 
 
5650
    double tmp_d = strtod (d1, &ptr_end);
 
5651
    if (!(ptr_end && ptr_end[0]==0))
 
5652
    {
5636
5653
        adios_conca_mesh_att_nam(&format_att_nam, name, "time-series-format");
5637
5654
        adios_common_define_attribute (p_new_group,format_att_nam,"/",adios_double,d1,"");
5638
 
        free(format_att_val);    }
5639
 
        free (d1);
5640
 
        return 1;
 
5655
        free(format_att_val);
 
5656
    }
 
5657
    free (d1);
 
5658
    return 1;
5641
5659
}
5642
5660
 
5643
5661
// Parse mesh time scale (real time tracking, not integers)
5644
 
int adios_define_mesh_timeScale (const char * timescale
5645
 
        ,struct adios_group_struct * new_group
5646
 
        ,const char * name
5647
 
        )
 
5662
int adios_common_define_mesh_timeScale (const char * timescale,
 
5663
                                        struct adios_group_struct * new_group,
 
5664
                                        const char * name
 
5665
                                       )
5648
5666
{
5649
5667
    char * c;                      // comma location
5650
5668
    char * d1;                     // save of strdup
5651
 
    int64_t      p_new_group = (int64_t) new_group;
 
5669
    int64_t p_new_group = (int64_t) new_group;
5652
5670
    char * gettscalefrom0 = 0;     // scale attribute xml value
5653
5671
    char * gettscalefrom1 = 0;     // scale attribute xml value
5654
5672
    char * gettscalefrom2 = 0;     // scale attribute xml value
5671
5689
    // 2. start/stride/count 3 components
5672
5690
    // 3. min/max range where this mesh is used
5673
5691
    // 4. An ADIOS var = time could be a list of int stored by user
5674
 
    char counterstr[5] = {0,0,0,0,0}; // used to create scale attributes
5675
5692
 
5676
5693
    /* We do not fail if this is not given as variables all have nsteps
5677
5694
       in ADIOS_inq_var = # of times the var was written
5678
5695
       */
5679
 
    if (!timescale){
5680
 
        printf("time-scale attribute for mesh: %s not provided.\n", name);
 
5696
    if (!timescale || !strcmp(timescale,"")){
 
5697
//        printf("time-scale attribute for mesh: %s not provided.\n", name);
5681
5698
        return 1;
5682
5699
    }
5683
5700
 
5689
5706
    {
5690
5707
        struct adios_var_struct * var = 0;
5691
5708
        //if (adios_int_is_num (c))
5692
 
        if (!strtod (c,&ptr_end))
 
5709
        double tmp_d1;
 
5710
        tmp_d1 = strtod (c,&ptr_end);
 
5711
        if (!(ptr_end && ptr_end[0]==0))
5693
5712
        {
5694
 
            var =
5695
 
                adios_find_var_by_name (new_group, c);
 
5713
            var = adios_find_var_by_name (new_group, c);
5696
5714
            if (!var)
5697
5715
            {
5698
5716
                log_warn ("config.xml: invalid variable %s\n"
5699
 
                        "for time scale of mesh: %s\n"
5700
 
                        ,c
5701
 
                        ,name
5702
 
                        );
 
5717
                          "for time scale of mesh: %s\n",
 
5718
                          c, name);
5703
5719
                free (d1);
5704
5720
 
5705
5721
                return 0;
5737
5753
        c = strtok (NULL, ",");
5738
5754
    }
5739
5755
    if (counter == 3){
 
5756
        double tmp_d2;
5740
5757
        time_start_att_val = strdup(gettscalefrom0);
5741
5758
        adios_conca_mesh_att_nam(&time_start_att_nam, name, "time-scale-start");
5742
5759
        // if this is string
5743
 
        if (!strtod (time_start_att_val, &ptr_end))
 
5760
        tmp_d2 = strtod (time_start_att_val, &ptr_end);
 
5761
        if (!(ptr_end && ptr_end[0]==0))
 
5762
//        if (!strtod (time_start_att_val, &ptr_end))
5744
5763
            adios_common_define_attribute (p_new_group,time_start_att_nam,"/",adios_string,time_start_att_val,"");
5745
5764
        else
5746
5765
            adios_common_define_attribute (p_new_group,time_start_att_nam,"/",adios_double,time_start_att_val,"");
5747
5766
        time_stride_att_val = strdup(gettscalefrom1);
5748
5767
        adios_conca_mesh_att_nam(&time_stride_att_nam, name, "time-scale-stride");
5749
5768
        // if this is string
5750
 
        if (!strtod (time_stride_att_val, &ptr_end))
 
5769
        tmp_d2 = strtod (time_stride_att_val, &ptr_end);
 
5770
//        if (!strtod (time_stride_att_val, &ptr_end))
 
5771
        if (!(ptr_end && ptr_end[0]==0))
5751
5772
            adios_common_define_attribute (p_new_group,time_stride_att_nam,"/",adios_string,time_stride_att_val,"");
5752
5773
        else
5753
5774
            adios_common_define_attribute (p_new_group,time_stride_att_nam,"/",adios_double,time_stride_att_val,"");
5754
5775
        time_count_att_val = strdup(gettscalefrom2);
5755
5776
        adios_conca_mesh_att_nam(&time_count_att_nam, name, "time-scale-count");
5756
5777
        // if this is string
5757
 
        if (!strtod (time_count_att_val, &ptr_end))
 
5778
        tmp_d2 = strtod (time_count_att_val, &ptr_end);
 
5779
//        if (!strtod (time_count_att_val, &ptr_end))
 
5780
        if (!(ptr_end && ptr_end[0]==0))
5758
5781
            adios_common_define_attribute (p_new_group,time_count_att_nam,"/",adios_string,time_count_att_val,"");
5759
5782
        else
5760
5783
            adios_common_define_attribute (p_new_group,time_count_att_nam,"/",adios_double,time_count_att_val,"");
5765
5788
        free(gettscalefrom1);
5766
5789
        free(gettscalefrom0);
5767
5790
    }else if (counter == 2) {
 
5791
        double tmp_d2;
5768
5792
        adios_conca_mesh_att_nam(&time_min_att_nam, name, "time-scale-min");
5769
5793
        // if this is string
5770
 
        if (!strtod (time_min_att_val, &ptr_end))
 
5794
        tmp_d2 = strtod (time_min_att_nam, &ptr_end);
 
5795
        if (!(ptr_end && ptr_end[0]==0))
 
5796
//        if (!strtod (time_min_att_val, &ptr_end))
5771
5797
            adios_common_define_attribute (p_new_group,time_min_att_nam,"/",adios_string,time_min_att_val,"");
5772
5798
        else
5773
5799
            adios_common_define_attribute (p_new_group,time_min_att_nam,"/",adios_double,time_min_att_val,"");
5774
5800
        time_max_att_val = strdup(gettscalefrom1);
5775
5801
        adios_conca_mesh_att_nam(&time_max_att_nam, name, "time-scale-max");
5776
5802
        // if this is string
5777
 
        if (!strtod (time_max_att_val, &ptr_end))
 
5803
        tmp_d2 = strtod (time_max_att_nam, &ptr_end);
 
5804
        if (!(ptr_end && ptr_end[0]==0))
 
5805
//        if (!strtod (time_max_att_val, &ptr_end))
5778
5806
            adios_common_define_attribute (p_new_group,time_max_att_nam,"/",adios_string,time_max_att_val,"");
5779
5807
        else
5780
5808
            adios_common_define_attribute (p_new_group,time_max_att_nam,"/",adios_double,time_max_att_val,"");
5783
5811
        free(gettscalefrom1);
5784
5812
        free(gettscalefrom0);
5785
5813
    } else if (counter == 1){
 
5814
        double tmp_d2;
5786
5815
        time_var_att_val = strdup(gettscalefrom0);
5787
 
        if (!strtod (time_var_att_val, &ptr_end)){
 
5816
        tmp_d2 = strtod (time_var_att_val, &ptr_end);
 
5817
        if (!(ptr_end && ptr_end[0]==0))
 
5818
//        if (!strtod (time_var_att_val, &ptr_end))
 
5819
        {
5788
5820
            adios_conca_mesh_att_nam(&time_var_att_nam, name, "time-scale-var");
5789
5821
            adios_common_define_attribute (p_new_group,time_var_att_nam,"/",adios_string,time_var_att_val,"");
5790
5822
        }else{
5804
5836
    return 1;
5805
5837
}
5806
5838
 
 
5839
int adios_common_define_mesh_timeVarying (const char * timevarying, int64_t group_id, const char * name)
 
5840
{
 
5841
    char * mpath = 0;
 
5842
    mpath = malloc(strlen("/adios_schema/")+strlen(name)+strlen("/time-varying")+1);
 
5843
    strcpy (mpath, "/adios_schema/");
 
5844
    strcat (mpath, name);
 
5845
    strcat (mpath, "/time-varying");
 
5846
    adios_common_define_attribute (group_id, mpath, "", adios_string, timevarying, "");
 
5847
    free (mpath);
 
5848
    return 0; 
 
5849
}
 
5850
 
5807
5851
// Parse mesh time steps (integers = number of times vars are written)
5808
 
int adios_define_mesh_timeSteps (const char * timesteps
5809
 
        ,struct adios_group_struct * new_group
5810
 
        ,const char * name
5811
 
        )
 
5852
int adios_common_define_mesh_timeSteps (const char * timesteps,
 
5853
                                        struct adios_group_struct * new_group,
 
5854
                                        const char * name
 
5855
                                       )
5812
5856
{
5813
5857
    char * c;                      // comma location
5814
5858
    char * d1;                     // save of strdup
5815
 
    int64_t      p_new_group = (int64_t) new_group;
 
5859
    int64_t p_new_group = (int64_t) new_group;
5816
5860
    char * gettstepsfrom0 = 0;     // tstep attribute xml value
5817
5861
    char * gettstepsfrom1 = 0;     // tstep attribute xml value
5818
5862
    char * gettstepsfrom2 = 0;     // tstep attribute xml value
5835
5879
    // 2. start/stride/count 3 components
5836
5880
    // 3. min/max range where this mesh is used
5837
5881
    // 4. An ADIOS var = time could be a list of int stored by user
5838
 
    char counterstr[5] = {0,0,0,0,0}; // used to create tsteps attributes
5839
5882
 
5840
5883
    /* We do not fail if this is not given as variables all have nsteps
5841
5884
       in ADIOS_inq_var = # of times the var was written
5842
5885
       */
5843
 
    if (!timesteps){
5844
 
        printf("time-steps for mesh %s attribute not provided.\n", name);
 
5886
    if (!timesteps || !strcmp(timesteps,"")){
 
5887
//        printf("time-steps for mesh %s attribute not provided.\n", name);
5845
5888
        return 1;
5846
5889
    }
5847
5890
 
5854
5897
        struct adios_var_struct * var = 0;
5855
5898
        if (adios_int_is_var (c))
5856
5899
        {
5857
 
            var =
5858
 
                adios_find_var_by_name (new_group, c);
 
5900
            var = adios_find_var_by_name (new_group, c);
5859
5901
            if (!var)
5860
5902
            {
5861
5903
                log_warn ("config.xml: invalid variable %s\n"
5862
 
                        "for dimensions of mesh: %s\n"
5863
 
                        ,c
5864
 
                        ,name
5865
 
                        );
 
5904
                          "for dimensions of mesh: %s\n",
 
5905
                          c, name);
5866
5906
                free (d1);
5867
5907
 
5868
5908
                return 0;
5970
6010
}
5971
6011
 
5972
6012
// defining a uniform mesh
5973
 
int adios_define_mesh_uniform (char * dimensions, char * origin, char * spacing, char * maximum, struct adios_group_struct * new_group ,const char * name)
5974
 
{
5975
 
    if (dimensions)
5976
 
    {
5977
 
        if (!adios_define_mesh_uniform_dimensions (dimensions, new_group, name))
5978
 
            return 0;
5979
 
    }else{
5980
 
        log_warn ("config.xml: value attribute on "
5981
 
                "dimensions required (%s)\n"
5982
 
                ,name
5983
 
                );
5984
 
        return 0;
5985
 
    }
5986
 
 
5987
 
    if (origin)
5988
 
    {
5989
 
        if (!adios_define_mesh_uniform_origins (origin, new_group, name))
5990
 
            return 0;
5991
 
    }else{
5992
 
        log_warn ("config.xml: value attribute on "
5993
 
                "origin required (%s)\n"
5994
 
                ,name
5995
 
                );
5996
 
        return 0;
5997
 
    }
5998
 
    if (spacing)
5999
 
    {
6000
 
        if (!adios_define_mesh_uniform_spacings (spacing, new_group, name))
6001
 
            return 0;
6002
 
    }else{
6003
 
        log_warn ("config.xml: value attribute on "
6004
 
                "spacing required (%s)\n"
6005
 
                ,name
6006
 
                );
6007
 
        return 0;
6008
 
    }
6009
 
 
6010
 
    if (maximum)
6011
 
    {
6012
 
        if (!adios_define_mesh_uniform_maximums (maximum, new_group, name))
6013
 
            return 0;
6014
 
    }else{
6015
 
        log_warn ("config.xml: value attribute on "
6016
 
                "max required (%s)\n"
6017
 
                ,name
6018
 
                );
6019
 
        return 0;
6020
 
    }
6021
 
 
6022
 
    return 1;
 
6013
int adios_common_define_mesh_uniform (char * dimensions, 
 
6014
                                      char * origin, 
 
6015
                                      char * spacing, 
 
6016
                                      char * maximum, 
 
6017
                                      char * nspace,
 
6018
//                                      struct adios_group_struct * new_group,
 
6019
                                      const char * name,
 
6020
                                      int64_t group_id
 
6021
                                     )
 
6022
{   
 
6023
    struct adios_group_struct * new_group = (struct adios_group_struct *) group_id;
 
6024
    char * mpath = 0;
 
6025
    mpath = malloc(strlen("/adios_schema/")+strlen(name)+strlen("/type")+1);
 
6026
    strcpy (mpath, "/adios_schema/");
 
6027
    strcat (mpath, name);
 
6028
    strcat (mpath, "/type");
 
6029
    adios_common_define_attribute (group_id, mpath, "", adios_string, "uniform", "");
 
6030
 
 
6031
    if (!adios_define_mesh_uniform_dimensions (dimensions, new_group, name))
 
6032
        return 1;
 
6033
 
 
6034
    adios_define_mesh_uniform_origins (origin, new_group, name);
 
6035
    
 
6036
    adios_define_mesh_uniform_spacings (spacing, new_group, name);
 
6037
 
 
6038
    adios_define_mesh_uniform_maximums (maximum, new_group, name);
 
6039
 
 
6040
    adios_define_mesh_nspace (nspace, new_group, name);
 
6041
 
 
6042
    free (mpath);   
 
6043
    return 0;
6023
6044
}
6024
6045
 
6025
 
int adios_define_mesh_rectilinear (char * dimensions, char * coordinates
6026
 
        ,struct adios_group_struct * new_group
6027
 
        ,const char * name
6028
 
        )
 
6046
// defining a rectilinear mesh
 
6047
int adios_common_define_mesh_rectilinear (char * dimensions, 
 
6048
                                          char * coordinates,
 
6049
//                                          struct adios_group_struct * new_group,
 
6050
                                          char * nspace,
 
6051
                                          const char * name,
 
6052
                                          int64_t group_id
 
6053
                                         )
6029
6054
{
6030
 
    if (dimensions)
6031
 
    {
6032
 
        if (!adios_define_mesh_rectilinear_dimensions (dimensions, new_group, name))
6033
 
            return 0;
6034
 
    }else{
6035
 
        log_warn ("config.xml: value attribute on "
6036
 
                "dimensions required (%s)\n"
6037
 
                ,name
6038
 
                );
6039
 
        return 0;
6040
 
    }
 
6055
    struct adios_group_struct * new_group = (struct adios_group_struct *) group_id;
 
6056
    char * mpath = 0;
 
6057
    mpath = malloc(strlen("/adios_schema/")+strlen(name)+strlen("/type")+1);
 
6058
    strcpy (mpath, "/adios_schema/");
 
6059
    strcat (mpath, name);
 
6060
    strcat (mpath, "/type");
 
6061
    adios_common_define_attribute (group_id, mpath, "", adios_string, "rectilinear", "");
 
6062
 
 
6063
    if (!adios_define_mesh_rectilinear_dimensions (dimensions, new_group, name))
 
6064
        return 1;
6041
6065
 
6042
6066
    // Determine if it is the multi-var or single-var case
6043
 
    if (coordinates)
6044
 
    {
6045
 
        char *p;
6046
 
        // If we do not find "," in the coordinates
6047
 
        if (!(p = strstr(coordinates, ","))){
6048
 
            if (!adios_define_mesh_rectilinear_coordinatesSingleVar (coordinates, new_group, name))
6049
 
                return 0;
6050
 
        }else{
6051
 
            if (!adios_define_mesh_rectilinear_coordinatesMultiVar (coordinates, new_group, name))
6052
 
                return 0;
6053
 
        }
6054
 
    }else{
6055
 
        log_warn ("config.xml: value attribute on "
6056
 
                "coordinates required for rectilinear mesh: (%s)\n"
6057
 
                ,name
6058
 
                );
6059
 
        return 0;
6060
 
    }
6061
 
    return 1;
 
6067
    char *p;
 
6068
    // If we do not find "," in the coordinates
 
6069
    if (!(p = strstr(coordinates, ",")))
 
6070
    {
 
6071
        if (!adios_define_mesh_rectilinear_coordinatesSingleVar (coordinates, new_group, name))
 
6072
            return 1;
 
6073
    }
 
6074
    else
 
6075
    {
 
6076
        if (!adios_define_mesh_rectilinear_coordinatesMultiVar (coordinates, new_group, name))
 
6077
            return 1;
 
6078
    }
 
6079
 
 
6080
    adios_define_mesh_nspace (nspace, new_group, name);
 
6081
 
 
6082
    free (mpath);
 
6083
    return 0;
6062
6084
}
6063
6085
 
6064
 
int adios_define_mesh_structured(char * dimensions, char * nspace
6065
 
        , char * points
6066
 
        ,struct adios_group_struct * new_group
6067
 
        , char * name){
 
6086
// defining a structured mesh
 
6087
int adios_common_define_mesh_structured (char * dimensions,
 
6088
                                         char * nspace,
 
6089
                                         char * points,
 
6090
//                                         struct adios_group_struct * new_group,
 
6091
                                         const char * name,
 
6092
                                         int64_t group_id
 
6093
                                        )
 
6094
{
 
6095
    struct adios_group_struct * new_group = (struct adios_group_struct *) group_id;
 
6096
    char * mpath = 0;
 
6097
    mpath = malloc(strlen("/adios_schema/")+strlen(name)+strlen("/type")+1);
 
6098
    strcpy (mpath, "/adios_schema/");
 
6099
    strcat (mpath, name);
 
6100
    strcat (mpath, "/type");
 
6101
    adios_common_define_attribute (group_id, mpath, "", adios_string, "structured", "");
 
6102
 
6068
6103
    if (dimensions){
6069
6104
        if (!adios_define_mesh_structured_dimensions (dimensions, new_group, name))
6070
6105
            return 0;
6071
6106
    }else{
6072
6107
        log_warn ("config.xml: value attribute on "
6073
 
                "dimensions required (%s)\n"
6074
 
                ,name
6075
 
                );
 
6108
                  "dimensions required (%s)\n", name);
6076
6109
 
6077
6110
        return 0;
6078
6111
    }
6079
6112
 
6080
6113
    if (nspace){
6081
 
        if (!adios_define_mesh_structured_nspace (nspace, new_group, name))
 
6114
//        if (!adios_define_mesh_structured_nspace (nspace, new_group, name))
 
6115
          if (!adios_define_mesh_nspace (nspace, new_group, name))
6082
6116
            return 0;
6083
6117
    }
6084
6118
    if (points){
6092
6126
                return 0;
6093
6127
        }
6094
6128
    }else{
6095
 
        log_warn ("config.xml: value on"
6096
 
                "points required for mesh type=structured (%s)\n"
6097
 
                ,name
6098
 
                );
 
6129
        log_warn ("config.xml: value on "
 
6130
                  "points required for mesh type=structured (%s)\n", name);
6099
6131
        return 0;
6100
6132
    }
6101
 
 
 
6133
    free (mpath);
6102
6134
    return 1;
6103
6135
}
6104
6136
 
6105
 
int adios_define_mesh_unstructured(char *nspace
6106
 
        , char *npoints, char *points
6107
 
        , char * data, char * count, char * type
6108
 
        , struct adios_group_struct * new_group
6109
 
        , const char * name)
 
6137
// defining a unstructured mesh
 
6138
int adios_common_define_mesh_unstructured (char * points,
 
6139
                                           char * data, 
 
6140
                                           char * count, 
 
6141
                                           char * type,
 
6142
                                           char * nspace,
 
6143
                                           char * npoints,
 
6144
                                           const char * name,
 
6145
                                           int64_t group_id)
6110
6146
{
6111
 
    int saw_cell_set = 0;
 
6147
    struct adios_group_struct * new_group = (struct adios_group_struct *) group_id;
 
6148
    char * mpath = 0;
 
6149
    mpath = malloc(strlen("/adios_schema/")+strlen(name)+strlen("/type")+1);
 
6150
    strcpy (mpath, "/adios_schema/");
 
6151
    strcat (mpath, name);
 
6152
    strcat (mpath, "/type");
 
6153
    adios_common_define_attribute (group_id, mpath, "", adios_string, "unstructured", "");
6112
6154
    if (nspace)
6113
6155
    {
6114
 
        if (!adios_define_mesh_unstructured_nspace (nspace, new_group, name))
 
6156
//        if (!adios_define_mesh_unstructured_nspace (nspace, new_group, name))
 
6157
            if (!adios_define_mesh_nspace (nspace, new_group, name))
6115
6158
            return 0;
6116
6159
    }
6117
6160
    if (npoints)
6131
6174
                return 0;
6132
6175
        }
6133
6176
    }else{
6134
 
        log_warn ("config.xml: value on"
6135
 
                "points required for mesh type=structured (%s)\n"
6136
 
                ,name
6137
 
                );
 
6177
        log_warn ("config.xml: value on "
 
6178
                  "points required for mesh type=structured (%s)\n", name);
6138
6179
        return 0;
6139
6180
    }
6140
6181
    if (!data){
6141
6182
        log_warn ("config.xml: data attribute on "
6142
 
                "uniform-cells required (%s)\n"
6143
 
                ,name
6144
 
                );
 
6183
                  "uniform-cells required (%s)\n", name);
6145
6184
        return 0;
6146
6185
    }
6147
6186
    if (!count)
6148
6187
    {
6149
6188
        log_warn ("config.xml: count attribute on "
6150
 
                "uniform-cells required (%s)\n"
6151
 
                ,name
6152
 
                );
 
6189
                  "uniform-cells required (%s)\n", name);
6153
6190
        return 0;
6154
6191
    }
6155
6192
    if (!type)
6156
6193
    {
6157
6194
        log_warn ("config.xml: type attribute on "
6158
 
                "uniform-cells required (%s)\n"
6159
 
                ,name
6160
 
                );
 
6195
                  "uniform-cells required (%s)\n", name);
6161
6196
        return 0;
6162
6197
    }
6163
6198
    char *pt;
6164
6199
    // If we do find "," in data (uniform cell case)
6165
6200
    if (!(pt = strstr(data, ","))){
6166
 
        if (pt = strstr(count,",")){
 
6201
        if ( (pt = strstr(count,",")) ){
6167
6202
            log_warn ("count value on uniform-cells (check data value)"
6168
 
                    " should not contain ',' (%s)\n",name);
 
6203
                      " should not contain ',' (%s)\n",name);
6169
6204
            return 0;
6170
6205
        }
6171
 
        if (pt = strstr(type,",")){
 
6206
        if ( (pt = strstr(type,",")) ){
6172
6207
            log_warn ("type value on uniform-cells (check data value)"
6173
 
                    " should not contain ',' (%s)\n", name);
 
6208
                      " should not contain ',' (%s)\n", name);
6174
6209
            return 0;
6175
6210
        }
6176
6211
        if (!adios_define_mesh_unstructured_uniformCells (count, data, type
6183
6218
    }else{
6184
6219
        if (!(pt = strstr(count,","))){
6185
6220
            log_warn ("count value on mixed-cells (check data value)"
6186
 
                    " should contain ',' (%s)\n",name);
 
6221
                      " should contain ',' (%s)\n", name);
6187
6222
            return 0;
6188
6223
        }
6189
6224
        if (!(pt = strstr(type,","))){
6190
6225
            log_warn ("type value on mixed-cells (check data value)"
6191
 
                    " should contain ',' (%s)\n", name);
 
6226
                      " should contain ',' (%s)\n", name);
6192
6227
            return 0;
6193
6228
        }
6194
6229
        if (!adios_define_mesh_unstructured_mixedCells (count, data, type
6195
6230
                    , new_group, name))
6196
6231
            return 0;
6197
6232
    }
6198
 
 
6199
6233
    return 1;
6200
6234
}
6201
6235
 
6293
6327
    if (flag == adios_flag_no)
6294
6328
    {
6295
6329
        log_warn ("config.xml: unique mesh names required; "
6296
 
                "second mesh: %s will be ignored.\n"
6297
 
                ,name
6298
 
                );
 
6330
                  "second mesh: %s will be ignored.\n", name);
6299
6331
        free(m);
6300
6332
        m = 0;
6301
6333
    } else {
6307
6339
 
6308
6340
// Define time steps, scale and formatting
6309
6341
// Parse var time steps (integers = number of times vars are written)
6310
 
int adios_define_var_timesteps (const char * timesteps
6311
 
        ,struct adios_group_struct * new_group
6312
 
        ,const char * name
6313
 
        ,const char * path
6314
 
        )
 
6342
int adios_common_define_var_timesteps (const char * timesteps,
 
6343
                                       struct adios_group_struct * new_group,
 
6344
                                       const char * name,
 
6345
                                       const char * path
 
6346
                                      )
6315
6347
{
6316
6348
    char * c;                      // comma location
6317
6349
    char * d1;                     // save of strdup
6318
 
    int64_t      p_new_group = (int64_t) new_group;
 
6350
    int64_t p_new_group = (int64_t) new_group;
6319
6351
    char * gettstepsfrom0 = 0;     // tstep attribute xml value
6320
6352
    char * gettstepsfrom1 = 0;     // tstep attribute xml value
6321
6353
    char * gettstepsfrom2 = 0;     // tstep attribute xml value
6338
6370
    // 2. start/stride/count 3 components - indices of the mesh time steps
6339
6371
    // 3. min/max range of the mesh time step
6340
6372
    // 4. An ADIOS var = time could be a list of int stored by user
6341
 
    char counterstr[5] = {0,0,0,0,0}; // used to create tsteps attributes
6342
6373
 
6343
6374
    /* We do not fail if this is not given as variables all have nsteps
6344
6375
       in ADIOS_inq_var = # of times the var was written
6345
6376
       */
6346
 
    if (!timesteps){
 
6377
    if (!timesteps || !strcmp(timesteps,"")){
6347
6378
        return 1;
6348
6379
    }
6349
6380
 
6356
6387
        struct adios_var_struct * var = 0;
6357
6388
        if (adios_int_is_var (c))
6358
6389
        {
6359
 
            var =
6360
 
                adios_find_var_by_name (new_group, c);
 
6390
            var = adios_find_var_by_name (new_group, c);
6361
6391
            if (!var)
6362
6392
            {
6363
6393
                log_warn ("config.xml: invalid variable %s\n"
6364
 
                        "for time-steps of var: %s\n"
6365
 
                        ,c
6366
 
                        ,name
6367
 
                        );
 
6394
                          "for time-steps of var: %s\n",
 
6395
                          c, name);
6368
6396
                free (d1);
6369
6397
 
6370
6398
                return 0;
6472
6500
}
6473
6501
 
6474
6502
// Parse var time series format (real time tracking, not integers)
6475
 
int adios_define_var_timeseriesformat (const char * timeseries
6476
 
        ,struct adios_group_struct * new_group
6477
 
        ,const char * name
6478
 
        ,const char * path
6479
 
        )
 
6503
int adios_common_define_var_timeseriesformat (const char * timeseries,
 
6504
                                              struct adios_group_struct * new_group,
 
6505
                                              const char * name,
 
6506
                                              const char * path
 
6507
                                             )
6480
6508
{
6481
6509
    char * d1;                     // save of strdup
6482
 
    int64_t      p_new_group = (int64_t) new_group;
 
6510
    int64_t p_new_group = (int64_t) new_group;
6483
6511
    char * format_att_nam = 0;     // extension format .xxxx att name
6484
6512
    char * format_att_val = 0;     // extension format att value
6485
6513
 
6487
6515
    // The number indicates how to write the time steps. Ex: 4 ==>
6488
6516
    // varname.XXXX.png where XXXX is the time step padded with 0s
6489
6517
    // We do not fail if this is not given as variables all have nsteps
6490
 
    if (!timeseries){
 
6518
    if (!timeseries || !strcmp(timeseries,"")){
6491
6519
        return 1;
6492
6520
    }
6493
6521
 
6494
6522
    char * ptr_end;
6495
6523
    d1 = strdup (timeseries);
6496
 
    if (strtod(d1, &ptr_end)){
 
6524
    double tmp_d2;
 
6525
    tmp_d2 = strtod (d1, &ptr_end);
 
6526
//    if (strtod(d1, &ptr_end))
 
6527
    if ( !(ptr_end && ptr_end[0]==0))
 
6528
    {
6497
6529
        adios_conca_mesh_att_nam(&format_att_nam, name, "time-series-format");
6498
6530
        adios_common_define_attribute (p_new_group,format_att_nam,path,adios_string,d1,"");
6499
6531
        free(format_att_val);
6503
6535
}
6504
6536
 
6505
6537
// Parse var time scale (real time tracking, not integers)
6506
 
int adios_define_var_timescale (const char * timescale
6507
 
        ,struct adios_group_struct * new_group
6508
 
        ,const char * name
6509
 
        ,const char * path
6510
 
        )
 
6538
int adios_common_define_var_timescale (const char * timescale,
 
6539
                                       struct adios_group_struct * new_group,
 
6540
                                       const char * name,
 
6541
                                       const char * path
 
6542
                                      )
6511
6543
{
6512
6544
    char * c;                      // comma location
6513
6545
    char * d1;                     // save of strdup
6514
 
    int64_t      p_new_group = (int64_t) new_group;
 
6546
    int64_t p_new_group = (int64_t) new_group;
6515
6547
    char * gettscalefrom0 = 0;     // scale attribute xml value
6516
6548
    char * gettscalefrom1 = 0;     // scale attribute xml value
6517
6549
    char * gettscalefrom2 = 0;     // scale attribute xml value
6534
6566
    // 2. start/stride/count 3 components - multiple of the mesh time steps
6535
6567
    // 3. min/max range where this var is used - a range of the mesh time steps
6536
6568
    // 4. An ADIOS var = time could be a list of int stored by user
6537
 
    char counterstr[5] = {0,0,0,0,0}; // used to create scale attributes
6538
6569
 
6539
6570
 
6540
6571
    /* We do not fail if this is not given as variables all have nsteps
6541
6572
       in ADIOS_inq_var = # of times the var was written
6542
6573
       */
6543
 
    if (!timescale){
 
6574
    if (!timescale || !strcmp(timescale,"")){
6544
6575
        return 1;
6545
6576
    }
6546
6577
 
6547
6578
    d1 = strdup (timescale);
 
6579
 
6548
6580
    char * ptr_end;
6549
6581
    c = strtok (d1, ",");
6550
6582
 
6552
6584
    {
6553
6585
        struct adios_var_struct * var = 0;
6554
6586
        //if (adios_int_is_num (c))
6555
 
        if (!strtod (c,&ptr_end))
 
6587
        double tmp_d1;
 
6588
        tmp_d1 = strtod (c,&ptr_end);
 
6589
        if (!(ptr_end && ptr_end[0]==0))
6556
6590
        {
6557
 
            var =
6558
 
                adios_find_var_by_name (new_group, c);
 
6591
            var = adios_find_var_by_name (new_group, c);
6559
6592
            if (!var)
6560
6593
            {
6561
6594
                log_warn ("config.xml: invalid variable %s\n"
6562
 
                        "for attribute of var: %s\n"
6563
 
                        ,c
6564
 
                        ,name
6565
 
                        );
 
6595
                          "for attribute of var: %s\n",
 
6596
                          c, name);
6566
6597
                free (d1);
6567
6598
 
6568
6599
                return 0;
6601
6632
    }
6602
6633
 
6603
6634
    if (counter == 3){
 
6635
        double tmp_d2;
6604
6636
        time_start_att_val = strdup(gettscalefrom0);
6605
6637
        conca_var_att_nam(&time_start_att_nam, name, "time-scale-start");
 
6638
        tmp_d2 = strtod (time_start_att_val, &ptr_end);
6606
6639
        // if this is string
6607
 
        if (!strtod (time_start_att_val, &ptr_end))
 
6640
        if ( !(ptr_end && ptr_end[0]==0))
 
6641
//        if (!strtod (time_start_att_val, &ptr_end))
6608
6642
            adios_common_define_attribute (p_new_group,time_start_att_nam,path,adios_string,time_start_att_val,"");
6609
6643
        else
6610
6644
            adios_common_define_attribute (p_new_group,time_start_att_nam,path,adios_double,time_start_att_val,"");
6611
6645
        time_stride_att_val = strdup(gettscalefrom1);
6612
6646
        conca_var_att_nam(&time_stride_att_nam, name, "time-scale-stride");
6613
6647
        // if this is string
6614
 
        if (!strtod (time_stride_att_val, &ptr_end))
 
6648
        tmp_d2 = strtod (time_stride_att_nam, &ptr_end);
 
6649
        if ( !(ptr_end && ptr_end[0]==0))
 
6650
//        if (!strtod (time_stride_att_val, &ptr_end))
6615
6651
            adios_common_define_attribute (p_new_group,time_stride_att_nam,path,adios_string,time_stride_att_val,"");
6616
6652
        else
6617
6653
            adios_common_define_attribute (p_new_group,time_stride_att_nam,path,adios_double,time_stride_att_val,"");
6618
6654
        time_count_att_val = strdup(gettscalefrom2);
6619
6655
        conca_var_att_nam(&time_count_att_nam, name, "time-scale-count");
6620
6656
        // if this is string
6621
 
        if (!strtod (time_count_att_val, &ptr_end))
 
6657
        tmp_d2 = strtod (time_count_att_nam, &ptr_end);
 
6658
        if ( !(ptr_end && ptr_end[0]==0))
 
6659
//        if (!strtod (time_count_att_val, &ptr_end))
6622
6660
            adios_common_define_attribute (p_new_group,time_count_att_nam,path,adios_string,time_count_att_val,"");
6623
6661
        else
6624
6662
            adios_common_define_attribute (p_new_group,time_count_att_nam,path,adios_double,time_count_att_val,"");
6629
6667
        free(gettscalefrom1);
6630
6668
        free(gettscalefrom0);
6631
6669
    }else if (counter == 2) {
 
6670
        double tmp_d2;
6632
6671
        time_min_att_val = strdup(gettscalefrom0);
6633
6672
        conca_var_att_nam(&time_min_att_nam, name, "time-scale-min");
6634
6673
        // if this is string
6635
 
        if (!strtod (time_min_att_val, &ptr_end))
 
6674
        tmp_d2 = strtod (time_min_att_val, &ptr_end);
 
6675
        if ( !(ptr_end && ptr_end[0]==0))
 
6676
//        if (!strtod (time_min_att_val, &ptr_end))
6636
6677
            adios_common_define_attribute (p_new_group,time_min_att_nam,path,adios_string,time_min_att_val,"");
6637
6678
        else
6638
6679
            adios_common_define_attribute (p_new_group,time_min_att_nam,path,adios_double,time_min_att_val,"");
6639
6680
        time_max_att_val = strdup(gettscalefrom1);
6640
6681
        conca_var_att_nam(&time_max_att_nam, name, "time-scale-max");
6641
6682
        // if this is string
6642
 
        if (!strtod (time_max_att_val, &ptr_end))
 
6683
        tmp_d2 = strtod (time_max_att_nam, &ptr_end);
 
6684
        if ( !(ptr_end && ptr_end[0]==0))
 
6685
//        if (!strtod (time_max_att_val, &ptr_end))
6643
6686
            adios_common_define_attribute (p_new_group,time_max_att_nam,path,adios_string,time_max_att_val,"");
6644
6687
        else
6645
6688
            adios_common_define_attribute (p_new_group,time_max_att_nam,path,adios_double,time_max_att_val,"");
6648
6691
        free(gettscalefrom1);
6649
6692
        free(gettscalefrom0);
6650
6693
    } else if (counter == 1){
 
6694
        double tmp_d2;
6651
6695
        time_var_att_val = strdup(gettscalefrom0);
6652
 
        if (!strtod (time_var_att_val, &ptr_end)){
 
6696
        tmp_d2 = strtod (time_var_att_val, &ptr_end);
 
6697
        if ( !(ptr_end && ptr_end[0]==0))
 
6698
//        if (!strtod (time_var_att_val, &ptr_end))
 
6699
        {
6653
6700
            conca_var_att_nam(&time_var_att_nam, name, "time-scale-var");
6654
6701
            adios_common_define_attribute (p_new_group,time_var_att_nam,path,adios_string,time_var_att_val,"");
6655
6702
        }else{
6670
6717
}
6671
6718
 
6672
6719
// Parse var hyper slab: lines or planes from a higher dimension mesh
6673
 
int adios_define_var_hyperslab ( const char * hyperslab,
6674
 
        struct adios_group_struct * new_group,
6675
 
        const char * name,
6676
 
        const char * path)
 
6720
int adios_common_define_var_hyperslab ( const char * hyperslab,
 
6721
                                        struct adios_group_struct * new_group,
 
6722
                                        const char * name,
 
6723
                                        const char * path)
6677
6724
{
6678
6725
    char * c;                      // comma location
6679
6726
    char * d1;                     // save of strdup
6680
 
    int64_t      p_new_group = (int64_t) new_group;
 
6727
    int64_t p_new_group = (int64_t) new_group;
6681
6728
    char * gethslabfrom0 = 0;       // hslab attribute xml value
6682
6729
    char * gethslabfrom1 = 0;       // hslab attribute xml value
6683
6730
    char * gethslabfrom2 = 0;       // hslab attribute xml value
6684
 
    char * hslab_var_att_nam = 0;   // hslab attribute name for var or num
6685
6731
    char * hslab_start_att_nam = 0; // hslab attribute name for start
6686
6732
    char * hslab_stride_att_nam = 0;// hslab attribute name for stride
6687
6733
    char * hslab_count_att_nam = 0; // hslab attribute name for count
6688
6734
    char * hslab_max_att_nam = 0;   // hslab attribute name for max
6689
6735
    char * hslab_min_att_nam = 0;   // hslab attribute name for min
6690
6736
    char * hslab_single_att_nam = 0;// hslab attribute name for min
6691
 
    char * hslab_var_att_val = 0;   // hslab attribute value for var or num
6692
6737
    char * hslab_start_att_val = 0; // hslab attribute value for start
6693
6738
    char * hslab_stride_att_val = 0;// hslab attribute value for stride
6694
6739
    char * hslab_count_att_val = 0; // hslab attribute value for count
6702
6747
    // 2. min/max range of the mesh dimensions
6703
6748
    // 3. single value
6704
6749
    //    single value of ":" means there is an extra dimension to process
6705
 
    char counterstr[5] = {0,0,0,0,0}; // used to create tsteps attributes
6706
6750
 
6707
6751
    /* We do not fail if this is not given as variables all have nsteps
6708
6752
       in ADIOS_inq_var = # of times the var was written
6709
6753
       */
6710
 
    if (!hyperslab){
 
6754
    if (!hyperslab || !strcmp(hyperslab,"")){
6711
6755
        return 1;
6712
6756
    }
6713
6757
 
6776
6820
 
6777
6821
}
6778
6822
 
6779
 
int adios_define_mesh_uniform_dimensions (const char * dimensions
6780
 
        ,struct adios_group_struct * new_group
6781
 
        ,const char * name
6782
 
        )
 
6823
int adios_define_mesh_nspace (const char * nspace,
 
6824
                              struct adios_group_struct * new_group,
 
6825
                              const char * name
 
6826
                             )
 
6827
{
 
6828
    char * d1; // save of strdup
 
6829
    int64_t p_new_group = (int64_t) new_group;
 
6830
    char * nsp_att_nam = 0; // nspace attribute name
 
6831
 
 
6832
    if (!nspace || !strcmp(nspace, ""))
 
6833
    {
 
6834
//        log_warn ("config.xml: nspace value (optional) is not provided"
 
6835
//                  "for uniform mesh: %s\n", name);
 
6836
        return 0;
 
6837
    }
 
6838
    d1 = strdup (nspace);
 
6839
 
 
6840
    adios_conca_mesh_att_nam(&nsp_att_nam, name, "nspace");
 
6841
    adios_common_define_attribute (p_new_group,nsp_att_nam,"/",adios_string,nspace,"");
 
6842
    free (nsp_att_nam);
 
6843
    free (d1);
 
6844
 
 
6845
    return 1;
 
6846
}
 
6847
 
 
6848
int adios_define_mesh_uniform_dimensions (const char * dimensions,
 
6849
                                          struct adios_group_struct * new_group,
 
6850
                                          const char * name
 
6851
                                         )
6783
6852
{
6784
6853
    char * c;  // comma location
6785
6854
    char * d1; // save of strdup
6786
 
    int64_t      p_new_group = (int64_t) new_group;
 
6855
    int64_t p_new_group = (int64_t) new_group;
6787
6856
    char * dim_att_nam = 0; // dimensions attribute name
6788
 
    char * getdimsfrom = 0; // dimensions attribute that is a var
6789
6857
    int counter = 0;        // used to create dimX attributes
6790
6858
    char counterstr[5] = {0,0,0,0,0}; // used to create dimX attributes
6791
6859
 
6792
 
    if (!dimensions)
 
6860
    if (!dimensions || !strcmp(dimensions,""))
6793
6861
    {
6794
 
        log_warn ("config.xml: dimensions value required for"
6795
 
                "uniform mesh: %s\n"
6796
 
                ,name
6797
 
                );
6798
 
 
 
6862
        log_warn ("config.xml: dimensions value required for "
 
6863
                  "uniform mesh: %s\n", name);
6799
6864
        return 0;
6800
6865
    }
6801
6866
 
6830
6895
    return 1;
6831
6896
}
6832
6897
 
6833
 
int adios_define_mesh_uniform_maximums (const char * maximum
6834
 
        ,struct adios_group_struct * new_group
6835
 
        ,const char * name
6836
 
        )
 
6898
int adios_define_mesh_uniform_maximums (const char * maximum,
 
6899
                                        struct adios_group_struct * new_group,
 
6900
                                        const char * name
 
6901
                                       )
6837
6902
{
6838
6903
    char * c;  // comma location
6839
6904
    char * d1; // save of strdup
6840
 
    int64_t      p_new_group = (int64_t) new_group;
 
6905
    int64_t p_new_group = (int64_t) new_group;
6841
6906
    char * max_att_nam = 0; // maxima attribute name
6842
 
    char * getmaxafrom = 0; // maxima attribute name that is a var
6843
6907
    int counter = 0;        // used to create maxX attributes
6844
6908
    char counterstr[5] = {0,0,0,0,0}; // used to create maxX attributes
6845
6909
 
6846
 
    if (!maximum)
 
6910
    if (!maximum || !strcmp(maximum,""))
6847
6911
    {
6848
 
        log_warn ("config.xml: maximum value required"
6849
 
                "for uniform mesh: %s\n"
6850
 
                ,name
6851
 
                );
6852
 
 
 
6912
//        log_warn ("config.xml: maximum value (optional) is not provided"
 
6913
//                  "for uniform mesh: %s\n",
 
6914
//                  name);
6853
6915
        return 0;
6854
6916
    }
6855
6917
 
6881
6943
    return 1;
6882
6944
}
6883
6945
 
6884
 
int adios_define_mesh_uniform_origins (const char * origin
6885
 
        ,struct adios_group_struct * new_group
6886
 
        ,const char * name
6887
 
        )
 
6946
int adios_define_mesh_uniform_origins (const char * origin,
 
6947
                                       struct adios_group_struct * new_group,
 
6948
                                       const char * name
 
6949
                                      )
6888
6950
{
6889
6951
    char * c;  // comma location
6890
6952
    char * d1; // save of strdup
6891
 
    struct adios_mesh_item_list_struct * item = 0;
6892
 
    int64_t      p_new_group = (int64_t) new_group;
 
6953
    int64_t p_new_group = (int64_t) new_group;
6893
6954
    char * org_att_nam = 0; // origins attribute name
6894
 
    char * getorgsfrom = 0; // origins attribute name that is a var
6895
6955
    int counter = 0;        // used to create orgX attributes
6896
6956
    char counterstr[5] = {0,0,0,0,0}; // used to create orgX attributes
6897
6957
 
6898
 
    if (!origin)
 
6958
    if (!origin || !strcmp(origin,""))
6899
6959
    {
6900
 
        log_warn ("config.xml: origin value required "
6901
 
                "for uniform mesh: %s\n"
6902
 
                ,name
6903
 
                );
6904
 
 
 
6960
//        log_warn ("config.xml: origin value (optional) not provided "
 
6961
//                  "for uniform mesh: %s\n",
 
6962
//                  name);
6905
6963
        return 0;
6906
6964
    }
6907
6965
 
6933
6991
    return 1;
6934
6992
}
6935
6993
 
6936
 
int adios_define_mesh_uniform_spacings (const char * spacing
6937
 
        ,struct adios_group_struct * new_group
6938
 
        ,const char * name
6939
 
        )
 
6994
int adios_define_mesh_uniform_spacings (const char * spacing,
 
6995
                                        struct adios_group_struct * new_group,
 
6996
                                        const char * name
 
6997
                                       )
6940
6998
{
6941
6999
    char * c;  // comma location
6942
7000
    char * d1; // save of strdup
6943
 
    int64_t      p_new_group = (int64_t) new_group;
 
7001
    int64_t p_new_group = (int64_t) new_group;
6944
7002
    char * spa_att_nam = 0; // spacings attribute name
6945
 
    char * getspasfrom = 0; // spacings attribute name that is a var
6946
7003
    int counter = 0;        // used to create spaX attributes
6947
7004
    char counterstr[5] = {0,0,0,0,0}; // used to create spaX attributes if (!spacing)
6948
7005
 
6949
 
    if (!spacing)
 
7006
    if (!spacing || !strcmp(spacing,""))
6950
7007
    {
6951
 
        log_warn ("config.xml: mesh uniform spacing value "
6952
 
                "required for mesh: %s\n"
6953
 
                ,name
6954
 
                );
 
7008
//        log_warn ("config.xml: spacing value (optional) not provided "
 
7009
//                  "for uniform mesh: %s\n",
 
7010
//                  name);
6955
7011
        return 0;
6956
7012
    }
6957
7013
 
6978
7034
    adios_conca_mesh_att_nam(&spas, name, "spacings-num");
6979
7035
    adios_common_define_attribute (p_new_group,spas,"/",adios_integer,counterstr,"");
6980
7036
    free (spas);
6981
 
 
6982
7037
    free (d1);
6983
7038
 
6984
7039
    return 1;
6985
7040
}
6986
7041
 
6987
 
int adios_define_mesh_rectilinear_dimensions (const char * dimensions
6988
 
        ,struct adios_group_struct * new_group
6989
 
        ,const char * name
6990
 
        )
 
7042
int adios_define_mesh_rectilinear_dimensions (const char * dimensions,
 
7043
                                              struct adios_group_struct * new_group,
 
7044
                                              const char * name
 
7045
                                             )
6991
7046
{
6992
7047
    char * c;  // comma location
6993
7048
    char * d1; // save of strdup
6994
 
    struct adios_mesh_item_list_struct * item = 0;
6995
 
    int64_t      p_new_group = (int64_t) new_group;
 
7049
    int64_t p_new_group = (int64_t) new_group;
6996
7050
    char * dim_att_nam = 0; // dimensions attribute name
6997
 
    char * getdimsfrom = 0; // dimensions attribute name that is a var
6998
7051
    int counter = 0;        // used to create dimX attributes
6999
7052
    char counterstr[5] = {0,0,0,0,0}; // used to create dimX attributes
7000
7053
 
7001
 
    if (!dimensions)
 
7054
    if (!dimensions || !strcmp(dimensions,""))
7002
7055
    {
7003
 
        log_warn ("config.xml: dimensions value required"
7004
 
                "for rectilinear mesh: %s\n"
7005
 
                ,name
7006
 
                );
7007
 
 
 
7056
        log_warn ("config.xml: dimensions value required "
 
7057
                  "for rectilinear mesh: %s\n", name);
7008
7058
        return 0;
7009
7059
    }
7010
7060
 
7032
7082
    adios_common_define_attribute (p_new_group,dims,"/",adios_integer,counterstr,"");
7033
7083
 
7034
7084
    free (dims);
7035
 
 
7036
7085
    free (d1);
7037
7086
 
7038
7087
    return 1;
7039
7088
}
7040
7089
 
7041
 
int adios_define_mesh_rectilinear_coordinatesMultiVar (const char * coordinates
7042
 
        ,struct adios_group_struct * new_group
7043
 
        ,const char * name
7044
 
        )
 
7090
int adios_define_mesh_rectilinear_coordinatesMultiVar (const char * coordinates,
 
7091
                                                       struct adios_group_struct * new_group,
 
7092
                                                       const char * name
 
7093
                                                      )
7045
7094
{
7046
7095
    char * c;  // comma location
7047
7096
    char * d1; // save of strdup
7048
 
    struct adios_mesh_var_list_struct * var = 0;
7049
 
    int64_t      p_new_group = (int64_t) new_group;
 
7097
    int64_t p_new_group = (int64_t) new_group;
7050
7098
    char * coo_att_nam = 0; // coordinates attribute name
7051
7099
    int counter = 0;        // used to create ptsX attributes
7052
7100
    char counterstr[5] = {0,0,0,0,0}; // used to create ptsX attributes
7053
7101
 
7054
 
    if (!coordinates)
 
7102
    if (!coordinates || !strcmp(coordinates,""))
7055
7103
    {
7056
 
        log_warn ("config.xml: coordinates-multi-var value required"
7057
 
                "for rectilinear mesh: %s\n"
7058
 
                ,name
7059
 
                );
 
7104
        log_warn ("config.xml: coordinates-multi-var value required "
 
7105
                  "for rectilinear mesh: %s\n", name);
7060
7106
 
7061
7107
        return 0;
7062
7108
    }
7086
7132
        adios_conca_mesh_att_nam(&coords, name, "coords-multi-var-num");
7087
7133
        adios_common_define_attribute (p_new_group,coords,"/",adios_integer,counterstr,"");
7088
7134
        free (coords);
7089
 
    } else
 
7135
    } 
 
7136
    else
7090
7137
    {
7091
7138
        log_warn ("config.xml: coordinates-multi-var expects "
7092
 
                "at least 2 variables (%s)\n"
7093
 
                ,name
7094
 
                );
 
7139
                  "at least 2 variables (%s)\n", name);
7095
7140
        free (d1);
7096
7141
        return 0;
7097
7142
    }
7101
7146
    return 1;
7102
7147
}
7103
7148
 
7104
 
int adios_define_mesh_rectilinear_coordinatesSingleVar (const char * coordinates
7105
 
        ,struct adios_group_struct * new_group
7106
 
        ,const char * name
7107
 
        )
 
7149
int adios_define_mesh_rectilinear_coordinatesSingleVar (const char * coordinates,
 
7150
                                                        struct adios_group_struct * new_group,
 
7151
                                                        const char * name
 
7152
                                                       )
7108
7153
{
7109
7154
    char * d1; // save of strdup
7110
 
    struct adios_mesh_var_list_struct * var = 0;
7111
 
    int64_t      p_new_group = (int64_t) new_group;
 
7155
    int64_t p_new_group = (int64_t) new_group;
7112
7156
    char * coo_att_nam = 0; // coordinates attribute name
7113
7157
 
7114
 
    if (!coordinates)
 
7158
    if (!coordinates || !strcmp(coordinates,""))
7115
7159
    {
7116
 
        log_warn ("config.xml: coordinates-single-var value required"
7117
 
                "for rectilinear mesh: %s\n"
7118
 
                ,name
7119
 
                );
 
7160
        log_warn ("config.xml: coordinates-single-var value required "
 
7161
                  "for rectilinear mesh: %s\n", name);
7120
7162
 
7121
7163
        return 0;
7122
7164
    }
7123
7165
 
7124
7166
    d1 = strdup (coordinates);
 
7167
    
7125
7168
    adios_conca_mesh_att_nam(&coo_att_nam, name, "coords-single-var");
7126
7169
    adios_common_define_attribute (p_new_group,coo_att_nam,"/",adios_string,d1,"");
7127
7170
    free (coo_att_nam);
7129
7172
    return 1;
7130
7173
}
7131
7174
 
 
7175
/*
7132
7176
int adios_define_mesh_structured_nspace (const char * nspace
7133
7177
        ,struct adios_group_struct * new_group
7134
7178
        ,const char * name
7136
7180
{
7137
7181
    char * d1; // save of strdup
7138
7182
    int64_t      p_new_group = (int64_t) new_group;
7139
 
    struct adios_mesh_item_struct * item = 0;
7140
7183
    char * nsp_att_nam = 0; // nspace attribute name
7141
7184
 
7142
7185
    if (!nspace)
7157
7200
 
7158
7201
    return 1;
7159
7202
}
 
7203
*/
7160
7204
 
7161
 
int adios_define_mesh_structured_dimensions (const char * dimensions
7162
 
        ,struct adios_group_struct * new_group
7163
 
        ,const char * name
7164
 
        )
 
7205
int adios_define_mesh_structured_dimensions (const char * dimensions,
 
7206
                                             struct adios_group_struct * new_group,
 
7207
                                             const char * name
 
7208
                                            )
7165
7209
{
7166
7210
    char * c;  // comma location
7167
7211
    char * d1; // save of strdup
7168
 
    struct adios_mesh_item_list_struct * item = 0;
7169
 
    int64_t      p_new_group = (int64_t) new_group;
 
7212
    int64_t p_new_group = (int64_t) new_group;
7170
7213
    char * dim_att_nam = 0; // dimensions attribute name
7171
 
    char * getdimsfrom = 0; // dimensions attribute name that is a var
7172
7214
    int counter = 0;        // used to create dimX attributes
7173
7215
    char counterstr[5] = {0,0,0,0,0}; // used to create dimX attributes
7174
7216
 
7175
 
    if (!dimensions)
 
7217
    if (!dimensions || !strcmp(dimensions,""))
7176
7218
    {
7177
 
        log_warn ("config.xml: dimensions value required"
7178
 
                "for structured mesh: %s\n"
7179
 
                ,name
7180
 
                );
 
7219
        log_warn ("config.xml: dimensions value required "
 
7220
                  "for structured mesh: %s\n", name);
7181
7221
 
7182
7222
        return 0;
7183
7223
    }
7184
7224
 
7185
7225
    d1 = strdup (dimensions);
 
7226
 
7186
7227
    c = strtok (d1, ",");
7187
7228
    while (c)
7188
7229
    {
7208
7249
    return 1;
7209
7250
}
7210
7251
 
7211
 
int adios_define_mesh_structured_pointsSingleVar (const char * points
7212
 
        ,struct adios_group_struct * new_group
7213
 
        ,const char * name
7214
 
                                              )
 
7252
int adios_define_mesh_structured_pointsSingleVar (const char * points,
 
7253
                                                  struct adios_group_struct * new_group,
 
7254
                                                  const char * name
 
7255
                                                 )
7215
7256
{
7216
 
    char * c;  // comma location
7217
7257
    char * d1; // save of strdup
7218
 
    struct adios_mesh_var_list_struct * var = 0;
7219
 
    int64_t      p_new_group = (int64_t) new_group;
 
7258
    int64_t p_new_group = (int64_t) new_group;
7220
7259
    char * pts_att_nam = 0; // points attribute name
7221
7260
 
7222
 
    if (!points)
 
7261
    if (!points || !strcmp(points,""))
7223
7262
    {
7224
 
        log_warn ("config.xml: points-single-var value required"
7225
 
                         "for structured mesh: %s\n"
7226
 
                         ,name
7227
 
                );
 
7263
        log_warn ("config.xml: points-single-var value required "
 
7264
                  "for structured mesh: %s\n", name);
7228
7265
 
7229
7266
        return 0;
7230
7267
    }
7231
7268
 
7232
7269
    d1 = strdup (points);
7233
 
        adios_conca_mesh_att_nam(&pts_att_nam, name, "points-single-var");
7234
 
        adios_common_define_attribute (p_new_group,pts_att_nam,"/",adios_string,d1,"");
7235
 
        free (pts_att_nam);
 
7270
    adios_conca_mesh_att_nam(&pts_att_nam, name, "points-single-var");
 
7271
    adios_common_define_attribute (p_new_group,pts_att_nam,"/",adios_string,d1,"");
 
7272
    free (pts_att_nam);
7236
7273
    free (d1);
7237
7274
    return 1;
7238
7275
}
7239
7276
 
7240
 
int adios_define_mesh_structured_pointsMultiVar (const char * points
7241
 
        ,struct adios_group_struct * new_group
7242
 
        ,const char * name
7243
 
        )
 
7277
int adios_define_mesh_structured_pointsMultiVar (const char * points,
 
7278
                                                 struct adios_group_struct * new_group,
 
7279
                                                 const char * name
 
7280
                                                )
7244
7281
{
7245
7282
    char * c;  // comma location
7246
7283
    char * d1; // save of strdup
7247
 
    struct adios_mesh_var_list_struct * var = 0;
7248
 
    int64_t      p_new_group = (int64_t) new_group;
 
7284
    int64_t p_new_group = (int64_t) new_group;
7249
7285
    char * pts_att_nam = 0; // pointss attribute name
7250
7286
    int counter = 0;        // used to create ptsX attributes
7251
7287
    char counterstr[5] = {0,0,0,0,0}; // used to create ptsX attributes
7252
7288
 
7253
 
    if (!points)
 
7289
    if (!points || !strcmp(points,""))
7254
7290
    {
7255
 
        log_warn ("config.xml: points-multi-var value required"
7256
 
                "for structured mesh: %s\n"
7257
 
                ,name
7258
 
                );
 
7291
        log_warn ("config.xml: points-multi-var value required "
 
7292
                  "for structured mesh: %s\n", name);
7259
7293
 
7260
7294
        return 0;
7261
7295
    }
7263
7297
    d1 = strdup (points);
7264
7298
 
7265
7299
    c = strtok (d1, ",");
7266
 
 
7267
7300
    while (c)
7268
7301
    {
7269
7302
        pts_att_nam = 0;
7288
7321
    } else
7289
7322
    {
7290
7323
        log_warn ("config.xml: points-multi-var tag for mesh: %s "
7291
 
                " expects at least 2 variables\n"
7292
 
                ,name
7293
 
                );
 
7324
                  " expects at least 2 variables\n", name);
7294
7325
        free (d1);
7295
7326
 
7296
7327
        return 0;
7301
7332
    return 1;
7302
7333
}
7303
7334
 
 
7335
/*
7304
7336
int adios_define_mesh_unstructured_nspace (const char * nspace
7305
7337
        ,struct adios_group_struct * new_group
7306
7338
        ,const char * name
7308
7340
{
7309
7341
    char * d1; // save of strdup
7310
7342
    int64_t      p_new_group = (int64_t) new_group;
7311
 
    struct adios_mesh_item_struct * item = 0;
7312
7343
    char * nsp_att_nam = 0; // nspace attribute name
7313
7344
 
7314
7345
    if (!nspace)
7315
7346
    {
7316
 
        log_warn ("config.xml: nspace value required"
7317
 
                         "for unstructured mesh: %s\n"
7318
 
                         ,name
7319
 
                );
 
7347
        log_warn ("config.xml: nspace value required for unstructured mesh: %s\n",
 
7348
                name);
7320
7349
 
7321
7350
        return 0;
7322
7351
    }
7329
7358
 
7330
7359
    return 1;
7331
7360
}
 
7361
*/
7332
7362
 
7333
7363
int adios_define_mesh_unstructured_npoints (const char * npoints
7334
7364
        ,struct adios_group_struct * new_group
7336
7366
        )
7337
7367
{
7338
7368
    char * d1; // save of strdup
7339
 
    int64_t      p_new_group = (int64_t) new_group;
7340
 
    struct adios_mesh_item_struct * item = 0;
 
7369
    int64_t p_new_group = (int64_t) new_group;
7341
7370
    char * npts_att_nam = 0; // npoints attribute name
7342
7371
 
7343
 
    if (!npoints)
 
7372
    if (!npoints || !strcmp(npoints,""))
7344
7373
    {
7345
 
        log_warn ("config.xml: npoints value required"
7346
 
                "for unstructured mesh\n"
7347
 
                ,name
7348
 
                );
 
7374
//        log_warn ("config.xml: npoints value required for unstructured mesh %s:\n",
 
7375
//                  name);
7349
7376
 
7350
7377
        return 0;
7351
7378
    }
7361
7388
    return 1;
7362
7389
}
7363
7390
 
7364
 
int adios_define_mesh_unstructured_pointsMultiVar (const char * points
7365
 
        ,struct adios_group_struct * new_group
7366
 
        ,const char * name
7367
 
        )
 
7391
int adios_define_mesh_unstructured_pointsMultiVar (const char * points,
 
7392
                                                   struct adios_group_struct * new_group,
 
7393
                                                   const char * name
 
7394
                                                  )
7368
7395
{
7369
7396
    char * c;  // comma location
7370
7397
    char * d1; // save of strdup
7371
 
    struct adios_mesh_var_list_struct * var = 0;
7372
 
    int64_t      p_new_group = (int64_t) new_group;
 
7398
    int64_t p_new_group = (int64_t) new_group;
7373
7399
    char * pts_att_nam = 0; // pointss attribute name
7374
7400
    int counter = 0;        // used to create ptsX attributes
7375
7401
    char counterstr[5] = {0,0,0,0,0}; // used to create ptsX attributes
7376
7402
 
7377
 
    if (!points)
 
7403
    if (!points || !strcmp(points,""))
7378
7404
    {
7379
 
        log_warn ("config.xml: points-multi-var value required"
7380
 
                "for unstructured mesh: %s\n"
7381
 
                ,name
7382
 
                );
 
7405
        log_warn ("config.xml: points-multi-var value required "
 
7406
                  "for unstructured mesh: %s\n", name);
7383
7407
 
7384
7408
        return 0;
7385
7409
    }
7386
7410
 
7387
7411
    d1 = strdup (points);
7388
 
 
7389
7412
    c = strtok (d1, ",");
7390
7413
 
7391
7414
    while (c)
7412
7435
    } else
7413
7436
    {
7414
7437
        log_warn ("config.xml: points-multi-var tag expects "
7415
 
                " at least two variabels. (%s)\n"
7416
 
                ,name
7417
 
                );
 
7438
                  "at least two variabels. (%s)\n" , name);
7418
7439
        free (d1);
7419
7440
        return 0;
7420
7441
    }
7422
7443
    return 1;
7423
7444
}
7424
7445
 
7425
 
int adios_define_mesh_unstructured_pointsSingleVar (const char * points
7426
 
        ,struct adios_group_struct * new_group
7427
 
        ,const char * name
7428
 
        )
 
7446
int adios_define_mesh_unstructured_pointsSingleVar (const char * points,
 
7447
                                                    struct adios_group_struct * new_group,
 
7448
                                                    const char * name
 
7449
                                                   )
7429
7450
{
7430
 
    char * c;  // comma location
7431
7451
    char * d1; // save of strdup
7432
 
    struct adios_mesh_var_list_struct * var = 0;
7433
 
    int64_t      p_new_group = (int64_t) new_group;
 
7452
    int64_t p_new_group = (int64_t) new_group;
7434
7453
    char * pts_att_nam = 0; // points attribute name
7435
7454
 
7436
 
    if (!points)
 
7455
    if (!points || !strcmp(points,""))
7437
7456
    {
7438
 
        log_warn ("config.xml: points-single-var value required"
7439
 
                "for unstructured mesh: %s\n"
7440
 
                ,name
7441
 
                );
 
7457
        log_warn ("config.xml: points-single-var value required "
 
7458
                  "for unstructured mesh: %s\n", name);
7442
7459
 
7443
7460
        return 0;
7444
7461
    }
7453
7470
    return 1;
7454
7471
}
7455
7472
 
7456
 
int adios_define_mesh_unstructured_uniformCells (const char * count
7457
 
        ,const char * data
7458
 
        ,const char * type
7459
 
        ,struct adios_group_struct * new_group
7460
 
        ,const char * name
7461
 
        )
 
7473
int adios_define_mesh_unstructured_uniformCells (const char * count,
 
7474
                                                 const char * data,
 
7475
                                                 const char * type,
 
7476
                                                 struct adios_group_struct * new_group,
 
7477
                                                 const char * name
 
7478
                                                )
7462
7479
{
7463
 
    char * c;  // comma location
7464
7480
    char * d1; // save of strdup
7465
 
    struct adios_mesh_cell_list_list_struct * cell_list = 0;
7466
 
    struct adios_mesh_item_struct * item = 0;
7467
 
    int64_t      p_new_group = (int64_t) new_group;
 
7481
    int64_t p_new_group = (int64_t) new_group;
7468
7482
    char * ncellset_att_nam = 0;  // ncellset attribute
7469
7483
    char * cellcount_att_nam = 0; // single cell count attribute
7470
7484
    char * celldata_att_nam = 0;  // single cell data  attribute
7474
7488
    adios_common_define_attribute (p_new_group,ncellset_att_nam,"/",adios_integer,"1","");
7475
7489
    free (ncellset_att_nam);
7476
7490
 
7477
 
    if (!count)
7478
 
    {
7479
 
        log_warn ("config.xml: uniform-cells count value required"
7480
 
                "for unstructured mesh: %s\n"
7481
 
                ,name
7482
 
                );
7483
 
 
7484
 
        return 0;
7485
 
    }
7486
 
    if (!data)
7487
 
    {
7488
 
        log_warn ("config.xml: uniform-cells data value required"
7489
 
                "for unstructured mesh: %s\n"
7490
 
                ,name
7491
 
                );
7492
 
 
7493
 
        return 0;
7494
 
    }
7495
 
    if (!type)
7496
 
    {
7497
 
        log_warn ("config.xml: uniform-cells type value required"
7498
 
                "for unstructured mesh: %s\n"
7499
 
                ,name
7500
 
                );
 
7491
    if (!count || !strcmp(count,""))
 
7492
    {
 
7493
        log_warn ("config.xml: uniform-cells count value required "
 
7494
                  "for unstructured mesh: %s\n", name);
 
7495
 
 
7496
        return 0;
 
7497
    }
 
7498
    if (!data || !strcmp(data,""))
 
7499
    {
 
7500
        log_warn ("config.xml: uniform-cells data value required "
 
7501
                  "for unstructured mesh: %s\n", name);
 
7502
 
 
7503
        return 0;
 
7504
    }
 
7505
    if (!type || !strcmp(type,""))
 
7506
    {
 
7507
        log_warn ("config.xml: uniform-cells type value required "
 
7508
                  "for unstructured mesh: %s\n", name);
7501
7509
 
7502
7510
        return 0;
7503
7511
    }
7523
7531
    return 1;
7524
7532
}
7525
7533
 
7526
 
int adios_define_mesh_unstructured_mixedCells (const char * count
7527
 
        ,const char * data
7528
 
        ,const char * types
7529
 
        ,struct adios_group_struct * new_group
7530
 
        ,const char * name
7531
 
        )
 
7534
int adios_define_mesh_unstructured_mixedCells (const char * count,
 
7535
                                               const char * data,
 
7536
                                               const char * types,
 
7537
                                               struct adios_group_struct * new_group,
 
7538
                                               const char * name
 
7539
                                              )
7532
7540
{
7533
7541
    char * c;  // comma location
7534
7542
    char * d1; // save of strdup
7535
 
    struct adios_mesh_cell_list_list_struct * cell_list = 0;
7536
 
    struct adios_mesh_item_struct * item = 0;
7537
7543
    int counter = 0;        // used to create countX, typeX, dataX? attributes
7538
7544
    char counterstr[5] = {0,0,0,0,0}; // used to create countX, typeX, dataX? attributes
7539
 
    int64_t      p_new_group = (int64_t) new_group;
 
7545
    int64_t p_new_group = (int64_t) new_group;
7540
7546
    char * ncellset_att_nam = 0;  // ncellset attribute
7541
7547
    char * ccounts_att_nam = 0;   // ccountX attributes
7542
7548
    char * cdata_att_nam = 0;     // cdataX attributes
7543
7549
    char * celltype_att_nam = 0;  // ctypeX attributes
7544
7550
 
7545
 
    if (!count)
7546
 
    {
7547
 
        log_warn ("config.xml: mixed-cells count value required"
7548
 
                "for unstructured mesh: %s\n"
7549
 
                ,name
7550
 
                );
7551
 
 
7552
 
        return 0;
7553
 
    }
7554
 
    if (!data)
7555
 
    {
7556
 
        log_warn ("config.xml: mixed-cells data value required"
7557
 
                "for unstructured mesh: %s\n"
7558
 
                ,name
7559
 
                );
7560
 
 
7561
 
        return 0;
7562
 
    }
7563
 
    if (!types)
 
7551
    if (!count || !strcmp(count,""))
 
7552
    {
 
7553
        log_warn ("config.xml: mixed-cells count value required "
 
7554
                  "for unstructured mesh: %s\n", name);
 
7555
 
 
7556
        return 0;
 
7557
    }
 
7558
    if (!data || !strcmp(data,""))
 
7559
    {
 
7560
        log_warn ("config.xml: mixed-cells data value required "
 
7561
                  "for unstructured mesh: %s\n", name);
 
7562
 
 
7563
        return 0;
 
7564
    }
 
7565
    if (!types || !strcmp(types,""))
7564
7566
    {
7565
7567
        log_warn ("config.xml: mixed-cells type value required "
7566
 
                "for unstructured mesh: %s\n"
7567
 
                ,name
7568
 
                );
 
7568
                  "for unstructured mesh: %s\n", name);
7569
7569
 
7570
7570
        return 0;
7571
7571
    }
7572
7572
 
7573
7573
    d1 = strdup (count);
7574
7574
    c = strtok (d1, ",");
7575
 
   
7576
7575
    while (c)
7577
7576
    {
7578
7577
        //cell_list->cell_list.count.var = 0;
7591
7590
    // We should have at least 2 cell sets, otherwise the cells are uniform
7592
7591
    if (counter <= 1){
7593
7592
        log_warn ("config.xml: Please provide at least 2 cell counts of mesh: %s\n"
7594
 
                "or use the 'uniform-cells' tag.\n"
7595
 
                ,name
7596
 
                );
 
7593
                  "or use the 'uniform-cells' tag.\n", name);
7597
7594
        return 0;
7598
7595
    }
7599
7596
 
7626
7623
    // Generate an error message
7627
7624
    if (counter != cell_set_count){
7628
7625
        log_warn ("config.xml: Please provide at least %d cell data of mesh: %s\n"
7629
 
                "or use the 'uniform-cells' tag\n"
7630
 
                ,cell_set_count
7631
 
                ,name
7632
 
                );
 
7626
                  "or use the 'uniform-cells' tag\n", cell_set_count, name);
7633
7627
        return 0;
7634
7628
    }
7635
7629
 
7656
7650
    // Generate an error message
7657
7651
    if (counter != cell_set_count){
7658
7652
        log_warn ("config.xml: Please provide at least %d cell types of mesh: %s\n"
7659
 
                "or use the 'uniform-cells' tag\n"
7660
 
                ,cell_set_count
7661
 
                ,name
7662
 
                );
 
7653
                  "or use the 'uniform-cells' tag\n", cell_set_count, name);
7663
7654
        return 0;
7664
7655
    }
7665
7656
 
7666
7657
    return 1;
7667
7658
}
7668
7659
 
7669
 
// NO-XML API
7670
 
int adios_define_var_mesh(int64_t ptr_new_group, char * varname, char * varpath, char * meshname){
 
7660
// called by NO-XML API
 
7661
int adios_common_define_var_mesh (int64_t group_id, const char * varname, const char * meshname, const char * path)
 
7662
{
7671
7663
    char *mpath = 0;
7672
7664
    mpath = malloc(strlen("/adios_schema")+strlen(varname)+1);
7673
7665
    strcpy(mpath,varname);
7674
7666
    strcat(mpath,"/adios_schema");
7675
 
    adios_common_define_attribute (ptr_new_group,mpath,varpath,adios_string,meshname,"");
 
7667
    adios_common_define_attribute (group_id, mpath, path, adios_string, meshname, "");
7676
7668
    free (mpath);
7677
7669
    return 0;
7678
7670
}
7679
7671
 
7680
 
int adios_define_var_centering(int64_t ptr_new_group, char * varname, char * varpath, char * centering){
 
7672
int adios_common_define_var_centering (int64_t group_id, const char * varname, const char * centering, const char * path)
 
7673
{
7681
7674
    char *mpath = 0;
7682
7675
    mpath = malloc(strlen("/adios_schema/centering")+strlen(varname)+1);
7683
7676
    strcpy(mpath,varname);
7684
7677
    strcat(mpath,"/adios_schema/centering");
7685
 
    adios_common_define_attribute (ptr_new_group,mpath,varpath,adios_string,centering,"");
7686
 
    free (mpath);
7687
 
    return 0;
7688
 
}
7689
 
 
7690
 
int adios_define_mesh_group(int64_t ptr_new_group, char * name, char * group){
7691
 
    char * meshgroup = 0;
7692
 
    adios_conca_mesh_att_nam(&group, name, "mesh-group");
7693
 
    adios_common_define_attribute (ptr_new_group,meshgroup,"/",adios_string,group,"");
7694
 
    return 0;
7695
 
}
7696
 
 
7697
 
int adios_define_mesh_file(int64_t ptr_new_group, char * name, char * file){
7698
 
    char * meshfile = 0;
7699
 
    adios_conca_mesh_att_nam(&meshfile, name, "mesh-file");
7700
 
    adios_common_define_attribute (ptr_new_group,file,"/",adios_string,file,"");
 
7678
    adios_common_define_attribute (group_id, mpath, path, adios_string, centering, "");
 
7679
    free (mpath);
 
7680
    return 0;
 
7681
}
 
7682
 
 
7683
int adios_common_define_mesh_group (int64_t group_id, const char * name, const char * group)
 
7684
{
 
7685
    char * mpath = 0;
 
7686
    mpath = malloc(strlen("/adios_schema/")+strlen(name)+strlen("/mesh-group")+1);
 
7687
    strcpy (mpath, "/adios_schema/");
 
7688
    strcat (mpath, name);
 
7689
    strcat (mpath, "/mesh-group");
 
7690
//    adios_conca_mesh_att_nam(&group, name, "mesh-group");
 
7691
    adios_common_define_attribute (group_id, mpath, "", adios_string, group, "");
 
7692
    free (mpath);
 
7693
    return 0;
 
7694
}
 
7695
 
 
7696
int adios_common_define_mesh_file (int64_t group_id, char * name, char * file){
 
7697
    char * mpath = 0;
 
7698
    mpath = malloc(strlen("/adios_schema/")+strlen(name)+strlen("/mesh-file")+1);
 
7699
    strcpy (mpath, "/adios_schema/");
 
7700
    strcat (mpath, name);
 
7701
    strcat (mpath, "/mesh-file");
 
7702
    adios_common_define_attribute (group_id, mpath, "", adios_string, file, "");
 
7703
    free (mpath);
7701
7704
    return 0;
7702
7705
}
7703
7706