aboutsummaryrefslogtreecommitdiff
path: root/src/Write.c
diff options
context:
space:
mode:
authortradke <tradke@4825ed28-b72c-4eae-9704-e50c059e567d>2002-04-17 08:42:50 +0000
committertradke <tradke@4825ed28-b72c-4eae-9704-e50c059e567d>2002-04-17 08:42:50 +0000
commit31bb9a3c76d7e18d4cce38c6dc3010bb5ef0f8ed (patch)
treefe64ab5d800ea2df189e51c21cfb0b29a8fc3523 /src/Write.c
parentd8aa32794e141b22fa9954b4ec3afe6b8ae50d8a (diff)
Just some minor changes before doing the transition to use the new hyperslabbing
API: completed grdoc, put in some more comments, removed dead code. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOHDF5/trunk@117 4825ed28-b72c-4eae-9704-e50c059e567d
Diffstat (limited to 'src/Write.c')
-rw-r--r--src/Write.c111
1 files changed, 32 insertions, 79 deletions
diff --git a/src/Write.c b/src/Write.c
index 859214a..8eea1bc 100644
--- a/src/Write.c
+++ b/src/Write.c
@@ -31,7 +31,6 @@ CCTK_FILEVERSION(AlphaThorns_IOHDF5_Write_c)
********************************************************************/
static char *IOHDF5_GetFilename (const cGH *GH,
int vindex,
- const ioHDF5Geo_t *slab,
const char *name,
int *is_new_file);
@@ -76,12 +75,11 @@ int IOHDF5_Write (const cGH *GH, int vindex, const char *alias)
ioHDF5GH *myGH;
hid_t file, plist;
int is_new_file;
- char *filename;
- char *fullname;
+ char *filename, *fullname;
DECLARE_CCTK_PARAMETERS
- /* Get the handle for IO extensions */
+ /* Get the handles for IO and IOHDF5 extensions */
ioUtilGH = (ioGH *) CCTK_GHExtension (GH, "IO");
myGH = (ioHDF5GH *) CCTK_GHExtension (GH, "IOHDF5");
@@ -96,8 +94,7 @@ int IOHDF5_Write (const cGH *GH, int vindex, const char *alias)
}
/* get the filename for output */
- filename = IOHDF5_GetFilename (GH, vindex, myGH->out_geo[vindex],
- alias, &is_new_file);
+ filename = IOHDF5_GetFilename (GH, vindex, alias, &is_new_file);
if (! filename)
{
fullname = CCTK_FullName (vindex);
@@ -162,8 +159,7 @@ int IOHDF5_Write (const cGH *GH, int vindex, const char *alias)
specific to any dataset goes into dedicated groups */
if (strcmp (out3D_parameters, "no"))
{
- IOHDF5Util_DumpParameters (GH, strcmp (out3D_parameters, "all") == 0,
- file);
+ IOHDF5Util_DumpParameters (GH, ! strcmp (out3D_parameters, "all"), file);
}
IOHDF5Util_DumpGHExtensions (GH, file);
@@ -198,7 +194,8 @@ int IOHDF5_Write (const cGH *GH, int vindex, const char *alias)
@routine IOHDF5_GetFilename
@author Paul Walker
@date Feb 1997
- @desc Builds the filename for output.
+ @desc
+ Builds the filename for output.
The names of all output files are stored in the filename
database.
The routine first searches in this database if there is already
@@ -207,6 +204,7 @@ int IOHDF5_Write (const cGH *GH, int vindex, const char *alias)
database.
Generalized for Hyperslab extraction (GL)
@enddesc
+
@var GH
@vdesc Pointer to CCTK GH
@vtype const cGH *
@@ -217,11 +215,6 @@ int IOHDF5_Write (const cGH *GH, int vindex, const char *alias)
@vtype int
@vio in
@endvar
- @var slab
- @vdesc pointer to hyperslab structure
- @vtype const ioHDF5Geo_t *
- @vio in
- @endvar
@var varname
@vdesc alias name of variable to output
@vtype const char *
@@ -240,67 +233,26 @@ int IOHDF5_Write (const cGH *GH, int vindex, const char *alias)
@@*/
static char *IOHDF5_GetFilename (const cGH *GH,
int vindex,
- const ioHDF5Geo_t *slab,
const char *varname,
int *is_new_file)
{
- const ioGH *ioUtilGH; /* handle for IOUtil extensions */
- ioHDF5GH *myGH; /* handle for IOHDF5 extensions */
- const ioHDF5UtilGH *h5UtilGH; /* handle for IOHDF5Util extensions */
- const pGH *pughGH; /* handle for PUGH extensions */
- int myproc;
+ const ioGH *ioUtilGH;
+ ioHDF5GH *myGH;
+ const pGH *pughGH;
+ int myproc, result;
/* FIXME: make these strings dynamic */
- char extra[256]; /* Extra stuff in fname based on mode */
- char extradir[256]; /* Extra stuff for an output dir */
- char *filename; /* the return value */
- int result;
- char *outputdir, *fullname;
+ char extra[256], extradir[256];
+ char *filename, *outputdir, *fullname, *tmp;
ioAdvertisedFileDesc advertised_file;
-#if 0
- int idim;
- char *extrageo; /* Extra stuff for geometry information */
-#endif
- char name[128];
DECLARE_CCTK_PARAMETERS
- /* get GH extensions for PUGH, IOUtil, IOHDF5Util, and IOHDF5 */
+ /* get GH extensions for PUGH, IOUtil, and IOHDF5 */
pughGH = (const pGH *) PUGH_pGH (GH);
ioUtilGH = (const ioGH *) CCTK_GHExtension (GH, "IO");
myGH = (ioHDF5GH *) CCTK_GHExtension (GH, "IOHDF5");
- h5UtilGH = (const ioHDF5UtilGH *) CCTK_GHExtension (GH, "IOHDF5Util");
-
-#if 0
- /*** FIXME: use new filenaming scheme ***/
- /* To identify the slab in a volume (if sdim<vdim)
- build a string like: "012" (3d volume, spanned by xyz)
- or "12" (2d volume, spanned by yz(!) and append this to the name:
- You get something like this: phi_s12_3d */
- if (slab->sdim<slab->vdim) {
- extrageo = (char*) malloc((slab->sdim+1)*sizeof(char));
- sprintf(extrageo,"%d",slab->direction[0]);
- for (idim=1;idim<slab->sdim;idim++)
- sprintf(extrageo,"%s%d",extrageo,slab->direction[idim]);
- sprintf(name,"%s_s%s_%dd",varname,extrageo,slab->vdim);
- free(extrageo);
- }
- /* If sdim==vdim, make it simple: e.g. phi_3d */
- else if (slab->sdim==slab->vdim)
- {
- sprintf(name,"%s_%dd",varname,slab->vdim);
- }
- else {
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Inconsitent dimensions for >%s<: slab (%dD), variable (%dD)\n",
- varname, slab->sdim,slab->vdim);
- return(NULL);
- }
-#else
- slab = slab;
- strcpy (name, varname);
-#endif
- filename = (char *) GetNamedData (myGH->open_output_files, name);
+ filename = (char *) GetNamedData (myGH->open_output_files, varname);
if (filename != NULL)
{
/* set flag to indicate that file should be opened in append mode */
@@ -315,15 +267,17 @@ static char *IOHDF5_GetFilename (const cGH *GH,
if (out3D_septimefiles)
{
- char *tmp = extra;
-
+ tmp = extra;
sprintf (extra, "%s.time_%7.3f", extra, GH->cctk_time);
/* And be sure to replace any spaces in the filename with an _ */
do
+ {
if (*tmp == ' ')
+ {
*tmp = '_';
- while (*++tmp);
+ }
+ } while (*++tmp);
}
@@ -335,22 +289,21 @@ static char *IOHDF5_GetFilename (const cGH *GH,
* a directory is created for each output variable to hold the multiple
* files.
*/
-
if (! ioUtilGH->unchunked && ioUtilGH->ioproc_every < CCTK_nProcs (GH))
{
/* Add the output processor number to the extra string */
sprintf (extra, "%s.file_%d", extra, myproc / ioUtilGH->ioproc_every);
/* If necessary create the output directory */
- outputdir = (char *) malloc (strlen (myGH->outdir) + strlen (name) + 5);
+ outputdir = (char *) malloc (strlen (myGH->outdir) + strlen (varname) + 5);
if (strcmp (myGH->outdir, "."))
{
- sprintf (outputdir, "%s/%s_3d", myGH->outdir, name);
+ sprintf (outputdir, "%s/%s_3d", myGH->outdir, varname);
}
else
{
- sprintf (outputdir, "%s_3d", name);
+ sprintf (outputdir, "%s_3d", varname);
}
result = IOUtil_CreateDirectory (GH, outputdir,
@@ -375,27 +328,27 @@ static char *IOHDF5_GetFilename (const cGH *GH,
#endif
/* extradir is the relative output directory */
- sprintf (extradir, "%s_3d/", name);
+ sprintf (extradir, "%s_3d/", varname);
}
/* CREATE THE COMPLETE OUTPUT FILENAME
----------------------------------- */
filename = (char *) malloc (strlen (myGH->outdir) +
strlen (extradir) +
- strlen (name) +
+ strlen (varname) +
strlen (extra) +
(pughGH->identity_string ? strlen (pughGH->identity_string) : 0) +
8);
if (strcmp (myGH->outdir, "."))
{
sprintf (filename, "%s/%s%s%s%s.h5",
- myGH->outdir, extradir, name, extra,
+ myGH->outdir, extradir, varname, extra,
(pughGH->identity_string ? pughGH->identity_string : ""));
}
else
{
sprintf (filename, "%s%s%s%s.h5",
- extradir, name, extra,
+ extradir, varname, extra,
(pughGH->identity_string ? pughGH->identity_string : ""));
}
@@ -406,10 +359,10 @@ static char *IOHDF5_GetFilename (const cGH *GH,
{
if (ioUtilGH->recovered)
{
- IOHDF5_ERROR (H5Eset_auto (NULL, NULL));
- *is_new_file = H5Fis_hdf5 (filename) <= 0;
- IOHDF5_ERROR (H5Eset_auto (h5UtilGH->print_error_fn,
- h5UtilGH->print_error_fn_arg));
+ H5E_BEGIN_TRY
+ {
+ *is_new_file = H5Fis_hdf5 (filename) <= 0;
+ } H5E_END_TRY;
if (! *is_new_file)
{
myGH->check_exisiting_objects[vindex] = 1;
@@ -420,7 +373,7 @@ static char *IOHDF5_GetFilename (const cGH *GH,
*is_new_file = 1;
}
}
- StoreNamedData (&myGH->open_output_files, name, filename);
+ StoreNamedData (&myGH->open_output_files, varname, filename);
}
else
{