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/Write3D.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/Write3D.c')
-rw-r--r-- | src/Write3D.c | 72 |
1 files changed, 35 insertions, 37 deletions
diff --git a/src/Write3D.c b/src/Write3D.c index 149d0c3..f3d7cdb 100644 --- a/src/Write3D.c +++ b/src/Write3D.c @@ -57,10 +57,11 @@ void IOFlexIO_DumpParams (cGH *GH, IOFile iof); /* local function prototypes */ -IEEEfile_3D_t *IOFlexIO_Get3Dfile (cGH *GH, const char *alias, int *isNewFile); -void IOFlexIO_Write3D_openFile (cGH *GH, IEEEfile_3D_t *IEEEfile_3D, - int isNewFile); -void IOFlexIO_Write3D_closeFile (cGH *GH, IEEEfile_3D_t *IEEEfile_3D); +static IEEEfile_3D_t *IOFlexIO_Get3Dfile (cGH *GH, const char *alias, + int *isNewFile); +static void IOFlexIO_Write3D_openFile (cGH *GH, IEEEfile_3D_t *IEEEfile_3D, + int isNewFile); +static void IOFlexIO_Write3D_closeFile (cGH *GH, IEEEfile_3D_t *IEEEfile_3D); /*@@ @@ -99,12 +100,7 @@ void IOFlexIO_Write3D_closeFile (cGH *GH, IEEEfile_3D_t *IEEEfile_3D); Finally notice that @seeroutine main guarantees that this is never called on a 1- or 2-D grid. @enddesc - @calls CCTK_GHExtensionHandle - CCTK_MyProc - CCTK_nProcs - CCTK_WARN - @calledby IOFlexIO_Output3DVarAs - IOFlexIO_TriggerOutput3D + @calledby IOFlexIO_Output3DVarAs, IOFlexIO_TriggerOutput3D @history @hdate Wed Sep 2 10:11:41 1998 @hauthor Tom Goodale @hdesc Merged in Szu-Wen's Panda calls. @@ -145,12 +141,24 @@ void IOFlexIO_Write3D (cGH *GH, int index, const char *alias) /* first, check if variable has storage assigned */ if (! CCTK_QueryGroupStorageI (GH, CCTK_GroupIndexFromVarI (index))) { char *fullname = CCTK_FullName (index); - char *msg = (char *) malloc (80 + strlen (fullname)); - sprintf (msg, "No IOFlexIO 3D output for '%s' (no storage)", fullname); - CCTK_WARN (2, msg); + CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, + "No IOFlexIO 3D output for '%s' (no storage)", fullname); + free (fullname); + return; + } + +/*** FIXME: IEEEIO doesn't provide a COMPLEX datatype + so somehow CCTK_COMPLEX has to be mapped onto REALs or so. + We have to check this already here because if an IEEEIO file + is created and nothing is written to, it crashes at re-opening. ***/ + if (CCTK_VarTypeI (index) == CCTK_VARIABLE_COMPLEX) { + char *fullname = CCTK_FullName (index); + + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "IOFlexIO 3D output for complex variable '%s' not yet " + "supported", fullname); free (fullname); - free (msg); return; } @@ -224,10 +232,11 @@ void IOFlexIO_Write3D (cGH *GH, int index, const char *alias) printf ("-------------------\n"); USE_CCTK_PARAMETERS - } +/**************************** local routines ****************************/ + /*@@ @routine IOFlexIO_Write3D_closeFile @author Paul Walker @@ -243,7 +252,7 @@ void IOFlexIO_Write3D (cGH *GH, int index, const char *alias) @@*/ -void IOFlexIO_Write3D_closeFile (cGH *GH, IEEEfile_3D_t *IEEEfile_3D) +static void IOFlexIO_Write3D_closeFile (cGH *GH, IEEEfile_3D_t *IEEEfile_3D) { DECLARE_CCTK_PARAMETERS flexioGH *myGH; @@ -286,8 +295,8 @@ void IOFlexIO_Write3D_closeFile (cGH *GH, IEEEfile_3D_t *IEEEfile_3D) @endhistory @@*/ -void IOFlexIO_Write3D_openFile (cGH *GH, IEEEfile_3D_t *IEEEfile_3D, - int isNewFile) +static void IOFlexIO_Write3D_openFile (cGH *GH, IEEEfile_3D_t *IEEEfile_3D, + int isNewFile) { DECLARE_CCTK_PARAMETERS flexioGH *myGH; @@ -305,14 +314,9 @@ void IOFlexIO_Write3D_openFile (cGH *GH, IEEEfile_3D_t *IEEEfile_3D, printf ("Opening file '%s'\n", IEEEfile_3D->filename); IEEEfile_3D->iofile = IEEEopen (IEEEfile_3D->filename, "w"); - if (! IOisValid (IEEEfile_3D->iofile)) { - char *msg = (char *) malloc (strlen (IEEEfile_3D->filename) + 80); - - sprintf (msg, "The file '%s' could not be opened for writing.", - IEEEfile_3D->filename); - CCTK_WARN (1, msg); - free (msg); - } + if (! IOisValid (IEEEfile_3D->iofile)) + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "Couldn't create 3D output file '%s'", IEEEfile_3D->filename); } else if (myGH->out3d_reuse_filehandles) { @@ -334,21 +338,15 @@ void IOFlexIO_Write3D_openFile (cGH *GH, IEEEfile_3D_t *IEEEfile_3D, printf ("Re-opening file '%s' in append mode\n", IEEEfile_3D->filename); IEEEfile_3D->iofile = IEEEopen (IEEEfile_3D->filename, "a"); - if (! IOisValid (IEEEfile_3D->iofile)) { - char *msg = (char *) malloc (strlen (IEEEfile_3D->filename) + 80); - - sprintf (msg, "The file %s could not be opened for appending.\n", - IEEEfile_3D->filename); - CCTK_WARN (1, msg); - free (msg); - } + if (! IOisValid (IEEEfile_3D->iofile)) + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "Couldn't append to 3D output file '%s'",IEEEfile_3D->filename); } /* Turn on buffer cache (with default size chosen by IEEEIO lib) */ IEEEbufferOn (IEEEfile_3D->iofile, 0); USE_CCTK_PARAMETERS - } @@ -366,7 +364,8 @@ void IOFlexIO_Write3D_openFile (cGH *GH, IEEEfile_3D_t *IEEEfile_3D, @endhistory @@*/ -IEEEfile_3D_t *IOFlexIO_Get3Dfile (cGH *GH, const char *alias, int *isNewFile) +static IEEEfile_3D_t *IOFlexIO_Get3Dfile (cGH *GH, const char *alias, + int *isNewFile) { DECLARE_CCTK_PARAMETERS ioGH *ioUtilGH; /* handle for IOUtil extensions */ @@ -476,5 +475,4 @@ IEEEfile_3D_t *IOFlexIO_Get3Dfile (cGH *GH, const char *alias, int *isNewFile) return (IEEEfile_3D); USE_CCTK_PARAMETERS - } |