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

« back to all changes in this revision

Viewing changes to src/core/adios_internals_mxml.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:
22
22
#include "core/buffer.h"
23
23
#include "core/adios_logger.h"
24
24
#include "core/util.h" // PairStruct*
 
25
#include "transforms/adios_transforms_hooks_write.h"
 
26
#include "transforms/adios_transforms_write.h"
25
27
 
26
28
#ifdef DMALLOC
27
29
#include "dmalloc.h"
157
159
    return adios_flag_unknown;
158
160
}
159
161
 
160
 
 
 
162
/*
161
163
static void adios_append_mesh_item (struct adios_mesh_item_list_struct ** root
162
164
        ,struct adios_mesh_item_list_struct * item
163
165
        )
175
177
        }
176
178
    }
177
179
}
178
 
 
 
180
*/
 
181
/*
179
182
static void adios_append_mesh_var (struct adios_mesh_var_list_struct ** root
180
183
        ,struct adios_mesh_var_list_struct * var
181
184
        )
193
196
        }
194
197
    }
195
198
}
196
 
 
 
199
*/
 
200
/*
197
201
static void adios_append_mesh_cell_list
198
202
(struct adios_mesh_cell_list_list_struct ** root
199
203
 ,struct adios_mesh_cell_list_list_struct * cell_list
212
216
        }
213
217
    }
214
218
}
 
219
*/
215
220
 
216
221
// primary mesh XML parsing
217
222
int parseMeshUniform (mxml_node_t * node
354
359
                        if (!adios_define_mesh_uniform_maximums (value, new_group, name))
355
360
                            return 0;
356
361
                    } else
357
 
                    {
358
 
                        if (!strncmp (n->value.element.name, "!--", 3)) // a comment
 
362
                        if (!strcasecmp (n->value.element.name, "nspace"))
359
363
                        {
360
 
                            continue;
 
364
                            const char * value;
 
365
                            value = mxmlElementGetAttr (n, "value");
 
366
                            adios_define_mesh_nspace (value, new_group, name);
 
367
                        } else {
 
368
                            if (!strncmp (n->value.element.name, "!--", 3)) // a comment
 
369
                            {
 
370
                                continue;
 
371
                            }
361
372
                        }
362
 
                    }
363
373
    }
364
374
 
365
375
    return 1;
473
483
                    if (!adios_define_mesh_rectilinear_coordinatesSingleVar(value, new_group, name))
474
484
                        return 0;
475
485
                } else
476
 
                {
477
 
                    if (!strncmp (n->value.element.name, "!--", 3)) // a comment
478
 
                    {
479
 
                        continue;
 
486
                    if (!strcasecmp (n->value.element.name, "nspace"))
 
487
                    {
 
488
                        const char * value;
 
489
                        value = mxmlElementGetAttr (n, "value");
 
490
                        adios_define_mesh_nspace (value, new_group, name);
 
491
                    } else
 
492
                    {
 
493
                        if (!strncmp (n->value.element.name, "!--", 3)) // a comment
 
494
                        {
 
495
                            continue;
 
496
                        }
480
497
                    }
481
 
                }
482
498
    }
483
499
 
484
500
    if (!saw_dimensions)
540
556
 
541
557
            saw_nspace = 1;
542
558
            value = mxmlElementGetAttr (n, "value");
543
 
 
544
 
            if (!value)
545
 
            {
546
 
                log_warn ("config.xml: value attribute on "
547
 
                        "nspace required (%s)\n"
548
 
                        ,name
549
 
                        );
550
 
 
551
 
                return 0;
552
 
            }
553
 
 
554
 
            if (!adios_define_mesh_structured_nspace (value, new_group, name))
555
 
                return 0;
 
559
            adios_define_mesh_nspace (value, new_group, name);
 
560
//            if (!value)
 
561
//            {
 
562
//                log_warn ("config.xml: value attribute on "
 
563
//                        "nspace required (%s)\n"
 
564
//                        ,name
 
565
//                        );
 
566
//
 
567
//                return 0;
 
568
//            }
 
569
 
 
570
//            if (!adios_define_mesh_structured_nspace (value, new_group, name))
 
571
//                return 0;
556
572
        } else
