avtVisItXdmfFileFormat.C 112 KB
Newer Older
1 2
/*****************************************************************************
*
brugger's avatar
 
brugger committed
3
* Copyright (c) 2000 - 2011, Lawrence Livermore National Security, LLC
4
* Produced at the Lawrence Livermore National Laboratory
brugger's avatar
 
brugger committed
5
* LLNL-CODE-442911
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
* All rights reserved.
*
* This file is  part of VisIt. For  details, see https://visit.llnl.gov/.  The
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution  and  use  in  source  and  binary  forms,  with  or  without
* modification, are permitted provided that the following conditions are met:
*
*  - Redistributions of  source code must  retain the above  copyright notice,
*    this list of conditions and the disclaimer below.
*  - Redistributions in binary form must reproduce the above copyright notice,
*    this  list of  conditions  and  the  disclaimer (as noted below)  in  the
*    documentation and/or other materials provided with the distribution.
*  - Neither the name of  the LLNS/LLNL nor the names of  its contributors may
*    be used to endorse or promote products derived from this software without
*    specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT  HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR  IMPLIED WARRANTIES, INCLUDING,  BUT NOT  LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND  FITNESS FOR A PARTICULAR  PURPOSE
* ARE  DISCLAIMED. IN  NO EVENT  SHALL LAWRENCE  LIVERMORE NATIONAL  SECURITY,
* LLC, THE  U.S.  DEPARTMENT OF  ENERGY  OR  CONTRIBUTORS BE  LIABLE  FOR  ANY
* DIRECT,  INDIRECT,   INCIDENTAL,   SPECIAL,   EXEMPLARY,  OR   CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT  LIMITED TO, PROCUREMENT OF  SUBSTITUTE GOODS OR
* SERVICES; LOSS OF  USE, DATA, OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER
* CAUSED  AND  ON  ANY  THEORY  OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT
* LIABILITY, OR TORT  (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING IN ANY  WAY
* OUT OF THE  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/

// ************************************************************************* //
//                            avtVisItXdmfFileFormat.C                       //
// ************************************************************************* //

#include <avtVisItXdmfFileFormat.h>

#include <string>

#include <vtkCellArray.h>
#include <vtkCellData.h>
#include <vtkFloatArray.h>
#include <vtkIdTypeArray.h>
#include <vtkIntArray.h>
#include <vtkRectilinearGrid.h>
#include <vtkStructuredGrid.h>
#include <vtkUnsignedCharArray.h>
#include <vtkUnstructuredGrid.h>

#include <avtCallback.h>
#include <avtDatabaseMetaData.h>
#include <avtGhostData.h>
#include <avtStructuredDomainBoundaries.h>
#include <avtVariableCache.h>

#include <Expression.h>

#include <BadIndexException.h>
#include <DebugStream.h>
#include <InvalidVariableException.h>
#include <InvalidFilesException.h>

#include <XDMFParser.h>

// Define this symbol BEFORE including hdf5.h to indicate the HDF5 code
// in this file uses version 1.6 of the HDF5 API. This is harmless for
// versions of HDF5 before 1.8 and ensures correct compilation with
// version 1.8 and thereafter. When, and if, the HDF5 code in this file
// is explicitly upgraded to the 1.8 API, this symbol should be removed.
#define H5_USE_16_API
#include <hdf5.h>
79
#include <visit-hdf5.h>
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217

#include <visit-config.h>

static int CellTypeToNodeCount[17] =
     {0, 0, 0, 3, 4, 4, 5, 6, 8, 3, 6, 8, 10, 13, 15, 20, 0};

// ****************************************************************************
//  Method: avtVisItXdmfFileFormat constructor
//
//  Programmer: brugger -- generated by xml2avt
//  Creation:   Wed Nov 14 11:28:35 PDT 2007
//
//  Modifications:
//    Eric Brugger, Wed Mar 19 12:38:46 PDT 2008
//    I added code to initialize hdfFiles.
//
// ****************************************************************************

avtVisItXdmfFileFormat::avtVisItXdmfFileFormat(const char *filename)
    : avtSTMDFileFormat(&filename, 1)
{
    fname = filename;
    fileRead = false;

    hdfFiles = new hid_t[MAX_FILES];
    for (int i = 0; i < MAX_FILES; i++)
        hdfFiles[i] = H5I_INVALID_HID;

    //
    // Turn off HDF5 error message to the terminal.
    //
    H5Eset_auto(NULL, NULL);
}


// ****************************************************************************
//  Method: avtVisItXdmfFileFormat destructor
//
//  Programmer: brugger -- generated by xml2avt
//  Creation:   Wed Nov 14 11:28:35 PDT 2007
//
//  Modifications:
//    Eric Brugger, Wed Mar 19 12:38:46 PDT 2008
//    I added code to delete hdfFiles.
//
// ****************************************************************************

avtVisItXdmfFileFormat::~avtVisItXdmfFileFormat()
{
    FreeUpResources();
    delete [] hdfFiles;
}


// ****************************************************************************
//  Method: avtVisItXdmfFileFormat::OpenFile
//
//  Purpose:
//      Open an HDF file given an index into a list of files.
//
//  Arguments:
//      f       The index of the file in the list of file names.
//
//  Returns:    A handle to the open file.
//
//  Programmer: Eric Brugger
//  Creation:   Wed Mar 19 12:38:46 PDT 2008
//
// ****************************************************************************

hid_t
avtVisItXdmfFileFormat::OpenFile(int f)
{
    //
    // Make sure this is in range.
    //
    if (f < 0 || f >= nFiles)
    {
        EXCEPTION2(BadIndexException, f, nFiles);
    }

    //
    // Check to see if the file is already open.
    //
    if (hdfFiles[f] != H5I_INVALID_HID)
    {
        UsedFile(f);
        return hdfFiles[f];
    }

    debug4 << "Opening XDMF file " << filenames[f] << endl;

    //
    // Open the file.
    //
    if ((hdfFiles[f] = H5Fopen(filenames[f], H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
    {
        avtCallback::IssueWarning("Unable to open file.");
        return 0;
    }

    RegisterFile(f);

    return hdfFiles[f];
}


// ****************************************************************************
//  Method: avtVisItXdmfFileFormat::OpenFile
//
//  Purpose:
//      Open an HDF file given a file name.
//
//  Arguments:
//      n       The name of the file.
//
//  Returns:    A handle to the open file.
//
//  Programmer: Eric Brugger
//  Creation:   Wed Mar 19 12:38:46 PDT 2008
//
// ****************************************************************************

hid_t
avtVisItXdmfFileFormat::OpenFile(const char *n)
{
    //
    // The directory of this file is all relative to the directory of
    // the xmf file.  Reflect that here.
    //
    char name[1024];
    if (n[0] == '/')
    {
        strcpy(name, n);
    }
    else
    {
        int lastSlash = fname.find_last_of(VISIT_SLASH_STRING);
allens's avatar
allens committed
218
        if (lastSlash == std::string::npos)
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968
        {
            strcpy(name, n);
        }
        else
        {
            strcpy(name, fname.substr(0, lastSlash+1).c_str());
            strcpy(name + lastSlash + 1, n); 
        }
    }

    //
    // Check if the file is already in the list.  If not then add it
    // to the list.  Note that AddFile will automatically take care of
    // overflow issues.
    //
    int fileIndex = -1;
    for (int i = 0; i < nFiles; i++)
    {
        if (strcmp(filenames[i], name) == 0)
        {
            fileIndex = i;
            break;
        }
    }

    if (fileIndex == -1)
    {
        fileIndex = AddFile(name);
    }

    //
    // Open the file.
    //
    hid_t file_id = OpenFile(fileIndex);

    return file_id;
}


// ****************************************************************************
//  Method: avtVisItXdmfFileFormat::CloseFile
//
//  Purpose:
//      Close an HDF file, given an index into the list of open files.
//
//  Arguments:
//      f       The index of the file in the list of file names.
//
//  Programmer: Eric Brugger
//  Creation:   Wed Mar 19 12:38:46 PDT 2008
//
// ****************************************************************************

void
avtVisItXdmfFileFormat::CloseFile(int f)
{
    if (hdfFiles[f] != H5I_INVALID_HID)
    {
        debug4 << "Closing HDF file " << filenames[f] << endl;

        if (H5Fclose(hdfFiles[f]) < 0)
        {
            avtCallback::IssueWarning("Unable to close the HDF file.");
        }
        UnregisterFile(f);
        hdfFiles[f] = H5I_INVALID_HID;
    }
}


// ****************************************************************************
//  Method: avtVisItXdmfFileFormat::DetermineFileAndDataset
//
//  Purpose:
//      Split a filename:dataset location into the file name and dataset name.
//      The filename and datasetname buffers must be 1024 characters long
//      including the terminating NULL.
//
//  Programmer: Eric Brugger
//  Creation:   Fri Nov 16 13:08:36 PST 2007
//
//  Modifications:
//    Kathleen Bonnell, Tue Jan  8 17:51:30 PST 2008
//    Use 'const' with return of ststr to suppress error on Windows with MSVC8.
//
// ****************************************************************************

int
avtVisItXdmfFileFormat::DetermineFileAndDataset(const char *input,
    char *filename, char *datasetname) const
{
    //
    // Determine the start of the filename;
    //
    const char *ptr = input;
    while (isspace(*ptr))
        ptr++;
    
    //
    // Find the ':' in the string.
    //
    const char *ptr2 = strstr(ptr, ":");
    if (ptr2 == NULL)
    {
        avtCallback::IssueWarning("Dataset specifier missing a colon.");
        return 1;
    }

    //
    // Find the end of the dataset name.
    //
    const char *ptr3 = ptr2 + 1;
    while (!isspace(*ptr3))
        ptr3++;

    //
    // Copy the filename and dataset names.
    //
    if (ptr2 - ptr == 0)
    {
        avtCallback::IssueWarning("Dataset specifier missing a filename.");
        return 2;
    }
    if (ptr2 - ptr > 1023)
    {
        avtCallback::IssueWarning("Dataset specifier filename over 1023 characters.");
        return 3;
    }
    char *ptr4 = filename;
    while (ptr != ptr2)
        *ptr4++ = *ptr++;
    *ptr4 = '\0';

    ptr2++;
    if (ptr3 - ptr2 == 0)
    {
        avtCallback::IssueWarning("Dataset specifier missing a dataset name.");
        return 4;
    }
    if (ptr3 - ptr2 > 1023)
    {
        avtCallback::IssueWarning("Dataset specifier dataset name over 1023 characters.");
        return 5;
    }
    ptr4 = datasetname;
    while (ptr2 != ptr3)
        *ptr4++ = *ptr2++;
    *ptr4 = '\0';

    return 0;
}


// ****************************************************************************
//  Method: avtVisItXdmfFileFormat::ReadXMLDataItem
//
//  Purpose:
//      Read a data item in XML format.
//
//  Programmer: Eric Brugger
//  Creation:   Thu Mar 20 16:14:36 PDT 2008
//
//  Arguments:
//      dataItem    The data item to read.
//      buf         The buffer to read the data into.
//      lBuf        The length of the buffer.
//      bufType     The data type of the buffer.
//
//  Modifications:
//    Eric Brugger, Fri Mar 21 15:22:11 PDT 2008
//    I added the argument bufType.
//
// ****************************************************************************

int
avtVisItXdmfFileFormat::ReadXMLDataItem(DataItem *dataItem, void *buf, int lBuf,
    int bufType)
{
    //
    // Check that the size of the dataset and buffer match.
    //
    int ldataItem = 1;
    for (int j = 0; j < dataItem->nDims; j++)
        ldataItem *= dataItem->dims[j];
    if (ldataItem != lBuf)
    {
        avtCallback::IssueWarning("Dimensions don't match buffer size.");
        return 0;
    }

    //
    // Open the file and seek to the start of the data.
    //
    FILE *file = fopen(fname.c_str(), "r");
    fseek(file, dataItem->cdataOffset, SEEK_SET);

    //
    // Read the data.  We will read lBuf values and not make any type
    // of check to see if there is not any additional trailing stuff.
    //
    int i;
    for (i = 0; i < lBuf; i++)
    {
        //
        // Read the value.  Fscanf will skip over any leading
        // white space.
        //
        if (bufType == VTK_FLOAT)
        {
            double value;
            if (fscanf(file, "%lf", &value) == 1)
            {
                ((float *)buf)[i] = (float) value;
            }
            else
            {
                break;
            }
        }
        else
        {
            double value;
            if (fscanf(file, "%lf", &value) == 1)
            {
                ((int *)buf)[i] = (int) value;
            }
            else
            {
                break;
            }
        }
    }

    //
    // Close the file.
    //
    fclose(file);

    if (i != lBuf)
    {
        avtCallback::IssueWarning("Not enough values in the data item.");
        return 0;
    }

    return 1;
}


// ****************************************************************************
//  Method: avtVisItXdmfFileFormat::ReadHDFDataItem
//
//  Purpose:
//      Read a data item in HDF5 format.
//
//  Programmer: Eric Brugger
//  Creation:   Fri Nov 16 13:08:36 PST 2007
//
//  Arguments:
//      dataItem    The data item to read.
//      buf         The buffer to read the data into.
//      lBuf        The length of the buffer.
//      bufType     The data type of the buffer.
//
//  Modifications:
//    Eric Brugger, Wed Mar 19 12:38:46 PDT 2008
//    I modified the routine so that it no longer opens and closes an
//    hdf file each time it is called.  Instead it uses OpenFile, which
//    hides the details of caching multiple open files so that files
//    typically only need to be opened once.
//
//    Eric Brugger, Thu Mar 20 10:10:15 PDT 2008
//    I added error checking for the input arguments.
//
//    Eric Brugger, Thu Mar 20 16:14:36 PDT 2008
//    I moved the error checking to ReadDataItem.
//
//    Eric Brugger, Fri Mar 21 15:22:11 PDT 2008
//    I added the argument bufType.
//
//    Brad Whitlock, Fri May 16 09:52:31 PDT 2008
//    Added debugging info since it can help debug creation of XML schemas.
//
//    Eric Brugger, Tue Aug 19 15:49:00 PDT 2008
//    I added coding to convert uchar, char, uint, and int to float if
//    necessary, since HDF5 doesn't do that type of conversion.
//
//    Eric Brugger, Fri Apr 24 08:31:34 PDT 2009
//    I changed the way char and int conversions are made to float since
//    the previous method caused a crash. I added coding to convert ulong
//    and long to float if necessary, when sizeof(long) was 8.
//
// ****************************************************************************

int
avtVisItXdmfFileFormat::ReadHDFDataItem(DataItem *dataItem, void *buf, int lBuf,
    int bufType)
{
    const char *mName = "avtVisItXdmfFileFormat::ReadHDFDataItem: ";
    hid_t     file_id, dataset_id, dataspace_id;
    hid_t     dataset_type;
    size_t    dataset_type_size;
    H5T_sign_t dataset_type_sign;
    H5T_class_t dataset_type_class;

    //
    // Check that the buffer type is valid.
    //
    if (bufType != VTK_FLOAT && bufType != VTK_INT)
        return 0;

    //
    // If cdata is NULL, then read it from the file.
    //
    if (dataItem->cdata == NULL)
    {
        FILE *file = fopen(fname.c_str(), "r");
        fseek(file, dataItem->cdataOffset, SEEK_SET);
        dataItem->cdata = new char[dataItem->cdataLength+1];
        fread(dataItem->cdata, 1, dataItem->cdataLength, file);
        dataItem->cdata[dataItem->cdataLength] = '\0';
        fclose(file);
    }

    //
    // Split the path into the file and dataset parts.
    //
    if (DetermineFileAndDataset(dataItem->cdata, filename, datasetname) != 0)
    {
        avtCallback::IssueWarning("Dataset specification invalid.");
        return 0;
    }
    debug4 << mName << "filename = " << filename << endl;

    //
    // Open the data file.
    //
    if ((file_id = OpenFile(filename)) < 0)
    {
        avtCallback::IssueWarning("Unable to open file.");
        return 0;
    }
    debug4 << mName << "datasetname = " << datasetname << endl;

    //
    // Open the data set.
    //
    if ((dataset_id = H5Dopen(file_id, datasetname)) < 0)
    {
        avtCallback::IssueWarning("Unable to open dataset.");
        return 0;
    }

    //
    // Get the data type information for the data set.
    //
    if ((dataset_type = H5Dget_type(dataset_id)) < 0)
    {
        avtCallback::IssueWarning("Unable to get the dataset type.");
        H5Dclose(dataset_id);
        return 0;
    }

    dataset_type_class = H5Tget_class(dataset_type);
    dataset_type_sign  = H5Tget_sign(dataset_type);
    dataset_type_size  = H5Tget_size(dataset_type);

    //
    // Check that the type is supported.  This includes 1, 4, and 8 byte
    // integers and 4 and 8 byte floats.
    //
    if ((dataset_type_class == H5T_INTEGER &&
         dataset_type_size != 1 && dataset_type_size != 4 &&
         dataset_type_size != 8) ||
        (dataset_type_class == H5T_FLOAT &&
         dataset_type_size != 4 && dataset_type_size != 8) ||
        (dataset_type_class != H5T_INTEGER &&
         dataset_type_class != H5T_FLOAT))
    {
        avtCallback::IssueWarning("Unsupported data type.");
        H5Dclose(dataset_id);
        return 0;
    }
        
    //
    // Determine the size of the dataset.
    //
    if ((dataspace_id = H5Dget_space(dataset_id)) < 0)
    {
        avtCallback::IssueWarning("Unable to get the dataspace id.");
        H5Dclose(dataset_id);
        return 0;
    }
    hssize_t ldataset = H5Sget_simple_extent_npoints(dataspace_id);
    if (H5Sclose(dataspace_id) < 0)
    {
        avtCallback::IssueWarning("Unable to close the dataspace.");
    }

    //
    // Check that the size of the dataset and the dimensions match.
    //
    int ldataItem = 1;
    debug4 << mName << "nDims = " << dataItem->nDims << "  {";
    for (int i = 0; i < dataItem->nDims; i++)
    {
        ldataItem *= dataItem->dims[i];
        debug4 << dataItem->dims[i] << " ";
    }
    debug4 << "}" << endl;
    debug4 << mName << "ldataset=" << ldataset << endl;
    if (ldataItem != ldataset)
    {
        avtCallback::IssueWarning("Dimensions don't match dataset size.");
        H5Dclose(dataset_id);
        return 0;
    }

    //
    // Check that the size of the dataset and the buffer match.
    //
    if (ldataset != lBuf)
    {
        avtCallback::IssueWarning("Buffer size doesn't match dataset size.");
        H5Dclose(dataset_id);
        return 0;
    }

    //
    // Read the data set.
    //
    if (bufType == VTK_INT && dataset_type_class == H5T_INTEGER)
    {
        debug4 << mName << "Reading integer data" << endl;
        if (H5Dread(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
                    H5P_DEFAULT, buf) < 0)
        {
            avtCallback::IssueWarning("Unable to read the dataset.");
            H5Dclose(dataset_id);
            return 0;
        }
    }
    else if (bufType == VTK_FLOAT && dataset_type_class == H5T_FLOAT)
    {
        debug4 << mName << "Reading float data" << endl;
        if (H5Dread(dataset_id, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL,
                    H5P_DEFAULT, buf) < 0)
        {
            avtCallback::IssueWarning("Unable to read the dataset.");
            H5Dclose(dataset_id);
            return 0;
        }
    }
    else if (bufType == VTK_FLOAT)
    {
        if (dataset_type_size == 1 && dataset_type_sign == H5T_SGN_NONE)
        {
            debug4 << mName << "Converting uchar to float" << endl;
            unsigned char *cBuf = new unsigned char[lBuf];
            if (H5Dread(dataset_id, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL,
                        H5P_DEFAULT, cBuf) < 0)
            {
                avtCallback::IssueWarning("Unable to read the dataset.");
                H5Dclose(dataset_id);
                return 0;
            }
            float *fBuf = (float *)buf;
            for (int i = 0; i < lBuf; i++)
                fBuf[i] = (float) cBuf[i];
            delete [] cBuf;
        }
        else if (dataset_type_size == 1 && dataset_type_sign == H5T_SGN_2)
        {
            debug4 << mName << "Converting char to float" << endl;
            char *cBuf = new char[lBuf];
            if (H5Dread(dataset_id, H5T_NATIVE_CHAR, H5S_ALL, H5S_ALL,
                        H5P_DEFAULT, cBuf) < 0)
            {
                avtCallback::IssueWarning("Unable to read the dataset.");
                H5Dclose(dataset_id);
                return 0;
            }
            float *fBuf = (float *)buf;
            for (int i = 0; i < lBuf; i++)
                fBuf[i] = (float) cBuf[i];
            delete [] cBuf;
        }
        else if (dataset_type_size == 4 && dataset_type_sign == H5T_SGN_NONE)
        {
            debug4 << mName << "Converting uint to float" << endl;
            unsigned int *iBuf = new unsigned int[lBuf];
            if (H5Dread(dataset_id, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL,
                        H5P_DEFAULT, iBuf) < 0)
            {
                avtCallback::IssueWarning("Unable to read the dataset.");
                H5Dclose(dataset_id);
                return 0;
            }
            float *fBuf = (float *)buf;
            for (int i = 0; i < lBuf; i++)
                fBuf[i] = (float) iBuf[i];
            delete [] iBuf;
        }
        else if (dataset_type_size == 4 && dataset_type_sign == H5T_SGN_2)
        {
            debug4 << mName << "Converting int to float" << endl;
            int *iBuf = new int[lBuf];
            if (H5Dread(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
                        H5P_DEFAULT, iBuf) < 0)
            {
                avtCallback::IssueWarning("Unable to read the dataset.");
                H5Dclose(dataset_id);
                return 0;
            }
            float *fBuf = (float *)buf;
            for (int i = 0; i < lBuf; i++)
                fBuf[i] = (float) iBuf[i];
            delete [] iBuf;
        }
        else if (dataset_type_size == 8 && dataset_type_sign == H5T_SGN_NONE)
        {
            if (sizeof(unsigned long) == 8)
            {
                debug4 << mName << "Converting ulong to float" << endl;
                unsigned long *iBuf = new unsigned long[lBuf];
                if (H5Dread(dataset_id, H5T_NATIVE_ULONG, H5S_ALL, H5S_ALL,
                            H5P_DEFAULT, iBuf) < 0)
                {
                    avtCallback::IssueWarning("Unable to read the dataset.");
                    H5Dclose(dataset_id);
                    return 0;
                }
                float *fBuf = (float *)buf;
                for (int i = 0; i < lBuf; i++)
                    fBuf[i] = (float) iBuf[i];
                delete [] iBuf;
            }
            else
            {
                avtCallback::IssueWarning("Unable to read the dataset.");
                H5Dclose(dataset_id);
                return 0;
            }
        }
        else if (dataset_type_size == 8 && dataset_type_sign == H5T_SGN_2)
        {
            if (sizeof(long) == 8)
            {
                debug4 << mName << "Converting long to float" << endl;
                long *iBuf = new long[lBuf];
                if (H5Dread(dataset_id, H5T_NATIVE_LONG, H5S_ALL, H5S_ALL,
                            H5P_DEFAULT, iBuf) < 0)
                {
                    avtCallback::IssueWarning("Unable to read the dataset.");
                    H5Dclose(dataset_id);
                    return 0;
                }
                float *fBuf = (float *)buf;
                for (int i = 0; i < lBuf; i++)
                    fBuf[i] = (float) iBuf[i];
                delete [] iBuf;
            }
            else
            {
                avtCallback::IssueWarning("Unable to read the dataset.");
                H5Dclose(dataset_id);
                return 0;
            }
        }
        else
        {
            avtCallback::IssueWarning("Unable to read the dataset.");
            H5Dclose(dataset_id);
            return 0;
        }
    }

    //
    // Close the dataset.
    //
    if (H5Dclose(dataset_id) < 0)
    {
        avtCallback::IssueWarning("Unable to close the dataset.");
    }

    return 1;
}


// ****************************************************************************
//  Method: avtVisItXdmfFileFormat::ReadDataItem
//
//  Purpose:
//      Read a data item.
//
//  Programmer: Eric Brugger
//  Creation:   Thu Mar 20 16:14:36 PDT 2008
//
//  Arguments:
//      dataItem    The data item to read.
//      buf         The buffer to read the data into.
//      lBuf        The length of the buffer.
//      bufType     The data type of the buffer.
//
//  Modifications:
//    Eric Brugger, Fri Mar 21 15:22:11 PDT 2008
//    I added the argument bufType.
//
// ****************************************************************************

int
avtVisItXdmfFileFormat::ReadDataItem(DataItem *dataItem, void *buf, int lBuf,
    int bufType)
{
    //
    // Do some error checking.
    //
    if (dataItem == NULL || buf == NULL || lBuf <= 0)
        return 0;

    //
    // Read the data based on the format.
    //
    switch (dataItem->format)
    {
      case DataItem::DATA_FORMAT_XML:
        return ReadXMLDataItem(dataItem, buf, lBuf, bufType);

        break;
      case DataItem::DATA_FORMAT_HDF:
        return ReadHDFDataItem(dataItem, buf, lBuf, bufType);

        break;
    }
    
    return 0;
}


// ****************************************************************************
//  Method: avtVisItXdmfFileFormat::AddVarInfo
//
//  Purpose:
//      Add a VarInfo entry to the file variable list.
//
//  Programmer: Eric Brugger
//  Creation:   Fri Nov 16 13:08:36 PST 2007
//
// ****************************************************************************

void
avtVisItXdmfFileFormat::AddVarInfo(bool topGrid, int iBlock, VarInfo *varInfo)
{
    //
    // Check if the varInfo already exists in the file list.
    //
    unsigned int iVar = 0;
    while (iVar < fileVarList.size() &&
           (fileVarList[iVar]->iDomain != varInfo->iDomain || 
            fileVarList[iVar]->iGrid != varInfo->iGrid || 
            fileVarList[iVar]->name != varInfo->name))
    {
        iVar++;
    }

    if (iVar == fileVarList.size())
    {
        //
        // The entry is not in the list. If this is a top level grid add
        // it straight to the list, otherwise add it as block under a new
        // top level entry.  We are adding NULL blocks to fill any gapps
        // in the block list.
        //
        if (topGrid)
        {
            fileVarList.push_back(varInfo);
        }
        else
        {
            VarInfo *varInfo2 = new VarInfo;
            varInfo2->name         = varInfo->name;
            varInfo2->meshName     = varInfo->meshName;
            varInfo2->variableType = varInfo->variableType;
            varInfo2->centering    = varInfo->centering;
            varInfo2->varDimension = varInfo->varDimension;
            varInfo2->iDomain      = varInfo->iDomain;
            varInfo2->iGrid        = varInfo->iGrid;

            varInfo2->nBlocks = iBlock + 1;
            for (int i = fileVarList.size(); i < iBlock; i++)
            {
                varInfo2->blockList.push_back(NULL);
            } 
            varInfo2->blockList.push_back(varInfo);

            fileVarList.push_back(varInfo2);
        }
    }
    else
    {
        //
        // The entry is in the list. If this is a top level grid then it
        // is a duplicate and we will ignore it, otherwise it will normally
        // be added as a new block under an existing top level entry. If the
        // block is already in the list then it is a duplicate and we will
        // ignore it. We are adding NULL blocks to fill any gapps in the
        // block list.
        //
        if (topGrid)
        {
            debug1 << "Duplicate variable name, ignoring second instance." << endl;
        }
        else
        {
            if (fileVarList[iVar]->nBlocks == iBlock + 1)
            {
                debug1 << "Duplicate variable name, ignoring second instance." << endl;
                return;
            }

            fileVarList[iVar]->nBlocks = iBlock + 1;
            for (int i = fileVarList[iVar]->blockList.size(); i < iBlock; i++)
            {
                fileVarList[iVar]->blockList.push_back(NULL);
            } 
            fileVarList[iVar]->blockList.push_back(varInfo);
        }
    }
}


// ****************************************************************************
//  Method: avtVisItXdmfFileFormat::ParseDataItem
//
//  Purpose:
//      Parse a DataItem node in the DOM tree, returning a pointer to a
//      DataItem.
//
//  Programmer: Eric Brugger
//  Creation:   Fri Nov 16 13:08:36 PST 2007
//
//  Modifications:
//    Eric Brugger, Fri Apr 24 08:31:34 PDT 2009
//    I enhanced the routine to be insensitive to the case for element names,
//    attribute names, and attribute values that were not names.
//
// ****************************************************************************

DataItem *
avtVisItXdmfFileFormat::ParseDataItem()
{
allens's avatar
allens committed
969 970 971 972
    std::string    dimensions;
    std::string    numberType;
    std::string    precision;
    std::string    format;
973 974 975 976 977 978 979 980 981 982 983
    char     *cdata=NULL;
    int       cdataOffset=0;
    int       cdataLength=0;

    //
    // Process the attributes in the start tag.
    //
    while (xdmfParser.GetNextAttribute())
    {
        if (strcmp(xdmfParser.GetAttributeName(), "DIMENSIONS") == 0)
        {
allens's avatar
allens committed
984
            dimensions = std::string(xdmfParser.GetAttributeValueAsUpper());
985 986 987 988
        }
        else if (strcmp(xdmfParser.GetAttributeName(), "TYPE") == 0 ||
                 strcmp(xdmfParser.GetAttributeName(), "NUMBERTYPE") == 0)
        {
allens's avatar
allens committed
989
            numberType = std::string(xdmfParser.GetAttributeValueAsUpper());
990 991 992
        }
        else if (strcmp(xdmfParser.GetAttributeName(), "PRECISION") == 0)
        {
allens's avatar
allens committed
993
            precision = std::string(xdmfParser.GetAttributeValueAsUpper());
994 995 996
        }
        else if (strcmp(xdmfParser.GetAttributeName(), "FORMAT") == 0)
        {
allens's avatar
allens committed
997
            format = std::string(xdmfParser.GetAttributeValueAsUpper());
998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149
        }
    }

    //
    // Process the rest of the information.
    //
    XDMFParser::ElementType elementType = xdmfParser.GetNextElement();
    while (elementType != XDMFParser::TYPE_EOF)
    {
        if (elementType == XDMFParser::TYPE_START_TAG)
        {
            xdmfParser.SkipToEndTag();
        }
        else if (elementType == XDMFParser::TYPE_CDATA)
        {
            cdataOffset = xdmfParser.GetCDataOffset();
            cdataLength = xdmfParser.GetCDataLength();
            if (cdataLength <= 1023)
            {
                cdata = new char[cdataLength+1];
                memcpy(cdata, xdmfParser.GetCDataValue(), cdataLength+1);
            }
        }
        else if (elementType == XDMFParser::TYPE_END_TAG)
        {
            break;
        }
        elementType = xdmfParser.GetNextElement();
    }

    DataItem *dataItem = new DataItem;

    //
    // Store the CData. We do this first so that it will get freed
    // as part of the DataItem destructor.
    //
    if (cdataLength == 0)
    {
        debug1 << "Invalid DataItem: CData missing." << endl;
        delete dataItem;
        return NULL;
    }
    dataItem->cdata = cdata;
    dataItem->cdataOffset = cdataOffset;
    dataItem->cdataLength = cdataLength;
    
    //
    // Determine the format (HDF or XML).
    //
    if (format == "HDF")
        dataItem->format = DataItem::DATA_FORMAT_HDF; 
    else if (format == "" || format == "XML")
        dataItem->format = DataItem::DATA_FORMAT_XML; 
    else
    {
        debug1 << "Invalid DataItem: Format must be XML or HDF." << endl;
        delete dataItem;
        return NULL;
    }

    //
    // Determine the number type.
    //
    if (numberType == "" || numberType == "FLOAT")
        dataItem->type = DataItem::DATA_TYPE_FLOAT;
    else if (numberType == "INT")
        dataItem->type = DataItem::DATA_TYPE_INT;
    else if (numberType == "UINT")
        dataItem->type = DataItem::DATA_TYPE_UINT;
    else if (numberType == "CHAR")
        dataItem->type = DataItem::DATA_TYPE_CHAR;
    else if (numberType == "UCHAR")
        dataItem->type = DataItem::DATA_TYPE_UCHAR;
    else
    {
        debug1 << "Invalid DataItem: NumberType must be Float, Int, UInt, Char, or UChar." << endl;
        delete dataItem;
        return NULL;
    }

    //
    // Determine the precision.
    //
    if (precision == "" || precision == "4")
        dataItem->precision = 4;
    else if (precision == "8")
        dataItem->precision = 8;
    else if (precision == "1")
        dataItem->precision = 1;
    else
    {
        debug1 << "Invalid DataItem: Precision must be 1, 4, or 8." << endl;
        delete dataItem;
        return NULL;
    }

    //
    // Determine the dimensions.
    //
    if (dimensions == "")
    {
        debug1 << "Invalid DataItem: Dimensions missing." << endl;
        delete dataItem;
        return NULL;
    }
    dataItem->nDims = sscanf(dimensions.c_str(), "%d %d %d %d",
           &dataItem->dims[0],
           &dataItem->dims[1],
           &dataItem->dims[2],
           &dataItem->dims[3]);
    if (dataItem->nDims < 1)
    {
        debug1 << "Invalid DataItem: Dimensions must have at least 1 value." << endl;
        delete dataItem;
        return NULL;
    }

    return dataItem;
}


// ****************************************************************************
//  Method: avtVisItXdmfFileFormat::ParseTopology
//
//  Purpose:
//      Parse a Topology node in the DOM tree.
//
//  Programmer: Eric Brugger
//  Creation:   Fri Nov 16 13:08:36 PST 2007
//
//  Arguments:
//      topologyType      The topology type string.
//      numberOfElements  The number of elements string
//      nodesPerElement   The number of nodes per element string.
//      baseOffset        The base offset for the connectivity.
//      order             The order of the nodes for the element.
//      topologyData      The data item associated with the topology.
//
//  Modifications:
//    Eric Brugger, Fri Mar 21 15:22:11 PDT 2008
//    I added the arguments nodesPerElement and topology data.
//
//    Eric Brugger, Tue Apr  8 14:25:31 PDT 2008
//    Added the arguments baseOffset and order.
//
//    Eric Brugger, Fri Apr 24 08:31:34 PDT 2009
//    I enhanced the routine to be insensitive to the case for element names,
//    attribute names, and attribute values that were not names.
//
// ****************************************************************************

void
allens's avatar
allens committed
1150 1151 1152
avtVisItXdmfFileFormat::ParseTopology(std::string &topologyType,
    std::string &numberOfElements, std::string &nodesPerElement, std::string &baseOffset,
    std::string &order, DataItem **topologyData)
1153 1154 1155 1156 1157 1158 1159 1160 1161
{
    //
    // Process the attributes in the start tag.
    //
    while (xdmfParser.GetNextAttribute())
    {
        if (strcmp(xdmfParser.GetAttributeName(), "TYPE") == 0 ||
            strcmp(xdmfParser.GetAttributeName(), "TOPOLOGYTYPE") == 0)
        {
allens's avatar
allens committed
1162
            topologyType = std::string(xdmfParser.GetAttributeValueAsUpper());
1163 1164 1165 1166
        }
        else if (strcmp(xdmfParser.GetAttributeName(), "NUMBEROFELEMENTS") == 0 ||
                 strcmp(xdmfParser.GetAttributeName(), "DIMENSIONS") == 0)
        {
allens's avatar
allens committed
1167
            numberOfElements = std::string(xdmfParser.GetAttributeValueAsUpper());
1168 1169 1170
        }
        else if (strcmp(xdmfParser.GetAttributeName(), "NODESPERELEMENT") == 0)
        {
allens's avatar
allens committed
1171
            nodesPerElement = std::string(xdmfParser.GetAttributeValueAsUpper());
1172 1173 1174
        }
        else if (strcmp(xdmfParser.GetAttributeName(), "BASEOFFSET") == 0)
        {
allens's avatar
allens committed
1175
            baseOffset = std::string(xdmfParser.GetAttributeValueAsUpper());
1176 1177 1178
        }
        else if (strcmp(xdmfParser.GetAttributeName(), "ORDER") == 0)
        {
allens's avatar
allens committed
1179
            order = std::string(xdmfParser.GetAttributeValueAsUpper());
1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238
        }
    }

    //
    // Process the rest of the information.
    //
    bool haveTopologyData = false;
    XDMFParser::ElementType elementType = xdmfParser.GetNextElement();
    while (elementType != XDMFParser::TYPE_EOF)
    {
        if (elementType == XDMFParser::TYPE_START_TAG)
        {
            if (strcmp(xdmfParser.GetElementName(), "DATAITEM") == 0)
            {
                if (!haveTopologyData)
                {
                    *topologyData = ParseDataItem();
                    haveTopologyData = true;
                }
                else
                {
                    xdmfParser.SkipToEndTag();
                }
            }
            else
            {
                xdmfParser.SkipToEndTag();
            }
        }
        else if (elementType == XDMFParser::TYPE_END_TAG)
        {
            break;
        }
        elementType = xdmfParser.GetNextElement();
    }
}


// ****************************************************************************
//  Method: avtVisItXdmfFileFormat::ParseGeometry
//
//  Purpose:
//      Parse a Geometry node in the DOM tree.
//
//  Programmer: Eric Brugger
//  Creation:   Fri Nov 16 13:08:36 PST 2007
//
//  Modifications:
//    Kathleen Bonnell, Tue Jan  8 17:51:30 PST 2008
//    Remove 'struct' from in front of DataItem, to remove compile error on 
//    Windows.
//
//    Eric Brugger, Fri Apr 24 08:31:34 PDT 2009
//    I enhanced the routine to be insensitive to the case for element names,
//    attribute names, and attribute values that were not names.
//
// ****************************************************************************

void
allens's avatar
allens committed
1239
avtVisItXdmfFileFormat::ParseGeometry(std::string &geometryType, int &nDataItem,
1240 1241 1242 1243 1244 1245 1246 1247 1248 1249
    DataItem **geometryData)
{
    //
    // Process the attributes in the start tag.
    //
    while (xdmfParser.GetNextAttribute())
    {
        if (strcmp(xdmfParser.GetAttributeName(), "TYPE") == 0 ||
            strcmp(xdmfParser.GetAttributeName(), "GEOMETRYTYPE") == 0)
        {
allens's avatar
allens committed
1250
            geometryType = std::string(xdmfParser.GetAttributeValueAsUpper());
1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306
        }
    }

    //
    // Process the rest of the information.
    //
    nDataItem = 0;
    XDMFParser::ElementType elementType = xdmfParser.GetNextElement();
    while (elementType != XDMFParser::TYPE_EOF)
    {
        if (elementType == XDMFParser::TYPE_START_TAG)
        {
            if (strcmp(xdmfParser.GetElementName(), "DATAITEM") == 0)
            {
                if (nDataItem < 3)
                {
                    geometryData[nDataItem] = ParseDataItem();
                    nDataItem++;
                }
                else
                {
                    xdmfParser.SkipToEndTag();
                }
            }
            else
            {
                xdmfParser.SkipToEndTag();
            }
        }
        else if (elementType == XDMFParser::TYPE_END_TAG)
        {
            break;
        }
        elementType = xdmfParser.GetNextElement();
    }
}


// ****************************************************************************
//  Method: avtVisItXdmfFileFormat::ParseAttribute
//
//  Purpose:
//      Parse an Attribute node in the DOM tree.
//
//  Programmer: Eric Brugger
//  Creation:   Fri Nov 16 13:08:36 PST 2007
//
//  Modifications:
//    Eric Brugger, Fri Apr 24 08:31:34 PDT 2009
//    I enhanced the routine to be insensitive to the case for element names,
//    attribute names, and attribute values that were not names.
//
// ****************************************************************************

VarInfo *
avtVisItXdmfFileFormat::ParseAttribute(int iDomain, int iGrid,
allens's avatar
allens committed
1307
    const std::string &gridName)
1308
{
allens's avatar
allens committed
1309 1310 1311
    std::string    attributeName;
    std::string    attributeType;
    std::string    center;
1312 1313 1314 1315 1316 1317 1318 1319 1320
    DataItem *varData=NULL;
    
    //
    // Process the attributes in the start tag.
    //
    while (xdmfParser.GetNextAttribute())
    {
        if (strcmp(xdmfParser.GetAttributeName(), "NAME") == 0)
        {
allens's avatar
allens committed
1321
            attributeName = std::string(xdmfParser.GetAttributeValue());
1322 1323 1324 1325
        }
        else if (strcmp(xdmfParser.GetAttributeName(), "TYPE") == 0 ||
                 strcmp(xdmfParser.GetAttributeName(), "ATTRIBUTETYPE") == 0)
        {
allens's avatar
allens committed
1326
            attributeType = std::string(xdmfParser.GetAttributeValueAsUpper());
1327 1328 1329
        }
        else if (strcmp(xdmfParser.GetAttributeName(), "CENTER") == 0)
        {
allens's avatar
allens committed
1330
            center = std::string(xdmfParser.GetAttributeValueAsUpper());
1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475
        }
    }

    //
    // Process the rest of the information.
    //
    XDMFParser::ElementType elementType = xdmfParser.GetNextElement();
    while (elementType != XDMFParser::TYPE_EOF)
    {
        if (elementType == XDMFParser::TYPE_START_TAG)
        {
            if (strcmp(xdmfParser.GetElementName(), "DATAITEM") == 0)
            {
                varData = ParseDataItem();
            }
            else
            {
                xdmfParser.SkipToEndTag();
            }
        }
        else if (elementType == XDMFParser::TYPE_END_TAG)
        {
            break;
        }
        elementType = xdmfParser.GetNextElement();
    }

    //
    // Do some error checking.
    //
    if (attributeName == "")
    {
        debug1 << "Invalid Attribute: Name missing." << endl;
        return NULL;
    }

    if (varData == NULL)
    {
        debug1 << "Invalid Attribute: Data missing." << endl;
        return NULL;
    }

    VarInfo *varInfo = new VarInfo;

    //
    // Store the DataItem. We do this first so that it will get freed
    // as part of the VarInfo destructor.
    //
    varInfo->varData = varData;

    //
    // Set some identifying information for the variable.
    //
    varInfo->name = attributeName;
    varInfo->meshName = gridName;
    varInfo->iDomain = iDomain;
    varInfo->iGrid = iGrid;

    //
    // Determine the attribute type and dimension.
    //
    if (attributeType == "" || attributeType == "SCALAR")
    {
        varInfo->variableType = VarInfo::TYPE_SCALAR;
        varInfo->varDimension = 1;
    }
    else if (attributeType == "VECTOR")
    {
        varInfo->variableType = VarInfo::TYPE_VECTOR;
        varInfo->varDimension = varData->dims[varData->nDims-1];
    }
    else if (attributeType == "TENSOR")
    {
        varInfo->variableType = VarInfo::TYPE_TENSOR;
        varInfo->varDimension = 9;
    }
    else if (attributeType == "TENSOR6")
    {
        varInfo->variableType = VarInfo::TYPE_TENSOR;
        varInfo->varDimension = 6;
    }
    else if (attributeType == "MATRIX")
    {
        debug1 << "Invalid Attribute: Unsupported AttributeType - Matrix." << endl;
        delete varInfo;
        return NULL;
    }
    else
    {
        debug1 << "Invalid Attribute: Invalid AttributeType." << endl;
        delete varInfo;
        return NULL;
    }

    //
    // Determine the centering.
    //
    if (center == "" || center == "NODE")
    {
        varInfo->centering = AVT_NODECENT;
    }
    else if (center == "CELL")
    {
        varInfo->centering = AVT_ZONECENT;
    }
    else if (center == "FACE" || center == "EDGE" || center == "GRID")
    {
        debug1 << "Invalid Attribute: Unsupported Center." << endl;
        delete varInfo;
        return NULL;
    }
    else
    {
        debug1 << "Invalid Attribute: Invalid Center." << endl;
        delete varInfo;
        return NULL;
    }

    varInfo->nBlocks = 1;
    varInfo->extents = NULL;

    return varInfo;
}


// ****************************************************************************
//  Method: avtVisItXdmfFileFormat::ParseGridInformation
//
//  Purpose:
//      Parse an Information node within a grid node in the DOM tree.
//
//  Programmer: Eric Brugger
//  Creation:   Mon Mar 17 13:22:09 PDT 2008
//
//  Modifications:
//    Eric Brugger, Tue Aug 26 15:57:05 PDT 2008
//    Modified the routine to handle grid information with a baseIndex.
//
//    Eric Brugger, Fri Apr 24 08:31:34 PDT 2009
//    I enhanced the routine to be insensitive to the case for element names,
//    attribute names, and attribute values that were not names.
//
// ****************************************************************************

void
allens's avatar
allens committed
1476 1477
avtVisItXdmfFileFormat::ParseGridInformation(std::string &baseIndex,
    std::string &ghostOffsets)
1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496
{
    bool haveBaseIndex = false;
    bool haveGhostOffsets = false;

    //
    // Process the attributes in the start tag.
    //
    while (xdmfParser.GetNextAttribute())
    {
        if (strcmp(xdmfParser.GetAttributeName(), "NAME") == 0)
        {
            if (strcmp(xdmfParser.GetAttributeValueAsUpper(), "BASEINDEX") == 0)
                haveBaseIndex = true;
            else if (strcmp(xdmfParser.GetAttributeValueAsUpper(), "GHOSTOFFSETS") == 0)
                haveGhostOffsets = true;
        }
        else if (strcmp(xdmfParser.GetAttributeName(), "VALUE") == 0)
        {
            if (haveBaseIndex)
allens's avatar
allens committed
1497
                baseIndex = std::string(xdmfParser.GetAttributeValueAsUpper());
1498
            else if (haveGhostOffsets)
allens's avatar
allens committed
1499
                ghostOffsets = std::string(xdmfParser.GetAttributeValueAsUpper());
1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532
        }
    }

    //
    // Process the rest of the information.
    //
    XDMFParser::ElementType elementType = xdmfParser.GetNextElement();
    while (elementType != XDMFParser::TYPE_EOF)
    {
        if (elementType == XDMFParser::TYPE_START_TAG)
        {
            xdmfParser.SkipToEndTag();
        }
        else if (elementType == XDMFParser::TYPE_END_TAG)
        {
            break;
        }
        elementType = xdmfParser.GetNextElement();
    }
}

// ****************************************************************************
//  Method: avtVisItXdmfFileFormat::ParseTime
//
//  Purpose:
//      Parse a Time node in the DOM tree.
//
//  Programmer: Mark C. Miller
//  Creation:   Wed Jul 29 18:08:15 PDT 2009
//
// ****************************************************************************

void
allens's avatar
allens committed
1533
avtVisItXdmfFileFormat::ParseTime(std::string &time)
1534 1535 1536 1537 1538
{
    while (xdmfParser.GetNextAttribute())
    {
        if (strcmp(xdmfParser.GetAttributeName(), "VALUE") == 0)
        {
allens's avatar
allens committed
1539
            time = std::string(xdmfParser.GetAttributeValueAsUpper());
1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600
        }
    }

    //
    // Process the rest of the information.
    //
    XDMFParser::ElementType elementType = xdmfParser.GetNextElement();
    while (elementType != XDMFParser::TYPE_EOF)
    {
        if (elementType == XDMFParser::TYPE_START_TAG)
        {
            xdmfParser.SkipToEndTag();
        }
        else if (elementType == XDMFParser::TYPE_END_TAG)
        {
            break;
        }
        elementType = xdmfParser.GetNextElement();
    }
}

// ****************************************************************************
//  Method: avtVisItXdmfFileFormat::ParseUniformGrid
//
//  Purpose:
//      Parse a uniform grid node of the DOM tree.
//
//  Programmer: Eric Brugger
//  Creation:   Fri Nov 16 13:08:36 PST 2007
//
//  Modifications:
//    Eric Brugger, Mon Mar 17 13:22:09 PDT 2008
//    Added logic to read ghost offsets.
//
//    Eric Brugger, Thu Mar 20 10:10:15 PDT 2008
//    I changed some of the geometry type strings that were incorrect.
//
//    Eric Brugger, Fri Mar 21 15:22:11 PDT 2008
//    I added additional coding to fully handle unstructured grids.
//
//    Eric Brugger, Tue Apr  8 14:25:31 PDT 2008
//    I added coding to handle baseOffset and order for unstructured grids.
//
//    Eric Brugger, Tue Aug 26 15:57:05 PDT 2008
//    Modified the routine to handle grid information with a baseIndex. I
//    also reversed the order in which the ghost zone indices are interpreted
//    to match the order in which dimensions are interpreted.
//
//    Eric Brugger, Fri Apr 24 08:31:34 PDT 2009
//    I enhanced the routine to be insensitive to the case for element names,
//    attribute names, and attribute values that were not names.
//
//    Mark C. Miller, Thu Jul 30 11:12:17 PDT 2009
//    Added parsing of <Time Value="xxx" /> element.
//
//    Eric Brugger, Mon Feb  1 15:12:29 PST 2010
//    Allowed the geometry type TYPE_X_Y_Z to have only 2 arrays.
//
// ****************************************************************************

void
allens's avatar
allens committed
1601
avtVisItXdmfFileFormat::ParseUniformGrid(std::vector<MeshInfo*> &meshList,
1602
    int iDomain, int iGrid, bool topGrid,
allens's avatar
allens committed
1603
    const std::string &gridName)
1604
{
allens's avatar
allens committed
1605 1606 1607 1608 1609
    std::string    topologyType;
    std::string    numberOfElements;
    std::string    nodesPerElement;
    std::string    baseOffset;
    std::string    order;
1610
    DataItem *topologyData = NULL;
allens's avatar
allens committed
1611
    std::string    geometryType;
1612 1613 1614
    int       nMeshData;
    DataItem *meshData[3];
    VarInfo  *varInfo = NULL;
allens's avatar
allens committed
1615 1616 1617 1618
    std::vector<VarInfo*> varList;
    std::string    baseIndex;
    std::string    ghostOffsets;
    std::string    time;
1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954

    //
    // Process the elements of the grid.
    //
    XDMFParser::ElementType elementType = xdmfParser.GetNextElement();
    while (elementType != XDMFParser::TYPE_EOF)
    {
        if (elementType == XDMFParser::TYPE_START_TAG)
        {
            if (strcmp(xdmfParser.GetElementName(), "TOPOLOGY") == 0)
            {
                ParseTopology(topologyType, numberOfElements, nodesPerElement,
                    baseOffset, order, &topologyData);
            }
            else if (strcmp(xdmfParser.GetElementName(), "GEOMETRY") == 0)
            {
                ParseGeometry(geometryType, nMeshData, meshData);
            }
            else if (strcmp(xdmfParser.GetElementName(), "ATTRIBUTE") == 0)
            {
                if ((varInfo = ParseAttribute(iDomain, iGrid, gridName)) != NULL)
                    varList.push_back(varInfo);
            }
            else if (strcmp(xdmfParser.GetElementName(), "INFORMATION") == 0)
            {
                ParseGridInformation(baseIndex, ghostOffsets);
            }
            else if (strcmp(xdmfParser.GetElementName(), "TIME") == 0)
            {
                ParseTime(time);
            }
            else
            {
                xdmfParser.SkipToEndTag();
            }
        }
        else if (elementType == XDMFParser::TYPE_END_TAG)
        {
            break;
        }
        elementType = xdmfParser.GetNextElement();
    }

    //
    // Do some error checking.
    //
    if (topologyType == "")
    {
        debug1 << gridName << ": Invalid Grid elmement - "
               << "Topology type missing." << endl;
        for (unsigned int i = 0; i < varList.size(); i++)
            delete varList[i];
        return;
    }

    if (numberOfElements == "")
    {
        debug1 << gridName << ": Invalid Grid elmement - "
               << "Topology number of elements missing." << endl;
        for (unsigned int i = 0; i < varList.size(); i++)
            delete varList[i];
        return;
    }

    MeshInfo *meshInfo = new MeshInfo;

    if (topGrid)
    {
        meshInfo->name = gridName;
        meshInfo->iDomain = iDomain;
    }

    meshInfo->nBlocks = 1;
    meshInfo->extents = NULL;

    if (geometryType == "" || geometryType == "XYZ")
        meshInfo->geometryType = MeshInfo::TYPE_XYZ;
    else if (geometryType == "XY")
        meshInfo->geometryType = MeshInfo::TYPE_XY;
    else if (geometryType == "X_Y_Z")
        meshInfo->geometryType = MeshInfo::TYPE_X_Y_Z;
    else if (geometryType == "VXVYVZ")
        meshInfo->geometryType = MeshInfo::TYPE_VXVYVZ;
    else if (geometryType == "ORIGIN_DXDYDZ")
        meshInfo->geometryType = MeshInfo::TYPE_ORIGIN_DXDYDZ;
    else
    {
        debug1 << gridName << ": Invalid Grid elmement - "
               << "Illegal GeometryType." << endl;
        delete meshInfo;
        for (unsigned int i = 0; i < varList.size(); i++)
            delete varList[i];
        return;
    }

    if (topologyType == "2DRECTMESH" || topologyType == "2DCORECTMESH")
    {
        meshInfo->topologicalDimension = 2;
        meshInfo->spatialDimension = 2;
        meshInfo->type = AVT_RECTILINEAR_MESH;
    }
    else if (topologyType == "2DSMESH")
    {
        meshInfo->topologicalDimension = 2;
        meshInfo->spatialDimension = 2;
        meshInfo->type = AVT_CURVILINEAR_MESH;
    }
    else if (topologyType == "3DRECTMESH" || topologyType == "3DCORECTMESH")
    {
        meshInfo->topologicalDimension = 3;
        meshInfo->spatialDimension = 3;
        meshInfo->type = AVT_RECTILINEAR_MESH;
    }
    else if (topologyType == "3DSMESH")
    {
        meshInfo->topologicalDimension = 3;
        meshInfo->spatialDimension = 3;
        meshInfo->type = AVT_CURVILINEAR_MESH;
    }
    else
    {
        if (topologyType == "POLYVERTEX")
            meshInfo->cellType = MeshInfo::CELL_POLYVERTEX;
        else if (topologyType == "POLYLINE")
            meshInfo->cellType = MeshInfo::CELL_POLYLINE;
        else if (topologyType == "POLYGON")
            meshInfo->cellType = MeshInfo::CELL_POLYGON;
        else if (topologyType == "TRIANGLE")
            meshInfo->cellType = MeshInfo::CELL_TRIANGLE;
        else if (topologyType == "QUADRILATERAL")
            meshInfo->cellType = MeshInfo::CELL_QUADRILATERAL;
        else if (topologyType == "TETRAHEDRON")
            meshInfo->cellType = MeshInfo::CELL_TETRAHEDRON;
        else if (topologyType == "PYRAMID")
            meshInfo->cellType = MeshInfo::CELL_PYRAMID;
        else if (topologyType == "WEDGE")
            meshInfo->cellType = MeshInfo::CELL_WEDGE;
        else if (topologyType == "HEXAHEDRON")
            meshInfo->cellType = MeshInfo::CELL_HEXAHEDRON;
        else if (topologyType == "EDGE_3")
            meshInfo->cellType = MeshInfo::CELL_EDGE_3;
        else if (topologyType == "TRIANGLE_6")
            meshInfo->cellType = MeshInfo::CELL_TRIANGLE_6;
        else if (topologyType == "QUADRILATERAL_8")
            meshInfo->cellType = MeshInfo::CELL_QUADRILATERAL_8;
        else if (topologyType == "TETRAHEDRON_10")
            meshInfo->cellType = MeshInfo::CELL_TETRAHEDRON_10;
        else if (topologyType == "PYRAMID_13")
            meshInfo->cellType = MeshInfo::CELL_PYRAMID_13;
        else if (topologyType == "WEDGE_15")
            meshInfo->cellType = MeshInfo::CELL_WEDGE_15;
        else if (topologyType == "HEXAHEDRON_20")
            meshInfo->cellType = MeshInfo::CELL_HEXAHEDRON_20;
        else if (topologyType == "MIXED")
            meshInfo->cellType = MeshInfo::CELL_MIXED;
        else
        {
            debug1 << gridName << ": Invalid Grid elmement - "
                   << "Illegal Topology." << endl;
            delete meshInfo;
            for (unsigned int i = 0; i < varList.size(); i++)
                delete varList[i];
            return;
        }

        if (meshInfo->geometryType == MeshInfo::TYPE_XY)
        {
            meshInfo->topologicalDimension = 2;
            meshInfo->spatialDimension = 2;
        }
        else if (meshInfo->geometryType == MeshInfo::TYPE_VXVYVZ ||
                 meshInfo->geometryType == MeshInfo::TYPE_X_Y_Z)
        {
            meshInfo->topologicalDimension = nMeshData;
            meshInfo->spatialDimension = nMeshData;
        }
        else
        {
            meshInfo->topologicalDimension = 3;
            meshInfo->spatialDimension = 3;
        }
        meshInfo->type = AVT_UNSTRUCTURED_MESH;
    }

    meshInfo->dimensions[0] = 1;
    meshInfo->dimensions[1] = 1;
    meshInfo->dimensions[2] = 1;
    if (meshInfo->type == AVT_UNSTRUCTURED_MESH)
    {
        if (topologyData == NULL)
        {
            debug1 << gridName << ": Invalid Grid elmement - "
                   << "Topology data item missing." << endl;
            delete meshInfo;
            for (unsigned int i = 0; i < varList.size(); i++)
                delete varList[i];
            return;
        }

        meshInfo->topologyData = topologyData;

        //
        // In both cases below we store the dimensions in dimensions[1]
        // and the nodes per element in dimensions[0].  This way we know
        // where they are without any complex logic.
        //
        if (meshInfo->cellType == MeshInfo::CELL_POLYVERTEX ||
            meshInfo->cellType == MeshInfo::CELL_POLYLINE ||
            meshInfo->cellType == MeshInfo::CELL_POLYGON)
        {
            if (nodesPerElement == "")
            {
                debug1 << gridName << ": Invalid Grid elmement - "
                       << "Topology nodes per element missing."
                       << endl;
                delete meshInfo;
                for (unsigned int i = 0; i < varList.size(); i++)
                    delete varList[i];
                return;
            }

            sscanf(numberOfElements.c_str(), "%d", &meshInfo->dimensions[1]);
            sscanf(nodesPerElement.c_str(), "%d", &meshInfo->dimensions[0]);
        }
        else
        {
            sscanf(numberOfElements.c_str(), "%d", &meshInfo->dimensions[1]);

            meshInfo->baseOffset = 0;
            if (baseOffset != "")
            {
                sscanf(baseOffset.c_str(), "%d", &meshInfo->baseOffset);
            }

            int nNodes = CellTypeToNodeCount[meshInfo->cellType];
            if (order != "" && nNodes != 0)
            {
                meshInfo->order = new int[nNodes];
                char *str = NULL, *str2 = NULL;
                int iVal = (int)strtol(order.c_str(), &str, 10);
                meshInfo->order[0] = (iVal < 0) ? 0 :
                    ((iVal < nNodes) ? iVal : nNodes - 1);
                for (int i = 1; i < nNodes; i++)
                {
                    iVal = (int)strtol(str, &str2, 10);
                    meshInfo->order[i] = (iVal < 0) ? 0 :
                        ((iVal < nNodes) ? iVal : nNodes - 1);
                    str = str2;
                }
            }
        }
    }
    else
    {
        if (meshInfo->topologicalDimension == 2)
        {
            sscanf(numberOfElements.c_str(), "%d %d",
                   &meshInfo->dimensions[1], &meshInfo->dimensions[0]);
        }
        else
        {
            sscanf(numberOfElements.c_str(), "%d %d %d",
                   &meshInfo->dimensions[2], &meshInfo->dimensions[1],
                   &meshInfo->dimensions[0]);
        }
    }

    if (baseIndex != "")
    {
        meshInfo->baseIndex = new int[3];
        for (int i = 0; i < 3; i++)
            meshInfo->baseIndex[i] = 0;
        if (meshInfo->topologicalDimension == 2)
        {
            sscanf(baseIndex.c_str(), "%d %d",
                &meshInfo->baseIndex[1], &meshInfo->baseIndex[0]);
        }
        else
        {
            sscanf(baseIndex.c_str(), "%d %d %d", &meshInfo->baseIndex[2],
                &meshInfo->baseIndex[1], &meshInfo->baseIndex[0]);
        }
    }

    if (ghostOffsets != "")
    {
        meshInfo->ghostOffsets = new int[6];
        for (int i = 0; i < 6; i++)
            meshInfo->ghostOffsets[i] = 0;
        if (meshInfo->topologicalDimension == 2)
        {
            sscanf(ghostOffsets.c_str(), "%d %d %d %d",
                &meshInfo->ghostOffsets[2], &meshInfo->ghostOffsets[3],
                &meshInfo->ghostOffsets[0], &meshInfo->ghostOffsets[1]);
        }
        else
        {
            sscanf(ghostOffsets.c_str(), "%d %d %d %d %d %d",
                &meshInfo->ghostOffsets[4], &meshInfo->ghostOffsets[5],
                &meshInfo->ghostOffsets[2], &meshInfo->ghostOffsets[3],
                &meshInfo->ghostOffsets[0], &meshInfo->ghostOffsets[1]);
        }
    }

    if (time != "")
    {
        sscanf(time.c_str(), "%lf", &meshInfo->time);
    }

    for (int i = 0; i < nMeshData; i++)
        meshInfo->meshData[i] = meshData[i];

    meshList.push_back(meshInfo);

    for (unsigned int i = 0; i < varList.size(); i++)
        AddVarInfo(topGrid, meshList.size()-1, varList[i]);
}


// ****************************************************************************
//  Method: avtVisItXdmfFileFormat::ParseGrid
//
//  Purpose:
//      Parse a grid node of the DOM tree.
//
//  Programmer: Eric Brugger
//  Creation:   Fri Nov 16 13:08:36 PST 2007
//
//  Modifications:
//    Eric Brugger, Fri Apr 24 08:31:34 PDT 2009
//    I enhanced the routine to be insensitive to the case for element names,
//    attribute names, and attribute values that were not names.
//
// ****************************************************************************

void
allens's avatar
allens committed
1955 1956
avtVisItXdmfFileFormat::ParseGrid(std::vector<MeshInfo*> &meshList,
    int iDomain, int iGrid, std::string &gridName, bool topGrid)
1957
{
allens's avatar
allens committed
1958
    std::string    gridType;
1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969