Skip to content

Commit

Permalink
fix issue with check_netcdf
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards4b committed Feb 15, 2018
1 parent f8c9adc commit 944315f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
14 changes: 7 additions & 7 deletions examples/c/darray_no_async.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#define NDIM3 3

/* The number of timesteps of data. */
#define NUM_TIMESTEPS 2
#define NUM_TIMESTEPS 1

/* The length of our sample data in X dimension.*/
#define DIM_LEN_X 4
Expand Down Expand Up @@ -125,8 +125,8 @@ int check_file(int iosysid, int ntasks, char *filename, int iotype,
for (int d = 0; d < NDIM3; d++)
{
char my_dim_name[NC_MAX_NAME];
PIO_Offset dimlen;
PIO_Offset dimlen;

if ((ret = PIOc_inq_dim(ncid, d, my_dim_name, &dimlen)))
return ret;
if (dimlen != (d ? dim_len[d] : NUM_TIMESTEPS) || strcmp(my_dim_name, dim_name[d]))
Expand All @@ -148,7 +148,7 @@ int check_file(int iosysid, int ntasks, char *filename, int iotype,
for (int t = 0; t < NUM_TIMESTEPS; t++)
{
int varid = 0; /* There's only one var in sample file. */

/* This is the data we expect for this timestep. */
for (int i = 0; i < elements_per_pe; i++)
buffer[i] = 100 * t + START_DATA_VAL + my_rank;
Expand Down Expand Up @@ -208,7 +208,7 @@ netcdf darray_no_async_iotype_1 {
int ioproc_stride = 1; /* Stride in the mpi rank between io tasks. */
int ioproc_start = 0; /* Rank of first task to be used for I/O. */
PIO_Offset elements_per_pe; /* Array elements per processing unit. */
int iosysid; /* The ID for the parallel I/O system. */
int iosysid; /* The ID for the parallel I/O system. */
int ncid; /* The ncid of the netCDF file. */
int dimid[NDIM3]; /* The dimension ID. */
int varid; /* The ID of the netCDF varable. */
Expand Down Expand Up @@ -245,7 +245,7 @@ netcdf darray_no_async_iotype_1 {
/* Turn on logging. */
if ((ret = PIOc_set_log_level(LOG_LEVEL)))
return ret;

/* Initialize the PIO IO system. This specifies how many and
* which processors are involved in I/O. */
if ((ret = PIOc_Init_Intracomm(MPI_COMM_WORLD, 1, ioproc_stride,
Expand Down Expand Up @@ -310,7 +310,7 @@ netcdf darray_no_async_iotype_1 {
/* Create some data for this timestep. */
for (int i = 0; i < elements_per_pe; i++)
buffer[i] = 100 * t + START_DATA_VAL + my_rank;

/* Write data to the file. */
printf("rank: %d Writing sample data...\n", my_rank);
if ((ret = PIOc_setframe(ncid, varid, t)))
Expand Down
30 changes: 18 additions & 12 deletions src/clib/pio_darray_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,9 @@ int write_darray_multi_par(file_desc_t *file, int nvars, int fndims, const int *
var_desc_t *vdesc; /* Pointer to var info struct. */
int dsize; /* Data size (for one region). */
int ierr = PIO_NOERR;
PIO_Offset gdim0;

#if USE_VARD
PIO_Offset gdim0; /* global size of first dimension if no unlimited dimension and ndims<fndims */
#endif
/* Check inputs. */
pioassert(file && file->iosystem && varids && varids[0] >= 0 && varids[0] <= PIO_MAX_VARS &&
iodesc, "invalid input", __FILE__, __LINE__);
Expand Down Expand Up @@ -227,12 +228,11 @@ int write_darray_multi_par(file_desc_t *file, int nvars, int fndims, const int *
int ndims = iodesc->ndims;
#if USE_VARD
PIO_Offset unlimdimoffset;
int blocklengths[num_regions];
int mpierr;
MPI_Datatype filetype;
MPI_Datatype subarray[num_regions];
int sacount[fndims];
int sastart[fndims];
MPI_Datatype filetype;
MPI_Datatype subarray[num_regions];
filetype = MPI_DATATYPE_NULL;
#else
PIO_Offset *startlist[num_regions]; /* Array of start arrays for ncmpi_iput_varn(). */
Expand Down Expand Up @@ -287,15 +287,13 @@ int write_darray_multi_par(file_desc_t *file, int nvars, int fndims, const int *
if (dsize > 0)
{
#if USE_VARD
if (gdim0 == 0)
if (gdim0 == 0) /* if there is an unlimited dimension get the offset between records of a variable */
{
if((ierr = ncmpi_inq_recsize(file->fh, &unlimdimoffset)))
return pio_err(NULL, file, ierr, __FILE__, __LINE__);
}
else
sacount[0] = 1;
blocklengths[rrcnt] = 1;
subarray[rrcnt] = MPI_DATATYPE_NULL;
#else
/* Allocate storage for start/count arrays for
* this region. */
Expand Down Expand Up @@ -326,18 +324,23 @@ int write_darray_multi_par(file_desc_t *file, int nvars, int fndims, const int *
if ((ierr = get_var_desc(varids[nv], &file->varlist, &vdesc)))
return pio_err(NULL, file, ierr, __FILE__, __LINE__);

/* If this is a record var, set the start for
* the record dimension. */
#if USE_VARD
/* If this is the first variable or the frame has changed between variables (this should be rare) */
if(nv==0 || (nv > 0 && frame != NULL && frame[nv] != frame[nv-1])){
int sa_ndims;
int gdims[fndims];
int dim_offset;

int mpierr;
MPI_Aint displacements[rrcnt];
int blocklengths[rrcnt];


for ( int rc=0; rc<rrcnt; rc++)
{
displacements[rc] = 0;
blocklengths[rc] = 1;
subarray[rc] = MPI_DATATYPE_NULL;
}
if(filetype != MPI_DATATYPE_NULL)
{
for( int rc=0; rc<rrcnt; rc++)
Expand Down Expand Up @@ -383,7 +386,9 @@ int write_darray_multi_par(file_desc_t *file, int nvars, int fndims, const int *
sastart[0] = frame[nv];

for (int i=0; i< sa_ndims; i++)
LOG((3, "vard: sastart[%d]=%d sacount[%d]=%d gdims[%d]=%d %ld %ld", i,sastart[i], i,sacount[i], i, gdims[i], start[i], count[i]));
LOG((3, "vard: sastart[%d]=%d sacount[%d]=%d gdims[%d]=%d %ld %ld",
i,sastart[i], i,sacount[i], i, gdims[i], start[i], count[i]));

if((mpierr = MPI_Type_create_subarray(sa_ndims, gdims,
sacount, sastart,MPI_ORDER_C
,iodesc->mpitype, subarray + rc)))
Expand All @@ -394,6 +399,7 @@ int write_darray_multi_par(file_desc_t *file, int nvars, int fndims, const int *

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 src/clib/pioc_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ int check_netcdf2(iosystem_desc_t *ios, file_desc_t *file, int status,
LOG((2, "check_netcdf2 chose error handler = %d", eh));

/* Decide what to do based on the error handler. */
if (eh == PIO_INTERNAL_ERROR)
if (eh == PIO_INTERNAL_ERROR && status != PIO_NOERR)
{
char errmsg[PIO_MAX_NAME + 1]; /* Error message. */
PIOc_strerror(status, errmsg);
Expand Down

0 comments on commit 944315f

Please sign in to comment.