aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@4825ed28-b72c-4eae-9704-e50c059e567d>2005-06-10 11:57:51 +0000
committertradke <tradke@4825ed28-b72c-4eae-9704-e50c059e567d>2005-06-10 11:57:51 +0000
commit2acc4a8bf1d72672e935586c007b786ca160546e (patch)
tree2030290712c722bf2a58ef295a4c726b5e5d5598
parent6b8d776d50777dab331c728e40f2e08e59861ec2 (diff)
Added necessary logic to implement IO::checkpoint_keep as steerable parameter.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOHDF5/trunk@217 4825ed28-b72c-4eae-9704-e50c059e567d
-rw-r--r--src/DumpGH.c24
-rw-r--r--src/Startup.c3
-rw-r--r--src/ioHDF5GH.h1
3 files changed, 22 insertions, 6 deletions
diff --git a/src/DumpGH.c b/src/DumpGH.c
index 471e5c8..bc673c3 100644
--- a/src/DumpGH.c
+++ b/src/DumpGH.c
@@ -323,16 +323,30 @@ static int Checkpoint (const cGH *GH, int called_from)
}
else
{
- if (myGH->cp_filename_list[myGH->cp_filename_index])
+ if (checkpoint_keep > 0)
{
- if (checkpoint_keep > 0)
+ if (myGH->cp_filename_list[myGH->cp_filename_index])
{
remove (myGH->cp_filename_list[myGH->cp_filename_index]);
+ free (myGH->cp_filename_list[myGH->cp_filename_index]);
+ myGH->cp_filename_list[myGH->cp_filename_index] = NULL;
+ }
+ myGH->cp_filename_list[myGH->cp_filename_index] = strdup (filename);
+ myGH->cp_filename_index = (myGH->cp_filename_index+1) % checkpoint_keep;
+ if (myGH->checkpoint_keep != checkpoint_keep)
+ {
+ char **cp_filename_list = calloc (checkpoint_keep, sizeof (char *));
+ int min = myGH->checkpoint_keep < checkpoint_keep ?
+ myGH->checkpoint_keep : checkpoint_keep;
+ while (min-- > 0)
+ {
+ cp_filename_list[min] = myGH->cp_filename_list[min];
+ }
+ free (myGH->cp_filename_list);
+ myGH->cp_filename_list = cp_filename_list;
+ myGH->checkpoint_keep = checkpoint_keep;
}
- free (myGH->cp_filename_list[myGH->cp_filename_index]);
}
- myGH->cp_filename_list[myGH->cp_filename_index] = strdup (filename);
- myGH->cp_filename_index = (myGH->cp_filename_index+1) % abs (checkpoint_keep);
}
}
}
diff --git a/src/Startup.c b/src/Startup.c
index 2d2e06e..a7ee198 100644
--- a/src/Startup.c
+++ b/src/Startup.c
@@ -131,8 +131,9 @@ static void *SetupGH (tFleshConfig *config, int conv_level, cGH *GH)
myGH = malloc (sizeof (ioHDF5GH));
myGH->out_last = malloc (numvars * sizeof (int));
myGH->requests = calloc (numvars, sizeof (ioRequest *));
- myGH->cp_filename_list = calloc (abs (checkpoint_keep), sizeof (char *));
myGH->cp_filename_index = 0;
+ myGH->checkpoint_keep = abs (checkpoint_keep);
+ myGH->cp_filename_list = calloc (myGH->checkpoint_keep, sizeof (char *));
myGH->out_vars = strdup ("");
myGH->out_every_default = out_every - 1;
myGH->last_checkpoint_iteration = -1;
diff --git a/src/ioHDF5GH.h b/src/ioHDF5GH.h
index 927389e..11620b8 100644
--- a/src/ioHDF5GH.h
+++ b/src/ioHDF5GH.h
@@ -45,6 +45,7 @@ typedef struct
int print_timing_info;
/* ring buffer for list of successfully created cp files */
+ int checkpoint_keep;
int cp_filename_index;
char **cp_filename_list;