Skip to content

Commit

Permalink
getting closer
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards4b committed Feb 15, 2018
1 parent 73f0dcf commit 37b0975
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
30 changes: 20 additions & 10 deletions src/clib/pio_darray_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -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<rrcnt; rc++)
displacements[rc] = 0;
if(filetype != MPI_DATATYPE_NULL)
{
for( int rc=0; rc<rrcnt; rc++)
Expand All @@ -344,16 +346,24 @@ int write_darray_multi_par(file_desc_t *file, int nvars, int fndims, const int *
if ((mpierr = MPI_Type_free(&filetype)))
return check_mpi(NULL, mpierr, __FILE__, __LINE__);
}
if(fndims > 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; i<fndims; i++)
gdims[i] = iodesc->dimlen[i-dim_offset];
Expand All @@ -365,10 +375,10 @@ int write_darray_multi_par(file_desc_t *file, int nvars, int fndims, const int *
}
for( int rc=0; rc<rrcnt; rc++)
{
if(gdim0 > 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
Expand All @@ -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]));


Expand Down
2 changes: 1 addition & 1 deletion tests/cunit/test_darray.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
6 changes: 1 addition & 5 deletions tests/cunit/test_darray_frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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);

Expand All @@ -138,15 +137,13 @@ 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);

{
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);
Expand All @@ -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);
Expand Down

0 comments on commit 37b0975

Please sign in to comment.