From 37b09752793b6a83280c1edcd567f884e40ce9dd Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Wed, 14 Feb 2018 06:41:34 -0700 Subject: [PATCH] getting closer --- src/clib/pio_darray_int.c | 30 ++++++++++++++++++++---------- tests/cunit/test_darray.c | 2 +- tests/cunit/test_darray_frame.c | 6 +----- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/clib/pio_darray_int.c b/src/clib/pio_darray_int.c index 578074f1e61..eea5d7cf94d 100644 --- a/src/clib/pio_darray_int.c +++ b/src/clib/pio_darray_int.c @@ -336,6 +336,8 @@ int write_darray_multi_par(file_desc_t *file, int nvars, int fndims, const int * int mpierr; MPI_Aint displacements[rrcnt]; + for ( int rc=0; rc ndims && gdim0 > 0) + if(fndims > ndims) { - gdims[0] = gdim0; - sa_ndims = fndims; - dim_offset = 0; + if ( gdim0 > 0) + { + gdims[0] = gdim0; + sa_ndims = fndims; + dim_offset = 0; + } + else + { + sa_ndims = ndims; + dim_offset = 1; + } } else { - sa_ndims = ndims; - dim_offset = 1; + sa_ndims = fndims; + dim_offset = 0; } for (int i=dim_offset; idimlen[i-dim_offset]; @@ -365,10 +375,10 @@ int write_darray_multi_par(file_desc_t *file, int nvars, int fndims, const int * } for( int rc=0; rc 0) + if(gdim0 > 0 && frame != NULL) sastart[0] = frame[nv]; - for (int i=0; i< fndims-dim_offset; i++) + for (int i=0; i< sa_ndims; i++) LOG((3, "vard: sastart[%d]=%d sacount[%d]=%d", i,sastart[i], i,sacount[i])); if((mpierr = MPI_Type_create_subarray(sa_ndims, gdims, sacount, sastart,MPI_ORDER_C @@ -378,8 +388,8 @@ int write_darray_multi_par(file_desc_t *file, int nvars, int fndims, const int * if((mpierr = MPI_Type_commit(subarray + rc))) return check_mpi(NULL, mpierr, __FILE__, __LINE__); - - displacements[rc] = unlimdimoffset; + if (frame != NULL) + displacements[rc] = unlimdimoffset*frame[nv]; LOG((3,"vard: blocklengths[%d]=%d displacement[%d]=%ld",rc,blocklengths[rc], rc, displacements[rc])); diff --git a/tests/cunit/test_darray.c b/tests/cunit/test_darray.c index 0b6c9a033f9..aaca7d88d61 100644 --- a/tests/cunit/test_darray.c +++ b/tests/cunit/test_darray.c @@ -341,7 +341,7 @@ int main(int argc, char **argv) /* Initialize test. */ if ((ret = pio_test_init2(argc, argv, &my_rank, &ntasks, MIN_NTASKS, - MIN_NTASKS, 3, &test_comm))) + MIN_NTASKS, -1, &test_comm))) ERR(ERR_INIT); if ((ret = PIOc_set_iosystem_error_handling(PIO_DEFAULT, PIO_RETURN_ERROR, NULL))) diff --git a/tests/cunit/test_darray_frame.c b/tests/cunit/test_darray_frame.c index b479231c087..38c7e99e8a4 100644 --- a/tests/cunit/test_darray_frame.c +++ b/tests/cunit/test_darray_frame.c @@ -32,7 +32,7 @@ /* #define LON_LEN 192 */ /* Here's a shorter version for a simpler test. */ -#define TIME_LEN_SHORT 1 +#define TIME_LEN_SHORT 3 #define LAT_LEN_SHORT 2 #define LON_LEN_SHORT 2 @@ -112,7 +112,6 @@ int test_frame_simple(int iosysid, int num_iotypes, int *iotype, int my_rank, ERR(ret); /* Define a variable. */ - printf("rank: %d Define a variable\n", my_rank); if ((ret = PIOc_def_var(ncid, VAR_NAME, PIO_INT, NDIM3, dimids, &varid))) ERR(ret); @@ -138,7 +137,6 @@ int test_frame_simple(int iosysid, int num_iotypes, int *iotype, int my_rank, ERR(ret); } - printf("rank: %d close file\n", my_rank); /* Close the netCDF file. */ if ((ret = PIOc_closefile(ncid))) ERR(ret); @@ -146,7 +144,6 @@ int test_frame_simple(int iosysid, int num_iotypes, int *iotype, int my_rank, { int test_data_int_in[elements_per_pe]; - printf("rank: %d reopen sample file %s\n", my_rank, filename); /* Reopen the file. */ if ((ret = PIOc_openfile(iosysid, &ncid2, &iotype[fmt], filename, PIO_NOWRITE))) ERR(ret); @@ -158,7 +155,6 @@ int test_frame_simple(int iosysid, int num_iotypes, int *iotype, int my_rank, if ((ret = PIOc_setframe(ncid2, varid, r))) ERR(ret); - printf("rank: %d read darray record %d\n", my_rank, r); /* Read the data. */ if ((ret = PIOc_read_darray(ncid2, varid, ioid, elements_per_pe, test_data_int_in))) ERR(ret);