557
573
            if (!strcasecmp (n->value.element.name, "dimensions"))
558
574
            {
680
696
        )
681
697
{
682
698
    mxml_node_t * n;
683
 
    int saw_points = 0;
684
699
    int saw_nspace =0;
685
700
    int saw_number_of_points = 0;
686
701
    int saw_points_multi_var = 0;
713
728
 
714
729
            saw_nspace = 1;
715
730
            value = mxmlElementGetAttr (n, "value");
716
 
 
717
 
            if (!value)
718
 
            {
719
 
                log_warn ("config.xml: value attribute on "
720
 
                        "nspace required (%s)\n"
721
 
                        ,name
722
 
                        );
723
 
 
724
 
                return 0;
725
 
            }
726
 
 
727
 
            if (!adios_define_mesh_unstructured_nspace (value, new_group, name))
728
 
                return 0;
 
731
            adios_define_mesh_nspace (value, new_group, name);
 
732
 
 
733
//            if (!value)
 
734
//            {
 
735
//                log_warn ("config.xml: value attribute on "
 
736
//                        "nspace required (%s)\n"
 
737
//                        ,name
 
738
//                        );
 
739
//
 
740
//                return 0;
 
741
//            }
 
742
 
 
743
//            if (!adios_define_mesh_unstructured_nspace (value, new_group, name))
 
744
//                return 0;
729
745
        }else
730
746
            if (!strcasecmp (n->value.element.name, "number-of-points"))
731
747
            {
940
956
    return 1;
941
957
}
942
958
 
 
959
/*
943
960
static int validatePath (const struct adios_var_struct * vars
944
961
        ,const char * test_path
945
962
        )
1020
1037
 
1021
1038
    return 0;
1022
1039
}
 
1040
*/
1023
1041
 
1024
1042
static int parseGroup (mxml_node_t * node, char * schema_version)
1025
1043
{
1129
1147
            );
1130
1148
    new_group = (struct adios_group_struct *)ptr_new_group;
1131
1149
 
1132
 
   adios_define_schema_version(new_group, schema_version);
 
1150
   adios_common_define_schema_version(new_group, schema_version);
1133
1151
    for (n = mxmlWalkNext (node, node, MXML_DESCEND)
1134
1152
            ;n
1135
1153
            ;n = mxmlWalkNext (n, node, MXML_NO_DESCEND)
1222
1240
 
1223
1241
            // fix the bgp bugs
1224
1242
            //            if (!adios_common_define_var (*(int64_t *) &new_group, name
1225
 
            if (!adios_common_define_var (ptr_new_group, name
 
1243
            int64_t var = adios_common_define_var (ptr_new_group, name
1226
1244
                        ,path, t1, dimensions
1227
1245
                        ,gb_global_dimensions
1228
1246
                        ,gb_local_offsets
1229
 
                                         ,transform_type // NCSU ALACRITY-ADIOS
1230
 
                        )
1231
 
               )
 
1247
                        );
 
1248
            if (!var)
1232
1249
            {
1233
1250
                return 0;
1234
1251
            }else{
1235
1252
                // Successfully define a variable, so now
 
1253
                // an attribute for the transform method if given.
 
1254
                if (transform_type && strcmp(transform_type,"")) {
 
1255
                    adios_common_set_transform (var, transform_type);
 
1256
                }
1236
1257
                // an attribute for the mesh if it exists.
1237
1258
                if (strcmp(mesh,"")){
1238
 
                    mpath1 = malloc(strlen("/adios_schema")+strlen(name)+1);
1239
 
                    strcpy(mpath1,name);
1240
 
                    strcat(mpath1,"/adios_schema");
1241
 
                    adios_common_define_attribute (ptr_new_group,mpath1,path,adios_string,mesh,"");
 
1259
                    adios_common_define_var_mesh (ptr_new_group, name, mesh, path);
1242
1260
                }
1243
1261
                // an attribute for the center if it exists.
1244
1262
                if (strcmp(center,"")){
1245
 
                    mpath2 = malloc(strlen("/adios_schema/centering")+strlen(name)+1);
1246
 
                    strcpy(mpath2,name);
1247
 
                    strcat(mpath2,"/adios_schema/centering");
1248
 
                    adios_common_define_attribute (ptr_new_group,mpath2,path,adios_string,center,"");
 
1263
                    adios_common_define_var_centering (ptr_new_group, name, center, path);
1249
1264
                }
1250
1265
                // if a time attribute exists
1251
1266
                // parse it and define it
1252
1267
                if (strcmp(tsteps,"")){
1253
 
                    adios_define_var_timesteps(tsteps,new_group,name,path);
 
1268
                    adios_common_define_var_timesteps(tsteps,new_group,name,path);
1254
1269
                }
1255
1270
                // if a time scale attribute exists
1256
1271
                // parse it and define it
1257
1272
                if (strcmp(tscale,"")){
1258
 
                    adios_define_var_timescale(tscale,new_group,name,path);
 
1273
                    adios_common_define_var_timescale(tscale,new_group,name,path);
1259
1274
                }
1260
1275
                // if a time series format attribute exists
1261
1276
                // parse it and define it
1262
1277
                if (strcmp(tformat,"")){
1263
 
                    adios_define_var_timeseriesformat(tformat,new_group,name,path);
 
1278
                    adios_common_define_var_timeseriesformat(tformat,new_group,name,path);
1264
1279
                }
1265
1280
                // if a hyperslab attribute exists
1266
1281
                // parse it and define it
1267
1282
                if (strcmp(hyperslab,"")){
1268
 
                    adios_define_var_hyperslab(hyperslab,new_group,name,path);
 
1283
                    adios_common_define_var_hyperslab(hyperslab,new_group,name,path);
1269
1284
                }
1270
1285
            }
1271
1286
        } else
