Skip to content

Commit

Permalink
fixed problem with _FillValue
Browse files Browse the repository at this point in the history
  • Loading branch information
edhartnett committed May 9, 2018
1 parent 6d2fda3 commit e9854d6
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 15 deletions.
6 changes: 3 additions & 3 deletions examples/c/darray_no_async.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
2 changes: 1 addition & 1 deletion src/clib/pio_darray.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
48 changes: 37 additions & 11 deletions src/clib/pio_nc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit e9854d6

Please sign in to comment.