HugeWriteArray.cpp 2.33 KB
Newer Older
1 2 3 4 5 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
#include <iostream>
#include <stdlib.h>
#include <XdmfArray.hpp>
#include <XdmfArrayType.hpp>
#include <XdmfWriter.hpp>
#include <XdmfHDF5Writer.hpp>
#include <XdmfHDF5Controller.hpp>

int main(int, char **)
{
	
	shared_ptr<XdmfArray> writtenArray = XdmfArray::New();
	for (int i = 0; i < 600000; i++)
	{
		writtenArray->pushBack(i);
	}
	std::vector<unsigned int> starts;
	std::vector<unsigned int> strides;
	std::vector<unsigned int> dimensions;
	std::vector<unsigned int> dataspaces;
	starts.push_back(0);
	strides.push_back(6);
	dimensions.push_back(100000);
	dataspaces.push_back(600000);
	shared_ptr<XdmfHDF5Controller> arrayController = XdmfHDF5Controller::New("arraydata.h5", "Data", XdmfArrayType::Int32(), starts, strides, dimensions, dataspaces);
	writtenArray->insert(arrayController);
	starts[0] = 1;
	arrayController = XdmfHDF5Controller::New("arraydata.h5", "Data", XdmfArrayType::Int32(), starts, strides, dimensions, dataspaces);
	writtenArray->insert(arrayController);
        starts[0] = 2;
        arrayController = XdmfHDF5Controller::New("arraydata.h5", "Data", XdmfArrayType::Int32(), starts, strides, dimensions, dataspaces);
	writtenArray->insert(arrayController);
        starts[0] = 3;
        arrayController = XdmfHDF5Controller::New("arraydata.h5", "Data", XdmfArrayType::Int32(), starts, strides, dimensions, dataspaces);
	writtenArray->insert(arrayController);
        starts[0] = 4;
        arrayController = XdmfHDF5Controller::New("arraydata.h5", "Data", XdmfArrayType::Int32(), starts, strides, dimensions, dataspaces);
	writtenArray->insert(arrayController);
        starts[0] = 5;
	arrayController = XdmfHDF5Controller::New("arraydata.h5", "Data", XdmfArrayType::Int32(), starts, strides, dimensions, dataspaces);
        writtenArray->insert(arrayController);
	shared_ptr<XdmfHDF5Writer> arrayHeavyWriter = XdmfHDF5Writer::New("arraydata.h5");
	arrayHeavyWriter->setFileSizeLimit(1);
	arrayHeavyWriter->setMode(XdmfHDF5Writer::Hyperslab);
	shared_ptr<XdmfWriter> arrayWriter = XdmfWriter::New("arraydata.xmf", arrayHeavyWriter);
	arrayWriter->setLightDataLimit(5);
	writtenArray->accept(arrayWriter);

	printf("%s\n\n", writtenArray->getValuesString());
	writtenArray->release();
	printf("after release\narray contains: %s\n", writtenArray->getValuesString());
	writtenArray->read();
	printf("%s\n\n", writtenArray->getValuesString());

	return 0;
}