aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@4825ed28-b72c-4eae-9704-e50c059e567d>2004-05-06 11:59:32 +0000
committertradke <tradke@4825ed28-b72c-4eae-9704-e50c059e567d>2004-05-06 11:59:32 +0000
commit25e66e01ccad70cac0b32bf38dc6fe342873bc72 (patch)
treec9a0abf82c803388b4604e0c063b7bb996651d5c
parent8a0e01d88fca0701c45a322454ca3348dfc8ce46 (diff)
Fixed filenames for chunked output files.
Don't output chunked files for grid scalars. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOHDF5/trunk@191 4825ed28-b72c-4eae-9704-e50c059e567d
-rw-r--r--src/Write.c71
1 files changed, 31 insertions, 40 deletions
diff --git a/src/Write.c b/src/Write.c
index 4d9831a..1a69cf9 100644
--- a/src/Write.c
+++ b/src/Write.c
@@ -73,16 +73,16 @@ static char *IOHDF5_GetFilename (const cGH *GH,
@@*/
int IOHDF5_Write (const cGH *GH, int vindex, const char *alias)
{
- ioGH *ioUtilGH;
+ const ioGH *ioUtilGH;
ioHDF5GH *myGH;
hid_t file, plist;
- int is_new_file, retval;
+ int myproc, is_new_file, retval;
char *filename, *fullname;
DECLARE_CCTK_PARAMETERS
- ioUtilGH = (ioGH *) CCTK_GHExtension (GH, "IO");
- myGH = (ioHDF5GH *) CCTK_GHExtension (GH, "IOHDF5");
+ ioUtilGH = CCTK_GHExtension (GH, "IO");
+ myGH = CCTK_GHExtension (GH, "IOHDF5");
/* check if variable has storage assigned */
if (! CCTK_QueryGroupStorageI (GH, CCTK_GroupIndexFromVarI (vindex)))
@@ -105,18 +105,18 @@ int IOHDF5_Write (const cGH *GH, int vindex, const char *alias)
return (-2);
}
- /* open the output file on all IO processors or - in case of parallel HDF5 -
+ /* open the output file on all I/O processors or - in case of parallel HDF5 -
on every processor */
+ file = -1;
+ myproc = CCTK_MyProc (GH);
#ifdef H5_HAVE_PARALLEL
- if (CCTK_MyProc (GH) != ioUtilGH->ioproc && ! ioUtilGH->unchunked)
+ if ((myproc == ioUtilGH->ioproc || ioUtilGH->unchunked) &&
+ (CCTK_GroupTypeFromVarI (vindex) != CCTK_SCALAR || myproc == 0))
#else
- if (CCTK_MyProc (GH) != ioUtilGH->ioproc)
+ if (myproc == ioUtilGH->ioproc &&
+ (CCTK_GroupTypeFromVarI (vindex) != CCTK_SCALAR || myproc == 0))
#endif
{
- file = -1;
- }
- else
- {
if (CCTK_Equals (verbose, "full"))
{
CCTK_VInfo (CCTK_THORNSTRING, "%s HDF5 output file '%s'",
@@ -236,7 +236,7 @@ static char *IOHDF5_GetFilename (const cGH *GH,
{
const ioGH *ioUtilGH;
ioHDF5GH *myGH;
- int myproc, result;
+ int myproc, vdim, result;
/* FIXME: make these strings dynamic */
char extra[256], extradir[256];
char *filename, *outputdir, *fullname, *tmp;
@@ -245,21 +245,21 @@ static char *IOHDF5_GetFilename (const cGH *GH,
/* get GH extensions for IOUtil and IOHDF5 */
- ioUtilGH = (const ioGH *) CCTK_GHExtension (GH, "IO");
- myGH = (ioHDF5GH *) CCTK_GHExtension (GH, "IOHDF5");
+ ioUtilGH = CCTK_GHExtension (GH, "IO");
+ myGH = CCTK_GHExtension (GH, "IOHDF5");
- filename = (char *) GetNamedData (myGH->open_output_files, varname);
- if (filename != NULL)
+ filename = GetNamedData (myGH->open_output_files, varname);
+ if (filename)
{
/* set flag to indicate that file should be opened in append mode */
*is_new_file = 0;
return (filename);
}
- extra[0] = '\0';
- extradir[0]= '\0';
+ extra[0] = extradir[0]= '\0';
myproc = CCTK_MyProc (GH);
+ vdim = CCTK_GroupDimFromVarI (vindex);
if (out_timesteps_per_file > 0)
{
@@ -277,22 +277,23 @@ static char *IOHDF5_GetFilename (const cGH *GH,
}
- /* OUTPUT ONE FILE FOR EACH N PROCESSORS
+ /*
+ * OUTPUT ONE FILE FOR EACH N PROCESSORS
* -------------------------------------
*
- * If only one output file, the single file for each variable is written
- * in the normal output dir (that is extradir = ""). Otherwise
- * a directory is created for each output variable to hold the multiple
- * files.
+ * If only one output file, the single file for each GV is written
+ * in the default output directory (ie. extradir = ""). Otherwise
+ * a directory is created for each output GV to hold the multiple files.
*/
- if (! ioUtilGH->unchunked && ioUtilGH->ioproc_every < CCTK_nProcs (GH))
+ if (! ioUtilGH->unchunked && ioUtilGH->ioproc_every < CCTK_nProcs (GH) &&
+ CCTK_GroupTypeFromVarI (vindex) != CCTK_SCALAR)
{
/* 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->out_dir) + strlen (varname) + 5);
- sprintf (outputdir, "%s%s_3d", myGH->out_dir, varname);
+ outputdir = malloc (strlen (myGH->out_dir) + strlen (varname) + 5);
+ sprintf (outputdir, "%s%s_%dd", myGH->out_dir, varname, vdim);
result = IOUtil_CreateDirectory (GH, outputdir,
! CCTK_Equals (out_mode, "onefile"),
@@ -316,20 +317,18 @@ static char *IOHDF5_GetFilename (const cGH *GH,
#endif
/* extradir is the relative output directory */
- sprintf (extradir, "%s_3d/", varname);
+ sprintf (extradir, "%s_%dd/", varname, vdim);
}
/* CREATE THE COMPLETE OUTPUT FILENAME
----------------------------------- */
- filename = (char *) malloc (strlen (myGH->out_dir) +
- strlen (extradir) +
- strlen (varname) +
- strlen (extra) +
- strlen (GH->identity) + 8);
+ filename = malloc (8 + strlen (myGH->out_dir) + strlen (extradir) +
+ strlen (varname) + strlen (extra) + strlen (GH->identity));
sprintf (filename, "%s%s%s%s%s.h5",
myGH->out_dir, extradir, varname, extra, GH->identity);
/* no need to store filenames if used only once */
+ *is_new_file = 1;
if (out_timesteps_per_file < 0)
{
if (myproc == ioUtilGH->ioproc)
@@ -341,17 +340,9 @@ static char *IOHDF5_GetFilename (const cGH *GH,
*is_new_file = H5Fis_hdf5 (filename) <= 0;
} H5E_END_TRY;
}
- else
- {
- *is_new_file = 1;
- }
}
StoreNamedData (&myGH->open_output_files, varname, filename);
}
- else
- {
- *is_new_file = 1;
- }
/* advertise the file for downloading */
fullname = CCTK_FullName (vindex);