From e9854d6c1c762d4caa72f55aeb74d2b1bbb53577 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Wed, 9 May 2018 09:35:10 -0600 Subject: [PATCH] fixed problem with _FillValue --- examples/c/darray_no_async.c | 6 ++--- src/clib/pio_darray.c | 2 +- src/clib/pio_nc.c | 48 +++++++++++++++++++++++++++--------- 3 files changed, 41 insertions(+), 15 deletions(-) diff --git a/examples/c/darray_no_async.c b/examples/c/darray_no_async.c index 7bdb134fafa..126adcd5ba0 100644 --- a/examples/c/darray_no_async.c +++ b/examples/c/darray_no_async.c @@ -247,9 +247,9 @@ int main(int argc, char* argv[]) if ((ret = PIOc_set_log_level(LOG_LEVEL))) return ret; - /* Change error handling so we can test inval parameters. */ - if ((ret = PIOc_set_iosystem_error_handling(PIO_DEFAULT, PIO_RETURN_ERROR, NULL))) - return ret; + /* /\* Change error handling so we can test inval parameters. *\/ */ + /* if ((ret = PIOc_set_iosystem_error_handling(PIO_DEFAULT, PIO_RETURN_ERROR, NULL))) */ + /* return ret; */ /* Initialize the PIO IO system. This specifies how many and * which processors are involved in I/O. */ diff --git a/src/clib/pio_darray.c b/src/clib/pio_darray.c index 329bd4b5d18..116f0103770 100644 --- a/src/clib/pio_darray.c +++ b/src/clib/pio_darray.c @@ -411,7 +411,7 @@ pio_inq_var_fill_expected(int ncid, int varid, int pio_type, PIO_Offset type_siz ncid, varid, pio_type, type_size)); /* Is there a _FillValue attribute? */ - ret = PIOc_inq_att(ncid, varid, "_FillValue", NULL, NULL); + ret = PIOc_inq_att_eh(ncid, varid, "_FillValue", 0, NULL, NULL); LOG((3, "pio_inq_var_fill_expected ret %d", ret)); diff --git a/src/clib/pio_nc.c b/src/clib/pio_nc.c index f15da7856b4..147ee872b2f 100644 --- a/src/clib/pio_nc.c +++ b/src/clib/pio_nc.c @@ -1091,8 +1091,8 @@ int PIOc_inq_varid(int ncid, const char *name, int *varidp) * @return PIO_NOERR for success, error code otherwise. * @author Jim Edwards, Ed Hartnett */ -int PIOc_inq_att(int ncid, int varid, const char *name, nc_type *xtypep, - PIO_Offset *lenp) +int PIOc_inq_att_eh(int ncid, int varid, const char *name, int eh, + nc_type *xtypep, PIO_Offset *lenp) { int msg = PIO_MSG_INQ_ATT; iosystem_desc_t *ios; @@ -1160,18 +1160,44 @@ int PIOc_inq_att(int ncid, int varid, const char *name, nc_type *xtypep, /* 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) + if (eh && ierr) return check_netcdf(file, ierr, __FILE__, __LINE__); - /* Broadcast results. */ - if (xtypep) - if ((mpierr = MPI_Bcast(xtypep, 1, MPI_INT, ios->ioroot, ios->my_comm))) - check_mpi(file, mpierr, __FILE__, __LINE__); - if (lenp) - if ((mpierr = MPI_Bcast(lenp, 1, MPI_OFFSET, ios->ioroot, ios->my_comm))) - check_mpi(file, mpierr, __FILE__, __LINE__); + /* Broadcast results if call succeeded. */ + if (!ierr) + { + if (xtypep) + if ((mpierr = MPI_Bcast(xtypep, 1, MPI_INT, ios->ioroot, ios->my_comm))) + check_mpi(file, mpierr, __FILE__, __LINE__); + if (lenp) + if ((mpierr = MPI_Bcast(lenp, 1, MPI_OFFSET, ios->ioroot, ios->my_comm))) + check_mpi(file, mpierr, __FILE__, __LINE__); + } - return PIO_NOERR; + return ierr; +} + +/** + * @ingroup PIO_inq_att + * The PIO-C interface for the NetCDF function nc_inq_att. + * + * This routine is called collectively by all tasks in the communicator + * ios.union_comm. For more information on the underlying NetCDF commmand + * please read about this function in the NetCDF documentation at: + * http://www.unidata.ucar.edu/software/netcdf/docs/group__attributes.html + * + * @param ncid the ncid of the open file, obtained from + * PIOc_openfile() or PIOc_createfile(). + * @param varid the variable ID. + * @param xtypep a pointer that will get the type of the attribute. + * @param lenp a pointer that will get the number of values + * @return PIO_NOERR for success, error code otherwise. + * @author Jim Edwards, Ed Hartnett + */ +int PIOc_inq_att(int ncid, int varid, const char *name, nc_type *xtypep, + PIO_Offset *lenp) +{ + return PIOc_inq_att_eh(ncid, varid, name, 1, xtypep, lenp); } /**