1272
1287
            if (!strcasecmp (n->value.element.name, "global-bounds"))
1273
1288
            {
1274
1289
                mxml_node_t * n1;   // used for global_bounds
1275
 
                struct adios_global_bounds_struct * new_global_bounds = 0;
1276
 
 
1277
1290
                const char * dimensions = 0;
1278
1291
                const char * dimension = 0;
1279
1292
                const char * global_dimensions = 0;
1416
1429
                            parseFlag ("read", read_flag, adios_flag_no);
1417
1430
                        // fix the bgp bugs
1418
1431
                        //                    if (!adios_common_define_var (*(int64_t *) &new_group
1419
 
                        if (!adios_common_define_var (ptr_new_group
1420
 
                                    ,name
1421
 
                                    ,path, t1, dimensions
1422
 
                                    ,gb_global_dimensions
1423
 
                                    ,gb_local_offsets
1424
 
                                                 ,transform_type // NCSU ALACRITY-ADIOS
1425
 
                                    )
1426
 
                           )
 
1432
                        int64_t var = adios_common_define_var (ptr_new_group, name
 
1433
                                ,path, t1, dimensions
 
1434
                                ,gb_global_dimensions
 
1435
                                ,gb_local_offsets
 
1436
                                );
 
1437
                        if (!var)
1427
1438
                        {
1428
1439
                            return 0;
1429
1440
                        }else{
1430
1441
                            // Successfully define a variable, so now
 
1442
                            // an attribute for the transform method if given.
 
1443
                            if (transform_type && strcmp(transform_type,"")) {
 
1444
                                adios_common_set_transform (var, transform_type);
 
1445
                            }
1431
1446
                            // an attribute for the mesh if it exists.
1432
1447
                            if (strcmp(mesh,"")){
1433
 
                                mpath1 = malloc(strlen("/adios_schema")+strlen(name)+1);
1434
 
                                strcpy(mpath1,name);
1435
 
                                strcat(mpath1,"/adios_schema");
1436
 
                                adios_common_define_attribute (ptr_new_group,mpath1,path,adios_string,mesh,"");
 
1448
                                adios_common_define_var_mesh (ptr_new_group, name, mesh, path);
1437
1449
                            }
1438
1450
                            // an attribute for the mesh if it exists.
1439
1451
                            if (strcmp(center,"")){
1440
 
                                mpath2 = malloc(strlen("/adios_schema/centering")+strlen(name)+1);
1441
 
                                strcpy(mpath2,name);
1442
 
                                strcat(mpath2,"/adios_schema/centering");
1443
 
                                adios_common_define_attribute (ptr_new_group,mpath2,path,adios_string,center,"");
 
1452
                                adios_common_define_var_centering (ptr_new_group, name, center, path);
1444
1453
                            }
1445
1454
                            // if a time attribute exists
1446
1455
                            // parse it and define it
1447
1456
                            if (strcmp(tsteps,"")){
1448
 
                                adios_define_var_timesteps(tsteps,new_group,name,path);
 
1457
                                adios_common_define_var_timesteps(tsteps,new_group,name,path);
1449
1458
                            }
1450
1459
                            // if a time scale attribute exists
1451
1460
                            // parse it and define it
1452
1461
                            if (strcmp(tscale,"")){
1453
 
                                adios_define_var_timescale(tscale,new_group,name,path);
 
1462
                                adios_common_define_var_timescale(tscale,new_group,name,path);
1454
1463
                            }
1455
1464
                            // if a time series format attribute exists
1456
1465
                            // parse it and define it
1457
1466
                            if (strcmp(tformat,"")){
1458
 
                                adios_define_var_timeseriesformat(tformat,new_group,name,path);
 
1467
                                adios_common_define_var_timeseriesformat(tformat,new_group,name,path);
1459
1468
                            }
1460
1469
                            // if a hyperslab attribute exists
1461
1470
                            // parse it and define it
1462
1471
                            if (strcmp(hyperslab,"")){
1463
 
                                adios_define_var_hyperslab(hyperslab,new_group,name,path);
 
1472
                                adios_common_define_var_hyperslab(hyperslab,new_group,name,path);
1464
1473
                            }
1465
1474
                        }
1466
1475
                    } else
