From 1e5b4b1379a945c97bc1d6ba23123478acd8ae87 Mon Sep 17 00:00:00 2001
From: Cristian C Lalescu <Cristian.Lalescu@ds.mpg.de>
Date: Wed, 22 Jan 2020 15:45:40 +0100
Subject: [PATCH] use particle information for checkpointing

---
 cpp/full_code/kraichnan_field.cpp | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/cpp/full_code/kraichnan_field.cpp b/cpp/full_code/kraichnan_field.cpp
index 67123545..3ec76efc 100644
--- a/cpp/full_code/kraichnan_field.cpp
+++ b/cpp/full_code/kraichnan_field.cpp
@@ -327,14 +327,23 @@ void kraichnan_field<rnumber>::update_checkpoint()
             hsize_t fields_stored;
             hid_t fid, group_id;
             fid = H5Fopen(fname.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
-            group_id = H5Gopen(fid, "velocity/real", H5P_DEFAULT);
-            H5Gget_num_objs(
+            group_id = H5Gopen(fid, "tracers0/state", H5P_DEFAULT);
+            bool dset_exists;
+            if (group_id > 0)
+            {
+                H5Gget_num_objs(
                     group_id,
                     &fields_stored);
-            bool dset_exists = H5Lexists(
+                dset_exists = H5Lexists(
                     group_id,
                     std::to_string(this->iteration).c_str(),
                     H5P_DEFAULT);
+            }
+            else
+            {
+                fields_stored = 0;
+                dset_exists = false;
+            }
             H5Gclose(group_id);
             H5Fclose(fid);
             if ((int(fields_stored) >= this->checkpoints_per_file) &&
@@ -351,13 +360,13 @@ void kraichnan_field<rnumber>::update_checkpoint()
                     H5P_DEFAULT);
             hid_t gg = H5Gcreate(
                     fid,
-                    "velocity",
+                    "tracers0",
                     H5P_DEFAULT,
                     H5P_DEFAULT,
                     H5P_DEFAULT);
             hid_t ggg = H5Gcreate(
                     gg,
-                    "real",
+                    "state",
                     H5P_DEFAULT,
                     H5P_DEFAULT,
                     H5P_DEFAULT);
-- 
GitLab