diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2020-10-01 16:47:45 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2020-10-01 16:47:45 (GMT) |
commit | 1ba1f2f3222cbe8df0bf601929a4bffd478d7e02 (patch) | |
tree | ae51dfc33cf40432dad25a5088767115a98f195e /testpar/t_pflush1.c | |
parent | 8eef7d295cc3dd134aef0a826f1de4287629996d (diff) | |
download | hdf5-1ba1f2f3222cbe8df0bf601929a4bffd478d7e02.zip hdf5-1ba1f2f3222cbe8df0bf601929a4bffd478d7e02.tar.gz hdf5-1ba1f2f3222cbe8df0bf601929a4bffd478d7e02.tar.bz2 |
Source formatted
Diffstat (limited to 'testpar/t_pflush1.c')
-rw-r--r-- | testpar/t_pflush1.c | 105 |
1 files changed, 49 insertions, 56 deletions
diff --git a/testpar/t_pflush1.c b/testpar/t_pflush1.c index 27b561b..f21726a 100644 --- a/testpar/t_pflush1.c +++ b/testpar/t_pflush1.c @@ -23,17 +23,12 @@ */ #include "h5test.h" -const char *FILENAME[] = { - "flush", - "noflush", - NULL -}; +const char *FILENAME[] = {"flush", "noflush", NULL}; -static int data_g[100][100]; +static int data_g[100][100]; -#define N_GROUPS 100 +#define N_GROUPS 100 - /*------------------------------------------------------------------------- * Function: create_test_file * @@ -50,51 +45,51 @@ static int data_g[100][100]; static hid_t create_test_file(char *name, hid_t fapl_id) { - hid_t fid = H5I_INVALID_HID; - hid_t dcpl_id = H5I_INVALID_HID; - hid_t sid = H5I_INVALID_HID; - hid_t did = H5I_INVALID_HID; - hid_t top_level_gid = H5I_INVALID_HID; - hid_t gid = H5I_INVALID_HID; - hid_t dxpl_id = H5I_INVALID_HID; - hsize_t dims[2] = {100, 100}; - hsize_t chunk_dims[2] = {5, 5}; - hsize_t i, j; + hid_t fid = H5I_INVALID_HID; + hid_t dcpl_id = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t top_level_gid = H5I_INVALID_HID; + hid_t gid = H5I_INVALID_HID; + hid_t dxpl_id = H5I_INVALID_HID; + hsize_t dims[2] = {100, 100}; + hsize_t chunk_dims[2] = {5, 5}; + hsize_t i, j; - if((fid = H5Fcreate(name, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) + if ((fid = H5Fcreate(name, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) goto error; /* Create a chunked dataset */ - if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dcpl_id, 2, chunk_dims) < 0) + if (H5Pset_chunk(dcpl_id, 2, chunk_dims) < 0) goto error; - if((sid = H5Screate_simple(2, dims, NULL)) < 0) + if ((sid = H5Screate_simple(2, dims, NULL)) < 0) goto error; - if((did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) goto error; - if(H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE) < 0) + if (H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE) < 0) goto error; /* Write some data */ - for(i = 0; i < dims[0]; i++) - for(j = 0; j < dims[1]; j++) + for (i = 0; i < dims[0]; i++) + for (j = 0; j < dims[1]; j++) data_g[i][j] = (int)(i + (i * j) + j); - if(H5Dwrite(did, H5T_NATIVE_INT, sid, sid, dxpl_id, data_g) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, sid, sid, dxpl_id, data_g) < 0) goto error; /* Create some groups */ - if((top_level_gid = H5Gcreate2(fid, "some_groups", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((top_level_gid = H5Gcreate2(fid, "some_groups", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - for(i = 0; i < N_GROUPS; i++) { + for (i = 0; i < N_GROUPS; i++) { HDsprintf(name, "grp%02u", (unsigned)i); - if((gid = H5Gcreate2(top_level_gid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(top_level_gid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto error; } @@ -104,7 +99,6 @@ error: return H5I_INVALID_HID; } /* end create_test_file() */ - /*------------------------------------------------------------------------- * Function: main * @@ -118,33 +112,33 @@ error: *------------------------------------------------------------------------- */ int -main(int argc, char* argv[]) +main(int argc, char *argv[]) { - hid_t fid1 = H5I_INVALID_HID; - hid_t fid2 = H5I_INVALID_HID; - hid_t fapl_id = H5I_INVALID_HID; - MPI_File *mpifh_p = NULL; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + MPI_File * mpifh_p = NULL; char name[1024]; - const char *envval = NULL; + const char *envval = NULL; int mpi_size; int mpi_rank; - MPI_Comm comm = MPI_COMM_WORLD; - MPI_Info info = MPI_INFO_NULL; + MPI_Comm comm = MPI_COMM_WORLD; + MPI_Info info = MPI_INFO_NULL; MPI_Init(&argc, &argv); MPI_Comm_size(comm, &mpi_size); MPI_Comm_rank(comm, &mpi_rank); - if(mpi_rank == 0) + if (mpi_rank == 0) TESTING("H5Fflush (part1)"); /* Don't run using the split VFD */ envval = HDgetenv("HDF5_DRIVER"); - if(envval == NULL) + if (envval == NULL) envval = "nomatch"; - if(!HDstrcmp(envval, "split")) { - if(mpi_rank == 0) { + if (!HDstrcmp(envval, "split")) { + if (mpi_rank == 0) { SKIPPED(); HDputs(" Test not compatible with current Virtual File Driver"); } @@ -152,25 +146,25 @@ main(int argc, char* argv[]) HDexit(EXIT_FAILURE); } - if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; - if(H5Pset_fapl_mpio(fapl_id, comm, info) < 0) + if (H5Pset_fapl_mpio(fapl_id, comm, info) < 0) goto error; /* Create the file */ h5_fixname(FILENAME[0], fapl_id, name, sizeof(name)); - if((fid1 = create_test_file(name, fapl_id)) < 0) + if ((fid1 = create_test_file(name, fapl_id)) < 0) goto error; /* Flush and exit without closing the library */ - if(H5Fflush(fid1, H5F_SCOPE_GLOBAL) < 0) + if (H5Fflush(fid1, H5F_SCOPE_GLOBAL) < 0) goto error; /* Create the other file which will not be flushed */ h5_fixname(FILENAME[1], fapl_id, name, sizeof(name)); - if((fid2 = create_test_file(name, fapl_id)) < 0) + if ((fid2 = create_test_file(name, fapl_id)) < 0) goto error; - if(mpi_rank == 0) + if (mpi_rank == 0) PASSED(); HDfflush(stdout); @@ -184,15 +178,15 @@ main(int argc, char* argv[]) */ /* Close file 1 */ - if(H5Fget_vfd_handle(fid1, fapl_id, (void **)&mpifh_p) < 0) + if (H5Fget_vfd_handle(fid1, fapl_id, (void **)&mpifh_p) < 0) goto error; - if(MPI_File_close(mpifh_p) != MPI_SUCCESS) + if (MPI_File_close(mpifh_p) != MPI_SUCCESS) goto error; /* Close file 2 */ - if(H5Fget_vfd_handle(fid2, fapl_id, (void **)&mpifh_p) < 0) + if (H5Fget_vfd_handle(fid2, fapl_id, (void **)&mpifh_p) < 0) goto error; - if(MPI_File_close(mpifh_p) != MPI_SUCCESS) + if (MPI_File_close(mpifh_p) != MPI_SUCCESS) goto error; HDfflush(stdout); @@ -215,4 +209,3 @@ error: HDprintf("THERE WAS A REAL ERROR IN t_pflush1.\n"); HD_exit(EXIT_FAILURE); } /* end main() */ - |