diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2022-04-13 21:17:29 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2022-04-13 21:17:29 (GMT) |
commit | cabc39c3e197e2591449d2604bfee26465fb60e1 (patch) | |
tree | d5f39f5f5965584bf9bf49646a2af617adfd3e4e /testpar/t_pflush1.c | |
parent | 7355f4c505092a7a85474b47f18d5206028e2c95 (diff) | |
parent | ab69f5df770ee3cc6cd6c81d905a5317b894a002 (diff) | |
download | hdf5-feature/coding_standards.zip hdf5-feature/coding_standards.tar.gz hdf5-feature/coding_standards.tar.bz2 |
Merge branch 'develop' into feature/coding_standardsfeature/coding_standards
Diffstat (limited to 'testpar/t_pflush1.c')
-rw-r--r-- | testpar/t_pflush1.c | 115 |
1 files changed, 55 insertions, 60 deletions
diff --git a/testpar/t_pflush1.c b/testpar/t_pflush1.c index 27b561b..0500a2d 100644 --- a/testpar/t_pflush1.c +++ b/testpar/t_pflush1.c @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -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 * @@ -48,53 +43,53 @@ static int data_g[100][100]; *------------------------------------------------------------------------- */ static hid_t -create_test_file(char *name, hid_t fapl_id) +create_test_file(char *name, size_t name_length, 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++) { - HDsprintf(name, "grp%02u", (unsigned)i); - if((gid = H5Gcreate2(top_level_gid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + for (i = 0; i < N_GROUPS; i++) { + HDsnprintf(name, name_length, "grp%02u", (unsigned)i); + 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) + envval = HDgetenv(HDF5_DRIVER); + 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, sizeof(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, sizeof(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); @@ -213,6 +207,7 @@ error: HDfflush(stderr); HDprintf("*** ERROR ***\n"); HDprintf("THERE WAS A REAL ERROR IN t_pflush1.\n"); + HDfflush(stdout); + HD_exit(EXIT_FAILURE); } /* end main() */ - |