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/examples/c/examplePio.c b/examples/c/examplePio.c index a21fa27a0b7..61234f47c22 100644 --- a/examples/c/examplePio.c +++ b/examples/c/examplePio.c @@ -584,7 +584,6 @@ int main(int argc, char* argv[]) #ifdef TIMING /* Initialize the GPTL timing library. */ - int ret; if ((ret = GPTLinitialize ())) return ret; #endif diff --git a/src/clib/pio_darray.c b/src/clib/pio_darray.c index 7ff5a9ca33d..116f0103770 100644 --- a/src/clib/pio_darray.c +++ b/src/clib/pio_darray.c @@ -411,11 +411,17 @@ 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_get_att(ncid, varid, "_FillValue", fillvalue); + ret = PIOc_inq_att_eh(ncid, varid, "_FillValue", 0, NULL, NULL); + LOG((3, "pio_inq_var_fill_expected ret %d", ret)); - /* If no _FillValue at was found we still have work to do. */ - if (ret) + /* If there is a fill value, get it. */ + if (!ret) + { + if ((ret = PIOc_get_att(ncid, varid, "_FillValue", fillvalue))) + return ret; + } + else /* If no _FillValue at was found we still have work to do. */ { /* Did we get some other error? */ if (ret != PIO_ENOTATT) diff --git a/src/clib/pio_nc.c b/src/clib/pio_nc.c index f15da7856b4..17ca0bf3d8a 100644 --- a/src/clib/pio_nc.c +++ b/src/clib/pio_nc.c @@ -1085,14 +1085,17 @@ int PIOc_inq_varid(int ncid, const char *name, int *varidp) * * @param ncid the ncid of the open file, obtained from * PIOc_openfile() or PIOc_createfile(). - * @param varid the variable ID. + * @param varid the variable ID or NC_GLOBAL. + * @param name name of the attribute. + * @param eh non-zero to handle errors in the function. This will + * cause program to halt if PIO error handler is set to INTERNAL. * @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) +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 +1163,46 @@ 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 varid the variable ID or NC_GLOBAL. + * @param name name of the attribute. + * @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); } /**