diff options
author | tradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a> | 2000-01-21 18:00:59 +0000 |
---|---|---|
committer | tradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a> | 2000-01-21 18:00:59 +0000 |
commit | 400e340a12e6019f91ded50e5ba1791ee04edda0 (patch) | |
tree | d1e719baf82aa32efd45d36bf6b3ec7aec66713e /src/DumpGH.c | |
parent | d58e1c47d498896b0c1f208724c7d138abce6349 (diff) |
Added several stuff to IOFlexIO:
- checkpointing/recovery of parameters
- made 'out2D_every', 'out2D_vars', 'out3D_every' and 'out3D_vars' steerable
- fixed compiler warnings
- grdocs
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOFlexIO/trunk@78 ebee0441-1374-4afa-a3b5-247f3ba15b9a
Diffstat (limited to 'src/DumpGH.c')
-rw-r--r-- | src/DumpGH.c | 91 |
1 files changed, 26 insertions, 65 deletions
diff --git a/src/DumpGH.c b/src/DumpGH.c index a53af2a..522d020 100644 --- a/src/DumpGH.c +++ b/src/DumpGH.c @@ -5,7 +5,7 @@ @desc DumpGH dumps an entire grid hierarchy (except for 1D arrays) to a checkpoint file. This file also contains the different wrappers for - DumpGH: in case of initial data, termination or regular checkpointing + IOFlexIODumpGH: in case of initial data, termination or regular checkpointing @enddesc @version $Id$ @@*/ @@ -32,7 +32,6 @@ static char *rcsid = "$Id$"; checkpointing, sets the checkpoint type and calls DumpGH @enddesc @calls IOFlexIO_DumpGH - @calledby rfrTraverse @history @endhistory @@ -67,7 +66,6 @@ void IOFlexIO_ConditionallyDumpGH (cGH *GH) and checkpoints all available grid hierarchies. @enddesc @calls IOFlexIO_DumpGH - @calledby rfrTraverse @history @endhistory @@ -96,7 +94,6 @@ void IOFlexIO_TerminationDumpGH (cGH *GH) DumpGH; BoxInBox needs special treatment since for now. @enddesc @calls IOFlexIO_DumpGH - @calledby rfrTraverse @history @endhistory @@ -141,60 +138,27 @@ void IOFlexIO_DumpParams (cGH *GH, IOFile iof) first = 1; while ((param = ParameterWalk (first, NULL)) != NULL) { - char *impl, *name, *msg; + char *impl, *name, *aname, *value; first = 0; - if (Util_SplitString (&impl, &name, param, "::") != 0) { - - msg = (char *) malloc (100 + strlen (param)); - sprintf (msg, "Cannot dump parameter '%s' (SplitString failed)", param); - CCTK_WARN (2, msg); - free (msg); - - } else { - int type; - void *data; - - data = ParameterGet (name, CCTK_ImplementationThorn (impl), &type); - if (data == NULL) { - - msg = (char *) malloc (100 + strlen (param)); - sprintf(msg, "Cannot dump parameter '%s' (ParameterGet failed)", param); - CCTK_WARN (2, msg); - free (msg); - - } else { - CCTK_INT4 i_tmp; - - switch (type) { - case PARAMETER_KEYWORD: - case PARAMETER_STRING: - case PARAMETER_SENTENCE: - CACTUS_IEEEIO_ERROR (IOwriteAttribute (iof, param, FLEXIO_CHAR, - strlen (*(char **) data) + 1, *(char **)data)); - break; - - case PARAMETER_INT: - case PARAMETER_BOOLEAN: - /* CCTK_INTs are stored as 4 byte integers */ - i_tmp = (CCTK_INT4) (*(CCTK_INT *) data); - CACTUS_IEEEIO_ERROR (IOwriteAttribute (iof, param, FLEXIO_INT4, 1, - &i_tmp)); - break; - - case PARAMETER_REAL: - CACTUS_IEEEIO_ERROR (IOwriteAttribute (iof, param, FLEXIO_REAL, 1, - data)); - break; - - default: - msg = (char *) malloc (100 + strlen (param)); - sprintf (msg, "Cannot dump parameter '%s' (unknown type)", param); - CCTK_WARN (2, msg); - free (msg); - break; - } + if (Util_SplitString (&impl, &name, param, "::") != 0) + CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, + "Couldn't parse name of parameter '%s'", param); + else { + value = ParameterValString (name, CCTK_ImplementationThorn (impl)); + if (value == NULL) + CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, + "Couldn't get value for parameter '%s'", param); + else { + aname = (char *) malloc (sizeof (PARAMETER_PREFIX) + + sizeof (ANAME_DELIMITER) + strlen (param)); + sprintf (aname, "%s%s%s", PARAMETER_PREFIX, ANAME_DELIMITER, param); + + CACTUS_IEEEIO_ERROR (IOwriteAttribute (iof, aname, FLEXIO_CHAR, + strlen (value) + 1, value)); + free (aname); + free (value); } free (impl); @@ -269,7 +233,6 @@ void IOFlexIO_DumpGH (cGH *GH, int called_from) IOFile iof; int index, wrotech; int timelevel, current_timelevel; - int forceSync; int old_downsample_x, old_downsample_y, old_downsample_z; int old_out_single; ioGH *ioUtilGH; @@ -323,7 +286,9 @@ void IOFlexIO_DumpGH (cGH *GH, int called_from) printf ("Creating file %s\n", tmpfname); iof = IEEEopen (tmpfname, "w"); if (! IOisValid (iof)) { - CCTK_WARN (1, "Can't open checkpoint file. Checkpointing is skipped"); + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "Can't open checkpoint file '%s'. Checkpointing is skipped", + tmpfname); return; } } else @@ -391,14 +356,10 @@ void IOFlexIO_DumpGH (cGH *GH, int called_from) CACTUS_IEEEIO_ERROR (IOclose (iof)); if (CCTK_MyProc (GH) == ioUtilGH->ioproc) { - if (rename (tmpfname, dumpfname)) { - char msg [512]; - - sprintf (msg, "Could not rename temporary checkpoint file %s to %s", - tmpfname, dumpfname); - CCTK_WARN (0, msg); - /* should not return here */ - } + if (rename (tmpfname, dumpfname)) + CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING, + "Could not rename temporary checkpoint file %s to %s", + tmpfname, dumpfname); } /* delete the oldest dumpfile if checkpoint_keep_all isn't set |