From cadc3327f08187d9f4b189271c6cb51ed0e50780 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Mon, 13 Jun 2016 10:25:22 -0600 Subject: [PATCH 1/5] breaking branch to test cdash building of branches --- src/clib/pio_file.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/clib/pio_file.c b/src/clib/pio_file.c index 44bd07888f3..0fdaa9e54dd 100644 --- a/src/clib/pio_file.c +++ b/src/clib/pio_file.c @@ -2,7 +2,7 @@ #include #include -/* Open an existing file using pio +/* Open an existing file using pio. * @public * @ingroup PIO_openfile * @@ -205,7 +205,6 @@ int PIOc_openfile(const int iosysid, int *ncidp, int *iotype, * @param filename : The filename to open * @param mode : The netcdf mode for the open operation */ - int PIOc_createfile(const int iosysid, int *ncidp, int *iotype, const char filename[], const int mode) { @@ -479,6 +478,12 @@ int PIOc_deletefile(const int iosysid, const char filename[]) if (!mpierr) mpierr = MPI_Bcast((void *)filename, len + 1, MPI_CHAR, ios->compmaster, ios->intercomm); } + + /* Handle MPI errors. */ + if ((mpierr2 = MPI_Bcast(&mpierr, 1, MPI_INT, ios->comproot, ios->my_comm))) + return check_mpi(file, mpierr2, __FILE__, __LINE__); + if (mpierr) + return check_mpi(file, mpierr, __FILE__, __LINE__); } /* If this is an IO task, then call the netCDF function. The @@ -519,6 +524,7 @@ int PIOc_sync(int ncid) int mpierr = MPI_SUCCESS, mpierr2; /** Return code from MPI function codes. */ wmulti_buffer *wmb, *twmb; + return PIO_EBADID; /* Get the file info from the ncid. */ if (!(file = pio_get_file_from_id(ncid))) return PIO_EBADID; @@ -533,8 +539,10 @@ int PIOc_sync(int ncid) if(ios->comp_rank == 0) mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm); - - mpierr = MPI_Bcast(&(file->fh),1, MPI_INT, ios->compmaster, ios->intercomm); + + if (!mpierr) + mpierr = MPI_Bcast(&file->fh, 1, MPI_INT, ios->compmaster, + ios->intercomm); } } From 995ebc5a61f5e52a8c3336d6d46379e089ed1e8d Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Mon, 13 Jun 2016 10:53:54 -0600 Subject: [PATCH 2/5] more cleanup --- src/clib/pio_file.c | 50 ++++++++++++++++++++++++++----------- tests/unit/test_intercomm.c | 4 +-- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/src/clib/pio_file.c b/src/clib/pio_file.c index 0fdaa9e54dd..19282111472 100644 --- a/src/clib/pio_file.c +++ b/src/clib/pio_file.c @@ -31,10 +31,7 @@ int PIOc_openfile(const int iosysid, int *ncidp, int *iotype, /* Get the IO system info from the iosysid. */ if (!(ios = pio_get_iosystem_from_id(iosysid))) - { - LOG((0, "PIOc_openfile got bad iosysid %d",iosysid)); return PIO_EBADID; - } /* Allocate space for the file info. */ if (!(file = (file_desc_t *) malloc(sizeof(*file)))) @@ -451,14 +448,17 @@ int PIOc_closefile(int ncid) * @param iosysid : a pio system handle * @param filename : a filename */ -int PIOc_deletefile(const int iosysid, const char filename[]) +int PIOc_deletefile(const int iosysid, const char *filename) { iosystem_desc_t *ios; /** Pointer to io system information. */ file_desc_t *file; /** Pointer to file information. */ int ierr = PIO_NOERR; /** Return code from function calls. */ + int deleted = 0; /** Becomes true when file is deleted. */ int mpierr = MPI_SUCCESS, mpierr2; /** Return code from MPI function codes. */ - int msg = PIO_MSG_DELETE_FILE; - size_t len; + + /* Filename must be provided. */ + if (!filename || strlen(filename) > NC_MAX_NAME) + return PIO_EINVAL; /* Get the IO system info from the id. */ if (!(ios = pio_get_iosystem_from_id(iosysid))) @@ -469,10 +469,12 @@ int PIOc_deletefile(const int iosysid, const char filename[]) { if (!ios->ioproc) { - if(ios->comp_rank==0) + int msg = PIO_MSG_DELETE_FILE; + size_t len = strlen(filename); + + if(ios->compmaster) mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm); - len = strlen(filename); if (!mpierr) mpierr = MPI_Bcast(&len, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) @@ -489,21 +491,27 @@ int PIOc_deletefile(const int iosysid, const char filename[]) /* If this is an IO task, then call the netCDF function. The * barriers are needed to assure that no task is trying to operate * on the file while it is being deleted. */ - if(ios->ioproc){ + if (ios->ioproc) + { MPI_Barrier(ios->io_comm); #ifdef _NETCDF - if(ios->io_rank==0) + if (ios->iomaster) ierr = nc_delete(filename); + deleted++; #else #ifdef _PNETCDF - ierr = ncmpi_delete(filename, ios->info); + if (!deleted) + ierr = ncmpi_delete(filename, ios->info); #endif #endif MPI_Barrier(ios->io_comm); } - // Special case - always broadcast the return from the - MPI_Bcast(&ierr, 1, MPI_INT, ios->ioroot, ios->my_comm); + /* Broadcast and check the return code. */ + if ((mpierr = MPI_Bcast(&ierr, 1, MPI_INT, ios->ioroot, ios->my_comm))) + return check_mpi(file, mpierr, __FILE__, __LINE__); + if (ierr) + return check_netcdf(file, ierr, __FILE__, __LINE__); return ierr; } @@ -524,7 +532,6 @@ int PIOc_sync(int ncid) int mpierr = MPI_SUCCESS, mpierr2; /** Return code from MPI function codes. */ wmulti_buffer *wmb, *twmb; - return PIO_EBADID; /* Get the file info from the ncid. */ if (!(file = pio_get_file_from_id(ncid))) return PIO_EBADID; @@ -537,13 +544,19 @@ int PIOc_sync(int ncid) { int msg = PIO_MSG_SYNC; - if(ios->comp_rank == 0) + if (ios->compmaster) mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) mpierr = MPI_Bcast(&file->fh, 1, MPI_INT, ios->compmaster, ios->intercomm); } + + /* Handle MPI errors. */ + /* if ((mpierr2 = MPI_Bcast(&mpierr, 1, MPI_INT, ios->comproot, ios->my_comm))) */ + /* return check_mpi(file, mpierr2, __FILE__, __LINE__); */ + /* if (mpierr) */ + /* return check_mpi(file, mpierr, __FILE__, __LINE__); */ } if (file->mode & PIO_WRITE) @@ -593,6 +606,13 @@ int PIOc_sync(int ncid) ierr = check_netcdf(file, ierr, __FILE__,__LINE__); } + + /* Broadcast and check the return code. */ + /* if ((mpierr = MPI_Bcast(&ierr, 1, MPI_INT, ios->ioroot, ios->my_comm))) */ + /* return check_mpi(file, mpierr, __FILE__, __LINE__); */ + /* if (ierr) */ + /* return check_netcdf(file, ierr, __FILE__, __LINE__); */ + return ierr; } diff --git a/tests/unit/test_intercomm.c b/tests/unit/test_intercomm.c index 36fb2a72ad2..fa680201f39 100644 --- a/tests/unit/test_intercomm.c +++ b/tests/unit/test_intercomm.c @@ -531,8 +531,8 @@ main(int argc, char **argv) ERR(ret); /* Now delete the file. */ - /* if ((ret = PIOc_deletefile(iosysid, filename[fmt]))) */ - /* ERR(ret); */ + if ((ret = PIOc_deletefile(iosysid, filename[fmt]))) + ERR(ret); /* if ((ret = PIOc_openfile(iosysid, &ncid, &format[fmt], filename[fmt], */ /* NC_NOWRITE)) != PIO_ENFILE) */ /* ERR(ERR_AWFUL); */ From c1df0fb0002000a72377e7bb4d871fd42c4d9075 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Mon, 13 Jun 2016 14:00:35 -0600 Subject: [PATCH 3/5] more cleanup --- src/clib/pio_file.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/clib/pio_file.c b/src/clib/pio_file.c index 19282111472..2cebfa578bf 100644 --- a/src/clib/pio_file.c +++ b/src/clib/pio_file.c @@ -562,18 +562,23 @@ int PIOc_sync(int ncid) if (file->mode & PIO_WRITE) { // cn_buffer_report( *ios, true); - wmb = &(file->buffer); - while(wmb != NULL){ + wmb = &file->buffer; + while(wmb) + { // printf("%s %d %d %d\n",__FILE__,__LINE__,wmb->ioid, wmb->validvars); - if(wmb->validvars>0){ + if (wmb->validvars > 0) + { flush_buffer(ncid, wmb, true); } twmb = wmb; wmb = wmb->next; - if(twmb == &(file->buffer)){ - twmb->ioid=-1; - twmb->next=NULL; - }else{ + if (twmb == &file->buffer) + { + twmb->ioid = -1; + twmb->next = NULL; + } + else + { brel(twmb); } } From 87e32a2dc78015a9dff539c2d7295f650443fe76 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Mon, 13 Jun 2016 14:06:39 -0600 Subject: [PATCH 4/5] more cleanup --- src/clib/pio_file.c | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/src/clib/pio_file.c b/src/clib/pio_file.c index 2cebfa578bf..93599bed6ca 100644 --- a/src/clib/pio_file.c +++ b/src/clib/pio_file.c @@ -584,29 +584,17 @@ int PIOc_sync(int ncid) } flush_output_buffer(file, true, 0); - if(ios->ioproc){ - switch(file->iotype){ -#ifdef _NETCDF -#ifdef _NETCDF4 - case PIO_IOTYPE_NETCDF4P: - ierr = nc_sync(file->fh);; - break; - case PIO_IOTYPE_NETCDF4C: -#endif - case PIO_IOTYPE_NETCDF: - if(ios->io_rank==0){ - ierr = nc_sync(file->fh);; - } - break; -#endif + /* If this is an IO task, then call the netCDF function. */ + if (ios->ioproc) + { #ifdef _PNETCDF - case PIO_IOTYPE_PNETCDF: - ierr = ncmpi_sync(file->fh);; - break; -#endif - default: - ierr = iotype_error(file->iotype,__FILE__,__LINE__); - } + if (file->iotype == PIO_IOTYPE_PNETCDF) + ierr = ncmpi_sync(file->fh); +#endif /* _PNETCDF */ +#ifdef _NETCDF + if (file->iotype != PIO_IOTYPE_PNETCDF && file->do_io) + ierr = nc_sync(file->fh); +#endif /* _NETCDF */ } ierr = check_netcdf(file, ierr, __FILE__,__LINE__); From bf1ed730fc5c3c41aba4ff44a5e54265d79adcf8 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Mon, 13 Jun 2016 14:43:14 -0600 Subject: [PATCH 5/5] more cleanup --- src/clib/pio_file.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/clib/pio_file.c b/src/clib/pio_file.c index 93599bed6ca..e52f9423736 100644 --- a/src/clib/pio_file.c +++ b/src/clib/pio_file.c @@ -550,6 +550,8 @@ int PIOc_sync(int ncid) if (!mpierr) mpierr = MPI_Bcast(&file->fh, 1, MPI_INT, ios->compmaster, ios->intercomm); + if (mpierr) + return check_mpi(file, mpierr, __FILE__, __LINE__); } /* Handle MPI errors. */