aboutsummaryrefslogtreecommitdiff
path: root/CarpetAttic
diff options
context:
space:
mode:
authorcott <>2004-01-06 07:56:00 +0000
committercott <>2004-01-06 07:56:00 +0000
commit2df622d3e73a4c3b4cac7114efbb98e8b9382370 (patch)
tree7f004c50ecc8453965e84334db19398304b93efe /CarpetAttic
parent65df233e3c829a85a59e8efa5559d1c12fa09b8f (diff)
We can now recover parameters.
darcs-hash:20040106075639-19929-06e2883236b3a6710cabb2229a18e62219bd5452.gz
Diffstat (limited to 'CarpetAttic')
-rw-r--r--CarpetAttic/CarpetIOFlexIOCheckpoint/src/checkpointrestart.cc34
-rw-r--r--CarpetAttic/CarpetIOFlexIOCheckpoint/src/ioflexio.hh34
2 files changed, 65 insertions, 3 deletions
diff --git a/CarpetAttic/CarpetIOFlexIOCheckpoint/src/checkpointrestart.cc b/CarpetAttic/CarpetIOFlexIOCheckpoint/src/checkpointrestart.cc
index 89d7816bc..634d137ba 100644
--- a/CarpetAttic/CarpetIOFlexIOCheckpoint/src/checkpointrestart.cc
+++ b/CarpetAttic/CarpetIOFlexIOCheckpoint/src/checkpointrestart.cc
@@ -48,7 +48,7 @@
#include "ioflexio.hh"
extern "C" {
- static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/CarpetAttic/CarpetIOFlexIOCheckpoint/src/checkpointrestart.cc,v 1.15 2004/01/05 22:54:16 cott Exp $";
+ static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/CarpetAttic/CarpetIOFlexIOCheckpoint/src/checkpointrestart.cc,v 1.16 2004/01/06 08:56:39 cott Exp $";
CCTK_FILEVERSION(Carpet_CarpetIOFlexIO_checkpointrestart_cc);
}
@@ -224,7 +224,6 @@ int CarpetIOFlexIO_Recover (cGH* cgh, const char *basefilename, int called_from)
return (RecoverParameters (reader));
}
-
if (myproc == 0)
delete reader;
@@ -287,6 +286,37 @@ int CarpetIOFlexIO_Recover (cGH* cgh, const char *basefilename, int called_from)
delete reader;
}
+#ifdef CCTK_MPI
+ /* Broadcast the parameter buffer size to all processors */
+ /* NOTE: We have to use MPI_COMM_WORLD here
+ because CARPET_COMM_WORLD is not yet set up at parameter recovery time.
+ We also assume that CARPET_MPI_INT4 is a compile-time defined datatype. */
+ CACTUS_MPI_ERROR (MPI_Bcast (&parameterSize, 1, CARPET_MPI_INT4, 0,
+ MPI_COMM_WORLD));
+#endif
+
+ if (parameterSize > 0)
+ {
+#ifdef CCTK_MPI
+ if (myproc)
+ {
+ parameters = (char*) malloc (parameterSize + 1);
+ }
+
+ CACTUS_MPI_ERROR (MPI_Bcast (parameters, parameterSize + 1, CARPET_MPI_CHAR,
+ 0, MPI_COMM_WORLD));
+#endif
+
+ IOUtil_SetAllParameters (parameters);
+
+ free (parameters);
+ }
+
+ /* return positive value for success otherwise negative */
+ retval = (parameterSize > 0 ? 1 : -1);
+
+ return (retval);
+
CCTK_WARN (-1,"STOPSTOPSTOP");
diff --git a/CarpetAttic/CarpetIOFlexIOCheckpoint/src/ioflexio.hh b/CarpetAttic/CarpetIOFlexIOCheckpoint/src/ioflexio.hh
index 73d50ca9c..be467adfc 100644
--- a/CarpetAttic/CarpetIOFlexIOCheckpoint/src/ioflexio.hh
+++ b/CarpetAttic/CarpetIOFlexIOCheckpoint/src/ioflexio.hh
@@ -1,8 +1,9 @@
-// $Header: /home/eschnett/C/carpet/Carpet/CarpetAttic/CarpetIOFlexIOCheckpoint/src/ioflexio.hh,v 1.7 2003/12/01 13:15:21 cott Exp $
+// $Header: /home/eschnett/C/carpet/Carpet/CarpetAttic/CarpetIOFlexIOCheckpoint/src/ioflexio.hh,v 1.8 2004/01/06 08:56:39 cott Exp $
#ifndef CARPETIOFLEXIO_HH
#define CARPETIOFLEXIO_HH
+
#include <vector>
#include "cctk.h"
@@ -54,6 +55,37 @@
#elif CCTK_REAL_PRECISION_16
#define FLEXIO_REAL FLEXIO_REAL16
#endif
+
+/* some macros needed for recovery */
+#ifdef CCTK_MPI
+
+#define CACTUS_MPI_ERROR(fn_call) \
+ do { \
+ int errcode; \
+ \
+ if ((errcode = fn_call) != MPI_SUCCESS) \
+ { \
+ char mpi_error_string[MPI_MAX_ERROR_STRING+1]; \
+ int resultlen; \
+ \
+ MPI_Error_string (errcode, mpi_error_string, &resultlen); \
+ fprintf (stderr, "MPI call '%s' returned error code %d (%s)\n", \
+ #fn_call, errcode, mpi_error_string); \
+ fprintf(stderr, "At line %d of file %s\n", __LINE__, __FILE__); \
+ } \
+ } while (0)
+
+
+#ifdef CCTK_INT4
+#define CARPET_MPI_INT4 (sizeof (CCTK_INT4) == sizeof (int) ? MPI_INT : \
+ sizeof (CCTK_INT4) == sizeof (short) ? MPI_SHORT : \
+ MPI_DATATYPE_NULL)
+#endif
+
+#define CARPET_MPI_CHAR MPI_CHAR
+
+#endif
+
namespace CarpetIOFlexIO {
// Variable definitions