]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Reorder parameters
authorDaniel Garcia-Sanchez <daniel.garcia-sanchez@insp.upmc.fr>
Wed, 31 Oct 2018 15:57:44 +0000 (16:57 +0100)
committerDaniel Garcia-Sanchez <daniel.garcia-sanchez@insp.upmc.fr>
Wed, 9 Jan 2019 18:29:07 +0000 (19:29 +0100)
include/deal.II/base/hdf5.h
source/base/hdf5.cc
tests/base/hdf5_02.cc
tests/base/hdf5_03.cc
tests/base/hdf5_05.cc

index 52c0ed048c66200e427e6f414d81d2d9ab1ca875..bed768155527fe3f2b7c748fe6f98032e46d7000 100644 (file)
@@ -923,13 +923,13 @@ namespace HDF5
     enum class GroupAccessMode
     {
       /**
-       * Creates a new group
+       * Opens an existing group
        */
-      create,
+      open,
       /**
-       * Opens an existing group
+       * Creates a new group
        */
-      open
+      create
     };
     /**
      * This constructor creates or opens a group depending on the value of
@@ -1021,29 +1021,22 @@ namespace HDF5
     enum class FileAccessMode
     {
       /**
-       * Create file, truncate if exists
+       * Read/write, file must exist
        */
-      create,
+      open,
       /**
-       * Read/write, file must exist
+       * Create file, truncate if exists
        */
-      open
+      create
     };
 
-  private:
     /**
-     * Delegation internal constructor.
-     * File(const std::string &, const MPI_Comm, const Mode);
-     * and
-     * File(const std::string &, const Mode)
-     * should be used to open or create HDF5 files.
+     * Creates or opens a hdf5 file for serial operations. This call does not
+     * require MPI support. It creates or opens a HDF5 file depending on the
+     * value of @p mode.
      */
-    File(const std::string &  name,
-         const bool           mpi,
-         const MPI_Comm       mpi_communicator,
-         const FileAccessMode mode);
+    File(const std::string &name, const FileAccessMode mode);
 
-  public:
     /**
      * Creates or opens an HDF5 file in parallel using MPI. This requires that
      * deal.ii and HDF5 were compiled with MPI support. It creates or opens a
@@ -1052,16 +1045,21 @@ namespace HDF5
      * a common value for the MPI communicator.
      */
     File(const std::string &  name,
-         const MPI_Comm       mpi_communicator,
-         const FileAccessMode mode = FileAccessMode::create);
+         const FileAccessMode mode,
+         const MPI_Comm       mpi_communicator);
 
+  private:
     /**
-     * Creates or opens a hdf5 file for serial operations. This call does not
-     * require MPI support. It creates or opens a HDF5 file depending on the
-     * value of @p mode.
+     * Delegation internal constructor.
+     * File(const std::string &, const MPI_Comm, const Mode);
+     * and
+     * File(const std::string &, const Mode)
+     * should be used to open or create HDF5 files.
      */
     File(const std::string &  name,
-         const FileAccessMode mode = FileAccessMode::create);
+         const FileAccessMode mode,
+         const bool           mpi,
+         const MPI_Comm       mpi_communicator);
   };
 } // namespace HDF5
 
index 873f7cb0ae0013e5191d90ca0c3a56ed64a98a77..17013e6b396afb2d6d2bcbccc290aafcaf6b82bc 100644 (file)
@@ -1461,6 +1461,11 @@ namespace HDF5
     });
     switch (mode)
       {
+        case (GroupAccessMode::open):
+          *hdf5_reference =
+            H5Gopen2(*(parentGroup.hdf5_reference), name.data(), H5P_DEFAULT);
+          Assert(*hdf5_reference >= 0, ExcMessage("Error at H5Gopen2"));
+          break;
         case (GroupAccessMode::create):
           *hdf5_reference = H5Gcreate2(*(parentGroup.hdf5_reference),
                                        name.data(),
@@ -1469,11 +1474,6 @@ namespace HDF5
                                        H5P_DEFAULT);
           Assert(*hdf5_reference >= 0, ExcMessage("Error at H5Gcreate2"));
           break;
-        case (GroupAccessMode::open):
-          *hdf5_reference =
-            H5Gopen2(*(parentGroup.hdf5_reference), name.data(), H5P_DEFAULT);
-          Assert(*hdf5_reference >= 0, ExcMessage("Error at H5Gopen2"));
-          break;
         default:
           Assert(false, ExcInternalError());
           break;
@@ -1533,10 +1533,26 @@ namespace HDF5
     dataset.write(data);
   }
 
