diff --git a/tests/cunit/test_darray.c b/tests/cunit/test_darray.c index ec47a6b8717..5ed1f578763 100644 --- a/tests/cunit/test_darray.c +++ b/tests/cunit/test_darray.c @@ -83,7 +83,7 @@ int test_darray(int iosysid, int ioid, int num_flavors, int *flavor, int my_rank int type_size; /* size of a variable of type pio_type */ int other_type; /* another variable of the same size but different type */ PIO_Offset arraylen = 4; - void *fillvalue; + void *fillvalue, *ofillvalue; void *test_data; void *test_data_in; int fillvalue_int = NC_FILL_INT; @@ -119,7 +119,6 @@ int test_darray(int iosysid, int ioid, int num_flavors, int *flavor, int my_rank /* Create the filename. */ sprintf(filename, "data_%s_iotype_%d_pio_type_%d_test_multi_%d_provide_fill_%d.nc", TEST_NAME, flavor[fmt], pio_type, test_multi, provide_fill); - if(my_rank==0) printf("Test file %s\n", filename); /* Select the fill value and data. */ switch (pio_type) { @@ -146,7 +145,6 @@ int test_darray(int iosysid, int ioid, int num_flavors, int *flavor, int my_rank if ((ret = PIOc_createfile(iosysid, &ncid, &flavor[fmt], filename, PIO_CLOBBER))) ERR(ret); - if(my_rank==0) printf("Test file %s created\n", filename); /* Define netCDF dimensions and variable. */ for (int d = 0; d < NDIM; d++) if ((ret = PIOc_def_dim(ncid, dim_name[d], (PIO_Offset)dim_len[d], &dimids[d]))) @@ -165,14 +163,23 @@ int test_darray(int iosysid, int ioid, int num_flavors, int *flavor, int my_rank // other_type = pio_type == PIO_INT64 ? PIO_DOUBLE : PIO_INT64; else other_type = 0; /* skip the test */ - printf("pio_type %d other_type %d\n",pio_type, other_type); + switch (other_type) + { + case PIO_INT: + ofillvalue = provide_fill ? &fillvalue_int : NULL; + break; + case PIO_FLOAT: + ofillvalue = provide_fill ? &fillvalue_float : NULL; + break; + default: + break; + } if (other_type && (ret = PIOc_def_var(ncid, VAR_NAME2, other_type, NDIM, dimids, &varid2))) ERR(ret); /* End define mode. */ if ((ret = PIOc_enddef(ncid))) ERR(ret); - if(my_rank==0) printf("Test file %s defined\n", filename); /* Set the value of the record dimension. */ if ((ret = PIOc_setframe(ncid, varid, 0))) @@ -184,7 +191,6 @@ int test_darray(int iosysid, int ioid, int num_flavors, int *flavor, int my_rank int flushtodisk = test_multi - 1; if (!test_multi) { - if(my_rank==0) printf("expected fails\n"); /* These should not work. */ if (PIOc_write_darray(ncid + TEST_VAL_42, varid, ioid, arraylen, test_data, fillvalue) != PIO_EBADID) ERR(ERR_WRONG); @@ -195,17 +201,15 @@ int test_darray(int iosysid, int ioid, int num_flavors, int *flavor, int my_rank if (PIOc_write_darray(ncid, TEST_VAL_42, ioid, arraylen, test_data, fillvalue) != PIO_ENOTVAR) ERR(ERR_WRONG); - if(my_rank==0) printf("expected pass\n"); - /* This should work - library type conversion */ - if (other_type && (ret = PIOc_write_darray(ncid, varid2, ioid, arraylen, test_data, fillvalue))) + if (other_type && (ret = PIOc_write_darray(ncid, varid2, ioid, arraylen, test_data, ofillvalue))){ + printf("other_type %d ret %d fillvalue %x\n",other_type, ret, fillvalue); ERR(ret); - + } /* Write the data. */ if ((ret = PIOc_write_darray(ncid, varid, ioid, arraylen, test_data, fillvalue))) ERR(ret); - if(my_rank==0) printf("data write complete\n"); } else { @@ -246,7 +250,6 @@ int test_darray(int iosysid, int ioid, int num_flavors, int *flavor, int my_rank if ((ret = PIOc_closefile(ncid))) ERR(ret); - printf("file closed\n"); /* Reopen the file. */ if ((ret = PIOc_openfile(iosysid, &ncid2, &flavor[fmt], filename, PIO_NOWRITE))) @@ -259,7 +262,6 @@ int test_darray(int iosysid, int ioid, int num_flavors, int *flavor, int my_rank if (dimlen != 1) ERR(ERR_WRONG); - printf("file reopened\n"); /* These should not work. */ if (PIOc_read_darray(ncid2 + TEST_VAL_42, varid, ioid, arraylen, test_data_in) != PIO_EBADID) @@ -272,11 +274,9 @@ int test_darray(int iosysid, int ioid, int num_flavors, int *flavor, int my_rank if ((ret = PIOc_setframe(ncid2, varid, 0))) ERR(ret); - printf("read darray\n"); /* Read the data. */ if ((ret = PIOc_read_darray(ncid2, varid, ioid, arraylen, test_data_in))) ERR(ret); - if(my_rank==0) printf("read darray complete\n"); /* Check the results. */ for (int f = 0; f < arraylen; f++) @@ -299,8 +299,6 @@ int test_darray(int iosysid, int ioid, int num_flavors, int *flavor, int my_rank ERR(ERR_WRONG); } } - if(my_rank==0) printf("data read\n"); - /* Try to write, but it won't work, because we opened file read-only. */ if (!test_multi) @@ -317,7 +315,6 @@ int test_darray(int iosysid, int ioid, int num_flavors, int *flavor, int my_rank /* Close the netCDF file. */ if ((ret = PIOc_closefile(ncid2))) ERR(ret); - if(my_rank==0) printf("file closed\n"); } /* next fillvalue test case */ } /* next test multi */ } /* next iotype */