summaryrefslogtreecommitdiffstats
path: root/testpar/t_pread.c
diff options
context:
space:
mode:
Diffstat (limited to 'testpar/t_pread.c')
-rw-r--r--testpar/t_pread.c155
1 files changed, 47 insertions, 108 deletions
diff --git a/testpar/t_pread.c b/testpar/t_pread.c
index aac5bee..53701b9 100644
--- a/testpar/t_pread.c
+++ b/testpar/t_pread.c
@@ -25,16 +25,10 @@
* since each set of three is used by the tests either to construct
* or to read and validate.
*/
-#define NFILENAME 9
-const char *FILENAMES[NFILENAME + 1]={"t_pread_data_file",
- "reloc_t_pread_data_file",
- "prefix_file",
- "t_pread_group_0_file",
+#define NFILENAME 3
+const char *FILENAMES[NFILENAME + 1]={"reloc_t_pread_data_file",
"reloc_t_pread_group_0_file",
- "prefix_file_0",
- "t_pread_group_1_file",
"reloc_t_pread_group_1_file",
- "prefix_file_1",
NULL};
#define FILENAME_BUF_SIZE 1024
@@ -55,18 +49,13 @@ static int generate_test_file(MPI_Comm comm, int mpi_rank, int group);
static int test_parallel_read(MPI_Comm comm, int mpi_rank, int group);
static char *test_argv0 = NULL;
-extern char *dirname(char *path); /* Avoids additional includes */
-
+
/*-------------------------------------------------------------------------
* Function: generate_test_file
*
* Purpose: This function is called to produce an HDF5 data file
- * whose superblock is relocated to a non-zero offset by
- * utilizing the 'h5jam' utility to write random text
- * at the start of the file. Unlike simple concatenation
- * of files, h5jam is used to place the superblock on a
- * power-of-2 boundary.
+ * whose superblock is relocated to a power-of-2 boundary.
*
* Since data will be read back and validated, we generate
* data in a predictable manner rather than randomly.
@@ -98,13 +87,11 @@ extern char *dirname(char *path); /* Avoids additional includes */
static int
generate_test_file( MPI_Comm comm, int mpi_rank, int group_id )
{
- FILE *header = NULL;
+ int header = -1;
const char *fcn_name = "generate_test_file()";
const char *failure_mssg = NULL;
char *group_filename = NULL;
char data_filename[FILENAME_BUF_SIZE];
- char reloc_data_filename[FILENAME_BUF_SIZE];
- char prolog_filename[FILENAME_BUF_SIZE];
int file_index = 0;
int group_size;
int group_rank;
@@ -117,6 +104,7 @@ generate_test_file( MPI_Comm comm, int mpi_rank, int group_id )
hid_t file_id = -1;
hid_t memspace = -1;
hid_t filespace = -1;
+ hid_t fctmpl = -1;
hid_t fapl_id = -1;
hid_t dxpl_id = -1;
hid_t dset_id = -1;
@@ -154,10 +142,10 @@ generate_test_file( MPI_Comm comm, int mpi_rank, int group_id )
file_index = 0;
}
else if ( group_id == 0 ) { /* Test 2 group 0 */
- file_index = 3;
+ file_index = 1;
}
else { /* Test 2 group 1 */
- file_index = 6;
+ file_index = 2;
}
/* The 'group_filename' is just a temp variable and
@@ -175,32 +163,6 @@ generate_test_file( MPI_Comm comm, int mpi_rank, int group_id )
}
}
- if ( pass ) {
-
- group_filename = FILENAMES[file_index+1];
- HDassert( group_filename );
-
- /* Assign the 'reloc_data_filename' */
- if ( h5_fixname(group_filename, H5P_DEFAULT, reloc_data_filename,
- sizeof(reloc_data_filename)) == NULL ) {
-
- pass = FALSE;
- failure_mssg = "h5_fixname(1) failed.\n";
- }
- }
-
- if ( pass ) {
- group_filename = FILENAMES[file_index+2];
- HDassert( group_filename );
-
- /* Assign the 'prolog_filename' */
- if ( h5_fixname(group_filename, H5P_DEFAULT, prolog_filename,
- sizeof(prolog_filename)) == NULL ) {
- pass = FALSE;
- failure_mssg = "h5_fixname(2) failed.\n";
- }
- }
-
/* setup data to write */
if ( pass ) {
if ( (data_slice = (float *)HDmalloc(COUNT * sizeof(float))) == NULL ) {
@@ -218,6 +180,17 @@ generate_test_file( MPI_Comm comm, int mpi_rank, int group_id )
}
}
+ /* Initialize a file creation template */
+ if (pass) {
+ if ((fctmpl = H5Pcreate(H5P_FILE_CREATE)) < 0) {
+ pass = FALSE;
+ failure_mssg = "H5Pcreate(H5P_FILE_CREATE) failed.\n";
+ }
+ else if (H5Pset_userblock(fctmpl, 512) != SUCCEED) {
+ pass = FALSE;
+ failure_mssg = "H5Pset_userblock(,size) failed.\n";
+ }
+ }
/* setup FAPL */
if ( pass ) {
if ( (fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0 ) {
@@ -236,7 +209,7 @@ generate_test_file( MPI_Comm comm, int mpi_rank, int group_id )
/* create the data file */
if ( pass ) {
if ( (file_id = H5Fcreate(data_filename, H5F_ACC_TRUNC,
- H5P_DEFAULT, fapl_id)) < 0 ) {
+ fctmpl, fapl_id)) < 0 ) {
pass = FALSE;
failure_mssg = "H5Fcreate() failed.\n";
}
@@ -342,6 +315,13 @@ generate_test_file( MPI_Comm comm, int mpi_rank, int group_id )
}
}
+ if (pass || (fctmpl != -1)) {
+ if (H5Pclose(fctmpl) < 0) {
+ pass = false;
+ failure_mssg = "H5Pclose(fctmpl) failed.\n";
+ }
+ }
+
/* Add a userblock to the head of the datafile.
* We will use this to for a functional test of the
* file open optimization. This is superblock
@@ -354,11 +334,8 @@ generate_test_file( MPI_Comm comm, int mpi_rank, int group_id )
* group_rank(0) processes. Each parallel group
* will create a unique file with different text
* headers and different data.
- *
- * We also delete files that are no longer needed.
*/
- if ( group_rank == 0 ) {
-
+ if (group_rank == 0) {
const char *text_to_write;
size_t bytes_to_write;
@@ -367,69 +344,33 @@ generate_test_file( MPI_Comm comm, int mpi_rank, int group_id )
else
text_to_write = hitchhiker_quote;
- bytes_to_write = strlen(text_to_write);
-
- if ( pass ) {
- if ( (header = HDfopen(prolog_filename, "w+")) == NULL ) {
- pass = FALSE;
- failure_mssg = "HDfopen(prolog_filename, \"w+\") failed.\n";
- }
- }
-
- if ( pass ) {
+ bytes_to_write = HDstrlen(text_to_write);
- if ( HDfwrite(text_to_write, 1, bytes_to_write, header) !=
- bytes_to_write ) {
+ if (pass) {
+ if ((header = HDopen(data_filename, O_WRONLY)) < 0) {
pass = FALSE;
- failure_mssg = "Unable to write header file.\n";
+ failure_mssg = "HDopen(data_filename, O_WRONLY) failed.\n";
}
}
- if ( pass || (header != NULL) ) {
- if ( HDfclose(header) != 0 ) {
+ if (pass) {
+ HDlseek(header, 0, SEEK_SET);
+ if (HDwrite(header, text_to_write, bytes_to_write) < 0) {
pass = FALSE;
- failure_mssg = "HDfclose() failed.\n";
- }
+ failure_mssg = "Unable to write user text into file.\n";
+ }
}
- if ( pass ) {
- char cmd[256];
- char exe_path[256];
- char *relative_path = "../tools/src/h5jam";
- char *exe_dirname = relative_path;
-
- /* We're checking for the existance of the h5jam utility
- * With Cmake testing, all binaries are in the same directory
- * e.g. the same location where this executable is found.
- * We've copied the argv[0] argument and check to see
- * if h5jam is co-located here. Otherwise, the autotools
- * put things into directories, hence the relative path.
- */
- if (test_argv0 != NULL) {
- HDstrncpy(exe_path, test_argv0, sizeof(exe_path));
- if ( (exe_dirname = (char *)dirname(exe_path)) != NULL) {
- HDsprintf(cmd, "%s/h5jam", exe_dirname);
- if ( HDaccess(cmd, F_OK) != 0)
- exe_dirname = relative_path;
- }
- }
- HDsprintf(cmd, "%s/h5jam -i %s -u %s -o %s",
- exe_dirname,
- data_filename,
- prolog_filename, reloc_data_filename);
-
- if ( system(cmd) != 0 ) {
+ if (pass || (header > 0)) {
+ if (HDclose(header) < 0) {
pass = FALSE;
- failure_mssg = "invocation of h5jam failed.\n";
+ failure_mssg = "HDclose() failed.\n";
}
}
-
- HDremove(prolog_filename);
- HDremove(data_filename);
}
/* collect results from other processes.
- * Only overwrite the failure message if no preveious error
+ * Only overwrite the failure message if no previous error
* has been detected
*/
local_failure = ( pass ? 0 : 1 );
@@ -467,7 +408,7 @@ generate_test_file( MPI_Comm comm, int mpi_rank, int group_id )
} /* generate_test_file() */
-
+
/*-------------------------------------------------------------------------
* Function: test_parallel_read
*
@@ -564,11 +505,11 @@ test_parallel_read(MPI_Comm comm, int mpi_rank, int group_id)
if ( pass ) {
if ( comm == MPI_COMM_WORLD ) /* test 1 */
- group_filename = FILENAMES[1];
+ group_filename = FILENAMES[0];
else if ( group_id == 0 ) /* test 2 group 0 */
- group_filename = FILENAMES[4];
+ group_filename = FILENAMES[1];
else /* test 2 group 1 */
- group_filename = FILENAMES[7];
+ group_filename = FILENAMES[2];
HDassert(group_filename);
if ( h5_fixname(group_filename, H5P_DEFAULT, reloc_data_filename,
@@ -742,7 +683,7 @@ test_parallel_read(MPI_Comm comm, int mpi_rank, int group_id)
} /* test_parallel_read() */
-
+
/*-------------------------------------------------------------------------
* Function: main
*
@@ -781,7 +722,7 @@ main( int argc, char **argv)
int mpi_rank;
int mpi_size;
int split_size;
- MPI_Comm group_comm = MPI_COMM_WORLD;
+ MPI_Comm group_comm = MPI_COMM_NULL;
/* I don't believe that argv[0] can ever be NULL.
* It should thus be safe to dup and save as a check
@@ -905,7 +846,6 @@ finish:
HDfprintf(stderr, "MPI_Comm_free failed!\n");
}
-
/* make sure all processes are finished before final report, cleanup
* and exit.
*/
@@ -916,7 +856,6 @@ finish:
HDfprintf(stdout, "===================================\n");
if ( nerrs > 0 ) {
-
HDfprintf(stdout, "***%s detected %d failures***\n", header, nerrs);
}
else {