+
+
+  File::File(const std::string &name, const FileAccessMode mode)
+    : File(name, mode, false, MPI_COMM_NULL)
+  {}
+
+
+
+  File::File(const std::string &  name,
+             const FileAccessMode mode,
+             const MPI_Comm       mpi_communicator)
+    : File(name, mode, true, mpi_communicator)
+  {}
+
+
+
   File::File(const std::string &  name,
+             const FileAccessMode mode,
              const bool           mpi,
-             const MPI_Comm       mpi_communicator,
-             const FileAccessMode mode)
+             const MPI_Comm       mpi_communicator)
     : Group(name, mpi)
   {
     hdf5_reference = std::shared_ptr<hid_t>(new hid_t, [](auto pointer) {
@@ -1569,15 +1585,15 @@ namespace HDF5
 
     switch (mode)
       {
+        case (FileAccessMode::open):
+          *hdf5_reference = H5Fopen(name.data(), H5F_ACC_RDWR, plist);
+          Assert(*hdf5_reference >= 0, ExcMessage("Error at H5Fopen"));
+          break;
         case (FileAccessMode::create):
           *hdf5_reference =
             H5Fcreate(name.data(), H5F_ACC_TRUNC, H5P_DEFAULT, plist);
           Assert(*hdf5_reference >= 0, ExcMessage("Error at H5Fcreate"));
           break;
-        case (FileAccessMode::open):
-          *hdf5_reference = H5Fopen(name.data(), H5F_ACC_RDWR, plist);
-          Assert(*hdf5_reference >= 0, ExcMessage("Error at H5Fopen"));
-          break;
         default:
           Assert(false, ExcInternalError());
           break;
@@ -1595,20 +1611,6 @@ namespace HDF5
 
 
 
-  File::File(const std::string &  name,
-             const MPI_Comm       mpi_communicator,
-             const FileAccessMode mode)
-    : File(name, true, mpi_communicator, mode)
-  {}
-
-
-
-  File::File(const std::string &name, const FileAccessMode mode)
-    : File(name, false, MPI_COMM_NULL, mode)
-  {}
-
-
-
 #  ifndef DOXYGEN
 
   // instantiations of functions
index dc4686dc0f837f7a97e55954dc408fecd85cad22..80df31b075c19587381b6868b5365f6db68ab7b6 100644 (file)
@@ -30,8 +30,8 @@ test()
   {
     // Create file
     HDF5::File data_file(filename,
-                         MPI_COMM_WORLD,
-                         HDF5::File::FileAccessMode::create);
+                         HDF5::File::FileAccessMode::create,
+                         MPI_COMM_WORLD);
 
     // Create attributes attached to the root
     const float        root_float        = 2.45681934e5;
@@ -76,8 +76,8 @@ test()
   {
     // Read attributes attached to the root
     HDF5::File data_file(filename,
-                         MPI_COMM_WORLD,
-                         HDF5::File::FileAccessMode::open);
+                         HDF5::File::FileAccessMode::open,
+                         MPI_COMM_WORLD);
     auto       root_float  = data_file.get_attribute<float>("root_float");
     auto       root_double = data_file.get_attribute<double>("root_double");
     auto       root_int    = data_file.get_attribute<int>("root_int");
index a19402fd3fbc27829d3928c8ce80796b8683e00e..25a5196c5f79713ee43df5b428045201682ba208 100644 (file)
@@ -770,8 +770,8 @@ main(int argc, char **argv)
 
       {
         HDF5::File data_file(filename,
-                             mpi_communicator,
-                             HDF5::File::FileAccessMode::create);
+                             HDF5::File::FileAccessMode::create,
+                             mpi_communicator);
 
         write_test<std::vector, float>(data_file,
                                        dataset_dimensions,
@@ -844,8 +844,8 @@ main(int argc, char **argv)
 
       {
         HDF5::File data_file(filename,
-                             mpi_communicator,
-                             HDF5::File::FileAccessMode::open);
+                             HDF5::File::FileAccessMode::open,
+                             mpi_communicator);
         read_test<std::vector, float>(data_file, mpi_communicator, pcout);
         read_test<std::vector, double>(data_file, mpi_communicator, pcout);
 
index 4aa07239950deffbd87cdd2828b288daf7772236..76f3658a3dba567f84d7939eab8e10777513a1d2 100644 (file)
@@ -1409,8 +1409,8 @@ main(int argc, char **argv)
 
       {
         HDF5::File data_file(filename,
-                             mpi_communicator,
-                             HDF5::File::FileAccessMode::create);
+                             HDF5::File::FileAccessMode::create,
+                             mpi_communicator);
 
         write_test<float>(data_file, mpi_communicator, pcout);
         write_test<double>(data_file, mpi_communicator, pcout);
@@ -1423,8 +1423,8 @@ main(int argc, char **argv)
 
       {
         HDF5::File data_file(filename,
-                             mpi_communicator,
-                             HDF5::File::FileAccessMode::open);
+                             HDF5::File::FileAccessMode::open,
+                             mpi_communicator);
         read_test<float>(data_file, mpi_communicator, pcout);
         read_test<double>(data_file, mpi_communicator, pcout);
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.