1571
1580
                    const char * time_scale;
1572
1581
                    const char * time_format;
1573
1582
                    const char * mesh_file;
 
1583
                    const char * mesh_ref;
1574
1584
                    const char * mesh_group;
1575
1585
                    int t_varying;
1576
1586
                    const char * name;
1622
1632
                    // Define attribute for the type and time varying characteristics
1623
1633
                    adios_common_define_attribute (ptr_new_group,meshtype,"/",adios_string,type,"");
1624
1634
                    adios_common_define_attribute (ptr_new_group,meshtime,"/",adios_string,time_varying,"");
1625
 
                    adios_define_mesh_timeSteps(time_steps, new_group, name);
1626
 
                    adios_define_mesh_timeScale(time_scale, new_group, name);
1627
 
                    adios_define_mesh_timeSeriesFormat(time_format, new_group, name);
 
1635
                    adios_common_define_mesh_timeSteps(time_steps, new_group, name);
 
1636
                    adios_common_define_mesh_timeScale(time_scale, new_group, name);
 
1637
                    adios_common_define_mesh_timeSeriesFormat(time_format, new_group, name);
1628
1638
                    // Only parse mesh if the variables are in this file
1629
1639
                    // otherwise simply point the mesh file
1630
1640
                    mesh_file = mxmlElementGetAttr(n, "file");
1631
 
                    mesh_group = mxmlElementGetAttr(n, "group");
1632
 
 
1633
1641
                    if (mesh_file)
1634
1642
                        adios_common_define_attribute (ptr_new_group,meshfile,"/",adios_string,mesh_file,"");
 
1643
                    else
 
1644
                    {
 
1645
                        mesh_ref = mxmlElementGetAttr(n, "ref");
 
1646
                        if (mesh_ref)
 
1647
                            adios_common_define_attribute (ptr_new_group,meshfile,"/",adios_string,mesh_ref,"");
 
1648
                    }
1635
1649
 
 
1650
                    mesh_group = mxmlElementGetAttr(n, "group");
1636
1651
                    if (mesh_group)
1637
1652
                        adios_common_define_attribute (ptr_new_group,meshgroup,"/",adios_string,mesh_group,"");
1638
1653
 
1723
1738
 
1724
1739
static int parseAnalysis (mxml_node_t * node)
1725
1740
{
1726
 
    mxml_node_t * n;
1727
 
 
1728
1741
    const char * group = 0;
1729
1742
    const char * var = 0;
1730
1743
    const char * bin_intervals = 0;
1971
1984
    return 1;
1972
1985
}
1973
1986
 
 
1987
 
 
1988
void PRINT_MXML_NODE (mxml_node_t *root)
 
