write_core_vfd.c 1.57 KB
Newer Older
1
/*
gsell's avatar
gsell committed
2
  Copyright (c) 2006-2015, The Regents of the University of California,
3 4 5 6 7 8 9 10 11
  through Lawrence Berkeley National Laboratory (subject to receipt of any
  required approvals from the U.S. Dept. of Energy) and the Paul Scherrer
  Institut (Switzerland).  All rights reserved.

  License: see file COPYING in top level of source distribution.
*/

#include "H5hut.h"

12
#define DEFAULT_VERBOSITY       H5_VERBOSE_DEFAULT
13

14 15
#define FNAME                   "example_core_vfd"
#define DATASIZE                32
16 17 18 19 20

int
main (
        int argc, char* argv[]
        ){
21 22
        h5_int64_t verbosity = DEFAULT_VERBOSITY;

23
        // initialize MPI & H5hut
24 25
        int comm_rank = 0;
        int comm_size = 1;
26 27
        MPI_Init (&argc, &argv);
        MPI_Comm comm = MPI_COMM_WORLD;
28 29 30 31 32
        MPI_Comm_rank (comm, &comm_rank);
        MPI_Comm_size (comm, &comm_size);

        H5AbortOnError ();
        H5SetVerbosityLevel (verbosity);
33 34 35

        // open file and go to step#0
        char fname[64];
36
        sprintf (fname, "%s.%d.h5", FNAME, comm_rank);
37 38 39 40 41 42 43 44 45 46 47
        h5_prop_t prop = H5CreateFileProp ();
        H5SetPropFileCoreVFD (prop);
        h5_file_t file = H5OpenFile (fname, H5_O_RDONLY, prop);
        H5SetStep (file, 0);

        h5_int32_t data[DATASIZE];

        H5PartSetNumParticles(file, DATASIZE);

        // create fake data
        for (int i = 0; i < DATASIZE; i++) {
48
                data[i] = i + comm_rank * DATASIZE;
49 50 51 52 53 54 55 56 57 58 59
        }

        // write the data
        H5PartWriteDataInt32 (file, "data", data);
        
        H5CloseFile (file);

        MPI_Finalize ();
        return H5_SUCCESS;
}