diff --git a/src/clib/pio.h b/src/clib/pio.h index 1120aea5db0..228cadf1098 100644 --- a/src/clib/pio.h +++ b/src/clib/pio.h @@ -311,7 +311,8 @@ typedef struct io_desc_t * everywhere (false) */ bool needsfill; - /** If the map is not monotonically increasing we will need to sort it. */ + /** If the map is not monotonically increasing we will need to + * sort it. */ bool needssort; /** The maximum number of bytes of this iodesc before flushing. */ diff --git a/src/clib/pio_darray.c b/src/clib/pio_darray.c index a94b98f123a..b4a10c4836f 100644 --- a/src/clib/pio_darray.c +++ b/src/clib/pio_darray.c @@ -903,6 +903,9 @@ PIOc_read_darray(int ncid, int varid, int ioid, PIO_Offset arraylen, pio_start_mpe_log(DARRAY_READ); #endif /* USE_MPE */ + PLOG((1, "PIOc_read_darray ncid %d varid %d ioid %d arraylen %ld ", + ncid, varid, ioid, arraylen)); + /* Get the file info. */ if ((ierr = pio_get_file(ncid, &file))) return pio_err(NULL, NULL, PIO_EBADID, __FILE__, __LINE__); @@ -942,12 +945,15 @@ PIOc_read_darray(int ncid, int varid, int ioid, PIO_Offset arraylen, return pio_err(NULL, NULL, PIO_EBADIOTYPE, __FILE__, __LINE__); } + /* If the map is not monotonically increasing we will need to sort + * it. */ + PLOG((3, "iodesc->needssort %d", iodesc->needssort)); if (iodesc->needssort) { - if (!(tmparray = malloc(iodesc->piotype_size*iodesc->maplen))) + if (!(tmparray = malloc(iodesc->piotype_size * iodesc->maplen))) return pio_err(ios, NULL, PIO_ENOMEM, __FILE__, __LINE__); - for(int m=0; mmaplen;m++) - ((int *) array)[m] = -1; + for (int m = 0; m < iodesc->maplen; m++) + ((int *)array)[m] = -1; } else tmparray = array; @@ -956,6 +962,7 @@ PIOc_read_darray(int ncid, int varid, int ioid, PIO_Offset arraylen, if ((ierr = rearrange_io2comp(ios, iodesc, iobuf, tmparray))) return pio_err(ios, file, ierr, __FILE__, __LINE__); + /* If we need to sort the map, do it. */ if (iodesc->needssort) { pio_sorted_copy(tmparray, array, iodesc, 1, 1); @@ -970,5 +977,7 @@ PIOc_read_darray(int ncid, int varid, int ioid, PIO_Offset arraylen, pio_stop_mpe_log(DARRAY_READ, __func__); #endif /* USE_MPE */ + PLOG((2, "done with PIOc_read_darray()")); + return PIO_NOERR; } diff --git a/src/clib/pio_darray_int.c b/src/clib/pio_darray_int.c index 20ed259fa41..e39816bd216 100644 --- a/src/clib/pio_darray_int.c +++ b/src/clib/pio_darray_int.c @@ -1714,6 +1714,7 @@ pio_read_darray_nc_serial(file_desc_t *file, io_desc_t *iodesc, int vid, return pio_err(ios, NULL, ierr, __FILE__, __LINE__); #endif /* TIMING */ + PLOG((2, "pio_read_darray_nc_serial complete ierr %d", ierr)); return PIO_NOERR; } diff --git a/src/clib/pio_rearrange.c b/src/clib/pio_rearrange.c index ce8b8f18e34..ba87aedc15c 100644 --- a/src/clib/pio_rearrange.c +++ b/src/clib/pio_rearrange.c @@ -450,8 +450,9 @@ define_iodesc_datatypes(iosystem_desc_t *ios, io_desc_t *iodesc) int ret; /* Return value. */ pioassert(ios && iodesc, "invalid input", __FILE__, __LINE__); - PLOG((1, "define_iodesc_datatypes ios->ioproc = %d iodesc->rtype is %sNULL, iodesc->nrecvs", - ios->ioproc, iodesc->rtype ? "not " : "", iodesc->nrecvs)); + PLOG((1, "define_iodesc_datatypes ios->ioproc = %d iodesc->rtype is %sNULL, " + "iodesc->nrecvs %d", ios->ioproc, iodesc->rtype ? "not " : "", + iodesc->nrecvs)); /* Set up the to transfer data to and from the IO tasks. */ if (ios->ioproc) @@ -1014,6 +1015,7 @@ rearrange_io2comp(iosystem_desc_t *ios, io_desc_t *iodesc, void *sbuf, /* Check inputs. */ pioassert(ios && iodesc, "invalid input", __FILE__, __LINE__); + PLOG((2, "rearrange_io2comp iodesc->rearranger %d", iodesc->rearranger)); #ifdef TIMING /* Start timer if desired. */ @@ -1033,11 +1035,11 @@ rearrange_io2comp(iosystem_desc_t *ios, io_desc_t *iodesc, void *sbuf, mycomm = iodesc->subset_comm; niotasks = 1; } - PLOG((3, "niotasks = %d", niotasks)); /* Get the size of this communicator. */ if ((mpierr = MPI_Comm_size(mycomm, &ntasks))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); + PLOG((3, "niotasks %d ntasks %d", niotasks, ntasks)); /* Define the MPI data types that will be used for this * io_desc_t. */ @@ -1106,7 +1108,8 @@ rearrange_io2comp(iosystem_desc_t *ios, io_desc_t *iodesc, void *sbuf, } } - /* Data in sbuf on the ionodes is sent to rbuf on the compute nodes */ + /* Data in sbuf on the ionodes is sent to rbuf on the compute + * nodes. */ if ((ret = pio_swapm(sbuf, sendcounts, sdispls, sendtypes, rbuf, recvcounts, rdispls, recvtypes, mycomm, &iodesc->rearr_opts.io2comp))) return pio_err(ios, NULL, ret, __FILE__, __LINE__); diff --git a/tests/ncint/tst_pio_async.c b/tests/ncint/tst_pio_async.c index 9feaf2c285d..dae1a961609 100644 --- a/tests/ncint/tst_pio_async.c +++ b/tests/ncint/tst_pio_async.c @@ -53,7 +53,7 @@ main(int argc, char **argv) int i; /* Turn on logging for PIO library. */ - PIOc_set_log_level(3); + PIOc_set_log_level(4); if (!my_rank) nc_set_log_level(3); @@ -93,6 +93,53 @@ main(int argc, char **argv) if (nc_put_vard_int(ncid, varid, ioid, 0, my_data)) PERR; if (nc_close(ncid)) PERR; + /* Reopen the file using normal PIO calls. */ + { + int ndims, nvars, ngatts, unlimdimid; + nc_type xtype_in; + char var_name_in[NC_MAX_NAME + 1]; + char dim_name_in[NC_MAX_NAME + 1]; + int natts_in; + int dimids_in[NDIM3]; + int iotype = PIO_IOTYPE_NETCDF4C; + size_t dim_len_in; + + /* Open the file. */ + if (PIOc_openfile(iosysid, &ncid, &iotype, FILE_NAME, 0)) PERR; + if (PIOc_closefile(ncid)) PERR; + + /* Check the file. */ + /* if (nc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid)) PERR; */ + /* if (ndims != 3 || nvars != 1 || ngatts != 0 || */ + /* unlimdimid != 0) PERR; */ + /* if (nc_inq_var(ncid, 0, var_name_in, &xtype_in, &ndims, */ + /* dimids_in, &natts_in)) PERR; */ + /* if (strcmp(var_name_in, VAR_NAME) || xtype_in != NC_INT || ndims != NDIM3 */ + /* || dimids_in[0] != 0 || dimids_in[1] != 1 || dimids_in[2] != 2 || */ + /* natts_in != 0) PERR; */ + /* if (nc_inq_dim(ncid, 0, dim_name_in, &dim_len_in)) PERR; */ + /* if (strcmp(dim_name_in, DIM_NAME_UNLIMITED) || dim_len_in != 1) PERR; */ + /* if (nc_inq_dim(ncid, 1, dim_name_in, &dim_len_in)) PERR; */ + /* if (strcmp(dim_name_in, DIM_NAME_X) || dim_len_in != DIM_LEN_X) PERR; */ + /* if (nc_inq_dim(ncid, 2, dim_name_in, &dim_len_in)) PERR; */ + /* if (strcmp(dim_name_in, DIM_NAME_Y) || dim_len_in != DIM_LEN_Y) PERR; */ + + /* /\* Read distributed arrays. *\/ */ + /* if (!(data_in = malloc(elements_per_pe * sizeof(int)))) PERR; */ + /* if (nc_get_vard_int(ncid, varid, ioid, 0, data_in)) PERR; */ + + /* Check results. */ + /* for (i = 0; i < elements_per_pe; i++) */ + /* if (data_in[i] != my_data[i]) PERR; */ + + /* Close file. */ + /* if (nc_close(ncid)) PERR; */ + + /* /\* Free resources. *\/ */ + /* free(data_in); */ + } + + /* Reopen the file using netCDF integration. */ { int ndims, nvars, ngatts, unlimdimid; nc_type xtype_in; @@ -123,7 +170,7 @@ main(int argc, char **argv) /* Read distributed arrays. */ if (!(data_in = malloc(elements_per_pe * sizeof(int)))) PERR; - if (nc_get_vard_int(ncid, varid, ioid, 0, data_in)) PERR; + /* if (nc_get_vard_int(ncid, varid, ioid, 0, data_in)) PERR; */ /* Check results. */ /* for (i = 0; i < elements_per_pe; i++) */ @@ -131,10 +178,11 @@ main(int argc, char **argv) /* Close file. */ if (nc_close(ncid)) PERR; + + /* Free resources. */ + free(data_in); } - /* Free resources. */ - free(data_in); free(my_data); if (nc_free_decomp(ioid)) PERR; if (nc_free_iosystem(iosysid)) PERR;