C examples:

- define dummy MPI macros to be used in serial compilation, closing #10
- cleanup some "unused variable" warnings
- fix some format warnings, using C99 format macros
This commit is contained in:
2017-06-23 15:37:46 +02:00
parent f79c808e8d
commit 542daf7fc2
24 changed files with 60 additions and 30 deletions
+1
View File
@@ -17,6 +17,7 @@
#define VERBOSITY H5_VERBOSE_ERROR
#define DEBUG_MSK H5_DEBUG_ALL
#include "examples.h"
int
main (
+2 -4
View File
@@ -9,6 +9,8 @@
#include "H5hut.h"
#include "examples.h"
int
main (
int argc,
@@ -16,11 +18,7 @@ main (
) {
MPI_Comm comm = MPI_COMM_WORLD;
int myproc;
int nprocs;
MPI_Init (&argc, &argv);
MPI_Comm_size (comm, &nprocs);
MPI_Comm_rank (comm, &myproc);
h5_prop_t prop = H5CreateFileProp ();
H5SetPropFileMPIOCollective (prop, &comm);
+2
View File
@@ -9,6 +9,8 @@
#include "H5hut.h"
#include "examples.h"
#define FNAME1 "example_file_attribs.h5"
#define FNAME2 "example_step_attribs.h5"
+1
View File
@@ -8,6 +8,7 @@
*/
#include "H5hut.h"
#include "examples.h"
#include <stdlib.h>
+1
View File
@@ -8,6 +8,7 @@
*/
#include "H5hut.h"
#include "examples.h"
#include <stdlib.h>
+1
View File
@@ -8,6 +8,7 @@
*/
#include "H5hut.h"
#include "examples.h"
#define FNAME "example_file_attribs.h5"
+1
View File
@@ -8,6 +8,7 @@
*/
#include "H5hut.h"
#include "examples.h"
#define FNAME "example_step_attribs.h5"
+1 -5
View File
@@ -8,6 +8,7 @@
*/
#include "H5hut.h"
#include "examples.h"
// name of output file
const char* fname = "example_field.h5";
@@ -23,11 +24,6 @@ main (
// initialize MPI & H5hut
MPI_Init (&argc, &argv);
MPI_Comm comm = MPI_COMM_WORLD;
int comm_size = 1;
MPI_Comm_size (comm, &comm_size);
int comm_rank = 0;
MPI_Comm_rank (comm, &comm_rank);
H5AbortOnError ();
H5SetVerbosityLevel (h5_verbosity);
//H5SetDebugMask (-1);
+7 -4
View File
@@ -1,5 +1,5 @@
/*
Copyright (c) 2006-2015, The Regents of the University of California,
Copyright (c) 2006-2017, The Regents of the University of California,
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.
@@ -8,6 +8,9 @@
*/
#include "H5hut.h"
#include "examples.h"
#include <inttypes.h>
// name of output file
const char* fname = "example_field.h5";
@@ -30,9 +33,9 @@ dump_int64_attrib (
attrib_data);
printf ("Attribute: '%s'\n", attrib_name);
printf (" Type: H5_INT64_T\n");
printf (" Data: %lld", attrib_data[0]);
printf (" Data: %" PRId64, attrib_data[0]);
for (size_t i = 1; i < attrib_nelems; i++) {
printf (", %lld", attrib_data[i]);
printf (", %" PRId64, attrib_data[i]);
}
printf ("\n");
}
@@ -174,7 +177,7 @@ main (
h5_ssize_t n_attribs = H5BlockGetNumFieldAttribs (
file,
field_name);
printf ("Field has %lld attributes attached.\n",
printf ("Field has %" PRId64 " attributes attached.\n",
n_attribs);
// dump all attached attributes
+10
View File
@@ -1,4 +1,14 @@
/*
Copyright (c) 2006-2017, The Regents of the University of California,
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>
#include "examples.h"
#define XSIZE 8
#define YSIZE 8
+7 -4
View File
@@ -1,5 +1,5 @@
/*
Copyright (c) 2006-2015, The Regents of the University of California,
Copyright (c) 2006-2017, The Regents of the University of California,
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.
@@ -8,6 +8,9 @@
*/
#include "H5hut.h"
#include "examples.h"
#include <inttypes.h>
// name of output file
const char* fname = "example_write_field.h5";
@@ -69,10 +72,10 @@ main (
} else if (type == H5_STRING_T) {
stype = "H5_STRING_T";
}
printf ("rank of field: %lld\n", field_rank);
printf ("dims of field: [%lld, %lld, %lld]\n",
printf ("rank of field: %" PRId64 "\n", field_rank);
printf ("dims of field: [%" PRId64 ", %" PRId64 ", %" PRId64"]\n",
field_dims[0], field_dims[1], field_dims[2]);
printf ("rank of field data: %lld\n", elem_rank);
printf ("rank of field data: %" PRId64 "\n", elem_rank);
printf ("type of field data: '%s'\n", stype);
done:
// done
+2 -1
View File
@@ -1,5 +1,5 @@
/*
Copyright (c) 2006-2015, The Regents of the University of California,
Copyright (c) 2006-2017, The Regents of the University of California,
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.
@@ -8,6 +8,7 @@
*/
#include "H5hut.h"
#include "examples.h"
#include <stdlib.h>
+1
View File
@@ -8,6 +8,7 @@
*/
#include "H5hut.h"
#include "examples.h"
// name of output file
const char* fname = "example_field.h5";
+1
View File
@@ -8,6 +8,7 @@
*/
#include "H5hut.h"
#include "examples.h"
#define FNAME "example_setview.h5"
#define VERBOSITY H5_VERBOSE_ERROR
+1 -2
View File
@@ -8,6 +8,7 @@
*/
#include "H5hut.h"
#include "examples.h"
#include <stdlib.h>
@@ -25,8 +26,6 @@ main (
// initialize MPI & H5hut
MPI_Init (&argc, &argv);
MPI_Comm comm = MPI_COMM_WORLD;
int comm_size = 1;
MPI_Comm_size (comm, &comm_size);
int comm_rank = 0;
MPI_Comm_rank (comm, &comm_rank);
H5AbortOnError ();
+1 -2
View File
@@ -14,6 +14,7 @@
the VFD core driver.
*/
#include "H5hut.h"
#include "examples.h"
#include <stdlib.h>
@@ -32,8 +33,6 @@ main (
// initialize MPI & H5hut
MPI_Init (&argc, &argv);
MPI_Comm comm = MPI_COMM_WORLD;
int comm_size = 1;
MPI_Comm_size (comm, &comm_size);
int comm_rank = 0;
MPI_Comm_rank (comm, &comm_rank);
H5AbortOnError ();
+1
View File
@@ -8,6 +8,7 @@
*/
#include "H5hut.h"
#include "examples.h"
#include <stdlib.h>
+1
View File
@@ -8,6 +8,7 @@
*/
#include "H5hut.h"
#include "examples.h"
#include <stdlib.h>
+1
View File
@@ -8,6 +8,7 @@
*/
#include "H5hut.h"
#include "examples.h"
#include <stdlib.h>
+1 -2
View File
@@ -14,6 +14,7 @@
the VFD core driver.
*/
#include "H5hut.h"
#include "examples.h"
// name of output file
const char* fname = "example_core_vfd.h5";
@@ -33,8 +34,6 @@ main (
// initialize MPI & H5hut
MPI_Init (&argc, &argv);
MPI_Comm comm = MPI_COMM_WORLD;
int comm_size = 1;
MPI_Comm_size (comm, &comm_size);
int comm_rank = 0;
MPI_Comm_rank (comm, &comm_rank);
H5AbortOnError ();
+1 -2
View File
@@ -8,6 +8,7 @@
*/
#include "H5hut.h"
#include "examples.h"
// name of output file
const char* fname = "example_setnparticles.h5";
@@ -27,8 +28,6 @@ main (
// initialize MPI & H5hut
MPI_Init (&argc, &argv);
MPI_Comm comm = MPI_COMM_WORLD;
int comm_size = 1;
MPI_Comm_size (comm, &comm_size);
int comm_rank = 0;
MPI_Comm_rank (comm, &comm_rank);
H5AbortOnError ();
+1 -2
View File
@@ -8,6 +8,7 @@
*/
#include "H5hut.h"
#include "examples.h"
// name of output file
const char* fname = "example_setview.h5";
@@ -28,8 +29,6 @@ main (
// initialize MPI & H5hut
MPI_Init (&argc, &argv);
MPI_Comm comm = MPI_COMM_WORLD;
int comm_size = 1;
MPI_Comm_size (comm, &comm_size);
int comm_rank = 0;
MPI_Comm_rank (comm, &comm_rank);
H5AbortOnError ();
+1 -2
View File
@@ -8,6 +8,7 @@
*/
#include "H5hut.h"
#include "examples.h"
// name of output file
const char* fname = "example_strided.h5";
@@ -27,8 +28,6 @@ main (
// initialize MPI & H5hut
MPI_Init (&argc, &argv);
MPI_Comm comm = MPI_COMM_WORLD;
int comm_size = 1;
MPI_Comm_size (comm, &comm_size);
int comm_rank = 0;
MPI_Comm_rank (comm, &comm_rank);
H5AbortOnError ();
+13
View File
@@ -0,0 +1,13 @@
#ifndef __EXAMPLES_H
#define __EXAMPLES_H
#if !defined (PARALLEL_IO)
#define MPI_COMM_WORLD (0)
#define MPI_Init(argc, argv)
#define MPI_Comm_size(comm,nprocs) {comm = 0; *nprocs = 1;}
#define MPI_Comm_rank(comm,rank) {comm = 0; (void)(comm); *rank = 0;}
#define MPI_Finalize()
#endif
#endif