1989
{
 
1990
    if (!root)
 
1991
    {
 
1992
        log_debug("MXML root=NULL\n");
 
1993
    }
 
1994
    else if (root->type == MXML_ELEMENT) 
 
1995
    {
 
1996
        log_debug("MXML ELEMENT root=%p, name=[%s] parent=%p\n",
 
1997
                root, root->value.element.name, root->parent);
 
1998
    } 
 
1999
    else if (root->type == MXML_TEXT) 
 
2000
    {
 
2001
        log_debug("MXML TEXT root=%p, text=[%s] parent=%p\n",
 
2002
                root, root->value.text.string, root->parent);
 
2003
    } 
 
2004
    else 
 
2005
    {
 
2006
        log_debug("MXML Type=%d root=%p, parent=%p\n",
 
2007
                root->type, root, root->parent);
 
2008
    }
 
2009
}
 
2010
 
1974
2011
int adios_parse_config (const char * config, MPI_Comm comm)
1975
2012
{
1976
2013
    FILE * fp = 0;
2069
2106
    }
2070
2107
 
2071
2108
    root = doc;
2072
 
 
2073
 
    while (root && root->type != MXML_ELEMENT)
2074
 
    {
2075
 
        root = mxmlWalkNext (root, doc, MXML_DESCEND);
2076
 
    }
2077
 
 
2078
 
    while (!strncmp (root->value.element.name, "!--", 3))
2079
 
    {
2080
 
        root = mxmlWalkNext (root, doc, MXML_NO_DESCEND);
2081
 
        root = mxmlWalkNext (root, doc, MXML_NO_DESCEND);
2082
 
    }
2083
 
 
2084
 
    if (strcasecmp (root->value.element.name, "adios-config"))
2085
 
    {
2086
 
        if (strncmp (root->value.element.name, "?xml", 4))
2087
 
        {
2088
 
            adios_error (err_invalid_xml_doc, "config.xml: invalid root xml element: %s\n"
2089
 
                    ,root->value.element.name
2090
 
                    );
2091
 
 
2092
 
            mxmlRelease (doc);
2093
 
 
2094
 
            return 0;
2095
 
        }
2096
 
        else
2097
 
        {
2098
 
            while (!strncmp (root->value.element.name, "!--", 3))
2099
 
            {
2100
 
                root = mxmlWalkNext (root, doc, MXML_NO_DESCEND);
2101
 
            }
2102
 
 
2103
 
            root = mxmlWalkNext (root, doc, MXML_DESCEND);  // skip ver num
2104
 
            root = mxmlWalkNext (root, doc, MXML_NO_DESCEND);  // get next
2105
 
            while (!strncmp (root->value.element.name, "!--", 3))
2106
 
            {
2107
 
                root = mxmlWalkNext (root, doc, MXML_NO_DESCEND);
2108
 
                root = mxmlWalkNext (root, doc, MXML_NO_DESCEND);
2109
 
            }
2110
 
        }
2111
 
    }
2112
 
    else
2113
 
    {
2114
 
        //printf ("it is adios-config\n");
2115
 
    }
2116
 
 
2117
 
 
2118
 
    if (strcasecmp (root->value.element.name, "adios-config"))
2119
 
    {
2120
 
        adios_error (err_invalid_xml_doc, "config.xml: invalid root xml element: %s\n"
2121
 
                ,root->value.element.name
2122
 
                );
2123
 
 
 
2109
    PRINT_MXML_NODE(root);
 
2110
 
 
2111
    if (strcasecmp (root->value.element.name, "adios-config")) {
 
2112
        root = mxmlFindElement (doc, doc, "adios-config", NULL, NULL, MXML_DESCEND);
 
2113
        PRINT_MXML_NODE(root);
 
2114
    }
 
2115
 
 
2116
 
 
2117
    if (!root || !root->value.element.name || strcasecmp (root->value.element.name, "adios-config"))
 
2118
    {
 
2119
        adios_error (err_invalid_xml_doc, "config.xml: did not find adios-config xml element\n");
2124
2120
        mxmlRelease (doc);
2125
 
 
2126
2121
        return 0;
2127
2122
    }
2128
2123
    else