diff --git a/src/clib/pio_nc.c b/src/clib/pio_nc.c index 17ca0bf3d8a..bca31c07597 100644 --- a/src/clib/pio_nc.c +++ b/src/clib/pio_nc.c @@ -2045,10 +2045,13 @@ int PIOc_def_var(int ncid, const char *name, nc_type xtype, int ndims, /* Get the MPI type corresponding with the PIO type. */ if ((ierr = find_mpi_type(xtype, &mpi_type, NULL))) return pio_err(ios, NULL, ierr, __FILE__, __LINE__); - + /* Get the size of the MPI type. */ - if ((mpierr = MPI_Type_size(mpi_type, &mpi_type_size))) - return check_mpi2(ios, NULL, mpierr, __FILE__, __LINE__); + if(mpi_type == MPI_DATATYPE_NULL) + mpi_type_size = 0; + else + if ((mpierr = MPI_Type_size(mpi_type, &mpi_type_size))) + return check_mpi2(ios, NULL, mpierr, __FILE__, __LINE__); /* How many unlimited dims are present in the file? */ if ((ierr = PIOc_inq_unlimdims(ncid, &nunlimdims, NULL))) diff --git a/src/clib/pio_rearrange.c b/src/clib/pio_rearrange.c index 99640236869..688b30c85eb 100644 --- a/src/clib/pio_rearrange.c +++ b/src/clib/pio_rearrange.c @@ -2047,9 +2047,11 @@ void performance_tune_rearranger(iosystem_desc_t *ios, io_desc_t *iodesc) int mpierr; /* Return code for MPI calls. */ assert(iodesc); - - if ((mpierr = MPI_Type_size(iodesc->mpitype, &tsize))) - return check_mpi(NULL, mpierr, __FILE__, __LINE__); + if(iodesc->mpitype == MPI_DATATYPE_NULL) + tsize = 0; + else + if ((mpierr = MPI_Type_size(iodesc->mpitype, &tsize))) + return check_mpi(NULL, mpierr, __FILE__, __LINE__); cbuf = NULL; ibuf = NULL; if (iodesc->ndof > 0) diff --git a/src/clib/pioc_support.c b/src/clib/pioc_support.c index a514f60aec5..ae50248417a 100644 --- a/src/clib/pioc_support.c +++ b/src/clib/pioc_support.c @@ -691,8 +691,11 @@ int malloc_iodesc(iosystem_desc_t *ios, int piotype, int ndims, (*iodesc)->mpitype = mpi_type; /* Get the size of the type. */ - if ((mpierr = MPI_Type_size((*iodesc)->mpitype, &(*iodesc)->mpitype_size))) - return check_mpi2(ios, NULL, mpierr, __FILE__, __LINE__); + if (mpi_type == MPI_DATATYPE_NULL) + (*iodesc)->mpitype_size = 0; + else + if ((mpierr = MPI_Type_size((*iodesc)->mpitype, &(*iodesc)->mpitype_size))) + return check_mpi2(ios, NULL, mpierr, __FILE__, __LINE__); /* Initialize some values in the struct. */ (*iodesc)->maxregions = 1; @@ -2077,8 +2080,11 @@ int inq_file_metadata(file_desc_t *file, int ncid, int iotype, int *nvars, int * return pio_err(NULL, file, ret, __FILE__, __LINE__); /* Get the size of the MPI type. */ - if ((mpierr = MPI_Type_size((*mpi_type)[v], &(*mpi_type_size)[v]))) - return check_mpi2(NULL, file, mpierr, __FILE__, __LINE__); + if ((*mpi_type)[v] == MPI_DATATYPE_NULL) + (*mpi_type_size)[v] = 0; + else + if ((mpierr = MPI_Type_size((*mpi_type)[v], &(*mpi_type_size)[v]))) + return check_mpi2(NULL, file, mpierr, __FILE__, __LINE__); /* What are the dimids associated with this var? */ if (var_ndims)