diff options
author | Vailin Choi <vchoi@jam.ad.hdfgroup.org> | 2018-11-01 17:03:34 (GMT) |
---|---|---|
committer | Vailin Choi <vchoi@jam.ad.hdfgroup.org> | 2018-11-01 17:03:34 (GMT) |
commit | 4f62c084f1b0502bc984edd8ce380bea22518bd3 (patch) | |
tree | 864bdc70375a1390deea07fd140fc55cafd9e725 | |
parent | d1d2cf776d4f7b809e3cc1bda1a001ea147dfa89 (diff) | |
download | hdf5-4f62c084f1b0502bc984edd8ce380bea22518bd3.zip hdf5-4f62c084f1b0502bc984edd8ce380bea22518bd3.tar.gz hdf5-4f62c084f1b0502bc984edd8ce380bea22518bd3.tar.bz2 |
Fixed fprintf to HDfprintf in the following routines:
1) read_uc_file() in use_common.c
2) main() of use_append_chunk.c and use_append_mchunks.c
-rw-r--r-- | test/use_append_chunk.c | 60 | ||||
-rw-r--r-- | test/use_append_mchunks.c | 54 | ||||
-rw-r--r-- | test/use_common.c | 112 |
3 files changed, 113 insertions, 113 deletions
diff --git a/test/use_append_chunk.c b/test/use_append_chunk.c index 7dda732..fb906b6 100644 --- a/test/use_append_chunk.c +++ b/test/use_append_chunk.c @@ -130,7 +130,7 @@ main(int argc, char *argv[]) /* initialization */ if (setup_parameters(argc, argv) < 0){ - Hgoto_error(1); + Hgoto_error(1); } /* Determine the need to send/wait message file*/ @@ -148,20 +148,20 @@ main(int argc, char *argv[]) /* Create file */ /* ============*/ if (UC_opts.launch != UC_READER){ - printf("Creating skeleton data file for test...\n"); - if (create_uc_file() < 0){ - fprintf(stderr, "***encounter error\n"); - Hgoto_error(1); - }else - printf("File created.\n"); + HDprintf("Creating skeleton data file for test...\n"); + if (create_uc_file() < 0){ + HDfprintf(stderr, "***encounter error\n"); + Hgoto_error(1); + }else + HDprintf("File created.\n"); } if (UC_opts.launch==UC_READWRITE){ - /* fork process */ - if((childpid = HDfork()) < 0) { - HDperror("fork"); - Hgoto_error(1); - }; + /* fork process */ + if((childpid = HDfork()) < 0) { + HDperror("fork"); + Hgoto_error(1); + }; }; mypid = HDgetpid(); @@ -169,22 +169,22 @@ main(int argc, char *argv[]) /* launch reader */ /* ============= */ if (UC_opts.launch != UC_WRITER){ - /* child process launch the reader */ - if(0 == childpid) { - printf("%d: launch reader process\n", mypid); - if (read_uc_file(send_wait) < 0){ - fprintf(stderr, "read_uc_file encountered error\n"); - exit(1); - } - exit(0); - } + /* child process launch the reader */ + if(0 == childpid) { + HDprintf("%d: launch reader process\n", mypid); + if (read_uc_file(send_wait) < 0){ + HDfprintf(stderr, "read_uc_file encountered error\n"); + exit(1); + } + exit(0); + } } /* ============= */ /* launch writer */ /* ============= */ /* this process continues to launch the writer */ - printf("%d: continue as the writer process\n", mypid); + HDprintf("%d: continue as the writer process\n", mypid); name = UC_opts.filename; @@ -198,12 +198,12 @@ main(int argc, char *argv[]) /* Open the file */ if((fid = H5Fopen(name, H5F_ACC_RDWR | (UC_opts.use_swmr ? H5F_ACC_SWMR_WRITE : 0), fapl)) < 0) { - fprintf(stderr, "H5Fopen failed\n"); + HDfprintf(stderr, "H5Fopen failed\n"); Hgoto_error(1); } if(write_uc_file(send_wait, fid) < 0) { - fprintf(stderr, "write_uc_file encountered error\n"); + HDfprintf(stderr, "write_uc_file encountered error\n"); Hgoto_error(1); } @@ -218,24 +218,24 @@ main(int argc, char *argv[]) /* Close the file */ if(H5Fclose(fid) < 0) { - fprintf(stderr, "Failed to close file id\n"); + HDfprintf(stderr, "Failed to close file id\n"); Hgoto_error(1); } /* Close the property list */ if(H5Pclose(fapl) < 0) { - fprintf(stderr, "Failed to property list\n"); + HDfprintf(stderr, "Failed to close the property list\n"); Hgoto_error(1); } if (WIFEXITED(child_status)){ if ((child_ret_value=WEXITSTATUS(child_status)) != 0){ - printf("%d: child process exited with non-zero code (%d)\n", + HDprintf("%d: child process exited with non-zero code (%d)\n", mypid, child_ret_value); Hgoto_error(2); } } else { - printf("%d: child process terminated abnormally\n", mypid); + HDprintf("%d: child process terminated abnormally\n", mypid); Hgoto_error(2); } } @@ -243,9 +243,9 @@ main(int argc, char *argv[]) done: /* Print result and exit */ if (ret_value != 0){ - printf("Error(s) encountered\n"); + HDprintf("Error(s) encountered\n"); }else{ - printf("All passed\n"); + HDprintf("All passed\n"); } return(ret_value); diff --git a/test/use_append_mchunks.c b/test/use_append_mchunks.c index 2dc7bdb..da7e2b3 100644 --- a/test/use_append_mchunks.c +++ b/test/use_append_mchunks.c @@ -123,7 +123,7 @@ main(int argc, char *argv[]) /* initialization */ if (setup_parameters(argc, argv) < 0){ - Hgoto_error(1); + Hgoto_error(1); } /* Determine the need to send/wait message file*/ @@ -141,20 +141,20 @@ main(int argc, char *argv[]) /* Create file */ /* ============*/ if (UC_opts.launch != UC_READER){ - printf("Creating skeleton data file for test...\n"); + HDprintf("Creating skeleton data file for test...\n"); if (create_uc_file() < 0){ - fprintf(stderr, "***encounter error\n"); + HDfprintf(stderr, "***encounter error\n"); Hgoto_error(1); }else - printf("File created.\n"); + HDprintf("File created.\n"); } if (UC_opts.launch==UC_READWRITE){ - /* fork process */ - if((childpid = fork()) < 0) { - perror("fork"); - Hgoto_error(1); - }; + /* fork process */ + if((childpid = fork()) < 0) { + perror("fork"); + Hgoto_error(1); + }; }; mypid = getpid(); @@ -162,22 +162,22 @@ main(int argc, char *argv[]) /* launch reader */ /* ============= */ if (UC_opts.launch != UC_WRITER){ - /* child process launch the reader */ - if(0 == childpid) { - printf("%d: launch reader process\n", mypid); - if (read_uc_file(send_wait) < 0){ - fprintf(stderr, "read_uc_file encountered error\n"); - exit(1); - } - exit(0); - } + /* child process launch the reader */ + if(0 == childpid) { + HDprintf("%d: launch reader process\n", mypid); + if (read_uc_file(send_wait) < 0){ + HDfprintf(stderr, "read_uc_file encountered error\n"); + exit(1); + } + exit(0); + } } /* ============= */ /* launch writer */ /* ============= */ /* this process continues to launch the writer */ - printf("%d: continue as the writer process\n", mypid); + HDprintf("%d: continue as the writer process\n", mypid); name = UC_opts.filename; @@ -191,12 +191,12 @@ main(int argc, char *argv[]) /* Open the file */ if((fid = H5Fopen(name, H5F_ACC_RDWR | (UC_opts.use_swmr ? H5F_ACC_SWMR_WRITE : 0), fapl)) < 0) { - fprintf(stderr, "H5Fopen failed\n"); + HDfprintf(stderr, "H5Fopen failed\n"); Hgoto_error(1); } if(write_uc_file(send_wait, fid) < 0) { - fprintf(stderr, "write_uc_file encountered error\n"); + HDfprintf(stderr, "write_uc_file encountered error\n"); Hgoto_error(1); } @@ -212,24 +212,24 @@ main(int argc, char *argv[]) /* Close the file */ if(H5Fclose(fid) < 0) { - fprintf(stderr, "Failed to close file id\n"); + HDfprintf(stderr, "Failed to close file id\n"); Hgoto_error(1); } /* Close the property list */ if(H5Pclose(fapl) < 0) { - fprintf(stderr, "Failed to property list\n"); + HDfprintf(stderr, "Failed to close the property list\n"); Hgoto_error(1); } if (WIFEXITED(child_status)){ if ((child_ret_value=WEXITSTATUS(child_status)) != 0){ - printf("%d: child process exited with non-zero code (%d)\n", + HDprintf("%d: child process exited with non-zero code (%d)\n", mypid, child_ret_value); Hgoto_error(1); } } else { - printf("%d: child process terminated abnormally\n", mypid); + HDprintf("%d: child process terminated abnormally\n", mypid); Hgoto_error(2); } } @@ -237,9 +237,9 @@ main(int argc, char *argv[]) done: /* Print result and exit */ if (ret_value != 0){ - printf("Error(s) encountered\n"); + HDprintf("Error(s) encountered\n"); }else{ - printf("All passed\n"); + HDprintf("All passed\n"); } return(ret_value); diff --git a/test/use_common.c b/test/use_common.c index 164480f..3ecb2e1 100644 --- a/test/use_common.c +++ b/test/use_common.c @@ -447,7 +447,7 @@ int read_uc_file(hbool_t towait) /* Before reading, wait for the message that H5Fopen is complete--file lock is released */ if(towait && h5_wait_message(WRITER_MESSAGE) < 0) { - fprintf(stderr, "Cannot find writer message file...failed\n"); + HDfprintf(stderr, "Cannot find writer message file...failed\n"); return -1; } @@ -457,19 +457,19 @@ int read_uc_file(hbool_t towait) if((fapl = h5_fileaccess()) < 0) return -1; if((fid = H5Fopen(name, H5F_ACC_RDONLY | (UC_opts.use_swmr ? H5F_ACC_SWMR_READ : 0), fapl)) < 0){ - fprintf(stderr, "H5Fopen failed\n"); + HDfprintf(stderr, "H5Fopen failed\n"); return -1; } if (H5Pclose(fapl) < 0){ - fprintf(stderr, "Failed to property list\n"); + HDfprintf(stderr, "Failed to property list\n"); return -1; } /* Open the dataset of the program name */ if((dsid = H5Dopen2(fid, progname_g, H5P_DEFAULT)) < 0){ - fprintf(stderr, "H5Dopen2 failed\n"); - return -1; + HDfprintf(stderr, "H5Dopen2 failed\n"); + return -1; } /* allocate space for data buffer 1 X dims[1] X dims[2] of UC_CTYPE */ @@ -477,8 +477,8 @@ int read_uc_file(hbool_t towait) memdims[1] = UC_opts.dims[1]; memdims[2] = UC_opts.dims[2]; if ((buffer=(UC_CTYPE*)HDmalloc((size_t)memdims[1]*(size_t)memdims[2]*sizeof(UC_CTYPE)))==NULL) { - fprintf(stderr, "malloc: failed\n"); - return -1; + HDfprintf(stderr, "malloc: failed\n"); + return -1; }; /* @@ -488,31 +488,31 @@ int read_uc_file(hbool_t towait) f_sid = H5Dget_space(dsid); /* Get filespace handle first. */ rank = H5Sget_simple_extent_ndims(f_sid); if (rank != UC_RANK){ - fprintf(stderr, "rank(%d) of dataset does not match\n", rank); - return -1; + HDfprintf(stderr, "rank(%d) of dataset does not match\n", rank); + return -1; } if (H5Sget_simple_extent_dims(f_sid, dims, NULL) < 0){ - fprintf(stderr, "H5Sget_simple_extent_dims got error\n"); - return -1; + HDfprintf(stderr, "H5Sget_simple_extent_dims got error\n"); + return -1; } - printf("dataset rank %d, dimensions %llu x %llu x %llu\n", - rank, (unsigned long long)(dims[0]), (unsigned long long)(dims[1]), - (unsigned long long)(dims[2])); + HDprintf("dataset rank %d, dimensions %llu x %llu x %llu\n", + rank, (unsigned long long)(dims[0]), (unsigned long long)(dims[1]), + (unsigned long long)(dims[2])); /* verify that file space dims are as expected and are consistent with memory space dims */ if (dims[1] != memdims[1] || dims[2] != memdims[2]){ - fprintf(stderr, "dataset dimension is not as expected. Got dims=(%llu,%llu,%llu)\n", - (unsigned long long)dims[0], (unsigned long long)dims[1], + HDfprintf(stderr, "dataset dimension is not as expected. Got dims=(%llu,%llu,%llu)\n", + (unsigned long long)dims[0], (unsigned long long)dims[1], (unsigned long long)dims[2]); - fprintf(stderr, "But memdims=(%llu,%llu,%llu)\n", - (unsigned long long)memdims[0], (unsigned long long)memdims[1], + HDfprintf(stderr, "But memdims=(%llu,%llu,%llu)\n", + (unsigned long long)memdims[0], (unsigned long long)memdims[1], (unsigned long long)memdims[2]); - return -1; + return -1; } /* setup mem-space for buffer */ if ((m_sid=H5Screate_simple(rank, memdims, NULL))<0){ - fprintf(stderr, "H5Screate_simple for memory failed\n"); - return -1; + HDfprintf(stderr, "H5Screate_simple for memory failed\n"); + return -1; }; /* Read 1 plane at a time whenever the dataset grows larger @@ -526,22 +526,22 @@ int read_uc_file(hbool_t towait) /* print progress message according to if new planes are availalbe */ if (nplane_old < dims[0]) { if (nonewplane){ - /* end the previous message */ - printf("\n"); - nonewplane=0; + /* end the previous message */ + HDprintf("\n"); + nonewplane=0; } - printf("reading planes %llu to %llu\n", (unsigned long long)nplane_old, + HDprintf("reading planes %llu to %llu\n", (unsigned long long)nplane_old, (unsigned long long)dims[0]); }else{ if (nonewplane){ - printf("."); + HDprintf("."); if (nonewplane>=30){ - fprintf(stderr, "waited too long for new plane, quit.\n"); + HDfprintf(stderr, "waited too long for new plane, quit.\n"); return -1; } }else{ - /* print mesg only the first time; dots still no new plane */ - printf("no new planes to read "); + /* print mesg only the first time; dots still no new plane */ + HDprintf("no new planes to read "); } nonewplane++; /* pause for a second */ @@ -551,41 +551,41 @@ int read_uc_file(hbool_t towait) /* read planes between last old nplanes and current extent */ /* Get the dataset's dataspace */ if((f_sid = H5Dget_space(dsid)) < 0){ - fprintf(stderr, "H5Dget_space failed\n"); - return -1; + HDfprintf(stderr, "H5Dget_space failed\n"); + return -1; } start[0]=nplane; /* Choose the next plane to read */ if(H5Sselect_hyperslab(f_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0){ - fprintf(stderr, "H5Sselect_hyperslab failed\n"); - return -1; + HDfprintf(stderr, "H5Sselect_hyperslab failed\n"); + return -1; } /* Read the plane from the dataset */ if(H5Dread(dsid, UC_DATATYPE, m_sid, f_sid, H5P_DEFAULT, buffer) < 0){ - fprintf(stderr, "H5Dread failed\n"); - return -1; + HDfprintf(stderr, "H5Dread failed\n"); + return -1; } /* compare read data with expected data value which is nplane */ bufptr = buffer; nerrs=0; for (j=0; j<dims[1]; j++){ - for (k=0; k<dims[2]; k++){ - if ((hsize_t)*bufptr++ != nplane){ - if (++nerrs < ErrorReportMax){ - fprintf(stderr, - "found error %llu plane(%llu,%llu), expected %llu, got %d\n", - (unsigned long long)nplane, (unsigned long long)j, - (unsigned long long)k, (unsigned long long)nplane, (int)*(bufptr-1)); - } - } - } + for (k=0; k<dims[2]; k++){ + if ((hsize_t)*bufptr++ != nplane){ + if (++nerrs < ErrorReportMax){ + HDfprintf(stderr, + "found error %llu plane(%llu,%llu), expected %llu, got %d\n", + (unsigned long long)nplane, (unsigned long long)j, + (unsigned long long)k, (unsigned long long)nplane, (int)*(bufptr-1)); + } + } + } } if (nerrs){ - nreadererr++; - fprintf(stderr, "found %d unexpected values in plane %llu\n", nerrs, + nreadererr++; + HDfprintf(stderr, "found %d unexpected values in plane %llu\n", nerrs, (unsigned long long)nplane); } } @@ -596,19 +596,19 @@ int read_uc_file(hbool_t towait) #if 0 /* close dsid and file, then reopen them */ if (H5Dclose(dsid) < 0){ - fprintf(stderr, "H5Dclose failed\n"); + HDfprintf(stderr, "H5Dclose failed\n"); return -1; } if (H5Fclose(fid) < 0){ - fprintf(stderr, "H5Fclose failed\n"); + HDfprintf(stderr, "H5Fclose failed\n"); return -1; } if((fid = H5Fopen(name, H5F_ACC_RDONLY | (UC_opts.use_swmr ? H5F_ACC_SWMR_READ : 0), H5P_DEFAULT)) < 0){ - fprintf(stderr, "H5Fopen failed\n"); + HDfprintf(stderr, "H5Fopen failed\n"); return -1; } if((dsid = H5Dopen2(fid, progname_g, H5P_DEFAULT)) < 0){ - fprintf(stderr, "H5Dopen2 failed\n"); + HDfprintf(stderr, "H5Dopen2 failed\n"); return -1; } #else @@ -616,22 +616,22 @@ int read_uc_file(hbool_t towait) #endif f_sid = H5Dget_space(dsid); /* Get filespace handle first. */ if (H5Sget_simple_extent_dims(f_sid, dims, NULL) < 0){ - fprintf(stderr, "H5Sget_simple_extent_dims got error\n"); + HDfprintf(stderr, "H5Sget_simple_extent_dims got error\n"); return -1; } } /* Close the file */ if(H5Fclose(fid) < 0) { - fprintf(stderr, "H5Fclose failed\n"); + HDfprintf(stderr, "H5Fclose failed\n"); return -1; } if (nreadererr) - return -1; + return -1; else - return 0; -} + return 0; +} /* read_uc_file() */ #endif /* H5_HAVE_FORK */ |