Skip to content

Commit

Permalink
got working for current state of play
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardhartnett committed Jul 22, 2020
1 parent 3d4b09e commit e7cdd55
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions tests/cunit/test_simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ int main(int argc, char **argv)
return ERR_AWFUL;
}

PIOc_set_log_level(3);
/* Turn off logging, to prevent error messages from being logged
* when we intentionally call functions we know will fail. */
PIOc_set_log_level(-1);

/* Change error handling so we can test inval parameters. */
if ((ret = PIOc_set_iosystem_error_handling(PIO_DEFAULT, PIO_RETURN_ERROR, NULL)))
Expand Down Expand Up @@ -81,10 +83,7 @@ int main(int argc, char **argv)
if (!(data = malloc(elements_per_pe * sizeof(int))))
ERR(ERR_MEM);
for (i = 0; i < elements_per_pe; i++)
{
data[i] = my_rank + i;
printf("%d: data[%d] = %d\n", my_rank, i, data[i]);
}

/* Storage to read one record back in. */
if (!(data_in = malloc(elements_per_pe * sizeof(int))))
Expand All @@ -110,12 +109,34 @@ int main(int argc, char **argv)
if ((ret = PIOc_def_var(ncid, VAR_NAME, PIO_INT, NDIM2, dimid, &varid)))
ERR(ret);

/* Try to turn on deflate, it will only work for netCDF-4
* serial, and perhaps netCDF-4 parallel. */
ret = PIOc_def_var_deflate(ncid, varid, 0, 1, 1);
if (flavor[f] == PIO_IOTYPE_PNETCDF || flavor[f] == PIO_IOTYPE_NETCDF)
{
/* Pnetcdf and netcdf classic formats do not support
* compression. An error will be returned. */
if (ret != PIO_ENOTNC4)
ERR(ERR_WRONG);
}
else if (flavor[f] == PIO_IOTYPE_NETCDF4P)
{
if (ret != NC_EINVAL)
ERR(ERR_WRONG);
}
else
{
if (ret)
ERR(ret);
}

if ((ret = PIOc_enddef(ncid)))
ERR(ret);

/* Write a record of data. Each compute task writes its local
* array of data. */
if ((ret = PIOc_setframe(ncid, varid, 0)))
ERR(ret);

if ((ret = PIOc_write_darray(ncid, varid, ioid, elements_per_pe, data, NULL)))
ERR(ret);

Expand All @@ -129,7 +150,7 @@ int main(int argc, char **argv)
if ((ret = PIOc_openfile(iosysid, &ncid, &flavor[f], filename, NC_NOWRITE)))
ERR(ret);

/* Read the data. */
/* Read the local array of data for this task and confirm correctness. */
if ((ret = PIOc_setframe(ncid, varid, 0)))
ERR(ret);
if ((ret = PIOc_read_darray(ncid, varid, ioid, elements_per_pe, data_in)))
Expand Down

0 comments on commit e7cdd55

Please sign in to comment.