diff --git a/src/clib/CMakeLists.txt b/src/clib/CMakeLists.txt index 609de6f575..86ed405895 100644 --- a/src/clib/CMakeLists.txt +++ b/src/clib/CMakeLists.txt @@ -9,8 +9,8 @@ project (PIOC C) if (CMAKE_BUILD_TYPE) define_property( SOURCE - PROPERTY COMPILE_FLAGS - INHERITED + PROPERTY COMPILE_FLAGS + INHERITED BRIEF_DOCS "brief-doc" FULL_DOCS "full-doc" ) @@ -28,16 +28,19 @@ set (src topology.c pio_file.c pioc_support.c pio_lists.c if (NETCDF_INTEGRATION) set (src ${src} ../ncint/nc_get_vard.c ../ncint/ncintdispatch.c ../ncint/ncint_pio.c ../ncint/nc_put_vard.c) endif () +#<> if (GDAL_INTEGRATION) +set (src ${src} pio_gdal.c) +#endif () add_library (pioc ${src}) # Always use -fPIC set_property(TARGET pioc PROPERTY POSITION_INDEPENDENT_CODE ON) -set_source_files_properties( - pioc_async.c +set_source_files_properties( + pioc_async.c PROPERTIES - COMPILE_FLAGS -O0 + COMPILE_FLAGS -O0 ) @@ -63,7 +66,7 @@ target_compile_definitions (pioc # Compiler-specific compiler options if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") - string(APPEND CMAKE_C_FLAGS " -std=gnu99 " ) + string(APPEND CMAKE_C_FLAGS " -std=c99 " ) elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "PGI") string(APPEND CMAKE_C_FLAGS " -c99 ") elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel") @@ -173,6 +176,14 @@ if (PIO_USE_MPISERIAL) endif () endif () +#===== GDAL ===== +#if (GDAL_Found) + target_include_directories (pioc + PUBLIC ${GDAL_INCLUDE_DIR}) + target_link_libraries (pioc + PUBLIC ${GDAL_LIBRARY}) +#endif () + include(CheckTypeSize) check_type_size("size_t" SIZEOF_SIZE_T) CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG) diff --git a/src/clib/parallel_sort.c b/src/clib/parallel_sort.c index 7757106a4f..76b938c64d 100644 --- a/src/clib/parallel_sort.c +++ b/src/clib/parallel_sort.c @@ -1,5 +1,5 @@ /** - * c.f.: https://raw.githubusercontent.com/rabauke/mpl/main/examples/parallel_sort_mpi.c + * c.f.: https://raw.githubusercontent.com/rabauke/mpl/master/examples/parallel_sort_mpi.c * parallel sort algorithm for distributed memory computers * * algorithm works as follows: @@ -96,8 +96,8 @@ bool is_unique(CVector v) { * @param comm the MPI communicator over which v is distributed * @param v A CVector distributed over comm * @param ierr indicates an error was encountered - * @return A CVector sorted over comm, the size of the new vector may be different - * than v with a worst case of the entire result on one task. + * @return A CVector sorted over comm, the size of the new vector may be different + * than v with a worst case of the entire result on one task. */ CVector parallel_sort(MPI_Comm comm, CVector v, int *ierr) { @@ -130,7 +130,7 @@ CVector parallel_sort(MPI_Comm comm, CVector v, int *ierr) { if(!(pivot_pos = malloc((size + 1) * sizeof(*pivot_pos)))) *ierr = pio_err(NULL, NULL, PIO_ENOMEM, __FILE__,__LINE__); - + pivot_pos[0] = v.data; for (size_t i = 0; i < size - 1; ++i) pivot_pos[i + 1] = partition(pivot_pos[i], v.data + v.N, local_pivots[i]); @@ -189,15 +189,15 @@ CVector parallel_sort(MPI_Comm comm, CVector v, int *ierr) { */ int run_unique_check(MPI_Comm comm, size_t N,datatype *v, bool *has_dups) { - int rank, size; - int mpierr=MPI_SUCCESS; + int rank, size, i, r; + int mpierr=MPI_SUCCESS, mpierr2; int ierr; if ((mpierr = MPI_Comm_rank(comm, &rank))) - check_mpi(NULL, NULL, mpierr, __FILE__, __LINE__); + check_mpi(NULL, NULL, mpierr2, __FILE__, __LINE__); if ((mpierr = MPI_Comm_size(comm, &size))) - check_mpi(NULL, NULL, mpierr, __FILE__, __LINE__); - + check_mpi(NULL, NULL, mpierr2, __FILE__, __LINE__); + srand(time(NULL) * rank); CVector sorted = parallel_sort(comm, (CVector){v, N}, &ierr); @@ -205,13 +205,13 @@ int run_unique_check(MPI_Comm comm, size_t N,datatype *v, bool *has_dups) int i_have_dups = is_unique(sorted) ? 0:1; int global_dups; if ((mpierr = MPI_Allreduce(&i_have_dups, &global_dups, 1, MPI_INT, MPI_MAX, comm))) - check_mpi(NULL, NULL, mpierr, __FILE__, __LINE__); - + check_mpi(NULL, NULL, mpierr2, __FILE__, __LINE__); + if(global_dups > 0) *has_dups = true; else *has_dups = false; - + #ifdef DEBUG_PARALLEL_SORT for (r=0; r #include -#include - -#define NETCDF_VERSION_LE(Maj, Min, Pat) \ - (((NC_VERSION_MAJOR == Maj) && (NC_VERSION_MINOR == Min) && (NC_VERSION_PATCH <= Pat)) || \ - ((NC_VERSION_MAJOR == Maj) && (NC_VERSION_MINOR < Min)) || (NC_VERSION_MAJOR < Maj)) - -#define NETCDF_VERSION_GE(Maj, Min, Pat) \ - (((NC_VERSION_MAJOR == Maj) && (NC_VERSION_MINOR == Min) && (NC_VERSION_PATCH >= Pat)) || \ - ((NC_VERSION_MAJOR == Maj) && (NC_VERSION_MINOR > Min)) || (NC_VERSION_MAJOR > Maj)) +#include +//#include /** PIO_OFFSET is an integer type of size sufficient to represent the * size (in bytes) of the largest file supported by MPI. This is not @@ -124,7 +117,7 @@ typedef struct var_desc_t int record; /** ID of each outstanding pnetcdf request for this variable. */ -// int *request; + int *request; /** Number of requests pending with pnetcdf. */ int nreqs; @@ -316,7 +309,7 @@ typedef struct io_desc_t * sort it. */ bool needssort; - /** If the decomp has repeated values it can only be used for reading + /** If the decomp has repeated values it can only be used for reading since it doesn't make sense to write a single value from more than one location. */ bool readonly; @@ -460,13 +453,13 @@ typedef struct iosystem_desc_t * process is not part of the IO communicator. */ int io_rank; - /** Set to MPI_ROOT if this task is the main of IO communicator, 0 + /** Set to MPI_ROOT if this task is the master of IO communicator, 0 * otherwise. */ - int iomain; + int iomaster; - /** Set to MPI_ROOT if this task is the main of comp communicator, 0 + /** Set to MPI_ROOT if this task is the master of comp communicator, 0 * otherwise. */ - int compmain; + int compmaster; /** Rank of IO root task (which is rank 0 in io_comm) in the union * communicator. */ @@ -606,6 +599,13 @@ typedef struct file_desc_t * feature. One consequence is that PIO_IOTYPE_NETCDF4C files will * not have deflate automatically turned on for each var. */ int ncint_file; + + /** GDAL specific vars - M.Long */ + GDALDatasetH *hDS; + int dateVarID; // Index of field with type OFTDate + int timeVarID; // Index of field with type OFTTime + int datetimeVarID; // Index of field with type OFTDatetime + } file_desc_t; /** @@ -624,7 +624,10 @@ enum PIO_IOTYPE PIO_IOTYPE_NETCDF4C = 3, /** NetCDF4 (HDF5) parallel */ - PIO_IOTYPE_NETCDF4P = 4 + PIO_IOTYPE_NETCDF4P = 4, + + /** GDAL (serial only) */ + PIO_IOTYPE_GDAL = 5 }; /** @@ -687,13 +690,6 @@ enum PIO_ERROR_HANDLERS #define PIO_64BIT_OFFSET NC_64BIT_OFFSET /**< Use large (64-bit) file offsets. Mode flag for nc_create(). */ #define PIO_64BIT_DATA NC_64BIT_DATA /**< CDF5 format. */ -#ifdef NC_HAS_QUANTIZE -#define PIO_NOQUANTIZE NC_NOQUANTIZE -#define PIO_QUANTIZE_BITGROOM NC_QUANTIZE_BITGROOM -#define PIO_QUANTIZE_GRANULARBR NC_QUANTIZE_GRANULARBR -#define PIO_QUANTIZE_BITROUND NC_QUANTIZE_BITROUND /**< Use BitRound quantization. */ -#endif - /** Define the netCDF-based error codes. */ #define PIO_NOERR NC_NOERR /**< No Error */ #define PIO_EBADID NC_EBADID /**< Bad ncid */ @@ -784,7 +780,7 @@ enum PIO_ERROR_HANDLERS #define PIO_FILL_UINT64 NC_FILL_UINT64 /**< Default fill value for this type. */ #define PIO_EINDEP (-203) /**< independent access error. */ -#define PIO_EINSUFFBUF (-219) /**< Insufficient buffer size (pnetcdf only) */ + #define PIO_FIRST_ERROR_CODE (-500) /**< The first error code for PIO. */ #define PIO_EBADIOTYPE (-500) /**< Bad IOTYPE error. */ #define PIO_EVARDIMMISMATCH (-501) /**< Variable dimensions do not match in a multivar call. */ @@ -963,13 +959,6 @@ extern "C" { int PIOc_set_fill(int ncid, int fillmode, int *old_modep); int PIOc_def_var_fill(int ncid, int varid, int no_fill, const void *fill_value); int PIOc_inq_var_fill(int ncid, int varid, int *no_fill, void *fill_valuep); -#ifdef NC_HAS_BZ2 - int PIOc_inq_var_bzip2(int ncid, int varid, int* hasfilterp, int *levelp); -#endif -#ifdef NC_HAS_ZSTD - int PIOc_def_var_zstandard(int ncid, int varid, int level); - int PIOc_inq_var_zstandard(int ncid, int varid, int* hasfilterp, int *levelp); -#endif int PIOc_rename_var(int ncid, int varid, const char *name); /* These variable settings only apply to netCDF-4 files. */ @@ -1268,17 +1257,6 @@ extern "C" { int PIOc_put_vard_ulonglong(int ncid, int varid, int decompid, const PIO_Offset recnum, const unsigned long long *op); -#ifdef NC_HAS_PAR_FILTERS - int PIOc_def_var_filter(int ncid, int varid,unsigned int id, size_t nparams, unsigned int *params); - int PIOc_inq_var_filter_ids(int ncid, int varid, size_t *nfiltersp, unsigned int *ids); - int PIOc_inq_var_filter_info(int ncid, int varid, unsigned int id, size_t *nparamsp, unsigned int *params ); - int PIOc_inq_filter_avail(int ncid, unsigned int id ); -#endif -#ifdef NC_HAS_QUANTIZE - int PIOc_def_var_quantize(int ncid, int varid, int quantize_mode, int nsd ); - int PIOc_inq_var_quantize(int ncid, int varid, int *quantize_mode, int *nsdp ); -#endif - /* These functions are for the netCDF integration layer. */ int nc_def_iosystem(MPI_Comm comp_comm, int num_iotasks, int stride, int base, int rearr, int *iosysidp); @@ -1357,6 +1335,19 @@ extern "C" { int nc_put_vard_ulonglong(int ncid, int varid, int decompid, const size_t recnum, const unsigned long long *op); + /* These functions are for the GDAL integration layer. MSL - 9/7/2023 */ + int GDALc_inq_fieldid(int fileid, const char *name, int *varidp); + int GDALc_inq_timeid(int fileid, int *timeid); // Is there a field of type OFTDate, OFTTime, or OFTDateTime? +// int GDALc_openfile(int iosysid, GDALDatasetH *hDSp, int *iotype, const char *fname, bool mode); + int GDALc_openfile(int iosysid, int *fileIDp, GDALDatasetH *hDSp, int *iotype, const char *fname, bool mode); + int GDALc_sync(int fileid); + int GDALc_shp_get_int_field(int fileid); + int GDALc_shp_get_double_field(int fileid, int varid, const size_t *startp, + const size_t *countp, double *ip); + int GDALc_createfile(int iosysid, int *fileidp, int *iotype, const char *fname, bool mode); + int GDALc_createfile_shp(int iosysid, int *fileidp, int *iotype, const char *filename, bool mode); + int GDALc_def_field(int fileid, const char *name, int xtype, int *varidp); + #if defined(__cplusplus) } #endif diff --git a/src/clib/pio_darray.c b/src/clib/pio_darray.c index e7274da3e0..6ea308a5c6 100644 --- a/src/clib/pio_darray.c +++ b/src/clib/pio_darray.c @@ -181,7 +181,7 @@ PIOc_write_darray_multi(int ncid, const int *varids, int ioid, int nvars, /* Run these on all tasks if async is not in use, but only on * non-IO tasks if async is in use. */ - if (!ios->async || !ios->ioproc) + if ((!ios->async || !ios->ioproc) && (file->iotype != PIO_IOTYPE_GDAL)) { /* Get the number of dims for this var. */ PLOG((3, "about to call PIOc_inq_varndims varids[0] = %d", varids[0])); @@ -208,35 +208,35 @@ PIOc_write_darray_multi(int ncid, const int *varids, int ioid, int nvars, char fillvalue_present = fillvalue ? true : false; /* Is fillvalue non-NULL? */ int flushtodisk_int = flushtodisk; /* Need this to be int not boolean. */ - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); /* Send the function parameters and associated informaiton * to the msg handler. */ if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&nvars, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&nvars, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast((void *)varids, nvars, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((void *)varids, nvars, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&ioid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ioid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&arraylen, 1, MPI_OFFSET, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&arraylen, 1, MPI_OFFSET, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(array, arraylen * iodesc->piotype_size, MPI_CHAR, ios->compmain, + mpierr = MPI_Bcast(array, arraylen * iodesc->piotype_size, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&frame_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&frame_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr && frame_present) - mpierr = MPI_Bcast((void *)frame, nvars, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((void *)frame, nvars, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&fillvalue_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&fillvalue_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr && fillvalue_present) mpierr = MPI_Bcast((void *)fillvalue, nvars * iodesc->piotype_size, MPI_CHAR, - ios->compmain, ios->intercomm); + ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&flushtodisk_int, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&flushtodisk_int, 1, MPI_INT, ios->compmaster, ios->intercomm); PLOG((2, "PIOc_write_darray_multi file->pio_ncid = %d nvars = %d ioid = %d arraylen = %d " "frame_present = %d fillvalue_present = %d flushtodisk = %d", file->pio_ncid, nvars, ioid, arraylen, frame_present, fillvalue_present, flushtodisk)); @@ -263,14 +263,14 @@ PIOc_write_darray_multi(int ncid, const int *varids, int ioid, int nvars, /* Determine total size of aggregated data (all vars/records). * For netcdf serial writes we collect the data on io nodes and - * then move that data one node at a time to the io main node + * then move that data one node at a time to the io master node * and write (or read). The buffer size on io task 0 must be as * large as the largest used to accommodate this serial io * method. */ rlen = 0; if (iodesc->llen > 0 || ((file->iotype == PIO_IOTYPE_NETCDF || - file->iotype == PIO_IOTYPE_NETCDF4C) && ios->iomain)) + file->iotype == PIO_IOTYPE_NETCDF4C) && ios->iomaster)) rlen = iodesc->maxiobuflen * nvars; /* Allocate iobuf. */ @@ -333,6 +333,12 @@ PIOc_write_darray_multi(int ncid, const int *varids, int ioid, int nvars, return pio_err(ios, file, ierr, __FILE__, __LINE__); break; + case PIO_IOTYPE_GDAL: +// if ((ierr = gdal_write_darray_multi_serial(file, nvars, fndims, varids, iodesc, + if ((ierr = gdal_write_darray_multi_serial(file, nvars, 1, varids, iodesc, + DARRAY_DATA, frame))) + return pio_err(ios, file, ierr, __FILE__, __LINE__); + break; default: return pio_err(NULL, NULL, PIO_EBADIOTYPE, __FILE__, __LINE__); } @@ -661,6 +667,7 @@ PIOc_write_darray(int ncid, int varid, int ioid, PIO_Offset arraylen, void *arra #endif /* USE_MPE */ /* Get the file info. */ + printf(">>>> getting file %d\n",ncid); if ((ierr = pio_get_file(ncid, &file))) return pio_err(NULL, NULL, PIO_EBADID, __FILE__, __LINE__); ios = file->iosystem; @@ -686,9 +693,12 @@ PIOc_write_darray(int ncid, int varid, int ioid, PIO_Offset arraylen, void *arra arraylen, iodesc->ndof)); /* Get var description. */ + PLOG((3, "here1")); + printf(">>>> NCID: %d, %d\n",file->pio_ncid, file->fh); if ((ierr = get_var_desc(varid, &file->varlist, &vdesc))) return pio_err(ios, file, ierr, __FILE__, __LINE__); + PLOG((3, "here2")); /* If the type of the var doesn't match the type of the * decomposition, return an error. */ /* if (iodesc->piotype != vdesc->pio_type) */ @@ -697,13 +707,14 @@ PIOc_write_darray(int ncid, int varid, int ioid, PIO_Offset arraylen, void *arra /* __FILE__, __LINE__); */ /* If we don't know the fill value for this var, get it. */ - if (!vdesc->fillvalue) + if (!vdesc->fillvalue && file->iotype != PIO_IOTYPE_GDAL) if ((ierr = find_var_fillvalue(file, varid, vdesc))) return pio_err(ios, file, PIO_EBADID, __FILE__, __LINE__); /* Check that if the user passed a fill value, it is correct. If * use_fill is false, then find_var_fillvalue will not end up * getting a fill value. */ + PLOG((3, "here3")); if (fillvalue && vdesc->use_fill) if (memcmp(fillvalue, vdesc->fillvalue, vdesc->pio_type_size)) return pio_err(ios, file, PIO_EINVAL, __FILE__, __LINE__); @@ -895,19 +906,19 @@ PIOc_read_darray(int ncid, int varid, int ioid, PIO_Offset arraylen, { int msg = PIO_MSG_READDARRAY; - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); /* Send the function parameters and associated informaiton * to the msg handler. */ if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&ioid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ioid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&arraylen, 1, MPI_OFFSET, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&arraylen, 1, MPI_OFFSET, ios->compmaster, ios->intercomm); PLOG((2, "PIOc_read_darray ncid %d varid %d ioid %d arraylen %d", ncid, varid, ioid, arraylen)); } @@ -925,8 +936,8 @@ PIOc_read_darray(int ncid, int varid, int ioid, PIO_Offset arraylen, pioassert(iodesc->rearranger == PIO_REARR_BOX || iodesc->rearranger == PIO_REARR_SUBSET, "unknown rearranger", __FILE__, __LINE__); - /* iomain needs max of buflen, others need local len */ - if (ios->iomain == MPI_ROOT) + /* iomaster needs max of buflen, others need local len */ + if (ios->iomaster == MPI_ROOT) rlen = iodesc->maxiobuflen; else rlen = iodesc->llen; @@ -949,6 +960,10 @@ PIOc_read_darray(int ncid, int varid, int ioid, PIO_Offset arraylen, if ((ierr = pio_read_darray_nc(file, iodesc, varid, iobuf))) return pio_err(ios, file, ierr, __FILE__, __LINE__); break; + case PIO_IOTYPE_GDAL: + if ((ierr = gdal_read_darray_shp(file, iodesc, varid, iobuf))) + return pio_err(ios, file, ierr, __FILE__, __LINE__); + break; default: return pio_err(NULL, NULL, PIO_EBADIOTYPE, __FILE__, __LINE__); } diff --git a/src/clib/pio_darray_int.c b/src/clib/pio_darray_int.c index 084a214293..6ef60594a6 100644 --- a/src/clib/pio_darray_int.c +++ b/src/clib/pio_darray_int.c @@ -427,8 +427,6 @@ write_darray_multi_par(file_desc_t *file, int nvars, int fndims, const int *vari int rrcnt = 0; /* Number of subarray requests (pnetcdf only). */ PIO_Offset *startlist[num_regions]; /* Array of start arrays for ncmpi_iput_varn(). */ PIO_Offset *countlist[num_regions]; /* Array of count arrays for ncmpi_iput_varn(). */ - - ierr = ncmpi_wait_all(file->fh, NC_REQ_ALL, NULL, NULL); #endif /* _PNETCDF */ /* Process each region of data to be written. */ @@ -457,12 +455,11 @@ write_darray_multi_par(file_desc_t *file, int nvars, int fndims, const int *vari bufptr = (void *)((char *)iobuf + iodesc->mpitype_size * (nv * llen + region->loffset)); /* Ensure collective access. */ - if((ierr = nc_var_par_access(file->fh, varids[nv], NC_COLLECTIVE))) - return pio_err(ios, file, ierr, __FILE__, __LINE__); + ierr = nc_var_par_access(file->fh, varids[nv], NC_COLLECTIVE); /* Write the data for this variable. */ - if((ierr = nc_put_vara(file->fh, varids[nv], (size_t *)start, (size_t *)count, bufptr))) - return pio_err(ios, file, ierr, __FILE__, __LINE__); + if (!ierr) + ierr = nc_put_vara(file->fh, varids[nv], (size_t *)start, (size_t *)count, bufptr); } break; #endif @@ -645,10 +642,27 @@ write_darray_multi_par(file_desc_t *file, int nvars, int fndims, const int *vari else /* don't flush yet, accumulate the request size */ vard_llen += llen; #else + if (vdesc->nreqs % PIO_REQUEST_ALLOC_CHUNK == 0) + { + if (!(vdesc->request = realloc(vdesc->request, sizeof(int) * + (vdesc->nreqs + PIO_REQUEST_ALLOC_CHUNK)))) + return pio_err(ios, file, PIO_ENOMEM, __FILE__, __LINE__); + + for (int i = vdesc->nreqs; i < vdesc->nreqs + PIO_REQUEST_ALLOC_CHUNK; i++) + vdesc->request[i] = NC_REQ_NULL; + } + /* Write, in non-blocking fashion, a list of subarrays. */ +// PLOG((3, "about to call ncmpi_iput_varn() varids[%d] = %d rrcnt = %d, llen = %d", +// nv, varids[nv], rrcnt, llen)); +// for(int i=0;i < llen; i++) +// PLOG((3, "bufptr[%d] = %d",i,((int *)bufptr)[i])); ierr = ncmpi_iput_varn(file->fh, varids[nv], rrcnt, startlist, countlist, - bufptr, llen, iodesc->mpitype, NULL); + bufptr, llen, iodesc->mpitype, &vdesc->request[vdesc->nreqs]); + /* keeps wait calls in sync */ + if (vdesc->request[vdesc->nreqs] == NC_REQ_NULL) + vdesc->request[vdesc->nreqs] = PIO_REQ_NULL; vdesc->nreqs++; #endif @@ -1667,11 +1681,11 @@ pio_read_darray_nc_serial(file_desc_t *file, io_desc_t *iodesc, int vid, * ios->num_iotasks is the number of iotasks actually * used in this decomposition. */ if (rtask < ios->num_iotasks && tmp_bufsize > 0){ - + if ((mpierr = MPI_Send(iobuf, tmp_bufsize, iodesc->mpitype, rtask, 4 * ios->num_iotasks + rtask, ios->io_comm))) return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); - } + } } } } @@ -1735,34 +1749,58 @@ flush_output_buffer(file_desc_t *file, bool force, PIO_Offset addsize) * limit, then flush to disk. */ if (force || (usage >= pio_pnetcdf_buffer_size_limit)) { + int rcnt; int maxreq; + int reqcnt; maxreq = 0; + reqcnt = 0; + rcnt = 0; for (int i = 0; i < file->nvars; i++) { if ((ierr = get_var_desc(i, &file->varlist, &vdesc))) return pio_err(NULL, file, ierr, __FILE__, __LINE__); + reqcnt += vdesc->nreqs; if (vdesc->nreqs > 0) maxreq = i; } + int request[reqcnt]; + int status[reqcnt]; + if (file->varlist) { for (int i = 0; i <= maxreq; i++) { if ((ierr = get_var_desc(i, &file->varlist, &vdesc))) return pio_err(NULL, file, ierr, __FILE__, __LINE__); +#ifdef MPIO_ONESIDED + /*onesided optimization requires that all of the requests in a wait_all call represent + a contiguous block of data in the file */ + if (rcnt > 0 && (prev_record != vdesc->record || vdesc->nreqs == 0)) + { + ierr = ncmpi_wait_all(file->fh, rcnt, request, status); + rcnt = 0; + } + prev_record = vdesc->record; +#endif + for (reqcnt = 0; reqcnt < vdesc->nreqs; reqcnt++) + request[rcnt++] = max(vdesc->request[reqcnt], NC_REQ_NULL); + PLOG((3,"flush_output_buffer rcnt=%d",rcnt)); + if (vdesc->request != NULL) + free(vdesc->request); + vdesc->request = NULL; vdesc->nreqs = 0; #ifdef FLUSH_EVERY_VAR - ierr = ncmpi_wait_all(file->fh, NC_REQ_ALL, NULL, NULL); - //ierr = ncmpi_wait_all(file->fh, rcnt, request, status); + ierr = ncmpi_wait_all(file->fh, rcnt, request, status); rcnt = 0; #endif } } - /* make sure all buffers are now clean */ - ierr = ncmpi_wait_all(file->fh, NC_REQ_ALL, NULL, NULL); + + if (rcnt > 0) + ierr = ncmpi_wait_all(file->fh, rcnt, request, status); /* Release resources. */ if (file->iobuf) diff --git a/src/clib/pio_file.c b/src/clib/pio_file.c index e9edb6af4c..f2e28b91cc 100644 --- a/src/clib/pio_file.c +++ b/src/clib/pio_file.c @@ -156,7 +156,7 @@ PIOc_createfile(int iosysid, int *ncidp, int *iotype, const char *filename, PLOG((1, "PIOc_createfile iosysid = %d iotype = %d filename = %s mode = %d", iosysid, *iotype, filename, mode)); - + /* Create the file. */ if ((ret = PIOc_createfile_int(iosysid, ncidp, iotype, filename, mode, 0))) return pio_err(ios, NULL, ret, __FILE__, __LINE__); @@ -235,8 +235,8 @@ PIOc_closefile(int ncid) if (file->writable) PIOc_sync(ncid); - /* If async is in use and this is a comp tasks, then the compmain - * sends a msg to the pio_msg_handler running on the IO main and + /* If async is in use and this is a comp tasks, then the compmaster + * sends a msg to the pio_msg_handler running on the IO master and * waiting for a message. Then broadcast the ncid over the intercomm * to the IO tasks. */ if (ios->async) @@ -245,11 +245,11 @@ PIOc_closefile(int ncid) { int msg = PIO_MSG_CLOSE_FILE; - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); } /* Handle MPI errors. */ @@ -276,13 +276,15 @@ PIOc_closefile(int ncid) break; #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: - if (file->writable){ - ierr = ncmpi_wait_all(file->fh, NC_REQ_ALL, NULL, NULL); + if (file->writable) ierr = ncmpi_buffer_detach(file->fh); - } ierr = ncmpi_close(file->fh); break; #endif + case PIO_IOTYPE_GDAL: + ierr = GDALClose((void*)file->hDS); + printf("GDALClose ierr: %d\n",ierr); + break; default: return pio_err(ios, file, PIO_EBADIOTYPE, __FILE__, __LINE__); } @@ -328,7 +330,7 @@ PIOc_deletefile(int iosysid, const char *filename) if (!(ios = pio_get_iosystem_from_id(iosysid))) return pio_err(NULL, NULL, PIO_EBADID, __FILE__, __LINE__); - /* If async is in use, send message to IO main task. */ + /* If async is in use, send message to IO master task. */ if (ios->async) { if (!ios->ioproc) @@ -338,9 +340,9 @@ PIOc_deletefile(int iosysid, const char *filename) len = strlen(filename); if (!mpierr) - mpierr = MPI_Bcast(&len, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&len, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast((void *)filename, len + 1, MPI_CHAR, ios->compmain, + mpierr = MPI_Bcast((void *)filename, len + 1, MPI_CHAR, ios->compmaster, ios->intercomm); PLOG((2, "Bcast len = %d filename = %s", len, filename)); } @@ -428,18 +430,18 @@ PIOc_sync(int ncid) } } - /* If async is in use, send message to IO main tasks. */ + /* If async is in use, send message to IO master tasks. */ if (ios->async) { if (!ios->ioproc) { int msg = PIO_MSG_SYNC; - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); } /* Handle MPI errors. */ @@ -471,6 +473,11 @@ PIOc_sync(int ncid) flush_output_buffer(file, true, 0); break; #endif +//#ifdef _GDAL + case PIO_IOTYPE_GDAL: + printf("<<>> PIOc_sync() TEST <<>>"); + break; +//#endif default: return pio_err(ios, file, PIO_EBADIOTYPE, __FILE__, __LINE__); } @@ -479,8 +486,8 @@ PIOc_sync(int ncid) } /* Broadcast and check the return code. */ -// if ((mpierr = MPI_Bcast(&ierr, 1, MPI_INT, ios->ioroot, ios->my_comm))) -// return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); + if ((mpierr = MPI_Bcast(&ierr, 1, MPI_INT, ios->ioroot, ios->my_comm))) + return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); if (ierr) return check_netcdf2(ios, NULL, ierr, __FILE__, __LINE__); diff --git a/src/clib/pio_gdal.c b/src/clib/pio_gdal.c new file mode 100644 index 0000000000..d188fd09d7 --- /dev/null +++ b/src/clib/pio_gdal.c @@ -0,0 +1,1350 @@ +#include +#include +#include +#include + +/** + * The PIO library maintains its own set of ncids. This is the next + * ncid number that will be assigned. + */ +extern int pio_next_ncid; + +static int +GDALc_inq_file_metadata(file_desc_t *file, GDALDatasetH hDS, int iotype, int *nvars, + int **rec_var, int **pio_type, int **pio_type_size, + MPI_Datatype **mpi_type, int **mpi_type_size, int **ndims) +{ + int mpierr; + int ret; + + /* Check inputs. */ + pioassert(rec_var && pio_type && pio_type_size && mpi_type && mpi_type_size, + "pointers must be provided", __FILE__, __LINE__); + + if (hDS == NULL) { + return pio_err(file->iosystem, file, -999, __FILE__, __LINE__); + } + /* How many vars in the file? */ + if (iotype == PIO_IOTYPE_GDAL) + { + OGRLayerH hLayer = OGR_DS_GetLayer( hDS, 0 ); + OGR_L_ResetReading(hLayer); + + OGRFeatureDefnH hFD = OGR_L_GetLayerDefn(hLayer); + *nvars = OGR_FD_GetFieldCount(hFD); + if (nvars == 0) // empty file + return pio_err(NULL, file, PIO_ENOMEM, __FILE__, __LINE__); + + /* Allocate storage for info about each var. */ + if (*nvars) + { + if (!(*rec_var = malloc(*nvars * sizeof(int)))) + return PIO_ENOMEM; + if (!(*pio_type = malloc(*nvars * sizeof(int)))) + return PIO_ENOMEM; + if (!(*pio_type_size = malloc(*nvars * sizeof(int)))) + return PIO_ENOMEM; + if (!(*mpi_type = malloc(*nvars * sizeof(MPI_Datatype)))) + return PIO_ENOMEM; + if (!(*mpi_type_size = malloc(*nvars * sizeof(int)))) + return PIO_ENOMEM; + if (!(*ndims = malloc(*nvars * sizeof(int)))) + return PIO_ENOMEM; + } + + /* Learn about each variable in the file. */ + for (int v = 0; v < *nvars; v++) + { + int var_ndims; /* Number of dims for this var. */ + nc_type my_type; + + /* Find type of the var and number of dims in this var. Also + * learn about type. */ + size_t type_size; + + var_ndims = 1; // FIXED FOR NOW. For data-read purposes, it's a 1D stream across the number of + // elements. + (*ndims)[v] = var_ndims; + OGRFieldType Fld = OGR_Fld_GetType(OGR_FD_GetFieldDefn(hFD,v)); + bool typeOK = true; // assume we're good + switch (Fld) { + case OFTReal: + (*pio_type)[v] = (int)PIO_DOUBLE; + (*pio_type_size)[v] = sizeof(double); + break; + case OFTInteger: + (*pio_type)[v] = (int)PIO_INT; + (*pio_type_size)[v] = sizeof(int); + break; + case OFTString: + (*pio_type)[v] = (int)PIO_STRING; + (*pio_type_size)[v] = -1; + break; + // This needs to be done. How do we deal with timestamps etc in GDAL vector fields? + //>>case OFTDate: + //>> break; + //>> case OFTTime: + //>> break; + //>> case OFTDate: + //>> break; + //>> case OFTDateTime: + default: + typeOK = false; + break; + } + if (!typeOK) // Not a usable type + continue; + + /* Get the MPI type corresponding with the PIO type. */ + if ((ret = find_mpi_type((*pio_type)[v], &(*mpi_type)[v], NULL))) + return pio_err(NULL, file, ret, __FILE__, __LINE__); + + /* Get the size of the MPI type. */ + 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_mpi(NULL, file, mpierr, __FILE__, __LINE__); + + } /* next var */ + } /* If PIO_TYPE_GDAL */ + return PIO_NOERR; +} + +/** + * The PIO-C interface for the GDAL function OGR_L_FindFieldIndex() + * + * This routine is called collectively by all tasks in the communicator + * ios.union_comm. + * + * @param ncid the ncid of the open file, obtained from + * GDALc_openfile() or GDALc_createfile(). + * @param name the field name. + * @param varidp a pointer that will get the variable id + * @return PIO_NOERR for success, error code otherwise. <> + * @ingroup PIO_inq_var_c + * @author Michael Long (adapted from Jim Edwards, Ed Hartnett) + */ +int +GDALc_inq_fieldid(int fileid, const char *name, int *fieldidp) +{ + iosystem_desc_t *ios; /* Pointer to io system information. */ + file_desc_t *file; /* Pointer to file information. */ + int ierr; /* Return code from function calls. */ + int mpierr = MPI_SUCCESS, mpierr2; /* Return code from MPI function codes. */ + + /* Get file info based on fileid. */ + if ((ierr = pio_get_file(fileid, &file))) + return pio_err(NULL, NULL, ierr, __FILE__, __LINE__); + ios = file->iosystem; + + /* Caller must provide name. */ + if (!name || strlen(name) > NC_MAX_NAME) + return pio_err(ios, file, PIO_EINVAL, __FILE__, __LINE__); + + PLOG((1, "GDALc_inq_fieldid fileid = %d name = %s", fileid, name)); + + if (ios->async) + { + if (!ios->ioproc) + { + int msg = PIO_MSG_INQ_VARID; + + if (ios->compmaster == MPI_ROOT) + mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm); + + if (!mpierr) + mpierr = MPI_Bcast(&fileid, 1, MPI_INT, ios->compmaster, ios->intercomm); + int namelen; + namelen = strlen(name); + if (!mpierr) + mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmaster, ios->intercomm); + if (!mpierr) + mpierr = MPI_Bcast((void *)name, namelen + 1, MPI_CHAR, ios->compmaster, ios->intercomm); + } + + /* Handle MPI errors. */ + if ((mpierr2 = MPI_Bcast(&mpierr, 1, MPI_INT, ios->comproot, ios->my_comm))) + check_mpi(NULL, file, mpierr2, __FILE__, __LINE__); + if (mpierr) + return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); + } + + /* If this is an IO task, then call the GDAL function. */ + if (ios->ioproc) + { + GDALDatasetH *hDS = file->hDS; + if (file->do_io) { // We assume that its a GDAL file + OGRLayerH hLayer = OGR_DS_GetLayer( hDS, 0 ); + OGR_L_ResetReading(hLayer); + if (hLayer == NULL) { + printf("Layer is NULL"); + return -1; + } + *fieldidp = OGR_L_FindFieldIndex(hLayer,name,1); + } + } + + /* Broadcast and check the return code. */ + if ((mpierr = MPI_Bcast(&ierr, 1, MPI_INT, ios->ioroot, ios->my_comm))) + return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); + if (ierr) + return check_netcdf(file, ierr, __FILE__, __LINE__); + + /* Broadcast results to all tasks. Ignore NULL parameters. */ + if (fieldidp) + if ((mpierr = MPI_Bcast(fieldidp, 1, MPI_INT, ios->ioroot, ios->my_comm))) + check_mpi(NULL, file, mpierr, __FILE__, __LINE__); + + return PIO_NOERR; +} + +int +GDALc_openfile(int iosysid, int *fileIDp, GDALDatasetH *hDSp,int *iotype, const char *filename, bool mode) +{ + iosystem_desc_t *ios; /* Pointer to io system information. */ + file_desc_t *file; /* Pointer to file information. */ + int imode; /* Internal mode val for netcdf4 file open. */ + int nvars = 0; + int *rec_var = NULL; + int *pio_type = NULL; + int *pio_type_size = NULL; + MPI_Datatype *mpi_type = NULL; + int *mpi_type_size = NULL; + int *ndims = NULL; + int mpierr = MPI_SUCCESS, mpierr2; /** Return code from MPI function codes. */ + int ierr = PIO_NOERR; /* Return code from function calls. */ + GDALDatasetH hDS; + +#ifdef USE_MPE + pio_start_mpe_log(OPEN); +#endif /* USE_MPE */ + + /* Get the IO system info from the iosysid. */ + if (!(ios = pio_get_iosystem_from_id(iosysid))) + return pio_err(NULL, NULL, PIO_EBADID, __FILE__, __LINE__); + + /* User must provide valid input for these parameters. */ + if (!hDSp || !iotype || !filename) + return pio_err(ios, NULL, PIO_EINVAL, __FILE__, __LINE__); + if (*iotype != PIO_IOTYPE_GDAL ) + return pio_err(ios, NULL, PIO_EINVAL, __FILE__, __LINE__); + + /* Allocate space for the file info. */ + if (!(file = calloc(sizeof(*file), 1))) + return pio_err(ios, NULL, PIO_ENOMEM, __FILE__, __LINE__); + + /* Fill in some file values. */ + file->fh = -1; + file->iotype = *iotype; + file->iosystem = ios; + file->writable = (mode & PIO_WRITE) ? 1 : 0; + + /* Set to true if this task should participate in IO (only true + * for one task with netcdf serial files. */ + if (file->iotype == PIO_IOTYPE_GDAL || + ios->io_rank == 0) + file->do_io = 1; + + /* If async is in use, and this is not an IO task, bcast the parameters. */ + if (ios->async) + { + int msg = PIO_MSG_OPEN_FILE; + size_t len = strlen(filename); + + if (!ios->ioproc) + { + /* Send the message to the message handler. */ + if (ios->compmaster == MPI_ROOT) + mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); + + /* Send the parameters of the function call. */ + if (!mpierr) + mpierr = MPI_Bcast(&len, 1, MPI_INT, ios->compmaster, ios->intercomm); + if (!mpierr) + mpierr = MPI_Bcast((void *)filename, len + 1, MPI_CHAR, ios->compmaster, ios->intercomm); + if (!mpierr) + mpierr = MPI_Bcast(&file->iotype, 1, MPI_INT, ios->compmaster, ios->intercomm); + if (!mpierr) + mpierr = MPI_Bcast(&mode, 1, MPI_INT, ios->compmaster, ios->intercomm); + } + + /* Handle MPI errors. */ + if ((mpierr2 = MPI_Bcast(&mpierr, 1, MPI_INT, ios->comproot, ios->my_comm))) + return check_mpi(NULL, file, mpierr2, __FILE__, __LINE__); + if (mpierr) + return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); + } + + /* If this is an IO task, then call the netCDF function. */ + if (ios->ioproc) + { + switch (file->iotype) + { + case PIO_IOTYPE_GDAL: +// if (ios->io_rank == 0) + { + *hDSp = OGROpen( filename, mode, NULL ); + if( hDSp != NULL ) + + ierr = GDALc_inq_file_metadata(file, *hDSp, PIO_IOTYPE_GDAL, + &nvars, &rec_var, &pio_type, + &pio_type_size, &mpi_type, + &mpi_type_size, &ndims); + PLOG((2, "GDALc_openfile:OGROpen for filename = %s mode = %d " + "ierr = %d nvars = %d", filename, mode, ierr, nvars)); + } + break; + + default: + return pio_err(ios, file, PIO_EBADIOTYPE, __FILE__, __LINE__); + } + + } + + /* Broadcast and check the return code. */ + if (ios->ioroot == ios->union_rank) + PLOG((2, "Bcasting error code ierr %d ios->ioroot %d ios->my_comm %d", + ierr, ios->ioroot, ios->my_comm)); + if ((mpierr = MPI_Bcast(&ierr, 1, MPI_INT, ios->ioroot, ios->my_comm))) + return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); + PLOG((2, "Bcast openfile_retry error code ierr = %d", ierr)); + + /* If there was an error, free allocated memory and deal with the error. */ + if (ierr) + { + free(file); + return PIO_NOERR;// check_netcdf2(ios, NULL, ierr, __FILE__, __LINE__); + } + + /* Broadcast writability to all tasks. */ + if ((mpierr = MPI_Bcast(&file->writable, 1, MPI_INT, ios->ioroot, ios->my_comm))) + return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); + + if ((mpierr = MPI_Bcast(&nvars, 1, MPI_INT, ios->ioroot, ios->my_comm))) + return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); + + /* Non io tasks need to allocate to store info about variables. */ + if (nvars && !rec_var) + { + if (!(rec_var = malloc(nvars * sizeof(int)))) + return pio_err(ios, file, PIO_ENOMEM, __FILE__, __LINE__); + if (!(pio_type = malloc(nvars * sizeof(int)))) + return pio_err(ios, file, PIO_ENOMEM, __FILE__, __LINE__); + if (!(pio_type_size = malloc(nvars * sizeof(int)))) + return pio_err(ios, file, PIO_ENOMEM, __FILE__, __LINE__); + if (!(mpi_type = malloc(nvars * sizeof(MPI_Datatype)))) + return pio_err(ios, file, PIO_ENOMEM, __FILE__, __LINE__); + if (!(mpi_type_size = malloc(nvars * sizeof(int)))) + return pio_err(ios, file, PIO_ENOMEM, __FILE__, __LINE__); + if (!(ndims = malloc(nvars * sizeof(int)))) + return pio_err(ios, file, PIO_ENOMEM, __FILE__, __LINE__); + } + if (nvars) + { + if ((mpierr = MPI_Bcast(rec_var, nvars, MPI_INT, ios->ioroot, ios->my_comm))) + return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); + if ((mpierr = MPI_Bcast(pio_type, nvars, MPI_INT, ios->ioroot, ios->my_comm))) + return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); + if ((mpierr = MPI_Bcast(pio_type_size, nvars, MPI_INT, ios->ioroot, ios->my_comm))) + return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); + if ((mpierr = MPI_Bcast(mpi_type, nvars*(int)(sizeof(MPI_Datatype)/sizeof(int)), MPI_INT, ios->ioroot, ios->my_comm))) + return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); + if ((mpierr = MPI_Bcast(mpi_type_size, nvars, MPI_INT, ios->ioroot, ios->my_comm))) + return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); + if ((mpierr = MPI_Bcast(ndims, nvars, MPI_INT, ios->ioroot, ios->my_comm))) + return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); + } + + file->hDS = *hDSp; + + /* Create the ncid/fileid that the user will see. This is necessary + * because otherwise ids will be reused if files are opened + * on multiple iosystems. */ + file->pio_ncid = pio_next_ncid++; + *fileIDp=file->pio_ncid; + + /* Add this file to the list of currently open files. */ + pio_add_to_file_list(file); + + /* Add info about the variables to the file_desc_t struct. */ + for (int v = 0; v < nvars; v++) { + if ((ierr = add_to_varlist(v, rec_var[v], pio_type[v], pio_type_size[v], + mpi_type[v], mpi_type_size[v], ndims[v], + &file->varlist))) + return pio_err(ios, NULL, ierr, __FILE__, __LINE__);} + file->nvars = nvars; + + /* Free resources. */ + if (nvars) + { + if (rec_var) + free(rec_var); + if (pio_type) + free(pio_type); + if (pio_type_size) + free(pio_type_size); + if (mpi_type) + free(mpi_type); + if (mpi_type_size) + free(mpi_type_size); + if (ndims) + free(ndims); + } + +#ifdef USE_MPE + pio_stop_mpe_log(OPEN, __func__); +#endif /* USE_MPE */ + PLOG((2, "Opened file %s file->pio_ncid = %d file->fh = %d ierr = %d", + filename, file->pio_ncid, file->fh, ierr)); + + return ierr; +} + +int +GDALc_sync(int fileid) { + iosystem_desc_t *ios; /* Pointer to io system information. */ + file_desc_t *file; /* Pointer to file information. */ + int mpierr = MPI_SUCCESS, mpierr2; /* Return code from MPI function codes. */ + int ierr = PIO_NOERR; /* Return code from function calls. */ +} + +int GDALc_inq_timeid(int fileid, int *timeid) { // Is there a field of type OFTDate, OFTTime, or OFTDateTime? + iosystem_desc_t *ios; /* Pointer to io system information. */ + file_desc_t *file; /* Pointer to file information. */ + int ierr = PIO_NOERR; /* Return code from function calls. */ + int mpierr = MPI_SUCCESS, mpierr2; /* Return code from MPI function codes. */ + + /* Get file info based on ncid. */ + if ((ierr = pio_get_file(fileid, &file))) + return pio_err(NULL, NULL, ierr, __FILE__, __LINE__); + ios = file->iosystem; + if (file->hDS == NULL) + return pio_err(NULL, NULL, ierr, __FILE__, __LINE__); + + GDALDatasetH *hDS = file->hDS; + OGRLayerH hLayer = OGR_DS_GetLayer( hDS, 0 ); + if (hLayer == NULL) + return pio_err(NULL, NULL, ierr, __FILE__, __LINE__); + OGR_L_ResetReading(hLayer); + + OGRFeatureDefnH hFD = OGR_L_GetLayerDefn(hLayer); + if (hFD == NULL) + return pio_err(NULL, NULL, ierr, __FILE__, __LINE__); + int nFld = OGR_FD_GetFieldCount(hFD); + OGRFieldDefnH hTMP = OGR_FD_GetFieldDefn(hFD,1); + hTMP = OGR_FD_GetFieldDefn(hFD,0); + + for (int i=0;i<(file->nvars)-1;i++) { + OGRFieldDefnH hFlD = OGR_FD_GetFieldDefn(hFD,i); + OGRFieldType Fld = OGR_Fld_GetType(hFlD); + if (Fld == NULL) + return pio_err(NULL, NULL, ierr, __FILE__, __LINE__); + } + + return 0; + } + +/** + * Read an array of data from a file to the (serial) IO library. This + * function is only used with netCDF classic and netCDF-4 serial + * iotypes. + * + * @param file a pointer to the open file descriptor for the file + * that will be written to + * @param iodesc a pointer to the defined iodescriptor for the buffer + * @param vid the variable id to be read. + * @param iobuf the buffer to be written from this mpi task. May be + * null. for example we have 8 ionodes and a distributed array with + * global size 4, then at least 4 nodes will have a null iobuf. In + * practice the box rearranger trys to have at least blocksize bytes + * on each io task and so if the total number of bytes to write is + * less than blocksize * numiotasks then some iotasks will have a NULL + * iobuf. + * @returns 0 for success, error code otherwise. + * @ingroup PIO_read_darray_c + * @author Jim Edwards, Ed Hartnett + */ +int +gdal_read_darray_shp(file_desc_t *file, io_desc_t *iodesc, int vid, + void *iobuf) +{ + iosystem_desc_t *ios; /* Pointer to io system information. */ + var_desc_t *vdesc; /* Information about the variable. */ + int ndims; /* Number of dims in decomposition. */ + int fndims; /* Number of dims for this var in file. */ + MPI_Status status; + int mpierr; /* Return code from MPI functions. */ + int ierr; + + PLOG((1, "XXX fndims = %d vid = %d maxvars = %d", fndims, vid, PIO_MAX_VARS)); + + /* Check inputs. */ + pioassert(file && file->iosystem && iodesc && vid >= 0 && vid <= PIO_MAX_VARS, + "invalid input", __FILE__, __LINE__); + + PLOG((2, "pio_read_darray_shp vid = %d", vid)); + ios = file->iosystem; + +#ifdef TIMING + /* Start timer if desired. */ + if ((ierr = pio_start_timer("PIO:read_darray_shp"))) + return pio_err(ios, NULL, ierr, __FILE__, __LINE__); +#endif /* TIMING */ + + /* Get var info for this var. */ + if ((ierr = get_var_desc(vid, &file->varlist, &vdesc))) + return pio_err(NULL, file, ierr, __FILE__, __LINE__); + + /* Get the number of dims in our decomposition. */ + ndims = iodesc->ndims; + + /* Get number of dims for this var. */ + fndims = vdesc->ndims; + + /* If setframe was not called, use a default value of 0. This is + * required for backward compatibility. */ + if (fndims == ndims + 1 && vdesc->record < 0) + vdesc->record = 0; + PLOG((3, "fndims %d ndims %d vdesc->record %d vdesc->ndims %d", fndims, + ndims, vdesc->record, vdesc->ndims)); + + /* Confirm that we are being called with the correct ndims. */ + pioassert((fndims == ndims && vdesc->record < 0) || + (fndims == ndims + 1 && vdesc->record >= 0), + "unexpected record", __FILE__, __LINE__); + + if (ios->ioproc) + { + io_region *region; + size_t start[fndims]; + size_t count[fndims]; + size_t tmp_start[fndims * iodesc->maxregions]; + size_t tmp_count[fndims * iodesc->maxregions]; + size_t tmp_bufsize; + void *bufptr; + + /* buffer is incremented by byte and loffset is in terms of + the iodessc->mpitype so we need to multiply by the size of + the mpitype. */ + region = iodesc->firstregion; + + /* If setframe was not set before this call, assume a value of + * 0. This is required for backward compatibility. */ + if (fndims > ndims) + if (vdesc->record < 0) + vdesc->record = 0; + + /* Put together start/count arrays for all regions. */ + for (int regioncnt = 0; regioncnt < iodesc->maxregions; regioncnt++) + { + if (!region || iodesc->llen == 0) + { + /* Nothing to write for this region. */ + for (int i = 0; i < fndims; i++) + { + tmp_start[i + regioncnt * fndims] = 0; + tmp_count[i + regioncnt * fndims] = 0; + } + bufptr = NULL; + } + else + { + if (vdesc->record >= 0 && fndims > 1) + { + /* This is a record var. Find start for record dims. */ + tmp_start[regioncnt * fndims] = vdesc->record; + + /* Find start/count for all non-record dims. */ + for (int i = 1; i < fndims; i++) + { + tmp_start[i + regioncnt * fndims] = region->start[i - 1]; + tmp_count[i + regioncnt * fndims] = region->count[i - 1]; + } + + /* Set count for record dimension. */ + if (tmp_count[1 + regioncnt * fndims] > 0) + tmp_count[regioncnt * fndims] = 1; + } + else + { + /* Non-time dependent array */ + for (int i = 0; i < fndims; i++) + { + tmp_start[i + regioncnt * fndims] = region->start[i]; + tmp_count[i + regioncnt * fndims] = region->count[i]; + } + } + } + +#if PIO_ENABLE_LOGGING + /* Log arrays for debug purposes. */ + PLOG((3, "region = %d", region)); + for (int i = 0; i < fndims; i++) + PLOG((3, "tmp_start[%d] = %d tmp_count[%d] = %d", i + regioncnt * fndims, tmp_start[i + regioncnt * fndims], + i + regioncnt * fndims, tmp_count[i + regioncnt * fndims])); +#endif /* PIO_ENABLE_LOGGING */ + + /* Move to next region. */ + if (region) + region = region->next; + } /* next regioncnt */ + + /* IO tasks other than 0 send their starts/counts and data to + * IO task 0. */ + if (ios->io_rank > 0) + { + if ((mpierr = MPI_Send(&iodesc->llen, 1, MPI_OFFSET, 0, ios->io_rank, ios->io_comm))) + return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); + PLOG((3, "sent iodesc->llen = %d", iodesc->llen)); + + if (iodesc->llen > 0) + { + if ((mpierr = MPI_Send(&(iodesc->maxregions), 1, MPI_INT, 0, + ios->num_iotasks + ios->io_rank, ios->io_comm))) + return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); + if ((mpierr = MPI_Send(tmp_count, iodesc->maxregions * fndims, MPI_OFFSET, 0, + 2 * ios->num_iotasks + ios->io_rank, ios->io_comm))) + return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); + if ((mpierr = MPI_Send(tmp_start, iodesc->maxregions * fndims, MPI_OFFSET, 0, + 3 * ios->num_iotasks + ios->io_rank, ios->io_comm))) + return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); + PLOG((3, "sent iodesc->maxregions = %d tmp_count and tmp_start arrays", iodesc->maxregions)); + + if ((mpierr = MPI_Recv(iobuf, iodesc->llen, iodesc->mpitype, 0, + 4 * ios->num_iotasks + ios->io_rank, ios->io_comm, &status))) + return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); + PLOG((3, "received %d elements of data", iodesc->llen)); + } + } + else if (ios->io_rank == 0) + { + /* This is IO task 0. Get starts/counts and data from + * other IO tasks. */ + int maxregions = 0; + size_t loffset, regionsize; + size_t this_start[fndims * iodesc->maxregions]; + size_t this_count[fndims * iodesc->maxregions]; + + for (int rtask = 1; rtask <= ios->num_iotasks; rtask++) + { + if (rtask < ios->num_iotasks) + { + if ((mpierr = MPI_Recv(&tmp_bufsize, 1, MPI_OFFSET, rtask, rtask, ios->io_comm, &status))) + return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); + PLOG((3, "received tmp_bufsize = %d", tmp_bufsize)); + + if (tmp_bufsize > 0) + { + if ((mpierr = MPI_Recv(&maxregions, 1, MPI_INT, rtask, ios->num_iotasks + rtask, + ios->io_comm, &status))) + return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); + if ((mpierr = MPI_Recv(this_count, maxregions * fndims, MPI_OFFSET, rtask, + 2 * ios->num_iotasks + rtask, ios->io_comm, &status))) + return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); + if ((mpierr = MPI_Recv(this_start, maxregions * fndims, MPI_OFFSET, rtask, + 3 * ios->num_iotasks + rtask, ios->io_comm, &status))) + return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); + PLOG((3, "received maxregions = %d this_count, this_start arrays ", maxregions)); + } + } + else + { + maxregions = iodesc->maxregions; + tmp_bufsize = iodesc->llen; + } + PLOG((3, "maxregions = %d tmp_bufsize = %d", maxregions, tmp_bufsize)); + + /* Now get each region of data. */ + loffset = 0; + for (int regioncnt = 0; regioncnt < maxregions; regioncnt++) + { + /* Get pointer where data should go. */ + bufptr = (void *)((char *)iobuf + iodesc->mpitype_size * loffset); + regionsize = 1; + + /* ??? */ + if (rtask < ios->num_iotasks) + { + for (int m = 0; m < fndims; m++) + { + start[m] = this_start[m + regioncnt * fndims]; + count[m] = this_count[m + regioncnt * fndims]; + regionsize *= count[m]; + } + } + else + { + for (int m = 0; m < fndims; m++) + { + start[m] = tmp_start[m + regioncnt * fndims]; + count[m] = tmp_count[m + regioncnt * fndims]; + regionsize *= count[m]; + } + } + loffset += regionsize; + + /* Read the data. */ + /* ierr = nc_get_vara(file->fh, vid, start, count, bufptr); */ + switch (iodesc->piotype) + { + case PIO_BYTE: + return pio_err(ios, file, PIO_EBADTYPE, __FILE__, __LINE__); + case PIO_CHAR: + return pio_err(ios, file, PIO_EBADTYPE, __FILE__, __LINE__); + case PIO_SHORT: + return pio_err(ios, file, PIO_EBADTYPE, __FILE__, __LINE__); + case PIO_INT: + ierr = GDALc_shp_get_int_field(file->pio_ncid); + break; + case PIO_FLOAT: + return pio_err(ios, file, PIO_EBADTYPE, __FILE__, __LINE__); + case PIO_DOUBLE: + ierr = GDALc_shp_get_double_field(file->pio_ncid, vid, start, count, (double *)bufptr); +//>> if (ios->ioproc) { +//>> printf("bufptr: \n"); +//>> int length = sizeof((double *)bufptr)/sizeof((double *)bufptr[0]); +//>> for (int i = 0; i < length; i++) { +//>> printf("%d ", (double *)bufptr[i]); +//>> } +//>> } + break; + default: + return pio_err(ios, file, PIO_EBADTYPE, __FILE__, __LINE__); + } + + /* Check error code of netCDF call. */ + if (ierr) + return check_netcdf(file, ierr, __FILE__, __LINE__); + } + + /* The decomposition may not use all of the active io + * tasks. rtask here is the io task rank and + * ios->num_iotasks is the number of iotasks actually + * used in this decomposition. */ + if (rtask < ios->num_iotasks && tmp_bufsize > 0){ + if ((mpierr = MPI_Send(iobuf, tmp_bufsize, iodesc->mpitype, rtask, + 4 * ios->num_iotasks + rtask, ios->io_comm))) + return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); + } + } + } + } + +#ifdef TIMING + if ((ierr = pio_stop_timer("PIO:read_darray_nc_serial"))) + return pio_err(ios, NULL, ierr, __FILE__, __LINE__); +#endif /* TIMING */ + + PLOG((2, "pio_read_darray_nc_serial complete ierr %d", ierr)); + return PIO_NOERR; +} + +int +GDALc_shp_get_int_field(int fileid) +{ + return PIO_NOERR; +} +int +GDALc_shp_get_double_field(int fileid, int varid, const size_t *startp, + const size_t *countp, double *ip) +{ + OGRFeatureH hF; + file_desc_t *file; /* Pointer to file information. */ + int ierr; + + /* Get file info based on fileid. */ + if ((ierr = pio_get_file(fileid, &file))) + return pio_err(NULL, NULL, ierr, __FILE__, __LINE__); + if (file->hDS == NULL) + return pio_err(NULL, NULL, ierr, __FILE__, __LINE__); + + OGRLayerH hL = OGR_DS_GetLayer( file->hDS, 0 ); + + // here, we have to assume start and count are only one dimension, and have + // only one assigned value. + for (size_t i = startp[0]; ifh. + * @param iotype A pointer to a pio output format. Must be of type + * PIO_IOTYPE_GDAL. + * @param filename The filename to create. + * @param mode The mode for the create operation. + * + * @returns 0 for success, error code otherwise. + * @ingroup PIO_createfile_c + * @author Michael Long. Adapted from work by Ed Hartnett + */ +int +GDALc_createfile_shp(int iosysid, int *fileidp, int *iotype, const char *filename, bool mode) +{ + iosystem_desc_t *ios; /* Pointer to io system information. */ + file_desc_t *file; /* Pointer to file information. */ + int mpierr = MPI_SUCCESS, mpierr2; /* Return code from MPI function codes. */ + int ierr; /* Return code from function calls. */ + +#ifdef USE_MPE + pio_start_mpe_log(CREATE); +#endif /* USE_MPE */ + + /* Get the IO system info from the iosysid. */ + if (!(ios = pio_get_iosystem_from_id(iosysid))) + return pio_err(NULL, NULL, PIO_EBADID, __FILE__, __LINE__); + + /* User must provide valid input for these parameters. */ + if (!fileidp || !iotype || !filename || strlen(filename) > PIO_MAX_NAME) + return pio_err(ios, NULL, PIO_EINVAL, __FILE__, __LINE__); + + /* A valid iotype must be specified. */ + if (!iotype_is_valid(*iotype)) + return pio_err(ios, NULL, PIO_EINVAL, __FILE__, __LINE__); + + PLOG((1, "GDALc_createfile_int iosysid %d iotype %d filename %s mode %d " + , iosysid, *iotype, filename, mode)); + + /* Allocate space for the file info. */ + if (!(file = calloc(sizeof(file_desc_t), 1))) + return pio_err(ios, NULL, PIO_ENOMEM, __FILE__, __LINE__); + + /* Fill in some file values. */ + file->fh = -1; + file->iosystem = ios; + file->iotype = *iotype; + file->buffer = NULL; + file->writable = 1; + + /* Set to true if this task should participate in IO (only true for + * one task with netcdf serial files. */ + if (ios->io_rank == 0) + file->do_io = 1; + + PLOG((2, "file->do_io = %d ios->async = %d", file->do_io, ios->async)); + + /* If this task is in the IO component, do the IO. */ + if (ios->ioproc) + { + switch (file->iotype) + { + case PIO_IOTYPE_GDAL: + PLOG((2, "Calling GDALCreate io_comm = %d mode = %d fh = %d", + ios->io_comm, mode, file->fh)); + + OGRSpatialReferenceH hSpatial=OSRNewSpatialReference( NULL ); + int err = OSRSetWellKnownGeogCS( hSpatial, "WGS84"); + if (err != OGRERR_NONE ) { + printf("Error setting CRS. %d\n", err); + } + + const char *pszDriverName = "ESRI Shapefile"; + GDALDriverH hDriver = GDALGetDriverByName( pszDriverName ); + if( hDriver == NULL ) + { + printf( "%s driver not available.\n", pszDriverName ); + exit( 1 ); + } + + file->hDS = GDALCreate( hDriver, filename, 0, 0, 0, GDT_Unknown, NULL ); + if( file->hDS == NULL ) + { + printf( "Creation of output file failed.\n" ); + exit( 1 ); + } + PLOG((2, "GDALCreate returned %d file->fh = %d", ierr, file->fh)); + OGRLayerH hLayer = OGR_DS_CreateLayer( file->hDS, "test_", hSpatial, wkbMultiPolygon, NULL ); + if( hLayer == NULL ) + { + printf( "Layer creation failed.\n" ); + exit( 1 ); + } + break; + } + PLOG((3, "create call complete file->fh %d", file->fh)); + } + + /* Broadcast and check the return code. */ + if ((mpierr = MPI_Bcast(&ierr, 1, MPI_INT, ios->ioroot, ios->my_comm))) + return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); + + /* If there was an error, free the memory we allocated and handle error. */ + if (ierr) + { + free(file); + return check_netcdf2(ios, NULL, ierr, __FILE__, __LINE__); + } + + /* Broadcast writablility to all tasks. */ + if ((mpierr = MPI_Bcast(&file->writable, 1, MPI_INT, ios->ioroot, ios->my_comm))) + return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); + + /* Broadcast next fileid to all tasks from io root, necessary + * because files may be opened on mutilple iosystems, causing the + * underlying library to reuse fileids. Hilarious confusion + * ensues. */ + + /* Assign the PIO ncid. */ + file->pio_ncid = pio_next_ncid++; + + PLOG((2, "file->fh = %d file->pio_ncid = %d", file->fh, file->pio_ncid)); + + /* Return the ncid to the caller. */ + *fileidp = file->pio_ncid; + + /* Add the struct with this files info to the global list of + * open files. */ + pio_add_to_file_list(file); + +#ifdef USE_MPE + pio_stop_mpe_log(CREATE, __func__); +#endif /* USE_MPE */ + PLOG((2, "Created file %s file->fh = %d file->pio_ncid = %d", filename, + file->fh, file->pio_ncid)); + + return ierr; +} + +/** + * The PIO-C interface for the NetCDF function nc_def_var + * + * This routine is called collectively by all tasks in the communicator + * ios.union_comm. For more information on the underlying NetCDF commmand + * please read about this function in the NetCDF documentation at: + * http://www.unidata.ucar.edu/software/netcdf/docs/group__variables.html + * + * @param ncid the ncid of the open file, obtained from + * PIOc_openfile() or PIOc_createfile(). + * @param name the variable name. + * @param xtype the PIO_TYPE of the variable. + * @param ndims the number of dimensions. + * @param dimidsp pointer to array of dimension IDs. + * @param varidp a pointer that will get the variable ID. + * @return PIO_NOERR for success, error code otherwise. + * @ingroup PIO_def_var_c + * @author Jim Edwards, Ed Hartnett + */ +int +GDALc_def_field(int fileid, const char *name, int xtype, int *varidp) +{ + iosystem_desc_t *ios; /* Pointer to io system information. */ + file_desc_t *file; /* Pointer to file information. */ + int invalid_unlim_dim = 0; /* True invalid dims are used. */ + int varid; /* The varid of the created var. */ + int rec_var = 0; /* Non-zero if this var uses unlimited dim. */ + PIO_Offset pio_type_size; /* Size of pio type in bytes. */ + MPI_Datatype mpi_type; /* The correspoding MPI type. */ + int mpi_type_size; /* Size of mpi type. */ + int mpierr = MPI_SUCCESS, mpierr2; /* Return code from MPI function codes. */ + int ierr; /* Return code from function calls. */ + + int ndims = 1; // fixed for the moment + + /* Get the file information. */ + if ((ierr = pio_get_file(fileid, &file))) + return pio_err(NULL, NULL, ierr, __FILE__, __LINE__); + ios = file->iosystem; + + /* User must provide name. */ + if (!name || strlen(name) > NC_MAX_NAME) + return pio_err(ios, file, PIO_EINVAL, __FILE__, __LINE__); + +// PLOG((1, "GDALc_def_var ncid = %d name = %s xtype = %d ndims = %d", ncid, name, +// xtype, ndims)); + + /* Run this on all tasks if async is not in use, but only on + * non-IO tasks if async is in use. Learn whether each dimension + * is unlimited. */ + if (!ios->async || !ios->ioproc) + { + int nunlimdims; + + /* Get size of type. */ + switch (xtype) { + case PIO_DOUBLE: + pio_type_size = sizeof(double); + break; + case PIO_REAL: + pio_type_size = sizeof(double); + break; + case PIO_INT: + pio_type_size = sizeof(int); + break; + // This needs to be done. How do we deal with timestamps etc in GDAL vector fields? + //>>case OFTDate: + //>> break; + //>> case OFTTime: + //>> break; + //>> case OFTDate: + //>> break; + //>> case OFTDateTime: + default: + break; + } + /* 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(mpi_type == MPI_DATATYPE_NULL) + mpi_type_size = 0; + else + if ((mpierr = MPI_Type_size(mpi_type, &mpi_type_size))) + return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); + } + + /* If using async, and not an IO task, then send parameters. */ + if (ios->async) + { + if (!ios->ioproc) + { + int msg = PIO_MSG_DEF_VAR; + int namelen = strlen(name); + + if (ios->compmaster == MPI_ROOT) + mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); + + if (!mpierr) + mpierr = MPI_Bcast(&(fileid), 1, MPI_INT, ios->compmaster, ios->intercomm); + if (!mpierr) + mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmaster, ios->intercomm); + if (!mpierr) + mpierr = MPI_Bcast((void *)name, namelen + 1, MPI_CHAR, ios->compmaster, ios->intercomm); + if (!mpierr) + mpierr = MPI_Bcast(&xtype, 1, MPI_INT, ios->compmaster, ios->intercomm); + } + + /* Handle MPI errors. */ + if ((mpierr2 = MPI_Bcast(&mpierr, 1, MPI_INT, ios->comproot, ios->my_comm))) + check_mpi(NULL, file, mpierr2, __FILE__, __LINE__); + if (mpierr) + return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); + + /* Broadcast values currently only known on computation tasks to IO tasks. */ + if ((mpierr = MPI_Bcast(&pio_type_size, 1, MPI_OFFSET, ios->comproot, ios->my_comm))) + check_mpi(NULL, file, mpierr, __FILE__, __LINE__); + if ((mpierr = MPI_Bcast(&mpi_type, 1, MPI_INT, ios->comproot, ios->my_comm))) + check_mpi(NULL, file, mpierr, __FILE__, __LINE__); + if ((mpierr = MPI_Bcast(&mpi_type_size, 1, MPI_INT, ios->comproot, ios->my_comm))) + check_mpi(NULL, file, mpierr, __FILE__, __LINE__); + } + + /* If this is an IO task, then call the GDAL function. */ + if (ios->ioproc) + { + OGRLayerH hL = OGR_DS_GetLayer( file->hDS, 0 ); + OGRFieldDefnH hFD = OGR_Fld_Create( name, OFTReal ); + if( OGR_L_CreateField( hL, hFD, TRUE ) != OGRERR_NONE ) + { + printf( "Creating field failed.\n" ); + exit( 1 ); + } + varid = OGR_L_FindFieldIndex(hL,name,1); + OGR_Fld_Destroy(hFD); + } + + /* Broadcast and check the return code. */ + if ((mpierr = MPI_Bcast(&ierr, 1, MPI_INT, ios->ioroot, ios->my_comm))) + return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); + if (ierr) + return check_netcdf(file, ierr, __FILE__, __LINE__); + + /* Broadcast results. */ + if ((mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->ioroot, ios->my_comm))) + check_mpi(NULL, file, mpierr, __FILE__, __LINE__); + if (varidp) + *varidp = varid; + + /* Add to the list of var_desc_t structs for this file. */ + if ((ierr = add_to_varlist(varid, rec_var, xtype, (int)pio_type_size, mpi_type, + mpi_type_size, ndims, &file->varlist))) + return pio_err(ios, NULL, ierr, __FILE__, __LINE__); + file->nvars++; + + return PIO_NOERR; +} + +/* */ +int +gdal_write_darray_multi_serial(file_desc_t *file, int nvars, int fndims, const int *varids, + io_desc_t *iodesc, int fill, const int *frame) +{ + iosystem_desc_t *ios; /* Pointer to io system information. */ + var_desc_t *vdesc; /* Contains info about the variable. */ + int ierr; /* Return code. */ + + PLOG((1, "nvars = %d fndims = %d varids[0] = %d maxvars = %d", nvars, fndims, varids[0], PIO_MAX_VARS)); + + /* Check inputs. */ + pioassert(file && file->iosystem && varids && varids[0] >= 0 && + varids[0] <= PIO_MAX_VARS && iodesc, "invalid input", __FILE__, __LINE__); + + PLOG((1, "write_darray_multi_serial nvars = %d fndims = %d iodesc->ndims = %d " + "iodesc->mpitype = %d", nvars, fndims, iodesc->ndims, iodesc->mpitype)); + + /* Get the iosystem info. */ + ios = file->iosystem; + + /* Get the var info. */ + if ((ierr = get_var_desc(varids[0], &file->varlist, &vdesc))) + return pio_err(NULL, file, ierr, __FILE__, __LINE__); + + /* Set these differently for data and fill writing. iobuf may be + * null if array size < number of nodes. */ + int num_regions = fill ? iodesc->maxfillregions: iodesc->maxregions; + io_region *region = fill ? iodesc->fillregion : iodesc->firstregion; + PIO_Offset llen = fill ? iodesc->holegridsize : iodesc->llen; + void *iobuf = fill ? vdesc->fillbuf : file->iobuf; + +#ifdef TIMING + /* Start timer if desired. */ + if ((ierr = pio_start_timer("PIO:write_darray_multi_serial"))) + return pio_err(ios, NULL, ierr, __FILE__, __LINE__); +#endif /* TIMING */ + + /* Only IO tasks participate in this code. */ + if (ios->ioproc) + { + size_t tmp_start[fndims * num_regions]; /* A start array for each region. */ + size_t tmp_count[fndims * num_regions]; /* A count array for each region. */ + + PLOG((3, "num_regions = %d", num_regions)); + + /* Fill the tmp_start and tmp_count arrays, which contain the + * start and count arrays for all regions. */ + if ((ierr = find_all_start_count(region, num_regions, fndims, iodesc->ndims, vdesc, + tmp_start, tmp_count))) + return pio_err(ios, file, ierr, __FILE__, __LINE__); + + /* Tasks other than 0 will send their data to task 0. */ + if (ios->io_rank > 0) + { + /* Send the tmp_start and tmp_count arrays from this IO task + * to task 0. */ + if ((ierr = send_all_start_count(ios, iodesc, llen, num_regions, nvars, fndims, + tmp_start, tmp_count, iobuf))) + return pio_err(ios, file, ierr, __FILE__, __LINE__); + } + else + { + /* Task 0 will receive data from all other IO tasks. */ + + if ((ierr = recv_and_write_shp(file, varids, frame, iodesc, llen, num_regions, nvars, fndims, + tmp_start, tmp_count, iobuf))) + return pio_err(ios, file, ierr, __FILE__, __LINE__); + } + } + +#ifdef TIMING + if ((ierr = pio_stop_timer("PIO:write_darray_multi_serial"))) + return pio_err(ios, NULL, ierr, __FILE__, __LINE__); +#endif /* TIMING */ + + return PIO_NOERR; +} + +int +recv_and_write_shp(file_desc_t *file, const int *varids, const int *frame, + io_desc_t *iodesc, PIO_Offset llen, int maxregions, int nvars, + int fndims, size_t *tmp_start, size_t *tmp_count, void *iobuf) +{ + iosystem_desc_t *ios; /* Pointer to io system information. */ + size_t rlen; /* Length of IO buffer on this task. */ + int rregions; /* Number of regions in buffer for this task. */ + size_t start[fndims], count[fndims]; + size_t loffset; + void *bufptr; + var_desc_t *vdesc; /* Contains info about the variable. */ + MPI_Status status; /* Recv status for MPI. */ + int mpierr; /* Return code from MPI function codes. */ + int ierr; /* Return code. */ + + /* Check inputs. */ + pioassert(file && varids && iodesc && tmp_start && tmp_count, "invalid input", + __FILE__, __LINE__); + + PLOG((2, "recv_and_write_data llen = %d maxregions = %d nvars = %d fndims = %d", + llen, maxregions, nvars, fndims)); + + /* Get pointer to IO system. */ + ios = file->iosystem; + + /* For each of the other tasks that are using this task + * for IO. */ + for (int rtask = 0; rtask < ios->num_iotasks; rtask++) + { + /* From the remote tasks, we send information about + * the data regions. and also the data. */ + if (rtask) + { + /* handshake - tell the sending task I'm ready */ + if ((mpierr = MPI_Send(&ierr, 1, MPI_INT, rtask, 0, ios->io_comm))) + return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); + + /* Get length of iobuffer for each field on this + * task (all fields are the same length). */ + if ((mpierr = MPI_Recv(&rlen, 1, MPI_OFFSET, rtask, rtask, ios->io_comm, + &status))) + return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); + PLOG((3, "received rlen = %d", rlen)); + + /* Get the number of regions, the start/count + * values for all regions, and the data buffer. */ + if (rlen > 0) + { + if ((mpierr = MPI_Recv(&rregions, 1, MPI_INT, rtask, rtask + ios->num_iotasks, + ios->io_comm, &status))) + return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); + if ((mpierr = MPI_Recv(tmp_start, rregions * fndims, MPI_OFFSET, rtask, + rtask + 2 * ios->num_iotasks, ios->io_comm, &status))) + return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); + if ((mpierr = MPI_Recv(tmp_count, rregions * fndims, MPI_OFFSET, rtask, + rtask + 3 * ios->num_iotasks, ios->io_comm, &status))) + return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); + if ((mpierr = MPI_Recv(iobuf, nvars * rlen, iodesc->mpitype, rtask, + rtask + 4 * ios->num_iotasks, ios->io_comm, &status))) + return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); + PLOG((3, "received data rregions = %d fndims = %d", rregions, fndims)); + } + } + else /* task 0 */ + { + rlen = llen; + rregions = maxregions; + } + PLOG((3, "rtask = %d rlen = %d rregions = %d", rtask, rlen, rregions)); + + /* If there is data from this task, write it. */ + if (rlen > 0) + { + loffset = 0; + for (int regioncnt = 0; regioncnt < rregions; regioncnt++) + { + PLOG((3, "writing data for region with regioncnt = %d", regioncnt)); + bool needtowrite = true; + + if ((ierr = get_var_desc(varids[0], &file->varlist, &vdesc))) + return pio_err(NULL, file, ierr, __FILE__, __LINE__); + + /* Get the start/count arrays for this region. */ + for (int i = 0; i < fndims; i++) + { + start[i] = tmp_start[i + regioncnt * fndims]; + count[i] = tmp_count[i + regioncnt * fndims]; + PLOG((3, "needtowrite %d count[%d] %d\n",needtowrite, i, count[i])); + if(i>0 || vdesc->record <0) + needtowrite = (count[i] > 0 && needtowrite); + } + + /* Process each variable in the buffer. */ + for (int nv = 0; nv < nvars; nv++) + { + PLOG((3, "writing buffer var %d", nv)); + + /* Get a pointer to the correct part of the buffer. */ + bufptr = (void *)((char *)iobuf + iodesc->mpitype_size * (nv * rlen + loffset)); + + /* If this var has an unlimited dim, set + * the start on that dim to the frame + * value for this variable. */ + if (vdesc->record >= 0) + { + if (fndims > 1 && iodesc->ndims < fndims && count[1] > 0) + { + count[0] = 1; + start[0] = frame[nv]; + } + else if (fndims == iodesc->ndims) + { + start[0] += vdesc->record; + } + } + +#ifdef LOGGING + if(needtowrite) + for (int i = 1; i < fndims; i++) + PLOG((3, "(serial) start[%d] %d count[%d] %d needtowrite %d", i, start[i], i, count[i], needtowrite)); +#endif /* LOGGING */ + + /* Call the netCDF functions to write the data. */ +// if (needtowrite) + // ADD POLYGONS + // ADD DATA +// if ((ierr = nc_put_vara(file->fh, varids[nv], start, count, bufptr))) +// return check_netcdf2(ios, NULL, ierr, __FILE__, __LINE__); + + } /* next var */ + + /* Calculate the total size. */ + size_t tsize = 1; + for (int i = 0; i < fndims; i++) + tsize *= count[i]; + + /* Keep track of where we are in the buffer. */ + loffset += tsize; + + PLOG((3, " at bottom of loop regioncnt = %d tsize = %d loffset = %d", regioncnt, + tsize, loffset)); + } /* next regioncnt */ + } /* endif (rlen > 0) */ + } /* next rtask */ + + return PIO_NOERR; +} +/** + * @} + */ diff --git a/src/clib/pio_getput_int.c b/src/clib/pio_getput_int.c index 5ab5904169..ce1014b4ad 100644 --- a/src/clib/pio_getput_int.c +++ b/src/clib/pio_getput_int.c @@ -77,30 +77,30 @@ PIOc_put_att_tc(int ncid, int varid, const char *name, nc_type atttype, { int msg = PIO_MSG_PUT_ATT; - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmaster, ios->intercomm); int namelen = strlen(name); if (!mpierr) - mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast((void *)name, namelen + 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((void *)name, namelen + 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&atttype, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&atttype, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&len, 1, MPI_OFFSET, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&len, 1, MPI_OFFSET, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&atttype_len, 1, MPI_OFFSET, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&atttype_len, 1, MPI_OFFSET, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&memtype, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&memtype, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&memtype_len, 1, MPI_OFFSET, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&memtype_len, 1, MPI_OFFSET, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast((void *)op, len * memtype_len, MPI_BYTE, ios->compmain, + mpierr = MPI_Bcast((void *)op, len * memtype_len, MPI_BYTE, ios->compmaster, ios->intercomm); PLOG((2, "PIOc_put_att finished bcast ncid = %d varid = %d namelen = %d name = %s " "len = %d atttype_len = %d memtype = %d memtype_len = %d", ncid, varid, namelen, @@ -299,32 +299,32 @@ PIOc_get_att_tc(int ncid, int varid, const char *name, nc_type memtype, void *ip int msg = PIO_MSG_GET_ATT; PLOG((2, "sending parameters")); - /* Send the message to IO main. */ - if (ios->compmain == MPI_ROOT) + /* Send the message to IO master. */ + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm); /* Send the function parameters. */ if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmaster, ios->intercomm); int namelen = strlen(name); if (!mpierr) - mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast((void *)name, namelen + 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((void *)name, namelen + 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&file->iotype, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&file->iotype, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&atttype, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&atttype, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&attlen, 1, MPI_OFFSET, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&attlen, 1, MPI_OFFSET, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&atttype_len, 1, MPI_OFFSET, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&atttype_len, 1, MPI_OFFSET, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&memtype, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&memtype, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&memtype_len, 1, MPI_OFFSET, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&memtype_len, 1, MPI_OFFSET, ios->compmaster, ios->intercomm); PLOG((2, "Bcast complete ncid = %d varid = %d namelen = %d name = %s iotype = %d " "atttype = %d attlen = %d atttype_len = %d", ncid, varid, namelen, name, file->iotype, atttype, attlen, atttype_len)); @@ -563,35 +563,35 @@ PIOc_get_vars_tc(int ncid, int varid, const PIO_Offset *start, const PIO_Offset { int msg = PIO_MSG_GET_VARS; - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); /* Send the function parameters and associated informaiton * to the msg handler. */ if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&ndims, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ndims, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&start_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&start_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr && start_present) - mpierr = MPI_Bcast((PIO_Offset *)start, ndims, MPI_OFFSET, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((PIO_Offset *)start, ndims, MPI_OFFSET, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&count_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&count_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr && count_present) - mpierr = MPI_Bcast((PIO_Offset *)count, ndims, MPI_OFFSET, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((PIO_Offset *)count, ndims, MPI_OFFSET, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&stride_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&stride_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr && stride_present) - mpierr = MPI_Bcast((PIO_Offset *)stride, ndims, MPI_OFFSET, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((PIO_Offset *)stride, ndims, MPI_OFFSET, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&xtype, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&xtype, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&num_elem, 1, MPI_OFFSET, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&num_elem, 1, MPI_OFFSET, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&typelen, 1, MPI_OFFSET, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&typelen, 1, MPI_OFFSET, ios->compmaster, ios->intercomm); PLOG((2, "PIOc_get_vars_tc ncid = %d varid = %d ndims = %d start_present = %d " "count_present = %d stride_present = %d xtype = %d num_elem = %d", ncid, varid, ndims, start_present, count_present, stride_present, xtype, num_elem)); @@ -641,9 +641,9 @@ PIOc_get_vars_tc(int ncid, int varid, const PIO_Offset *start, const PIO_Offset if ((ierr = ncmpi_begin_indep_data(file->fh))) return pio_err(ios, file, ierr, __FILE__, __LINE__); - /* Only the IO main does the IO, so we are not really + /* Only the IO master does the IO, so we are not really * getting parallel IO here. */ - if (ios->iomain == MPI_ROOT) + if (ios->iomaster == MPI_ROOT) { switch(xtype) { @@ -1010,42 +1010,42 @@ PIOc_put_vars_tc(int ncid, int varid, const PIO_Offset *start, const PIO_Offset { int msg = PIO_MSG_PUT_VARS; - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); /* Send the function parameters and associated informaiton * to the msg handler. */ if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&ndims, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ndims, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&start_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&start_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr && start_present) - mpierr = MPI_Bcast((PIO_Offset *)start, ndims, MPI_OFFSET, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((PIO_Offset *)start, ndims, MPI_OFFSET, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&count_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&count_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr && count_present) - mpierr = MPI_Bcast((PIO_Offset *)count, ndims, MPI_OFFSET, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((PIO_Offset *)count, ndims, MPI_OFFSET, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&stride_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&stride_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr && stride_present) - mpierr = MPI_Bcast((PIO_Offset *)stride, ndims, MPI_OFFSET, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((PIO_Offset *)stride, ndims, MPI_OFFSET, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&xtype, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&xtype, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&num_elem, 1, MPI_OFFSET, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&num_elem, 1, MPI_OFFSET, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&typelen, 1, MPI_OFFSET, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&typelen, 1, MPI_OFFSET, ios->compmaster, ios->intercomm); PLOG((2, "PIOc_put_vars_tc ncid = %d varid = %d ndims = %d start_present = %d " "count_present = %d stride_present = %d xtype = %d num_elem = %d", ncid, varid, ndims, start_present, count_present, stride_present, xtype, num_elem)); /* Send the data. */ if (!mpierr) - mpierr = MPI_Bcast((void *)buf, num_elem * typelen, MPI_BYTE, ios->compmain, + mpierr = MPI_Bcast((void *)buf, num_elem * typelen, MPI_BYTE, ios->compmaster, ios->intercomm); } @@ -1085,38 +1085,95 @@ PIOc_put_vars_tc(int ncid, int varid, const PIO_Offset *start, const PIO_Offset #ifdef _PNETCDF if (file->iotype == PIO_IOTYPE_PNETCDF) { - if (ios->iomain == MPI_ROOT) + /* Scalars have to be handled differently. */ + if (ndims == 0) + { + /* This is a scalar var. */ + PLOG((2, "pnetcdf writing scalar with ncmpi_put_vars_*() file->fh = %d varid = %d", + file->fh, varid)); + pioassert(!start && !count && !stride, "expected NULLs", __FILE__, __LINE__); + + /* Turn on independent access for pnetcdf file. */ + if ((ierr = ncmpi_begin_indep_data(file->fh))) + return pio_err(ios, file, ierr, __FILE__, __LINE__); + + /* Only the IO master does the IO, so we are not really + * getting parallel IO here. */ + if (ios->iomaster == MPI_ROOT) + { + switch(xtype) + { + case NC_BYTE: + ierr = ncmpi_put_vars_schar(file->fh, varid, start, count, stride, buf); + break; + case NC_CHAR: + ierr = ncmpi_put_vars_text(file->fh, varid, start, count, stride, buf); + break; + case NC_SHORT: + ierr = ncmpi_put_vars_short(file->fh, varid, start, count, stride, buf); + break; + case NC_INT: + ierr = ncmpi_put_vars_int(file->fh, varid, start, count, stride, buf); + break; + case PIO_LONG_INTERNAL: + ierr = ncmpi_put_vars_long(file->fh, varid, start, count, stride, buf); + break; + case NC_FLOAT: + ierr = ncmpi_put_vars_float(file->fh, varid, start, count, stride, buf); + break; + case NC_DOUBLE: + ierr = ncmpi_put_vars_double(file->fh, varid, start, count, stride, buf); + break; + default: + return pio_err(ios, file, PIO_EBADIOTYPE, __FILE__, __LINE__); + } + } + + /* Turn off independent access for pnetcdf file. */ + if ((ierr = ncmpi_end_indep_data(file->fh))) + return pio_err(ios, file, ierr, __FILE__, __LINE__); + } + else { /* This is not a scalar var. */ var_desc_t *vdesc; - + int *request; + PLOG((2, "PIOc_put_vars_tc calling pnetcdf function")); - + flush_output_buffer(file, false, num_elem*typelen); + + /*vdesc = &file->varlist[varid];*/ if ((ierr = get_var_desc(varid, &file->varlist, &vdesc))) return pio_err(ios, file, ierr, __FILE__, __LINE__); - + if (vdesc->nreqs % PIO_REQUEST_ALLOC_CHUNK == 0) + if (!(vdesc->request = realloc(vdesc->request, + sizeof(int) * (vdesc->nreqs + PIO_REQUEST_ALLOC_CHUNK)))) + return pio_err(ios, file, PIO_ENOMEM, __FILE__, __LINE__); + request = vdesc->request + vdesc->nreqs; + PLOG((2, "PIOc_put_vars_tc request = %d size = %d", vdesc->request, num_elem*typelen)); + switch(xtype) { case NC_BYTE: - ierr = ncmpi_bput_vars_schar(file->fh, varid, start, count, fake_stride, buf, NULL); + ierr = ncmpi_bput_vars_schar(file->fh, varid, start, count, fake_stride, buf, request); break; case NC_CHAR: - ierr = ncmpi_bput_vars_text(file->fh, varid, start, count, fake_stride, buf, NULL); + ierr = ncmpi_bput_vars_text(file->fh, varid, start, count, fake_stride, buf, request); break; case NC_SHORT: - ierr = ncmpi_bput_vars_short(file->fh, varid, start, count, fake_stride, buf, NULL); + ierr = ncmpi_bput_vars_short(file->fh, varid, start, count, fake_stride, buf, request); break; case NC_INT: - ierr = ncmpi_bput_vars_int(file->fh, varid, start, count, fake_stride, buf, NULL); + ierr = ncmpi_bput_vars_int(file->fh, varid, start, count, fake_stride, buf, request); break; case PIO_LONG_INTERNAL: - ierr = ncmpi_bput_vars_long(file->fh, varid, start, count, fake_stride, buf, NULL); + ierr = ncmpi_bput_vars_long(file->fh, varid, start, count, fake_stride, buf, request); break; case NC_FLOAT: - ierr = ncmpi_bput_vars_float(file->fh, varid, start, count, fake_stride, buf, NULL); + ierr = ncmpi_bput_vars_float(file->fh, varid, start, count, fake_stride, buf, request); break; case NC_DOUBLE: - ierr = ncmpi_bput_vars_double(file->fh, varid, start, count, fake_stride, buf, NULL); + ierr = ncmpi_bput_vars_double(file->fh, varid, start, count, fake_stride, buf, request); break; default: return pio_err(ios, file, PIO_EBADTYPE, __FILE__, __LINE__); @@ -1125,11 +1182,13 @@ PIOc_put_vars_tc(int ncid, int varid, const PIO_Offset *start, const PIO_Offset vdesc->nreqs++; +// flush_output_buffer(file, ierr == PIO_EINSUFFBUF, 0); +// PLOG((2, "PIOc_put_vars_tc flushed output buffer")); if(ierr == PIO_EINVALCOORDS) for(int i=0; i #include #include -#include #include #include #include -#ifdef NC_HAS_PAR_FILTERS -#include -#include -#endif #ifdef _NETCDF4 #include #endif @@ -35,22 +30,6 @@ #include #endif /* USE_MPE */ -/* define an MPI type equivalent to size_t */ -#if SIZE_MAX == UCHAR_MAX - #define PIO_MPI_SIZE_T MPI_UNSIGNED_CHAR -#elif SIZE_MAX == USHRT_MAX - #define PIO_MPI_SIZE_T MPI_UNSIGNED_SHORT -#elif SIZE_MAX == UINT_MAX - #define PIO_MPI_SIZE_T MPI_UNSIGNED -#elif SIZE_MAX == ULONG_MAX - #define PIO_MPI_SIZE_T MPI_UNSIGNED_LONG -#elif SIZE_MAX == ULLONG_MAX - #define PIO_MPI_SIZE_T MPI_UNSIGNED_LONG_LONG -#else - #error "what is happening here?" -#endif - - //#ifndef MPI_OFFSET /** MPI_OFFSET is an integer type of size sufficient to represent the * size (in bytes) of the largest file supported by MPI. In some MPI @@ -86,7 +65,7 @@ /** Some MPI implementations do not allow passing MPI_DATATYPE_NULL to * comm functions even though the send or recv length is 0, in these * cases we use MPI_CHAR, after this issue raised its ugly head again in mpich - * 4.0.0 we decided to use this workaround in all cases. + * 4.0.0 we decided to use this workaround in all cases. * See https://github.com/NCAR/ParallelIO/issues/1945 */ #define PIO_DATATYPE_NULL MPI_CHAR @@ -634,7 +613,6 @@ enum PIO_MSG PIO_MSG_DEF_VAR_DEFLATE, PIO_MSG_INQ_VAR_DEFLATE, PIO_MSG_INQ_VAR_SZIP, - PIO_MSG_DEF_VAR_SZIP, PIO_MSG_DEF_VAR_FLETCHER32, PIO_MSG_INQ_VAR_FLETCHER32, PIO_MSG_DEF_VAR_CHUNKING, @@ -660,24 +638,7 @@ enum PIO_MSG PIO_MSG_GET_ATT, PIO_MSG_PUT_ATT, PIO_MSG_INQ_TYPE, - PIO_MSG_INQ_UNLIMDIMS, -#ifdef NC_HAS_BZ2 - PIO_MSG_INQ_VAR_BZIP2, - PIO_MSG_DEF_VAR_BZIP2, -#endif -#ifdef NC_HAS_ZSTD - PIO_MSG_INQ_VAR_ZSTANDARD, - PIO_MSG_DEF_VAR_ZSTANDARD, -#endif - PIO_MSG_DEF_VAR_FILTER, - PIO_MSG_INQ_VAR_FILTER_IDS, - PIO_MSG_INQ_VAR_FILTER_INFO, - PIO_MSG_INQ_FILTER_AVAIL, - -#ifdef NC_HAS_QUANTIZE - PIO_MSG_DEF_VAR_QUANTIZE, - PIO_MSG_INQ_VAR_QUANTIZE, -#endif + PIO_MSG_INQ_UNLIMDIMS }; #endif /* __PIO_INTERNAL__ */ diff --git a/src/clib/pio_meta.h.in b/src/clib/pio_meta.h.in index b98f10d73d..a735a89002 100644 --- a/src/clib/pio_meta.h.in +++ b/src/clib/pio_meta.h.in @@ -22,11 +22,10 @@ #define PIO_VERSION_MINOR @PIO_VERSION_MINOR@ /*!< pio-c minor version. */ #define PIO_VERSION_PATCH @PIO_VERSION_PATCH@ /*!< pio-c patch version. */ #define PIO_VERSION "@PACKAGE_VERSION@" -#ifndef PIO_HAS_PAR_FILTERS -#define PIO_HAS_PAR_FILTERS @PIO_HAS_PAR_FILTERS@ /*!< NetCDF supports parallel I/O with filters. */ -#endif + #define PIO_HAS_SZIP_WRITE @PIO_HAS_SZIP_WRITE@ /*!< szip write support */ #define PIO_HAS_PNETCDF @PIO_HAS_PNETCDF@ /*!< PnetCDF support. */ +#define PIO_HAS_PAR_FILTERS @PIO_HAS_PAR_FILTERS@ /*!< NetCDF supports parallel I/O with filters. */ #define PIO_HAS_NETCDF4 @PIO_HAS_NETCDF4@ /*!< NetCDF-4 supported. */ #define PIO_HAS_NETCDF4_PAR @PIO_HAS_NETCDF4_PAR@ /*!< NetCDF-4 parallel I/O supported. */ #define PIO_HAS_NETCDF_INTEGRATION @PIO_HAS_NETCDF_INTEGRATION@ /*!< NetCDF integration supported. */ diff --git a/src/clib/pio_msg.c b/src/clib/pio_msg.c index 3302ae7a36..f49384d297 100644 --- a/src/clib/pio_msg.c +++ b/src/clib/pio_msg.c @@ -14,9 +14,9 @@ * @author Ed Hartnett */ +#include #include #include -#include #ifdef PIO_ENABLE_LOGGING extern int my_rank; @@ -50,7 +50,7 @@ int inq_type_handler(iosystem_desc_t *ios) PLOG((1, "inq_type_handler")); assert(ios); - /* Get the parameters for this function that the the comp main + /* Get the parameters for this function that the the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -94,7 +94,7 @@ int inq_format_handler(iosystem_desc_t *ios) PLOG((1, "inq_format_handler")); assert(ios); - /* Get the parameters for this function that the the comp main + /* Get the parameters for this function that the the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -134,7 +134,7 @@ int set_fill_handler(iosystem_desc_t *ios) PLOG((1, "set_fill_handler")); assert(ios); - /* Get the parameters for this function that the the comp main + /* Get the parameters for this function that the the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -182,7 +182,7 @@ int create_file_handler(iosystem_desc_t *ios) PLOG((1, "create_file_handler comproot = %d", ios->comproot)); assert(ios); - /* Get the parameters for this function that the he comp main + /* Get the parameters for this function that the he comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&len, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -252,7 +252,7 @@ int close_file_handler(iosystem_desc_t *ios) PLOG((1, "close_file_handler")); assert(ios); - /* Get the parameters for this function that the the comp main + /* Get the parameters for this function that the the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -286,7 +286,7 @@ int inq_handler(iosystem_desc_t *ios) PLOG((1, "inq_handler")); assert(ios); - /* Get the parameters for this function that the the comp main + /* Get the parameters for this function that the the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -341,7 +341,7 @@ int inq_unlimdims_handler(iosystem_desc_t *ios) PLOG((1, "inq_unlimdims_handler")); assert(ios); - /* Get the parameters for this function that the the comp main + /* Get the parameters for this function that the the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -390,7 +390,7 @@ int inq_dim_handler(iosystem_desc_t *ios, int msg) PLOG((1, "inq_dim_handler")); assert(ios); - /* Get the parameters for this function that the the comp main + /* Get the parameters for this function that the the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -436,7 +436,7 @@ int inq_dimid_handler(iosystem_desc_t *ios) PLOG((1, "inq_dimid_handler")); assert(ios); - /* Get the parameters for this function that the the comp main + /* Get the parameters for this function that the the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -483,15 +483,15 @@ int inq_att_handler(iosystem_desc_t *ios) PLOG((1, "inq_att_handler")); assert(ios); - /* Get the parameters for this function that the the comp main + /* Get the parameters for this function that the the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); if ((mpierr = MPI_Bcast(&varid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmain, ios->intercomm))) + if ((mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmaster, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(name, namelen + 1, MPI_CHAR, ios->compmain, + if ((mpierr = MPI_Bcast(name, namelen + 1, MPI_CHAR, ios->compmaster, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); if ((mpierr = MPI_Bcast(&xtype_present, 1, MPI_CHAR, 0, ios->intercomm))) @@ -534,13 +534,13 @@ int inq_attname_handler(iosystem_desc_t *ios) PLOG((1, "inq_att_name_handler")); assert(ios); - /* Get the parameters for this function that the the comp main + /* Get the parameters for this function that the the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); if ((mpierr = MPI_Bcast(&varid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(&attnum, 1, MPI_INT, ios->compmain, ios->intercomm))) + if ((mpierr = MPI_Bcast(&attnum, 1, MPI_INT, ios->compmaster, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); if ((mpierr = MPI_Bcast(&name_present, 1, MPI_CHAR, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -579,15 +579,15 @@ int inq_attid_handler(iosystem_desc_t *ios) PLOG((1, "inq_attid_handler")); assert(ios); - /* Get the parameters for this function that the the comp main + /* Get the parameters for this function that the the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); if ((mpierr = MPI_Bcast(&varid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmain, ios->intercomm))) + if ((mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmaster, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(name, namelen + 1, MPI_CHAR, ios->compmain, ios->intercomm))) + if ((mpierr = MPI_Bcast(name, namelen + 1, MPI_CHAR, ios->compmaster, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); if ((mpierr = MPI_Bcast(&id_present, 1, MPI_CHAR, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -629,15 +629,15 @@ int att_put_handler(iosystem_desc_t *ios) PLOG((1, "att_put_handler")); assert(ios); - /* Get the parameters for this function that the the comp main + /* Get the parameters for this function that the the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); if ((mpierr = MPI_Bcast(&varid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmain, ios->intercomm))) + if ((mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmaster, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(name, namelen + 1, MPI_CHAR, ios->compmain, ios->intercomm))) + if ((mpierr = MPI_Bcast(name, namelen + 1, MPI_CHAR, ios->compmaster, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); if ((mpierr = MPI_Bcast(&atttype, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -698,15 +698,15 @@ int att_get_handler(iosystem_desc_t *ios) PLOG((1, "att_get_handler")); assert(ios); - /* Get the parameters for this function that the the comp main + /* Get the parameters for this function that the the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); if ((mpierr = MPI_Bcast(&varid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmain, ios->intercomm))) + if ((mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmaster, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(name, namelen + 1, MPI_CHAR, ios->compmain, ios->intercomm))) + if ((mpierr = MPI_Bcast(name, namelen + 1, MPI_CHAR, ios->compmaster, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); if ((mpierr = MPI_Bcast(&iotype, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -765,7 +765,7 @@ int put_vars_handler(iosystem_desc_t *ios) PLOG((1, "put_vars_handler")); assert(ios); - /* Get the parameters for this function that the the comp main + /* Get the parameters for this function that the the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -906,7 +906,7 @@ int get_vars_handler(iosystem_desc_t *ios) PLOG((1, "get_vars_handler")); assert(ios); - /* Get the parameters for this function that the the comp main + /* Get the parameters for this function that the the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -1051,7 +1051,7 @@ int inq_var_handler(iosystem_desc_t *ios) PLOG((1, "inq_var_handler")); assert(ios); - /* Get the parameters for this function that the the comp main + /* Get the parameters for this function that the the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -1112,7 +1112,7 @@ int inq_var_chunking_handler(iosystem_desc_t *ios) assert(ios); PLOG((1, "inq_var_chunking_handler")); - /* Get the parameters for this function that the the comp main + /* Get the parameters for this function that the the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -1142,350 +1142,6 @@ int inq_var_chunking_handler(iosystem_desc_t *ios) return PIO_NOERR; } -#ifdef PIO_HAS_PAR_FILTERS -/** - * Do an inq_var_filter_ids on a netCDF variable. This function is only - * run on IO tasks. - * - * @param ios pointer to the iosystem_desc_t. - * @returns 0 for success, error code otherwise. - */ -int inq_var_filter_ids_handler(iosystem_desc_t *ios) -{ - int ncid; - int varid; - size_t *nfiltersp=NULL; - unsigned int *ids=NULL; - size_t nfilters; - char nfilters_present; - char ids_present; - size_t idsize=0; - int mpierr; - - assert(ios); - PLOG((1, "inq_var_filter_ids_handler")); - - /* Get the parameters for this function that the the comp main - * task is broadcasting. */ - if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(&varid, 1, MPI_INT, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(&nfilters_present, 1, MPI_CHAR, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(&ids_present, 1, MPI_CHAR, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if(ids_present){ - if ((mpierr = MPI_Bcast(&idsize, 1, PIO_MPI_SIZE_T, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if (!(ids = malloc(idsize *sizeof(size_t)))) - return pio_err(ios, NULL, PIO_ENOMEM, __FILE__, __LINE__); - } - - PLOG((2,"inq_var_filter_ids_handler ncid = %d varid = %d nfilters_present = %d ids_present = %d idsize = %d", - ncid, varid, nfilters_present, ids_present, idsize)); - - /* Set the non-NULL pointers. */ - if(nfilters_present) - nfiltersp = &nfilters; - - /* Call the inq function to get the values. */ - PIOc_inq_var_filter_ids(ncid, varid, nfiltersp, ids); - - if(ids_present) - free(ids); - - return PIO_NOERR; -} -#ifdef NC_HAS_BZ2 -/** - * Do an inq_var_bzip2 on a netCDF variable. This function is only - * run on IO tasks. - * - * @param ios pointer to the iosystem_desc_t. - * @returns 0 for success, error code otherwise. - */ -int inq_var_bzip2_handler(iosystem_desc_t *ios) -{ - int ncid; - int varid; - int *hasfilterp=NULL; - int *levelp=NULL; - char hasfilterp_present; - char levelp_present; - int hasfilter; - int level; - int mpierr; - - assert(ios); - PLOG((1, "inq_var_bzip2_handler")); - - /* Get the parameters for this function that the the comp main - * task is broadcasting. */ - if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(&varid, 1, MPI_INT, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(&hasfilterp_present, 1, MPI_CHAR, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(&levelp_present, 1, MPI_CHAR, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - - PLOG((2,"inq_var_bzip2_handler ncid = %d varid = %d hasfilter_present = %d ", - ncid, varid, hasfilterp_present, levelp_present)); - - /* Set the non-NULL pointers. */ - if(hasfilterp_present) - hasfilterp = &hasfilter; - if(levelp_present) - levelp = &level; - - /* Call the inq function to get the values. */ - PIOc_inq_var_bzip2(ncid, varid, hasfilterp, levelp); - - return PIO_NOERR; -} -#endif - -#ifdef PIO_HAS_PAR_FILTERS -/** - * Do an inq_var_filter_info on a netCDF variable. This function is only - * run on IO tasks. - * - * @param ios pointer to the iosystem_desc_t. - * @returns 0 for success, error code otherwise. - */ -int inq_var_filter_info_handler(iosystem_desc_t *ios) -{ - int ncid; - int varid; - unsigned int id; - size_t *nparamsp = NULL; - size_t nparams; - unsigned int *params = NULL; - char nparams_present; - char params_present; - size_t paramssize; - int mpierr; - - assert(ios); - PLOG((1, "inq_var_filter_info_handler")); - - /* Get the parameters for this function that the the comp main - * task is broadcasting. */ - if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(&varid, 1, MPI_INT, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(&id, 1, MPI_UNSIGNED, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(&nparams_present, 1, MPI_CHAR, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(¶ms_present, 1, MPI_CHAR, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if(params_present){ - if ((mpierr = MPI_Bcast(¶mssize, 1, PIO_MPI_SIZE_T, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if (!(params = malloc(paramssize *sizeof(unsigned int)))) - return pio_err(ios, NULL, PIO_ENOMEM, __FILE__, __LINE__); - - } - PLOG((2,"inq_var_filter_info_handler ncid = %d varid = %d nparams_present = %d params_present = %d", - ncid, varid, nparams_present, params_present)); - - /* Set the non-NULL pointers. */ - if (nparams_present) - nparamsp = &nparams; - - /* Call the inq function to get the values. */ - PIOc_inq_var_filter_info(ncid, varid, id, nparamsp, params); - - if(params_present) - free(params); - - return PIO_NOERR; -} -#endif -#ifdef NC_HAS_QUANTIZE -/** - * Do an inq_var_quantize on a netCDF variable. This function is only - * run on IO tasks. - * - * @param ios pointer to the iosystem_desc_t. - * @returns 0 for success, error code otherwise. - */ -int inq_var_quantize_handler(iosystem_desc_t *ios) -{ - int ncid; - int varid; - int *quantize_modep = NULL; - int *nsdp = NULL; - int qmode; - int nsd; - int mpierr; - char qmode_present; - char nsd_present; - - assert(ios); - PLOG((1, "inq_var_chunking_handler")); - - /* Get the parameters for this function that the the comp main - * task is broadcasting. */ - if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(&varid, 1, MPI_INT, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(&qmode_present, 1, MPI_CHAR, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(&nsd_present, 1, MPI_CHAR, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - - - PLOG((2,"inq_var_handler ncid = %d varid = %d", - ncid, varid)); - - if (qmode_present) - quantize_modep = &qmode; - if(nsd_present) - nsdp = &nsd; - /* Call the inq function to get the values. */ - PIOc_inq_var_quantize(ncid, varid, quantize_modep, nsdp); - - return PIO_NOERR; -} - -/** - * This function is run on the IO tasks to define a netCDF - * variable quantize level. - * - * @param ios pointer to the iosystem_desc_t. - * @returns 0 for success, PIO_EIO for MPI Bcast errors, or error code - * from netCDF base function. - * @internal - * @author Jim Edwards, Ed Hartnett - */ -int def_var_quantize_handler(iosystem_desc_t *ios) -{ - int ncid; - int varid; - int mode; - int nsd; - int mpierr; - - PLOG((1, "def_var_quantize_handler comproot = %d", ios->comproot)); - assert(ios); - - /* Get the parameters for this function that the he comp main - * task is broadcasting. */ - if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(&varid, 1, MPI_INT, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(&mode, 1, MPI_INT, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(&nsd, 1, MPI_INT, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - - PLOG((1, "def_var_quantize_handler got parameters ncid = %d " - "varid = %d mode = %d nsd = %d ", ncid, varid, mode, nsd)); - - /* Call the function. */ - PIOc_def_var_quantize(ncid, varid, mode, nsd); - - - PLOG((1, "def_var_quantize_handler succeeded!")); - return PIO_NOERR; -} -#endif - -#ifdef NC_HAS_ZSTD -/** - * Do an inq_var_bzip2 on a netCDF variable. This function is only - * run on IO tasks. - * - * @param ios pointer to the iosystem_desc_t. - * @returns 0 for success, error code otherwise. - */ -int inq_var_zstandard_handler(iosystem_desc_t *ios) -{ - int ncid; - int varid; - int *hasfilterp=NULL; - int *levelp=NULL; - char hasfilterp_present; - char levelp_present; - int hasfilter; - int level; - int mpierr; - - assert(ios); - PLOG((1, "inq_var_zstandard_handler")); - - /* Get the parameters for this function that the the comp main - * task is broadcasting. */ - if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(&varid, 1, MPI_INT, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(&hasfilterp_present, 1, MPI_CHAR, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(&levelp_present, 1, MPI_CHAR, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - - PLOG((2,"inq_var_zstandard_handler ncid = %d varid = %d hasfilter_present = %d ", - ncid, varid, hasfilterp_present, levelp_present)); - - /* Set the non-NULL pointers. */ - if(hasfilterp_present) - hasfilterp = &hasfilter; - if(levelp_present) - levelp = &level; - - /* Call the inq function to get the values. */ - PIOc_inq_var_zstandard(ncid, varid, hasfilterp, levelp); - - return PIO_NOERR; -} -/** - * This function is run on the IO tasks to define a netCDF - * variable quantize level. - * - * @param ios pointer to the iosystem_desc_t. - * @returns 0 for success, PIO_EIO for MPI Bcast errors, or error code - * from netCDF base function. - * @internal - * @author Jim Edwards, Ed Hartnett - */ -int def_var_zstandard_handler(iosystem_desc_t *ios) -{ - int ncid; - int varid; - int level; - int mpierr; - - PLOG((1, "def_var_zstandard_handler comproot = %d", ios->comproot)); - assert(ios); - - /* Get the parameters for this function that the he comp main - * task is broadcasting. */ - if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(&varid, 1, MPI_INT, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(&level, 1, MPI_INT, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - - PLOG((1, "def_var_zstandard_handler got parameters ncid = %d " - "varid = %d level = %d ", ncid, varid, level)); - - /* Call the function. */ - PIOc_def_var_zstandard(ncid, varid, level); - - PLOG((1, "def_var_zstandard_handler succeeded!")); - return PIO_NOERR; -} -#endif -#endif /** * Do an inq_var_fill on a netCDF variable. This function is only @@ -1507,7 +1163,7 @@ int inq_var_fill_handler(iosystem_desc_t *ios) assert(ios); PLOG((1, "inq_var_fill_handler")); - /* Get the parameters for this function that the the comp main + /* Get the parameters for this function that the the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -1570,7 +1226,7 @@ int inq_var_endian_handler(iosystem_desc_t *ios) assert(ios); PLOG((1, "inq_var_endian_handler")); - /* Get the parameters for this function that the the comp main + /* Get the parameters for this function that the the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -1613,7 +1269,7 @@ int inq_var_deflate_handler(iosystem_desc_t *ios) assert(ios); PLOG((1, "inq_var_deflate_handler")); - /* Get the parameters for this function that the the comp main + /* Get the parameters for this function that the the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -1671,7 +1327,7 @@ int inq_varid_handler(iosystem_desc_t *ios) assert(ios); - /* Get the parameters for this function that the the comp main + /* Get the parameters for this function that the the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -1703,7 +1359,7 @@ int sync_file_handler(iosystem_desc_t *ios) PLOG((1, "sync_file_handler")); assert(ios); - /* Get the parameters for this function that the comp main + /* Get the parameters for this function that the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -1736,7 +1392,7 @@ int setframe_handler(iosystem_desc_t *ios) PLOG((1, "setframe_handler")); assert(ios); - /* Get the parameters for this function that the comp main + /* Get the parameters for this function that the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -1773,7 +1429,7 @@ int advanceframe_handler(iosystem_desc_t *ios) PLOG((1, "advanceframe_handler")); assert(ios); - /* Get the parameters for this function that the comp main + /* Get the parameters for this function that the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -1807,7 +1463,7 @@ int change_def_file_handler(iosystem_desc_t *ios, int msg) PLOG((1, "change_def_file_handler")); assert(ios); - /* Get the parameters for this function that the comp main + /* Get the parameters for this function that the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -1846,7 +1502,7 @@ int def_var_handler(iosystem_desc_t *ios) PLOG((1, "def_var_handler comproot = %d", ios->comproot)); assert(ios); - /* Get the parameters for this function that the he comp main + /* Get the parameters for this function that the he comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -1898,7 +1554,7 @@ int def_var_chunking_handler(iosystem_desc_t *ios) assert(ios); PLOG((1, "def_var_chunking_handler comproot = %d", ios->comproot)); - /* Get the parameters for this function that the he comp main + /* Get the parameters for this function that the he comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -1949,7 +1605,7 @@ int def_var_fill_handler(iosystem_desc_t *ios) assert(ios); PLOG((1, "def_var_fill_handler comproot = %d", ios->comproot)); - /* Get the parameters for this function that the he comp main + /* Get the parameters for this function that the he comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -2002,7 +1658,7 @@ int def_var_endian_handler(iosystem_desc_t *ios) assert(ios); PLOG((1, "def_var_endian_handler comproot = %d", ios->comproot)); - /* Get the parameters for this function that the he comp main + /* Get the parameters for this function that the he comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -2039,7 +1695,7 @@ int def_var_deflate_handler(iosystem_desc_t *ios) assert(ios); PLOG((1, "def_var_deflate_handler comproot = %d", ios->comproot)); - /* Get the parameters for this function that the he comp main + /* Get the parameters for this function that the he comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -2080,7 +1736,7 @@ int set_var_chunk_cache_handler(iosystem_desc_t *ios) assert(ios); PLOG((1, "set_var_chunk_cache_handler comproot = %d", ios->comproot)); - /* Get the parameters for this function that the he comp main + /* Get the parameters for this function that the he comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -2123,7 +1779,7 @@ int def_dim_handler(iosystem_desc_t *ios) PLOG((1, "def_dim_handler comproot = %d", ios->comproot)); assert(ios); - /* Get the parameters for this function that the he comp main + /* Get the parameters for this function that the he comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -2164,7 +1820,7 @@ int rename_dim_handler(iosystem_desc_t *ios) PLOG((1, "rename_dim_handler")); assert(ios); - /* Get the parameters for this function that the he comp main + /* Get the parameters for this function that the he comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -2205,7 +1861,7 @@ int rename_var_handler(iosystem_desc_t *ios) PLOG((1, "rename_var_handler")); assert(ios); - /* Get the parameters for this function that the he comp main + /* Get the parameters for this function that the he comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -2246,7 +1902,7 @@ int rename_att_handler(iosystem_desc_t *ios) PLOG((1, "rename_att_handler")); assert(ios); - /* Get the parameters for this function that the he comp main + /* Get the parameters for this function that the he comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -2291,7 +1947,7 @@ int delete_att_handler(iosystem_desc_t *ios) PLOG((1, "delete_att_handler")); assert(ios); - /* Get the parameters for this function that the he comp main + /* Get the parameters for this function that the he comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -2336,7 +1992,7 @@ int open_file_handler(iosystem_desc_t *ios) PLOG((1, "open_file_handler comproot = %d", ios->comproot)); assert(ios); - /* Get the parameters for this function that the he comp main + /* Get the parameters for this function that the he comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&len, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -2376,10 +2032,8 @@ int open_file_handler(iosystem_desc_t *ios) } else { -// PIOc_set_log_level(3); PIOc_openfile_retry(ios->iosysid, &ncid, &iotype, filename, mode, 0, use_ext_ncid); -// PIOc_set_log_level(0); } return PIO_NOERR; @@ -2403,7 +2057,7 @@ int delete_file_handler(iosystem_desc_t *ios) PLOG((1, "delete_file_handler comproot = %d", ios->comproot)); assert(ios); - /* Get the parameters for this function that the he comp main + /* Get the parameters for this function that the he comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&len, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -2449,7 +2103,7 @@ int initdecomp_dof_handler(iosystem_desc_t *ios) PLOG((1, "initdecomp_dof_handler called")); assert(ios); - /* Get the parameters for this function that the the comp main + /* Get the parameters for this function that the the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&iosysid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -2555,7 +2209,7 @@ int write_darray_multi_handler(iosystem_desc_t *ios) PLOG((1, "write_darray_multi_handler")); assert(ios); - /* Get the parameters for this function that the the comp main + /* Get the parameters for this function that the the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -2656,7 +2310,7 @@ int read_darray_handler(iosystem_desc_t *ios) PLOG((1, "read_darray_handler called")); assert(ios); - /* Get the parameters for this function that the the comp main + /* Get the parameters for this function that the the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -2697,7 +2351,7 @@ int seterrorhandling_handler(iosystem_desc_t *ios) PLOG((1, "seterrorhandling_handler comproot = %d", ios->comproot)); assert(ios); - /* Get the parameters for this function that the he comp main + /* Get the parameters for this function that the he comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&method, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -2738,7 +2392,7 @@ int set_chunk_cache_handler(iosystem_desc_t *ios) PLOG((1, "set_chunk_cache_handler called")); assert(ios); - /* Get the parameters for this function that the the comp main + /* Get the parameters for this function that the the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&iosysid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -2782,7 +2436,7 @@ int get_chunk_cache_handler(iosystem_desc_t *ios) PLOG((1, "get_chunk_cache_handler called")); assert(ios); - /* Get the parameters for this function that the the comp main + /* Get the parameters for this function that the the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&iosysid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -2835,7 +2489,7 @@ int get_var_chunk_cache_handler(iosystem_desc_t *ios) PLOG((1, "get_var_chunk_cache_handler called")); assert(ios); - /* Get the parameters for this function that the the comp main + /* Get the parameters for this function that the the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -2883,7 +2537,7 @@ int freedecomp_handler(iosystem_desc_t *ios) PLOG((1, "freedecomp_handler called")); assert(ios); - /* Get the parameters for this function that the the comp main + /* Get the parameters for this function that the the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&iosysid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -2916,7 +2570,7 @@ int finalize_handler(iosystem_desc_t *ios, int index) PLOG((1, "finalize_handler called index = %d", index)); assert(ios); - /* Get the parameters for this function that the the comp main + /* Get the parameters for this function that the the comp master * task is broadcasting. */ if ((mpierr = MPI_Bcast(&iosysid, 1, MPI_INT, 0, ios->intercomm))) return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); @@ -2938,12 +2592,12 @@ int finalize_handler(iosystem_desc_t *ios, int index) */ int set_loglevel_handler(iosystem_desc_t *ios) { -#if PIO_ENABLE_LOGGING +#if PIO_ENABLE_LOGGING int iosysid; int level; int mpierr; #endif - + PLOG((0, "set_loglevel_handler called")); assert(ios); #if PIO_ENABLE_LOGGING @@ -2955,89 +2609,8 @@ int set_loglevel_handler(iosystem_desc_t *ios) #endif return PIO_NOERR; } -#ifdef PIO_HAS_PAR_FILTERS -/** - * Do an inq_var_filter_avail on a netCDF variable. This function is only - * run on IO tasks. - * - * @param ios pointer to the iosystem_desc_t. - * @returns 0 for success, error code otherwise. - */ -int inq_filter_avail_handler(iosystem_desc_t *ios) -{ - int ncid; - unsigned int id; - int mpierr; - - assert(ios); - PLOG((1, "inq_filter_avail_handler")); - - /* Get the parameters for this function that the the comp main - * task is broadcasting. */ - if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(&id, 1, MPI_INT, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - - PLOG((2,"inq_filter_avail_handler ncid = %d id = %d", - ncid, id)); - /* Call the inq function to get the values. */ - PIOc_inq_filter_avail(ncid, id); - return PIO_NOERR; -} -/** - * This function is run on the IO tasks to define a netCDF - * variable filter. - * - * @param ios pointer to the iosystem_desc_t. - * @returns 0 for success, PIO_EIO for MPI Bcast errors, or error code - * from netCDF base function. - * @internal - * @author Jim Edwards, Ed Hartnett - */ -int def_var_filter_handler(iosystem_desc_t *ios) -{ - int ncid; - int varid; - int id; - size_t nparams; - unsigned int *params; - int mpierr; - - PLOG((1, "def_var_filter_handler comproot = %d", ios->comproot)); - assert(ios); - - /* Get the parameters for this function that the he comp main - * task is broadcasting. */ - if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(&varid, 1, MPI_INT, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(&id, 1, MPI_INT, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(&nparams, 1, PIO_MPI_SIZE_T, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - if (!(params = malloc(nparams * sizeof(int)))) - return pio_err(ios, NULL, PIO_ENOMEM, __FILE__, __LINE__); - - if ((mpierr = MPI_Bcast(params, nparams, MPI_UNSIGNED, 0, ios->intercomm))) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - - PLOG((1, "def_var_filter_handler got parameters ncid = %d " - "varid = %d id = %d nparams = %d ", ncid, varid, id, nparams)); - - /* Call the function. */ - PIOc_def_var_filter(ncid, varid, id, nparams, params); - - /* Free resources. */ - free(params); - - PLOG((1, "def_var_filter_handler succeeded!")); - return PIO_NOERR; -} -#endif /** * This function is called by the IO tasks. This function will not * return, unless there is an error. @@ -3109,7 +2682,7 @@ int pio_msg_handler2(int io_rank, int component_count, iosystem_desc_t **iosys, if ((mpierr = MPI_Bcast(&outcount, 1, MPI_INT, 0, io_comm))) return check_mpi(NULL, NULL, mpierr, __FILE__, __LINE__); PLOG((3, "outcount MPI_Bcast complete outcount = %d", outcount)); - + for(int creq=0; creq < outcount; creq++) { int idx = index[creq]; @@ -3177,16 +2750,6 @@ int pio_msg_handler2(int io_rank, int component_count, iosystem_desc_t **iosys, case PIO_MSG_DEF_VAR: ret = def_var_handler(my_iosys); break; -#ifdef PIO_HAS_PAR_FILTERS -#ifdef NC_HAS_ZSTD - case PIO_MSG_INQ_VAR_ZSTANDARD: - ret = inq_var_zstandard_handler(my_iosys); - break; - case PIO_MSG_DEF_VAR_ZSTANDARD: - ret = def_var_zstandard_handler(my_iosys); - break; -#endif -#endif case PIO_MSG_DEF_VAR_CHUNKING: ret = def_var_chunking_handler(my_iosys); break; @@ -3289,28 +2852,6 @@ int pio_msg_handler2(int io_rank, int component_count, iosystem_desc_t **iosys, case PIO_MSG_SETLOGLEVEL: ret = set_loglevel_handler(my_iosys); break; -#ifdef PIO_HAS_PAR_FILTERS -#ifdef NC_HAS_QUANTIZE - case PIO_MSG_DEF_VAR_QUANTIZE: - ret = def_var_quantize_handler(my_iosys); - break; - case PIO_MSG_INQ_VAR_QUANTIZE: - ret = inq_var_quantize_handler(my_iosys); - break; -#endif - case PIO_MSG_DEF_VAR_FILTER: - ret = def_var_filter_handler(my_iosys); - break; - case PIO_MSG_INQ_FILTER_AVAIL: - ret = inq_filter_avail_handler(my_iosys); - break; - case PIO_MSG_INQ_VAR_FILTER_IDS: - ret = inq_var_filter_ids_handler(my_iosys); - break; - case PIO_MSG_INQ_VAR_FILTER_INFO: - ret = inq_var_filter_info_handler(my_iosys); - break; -#endif case PIO_MSG_EXIT: finalize++; ret = finalize_handler(my_iosys, idx); diff --git a/src/clib/pio_nc.c b/src/clib/pio_nc.c index 2808e45ec3..5f874c4996 100644 --- a/src/clib/pio_nc.c +++ b/src/clib/pio_nc.c @@ -118,19 +118,19 @@ PIOc_inq(int ncid, int *ndimsp, int *nvarsp, int *ngattsp, int *unlimdimidp) char ngatts_present = ngattsp ? true : false; char unlimdimid_present = unlimdimidp ? true : false; - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&ndims_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ndims_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&nvars_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&nvars_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&ngatts_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ngatts_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&unlimdimid_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&unlimdimid_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); PLOG((2, "PIOc_inq ncid = %d ndims_present = %d nvars_present = %d ngatts_present = %d unlimdimid_present = %d", ncid, ndims_present, nvars_present, ngatts_present, unlimdimid_present)); } @@ -313,15 +313,15 @@ PIOc_inq_unlimdims(int ncid, int *nunlimdimsp, int *unlimdimidsp) char nunlimdimsp_present = nunlimdimsp ? true : false; char unlimdimidsp_present = unlimdimidsp ? true : false; - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&nunlimdimsp_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&nunlimdimsp_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&unlimdimidsp_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&unlimdimidsp_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); PLOG((2, "PIOc_inq_unlimdims ncid = %d nunlimdimsp_present = %d unlimdimidsp_present = %d", ncid, nunlimdimsp_present, unlimdimidsp_present)); } @@ -449,17 +449,17 @@ PIOc_inq_type(int ncid, nc_type xtype, char *name, PIO_Offset *sizep) char name_present = name ? true : false; char size_present = sizep ? true : false; - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&xtype, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&xtype, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&name_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&name_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&size_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&size_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); } /* Handle MPI errors. */ if ((mpierr2 = MPI_Bcast(&mpierr, 1, MPI_INT, ios->comproot, ios->my_comm))) @@ -491,7 +491,7 @@ PIOc_inq_type(int ncid, nc_type xtype, char *name, PIO_Offset *sizep) if (name) { int slen; - if (ios->iomain == MPI_ROOT) + if (ios->iomaster == MPI_ROOT) slen = strlen(name); if ((mpierr = MPI_Bcast(&slen, 1, MPI_INT, ios->ioroot, ios->my_comm))) return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); @@ -538,13 +538,13 @@ PIOc_inq_format(int ncid, int *formatp) int msg = PIO_MSG_INQ_FORMAT; char format_present = formatp ? true : false; - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&format_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&format_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); } /* Handle MPI errors. */ @@ -624,18 +624,18 @@ PIOc_inq_dim(int ncid, int dimid, char *name, PIO_Offset *lenp) char name_present = name ? true : false; char len_present = lenp ? true : false; - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&dimid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&dimid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&name_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&name_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); PLOG((2, "PIOc_inq netcdf Bcast name_present = %d", name_present)); if (!mpierr) - mpierr = MPI_Bcast(&len_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&len_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); PLOG((2, "PIOc_inq netcdf Bcast len_present = %d", len_present)); } @@ -676,7 +676,7 @@ PIOc_inq_dim(int ncid, int dimid, char *name, PIO_Offset *lenp) { int slen; PLOG((2, "bcasting results my_comm = %d", ios->my_comm)); - if (ios->iomain == MPI_ROOT) + if (ios->iomaster == MPI_ROOT) slen = strlen(name); if ((mpierr = MPI_Bcast(&slen, 1, MPI_INT, ios->ioroot, ios->my_comm))) return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); @@ -771,18 +771,18 @@ PIOc_inq_dimid(int ncid, const char *name, int *idp) int msg = PIO_MSG_INQ_DIMID; char id_present = idp ? true : false; - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); int namelen = strlen(name); if (!mpierr) - mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast((void *)name, namelen + 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((void *)name, namelen + 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&id_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&id_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); } /* Handle MPI errors. */ @@ -873,23 +873,23 @@ PIOc_inq_var(int ncid, int varid, char *name, nc_type *xtypep, int *ndimsp, char dimids_present = dimidsp ? true : false; char natts_present = nattsp ? true : false; - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&name_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&name_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&xtype_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&xtype_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&ndims_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ndims_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&dimids_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&dimids_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&natts_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&natts_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); PLOG((2, "PIOc_inq_var name_present = %d xtype_present = %d ndims_present = %d " "dimids_present = %d, natts_present = %d nattsp = %d", name_present, xtype_present, ndims_present, dimids_present, natts_present, nattsp)); @@ -967,7 +967,7 @@ PIOc_inq_var(int ncid, int varid, char *name, nc_type *xtypep, int *ndimsp, if (name) { int slen; - if (ios->iomain == MPI_ROOT) + if (ios->iomaster == MPI_ROOT) slen = strlen(name); if ((mpierr = MPI_Bcast(&slen, 1, MPI_INT, ios->ioroot, ios->my_comm))) return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); @@ -1125,17 +1125,17 @@ PIOc_inq_varid(int ncid, const char *name, int *varidp) { int msg = PIO_MSG_INQ_VARID; - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); int namelen; namelen = strlen(name); if (!mpierr) - mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast((void *)name, namelen + 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((void *)name, namelen + 1, MPI_CHAR, ios->compmaster, ios->intercomm); } /* Handle MPI errors. */ @@ -1221,23 +1221,23 @@ PIOc_inq_att_eh(int ncid, int varid, const char *name, int eh, char len_present = lenp ? true : false; int namelen = strlen(name); - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast((void *)name, namelen + 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((void *)name, namelen + 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&xtype_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&xtype_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&len_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&len_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&eh, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&eh, 1, MPI_INT, ios->compmaster, ios->intercomm); } /* Handle MPI errors. */ @@ -1382,17 +1382,17 @@ PIOc_inq_attname(int ncid, int varid, int attnum, char *name) int msg = PIO_MSG_INQ_ATTNAME; char name_present = name ? true : false; - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&attnum, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&attnum, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&name_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&name_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); } /* Handle MPI errors. */ @@ -1482,19 +1482,19 @@ PIOc_inq_attid(int ncid, int varid, const char *name, int *idp) int namelen = strlen(name); char id_present = idp ? true : false; - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast((char *)name, namelen + 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((char *)name, namelen + 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&id_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&id_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); } /* Handle MPI errors. */ @@ -1575,17 +1575,17 @@ PIOc_rename_dim(int ncid, int dimid, const char *name) int msg = PIO_MSG_RENAME_DIM; /* Message for async notification. */ int namelen = strlen(name); - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&dimid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&dimid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast((void *)name, namelen + 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((void *)name, namelen + 1, MPI_CHAR, ios->compmaster, ios->intercomm); PLOG((2, "PIOc_rename_dim Bcast file->fh = %d dimid = %d namelen = %d name = %s", file->fh, dimid, namelen, name)); } @@ -1664,17 +1664,17 @@ PIOc_rename_var(int ncid, int varid, const char *name) int msg = PIO_MSG_RENAME_VAR; /* Message for async notification. */ int namelen = strlen(name); - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast((void *)name, namelen + 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((void *)name, namelen + 1, MPI_CHAR, ios->compmaster, ios->intercomm); PLOG((2, "PIOc_rename_var Bcast file->fh = %d varid = %d namelen = %d name = %s", file->fh, varid, namelen, name)); } @@ -1758,21 +1758,21 @@ PIOc_rename_att(int ncid, int varid, const char *name, int namelen = strlen(name); int newnamelen = strlen(newname); - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast((char *)name, namelen + 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((char *)name, namelen + 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&newnamelen, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&newnamelen, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast((char *)newname, newnamelen + 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((char *)newname, newnamelen + 1, MPI_CHAR, ios->compmaster, ios->intercomm); } /* Handle MPI errors. */ @@ -1847,17 +1847,17 @@ PIOc_del_att(int ncid, int varid, const char *name) int msg = PIO_MSG_DEL_ATT; int namelen = strlen(name); /* Length of name string. */ - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast((char *)name, namelen + 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((char *)name, namelen + 1, MPI_CHAR, ios->compmaster, ios->intercomm); } /* Handle MPI errors. */ @@ -1928,15 +1928,15 @@ PIOc_set_fill(int ncid, int fillmode, int *old_modep) int old_modep_present = old_modep ? 1 : 0; PLOG((3, "PIOc_set_fill about to send msg %d", msg)); - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&fillmode, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&fillmode, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&old_modep_present, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&old_modep_present, 1, MPI_INT, ios->compmaster, ios->intercomm); PLOG((2, "PIOc_set_fill sent ncid = %d fillmode = %d old_modep_present = %d", ncid, fillmode, old_modep_present)); } @@ -2065,18 +2065,18 @@ PIOc_def_dim(int ncid, const char *name, PIO_Offset len, int *idp) int msg = PIO_MSG_DEF_DIM; int namelen = strlen(name); - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast((void *)name, namelen + 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((void *)name, namelen + 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&len, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&len, 1, MPI_INT, ios->compmaster, ios->intercomm); } @@ -2091,7 +2091,6 @@ PIOc_def_dim(int ncid, const char *name, PIO_Offset len, int *idp) if (ios->ioproc) { #ifdef _PNETCDF - if (file->iotype == PIO_IOTYPE_PNETCDF) ierr = ncmpi_def_dim(file->fh, name, len, idp); #endif /* _PNETCDF */ @@ -2231,21 +2230,21 @@ PIOc_def_var(int ncid, const char *name, nc_type xtype, int ndims, int msg = PIO_MSG_DEF_VAR; int namelen = strlen(name); - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&(ncid), 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&(ncid), 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&namelen, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast((void *)name, namelen + 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((void *)name, namelen + 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&xtype, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&xtype, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&ndims, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ndims, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast((void *)dimidsp, ndims, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((void *)dimidsp, ndims, MPI_INT, ios->compmaster, ios->intercomm); } /* Handle MPI errors. */ @@ -2382,21 +2381,21 @@ PIOc_def_var_fill(int ncid, int varid, int fill_mode, const void *fill_valuep) int msg = PIO_MSG_DEF_VAR_FILL; char fill_value_present = fill_valuep ? true : false; - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&fill_mode, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&fill_mode, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&type_size, 1, MPI_OFFSET, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&type_size, 1, MPI_OFFSET, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&fill_value_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&fill_value_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr && fill_value_present) - mpierr = MPI_Bcast((PIO_Offset *)fill_valuep, type_size, MPI_CHAR, ios->compmain, + mpierr = MPI_Bcast((PIO_Offset *)fill_valuep, type_size, MPI_CHAR, ios->compmaster, ios->intercomm); PLOG((2, "PIOc_def_var_fill ncid = %d varid = %d fill_mode = %d type_size = %d fill_value_present = %d", ncid, varid, fill_mode, type_size, fill_value_present)); @@ -2512,19 +2511,19 @@ PIOc_inq_var_fill(int ncid, int varid, int *no_fill, void *fill_valuep) char fill_value_present = fill_valuep ? true : false; PLOG((2, "sending msg type_size = %d", type_size)); - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&type_size, 1, MPI_OFFSET, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&type_size, 1, MPI_OFFSET, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&no_fill_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&no_fill_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&fill_value_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&fill_value_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); PLOG((2, "PIOc_inq_var_fill ncid = %d varid = %d type_size = %lld no_fill_present = %d fill_value_present = %d", ncid, varid, type_size, no_fill_present, fill_value_present)); } diff --git a/src/clib/pio_nc4.c b/src/clib/pio_nc4.c index 3074bbd95a..becaf1cdf8 100644 --- a/src/clib/pio_nc4.c +++ b/src/clib/pio_nc4.c @@ -4,9 +4,9 @@ * * @author Ed Hartnett */ +#include #include #include -#include /** * Set deflate (zlib) settings for a variable. @@ -49,7 +49,7 @@ PIOc_def_var_deflate(int ncid, int varid, int shuffle, int deflate, return pio_err(ios, file, PIO_ENOTNC4, __FILE__, __LINE__); PLOG((1, "PIOc_def_var_deflate ncid = %d varid = %d shuffle = %d deflate = %d deflate_level = %d", - ncid, varid, shuffle, deflate, deflate_level)); + ncid, varid, shuffle, deflate, deflate_level)); /* If async is in use, and this is not an IO task, bcast the parameters. */ if (ios->async) @@ -58,272 +58,19 @@ PIOc_def_var_deflate(int ncid, int varid, int shuffle, int deflate, { int msg = PIO_MSG_DEF_VAR_DEFLATE; - if (ios->compmain == MPI_ROOT) - mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm); - - if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(&shuffle, 1, MPI_INT, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(&deflate, 1, MPI_INT, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(&deflate_level, 1, MPI_INT, ios->compmain, ios->intercomm); - } - - /* Handle MPI errors from computation tasks. */ - if ((mpierr2 = MPI_Bcast(&mpierr, 1, MPI_INT, ios->comproot, ios->my_comm))) - return check_mpi(NULL, file, mpierr2, __FILE__, __LINE__); - if (mpierr) - return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); - } - - if (ios->ioproc) - { -#ifdef _NETCDF4 - if (file->do_io) - ierr = nc_def_var_deflate(file->fh, varid, shuffle, deflate, deflate_level); -#endif - } - - /* Broadcast and check the return code. */ - if ((mpierr = MPI_Bcast(&ierr, 1, MPI_INT, ios->ioroot, ios->my_comm))) - return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); - if (ierr) - return check_netcdf(file, ierr, __FILE__, __LINE__); - - return PIO_NOERR; -} - -/** - * Set szip settings for a variable. - * - * This function only applies to netCDF-4 files. When used with netCDF - * classic files, the error PIO_ENOTNC4 will be returned. - * - * See the netCDF - * variable documentation for details about the operation of this - * function. - * - * @param ncid the ncid of the open file. - * @param varid the ID of the variable. - * @param option_mask The options mask. Can be PIO_SZIP_EC or PIO_SZIP_NN. - * @param pixels_per_block Pixels per block. Must be even and not greater than 32, with typical - * values being 8, 10, 16, or 32. This parameter affects compression - * ratio; the more pixel values vary, the smaller this number should be - * to achieve better performance. If pixels_per_block is bigger than the - * total number of elements in a dataset chunk, NC_EINVAL will be - * returned. - * @return PIO_NOERR for success, otherwise an error code. - * @ingroup PIO_def_var_c - * @author Jim Edwards, Ed Hartnett - */ -int -PIOc_def_var_szip(int ncid, int varid, int options_mask, int pixels_per_block) -{ - iosystem_desc_t *ios; /* Pointer to io system information. */ - file_desc_t *file; /* Pointer to file information. */ - int ierr = PIO_NOERR; /* Return code from function calls. */ - int mpierr = MPI_SUCCESS, mpierr2; /* Return code from MPI function codes. */ - - /* Get the file info. */ - if ((ierr = pio_get_file(ncid, &file))) - return pio_err(NULL, NULL, ierr, __FILE__, __LINE__); - ios = file->iosystem; - - /* Only netCDF-4 files can use this feature. */ - if (file->iotype != PIO_IOTYPE_NETCDF4P && file->iotype != PIO_IOTYPE_NETCDF4C) - return pio_err(ios, file, PIO_ENOTNC4, __FILE__, __LINE__); - - PLOG((1, "PIOc_def_var_szip ncid = %d varid = %d mask = %d ppb = %d", - ncid, varid, options_mask, pixels_per_block)); - - /* If async is in use, and this is not an IO task, bcast the parameters. */ - if (ios->async) - { - if (!ios->ioproc) - { - int msg = PIO_MSG_DEF_VAR_SZIP; - - if (ios->compmain == MPI_ROOT) - mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm); - - if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(&options_mask, 1, MPI_INT, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(&pixels_per_block, 1, MPI_INT, ios->compmain, ios->intercomm); - } - - /* Handle MPI errors from computation tasks. */ - if ((mpierr2 = MPI_Bcast(&mpierr, 1, MPI_INT, ios->comproot, ios->my_comm))) - return check_mpi(NULL, file, mpierr2, __FILE__, __LINE__); - if (mpierr) - return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); - } - - if (ios->ioproc) - { -#ifdef _NETCDF4 - if (file->do_io) - ierr = nc_def_var_szip(file->fh, varid, options_mask, pixels_per_block); -#endif - } - - /* Broadcast and check the return code. */ - if ((mpierr = MPI_Bcast(&ierr, 1, MPI_INT, ios->ioroot, ios->my_comm))) - return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); - if (ierr) - return check_netcdf(file, ierr, __FILE__, __LINE__); - - return PIO_NOERR; -} - -#ifdef NC_HAS_BZ2 -/** - * Set bzip2 settings for a variable. - * - * This function only applies to netCDF-4 files. When used with netCDF - * classic files, the error PIO_ENOTNC4 will be returned. - * - * See the netCDF - * variable documentation for details about the operation of this - * function. - * - * @param ncid the ncid of the open file. - * @param varid the ID of the variable. - * @param bzip2_level 1 to 9, with 1 being faster and 9 being more - * compressed. - * @return PIO_NOERR for success, otherwise an error code. - * @ingroup PIO_def_var_c - * @author Jim Edwards, Ed Hartnett - */ -int -PIOc_def_var_bzip2(int ncid, int varid, int level) -{ - iosystem_desc_t *ios; /* Pointer to io system information. */ - file_desc_t *file; /* Pointer to file information. */ - int ierr = PIO_NOERR; /* Return code from function calls. */ - int mpierr = MPI_SUCCESS, mpierr2; /* Return code from MPI function codes. */ - - /* Get the file info. */ - if ((ierr = pio_get_file(ncid, &file))) - return pio_err(NULL, NULL, ierr, __FILE__, __LINE__); - ios = file->iosystem; - - /* Only netCDF-4 files can use this feature. */ - if (file->iotype != PIO_IOTYPE_NETCDF4P && file->iotype != PIO_IOTYPE_NETCDF4C) - return pio_err(ios, file, PIO_ENOTNC4, __FILE__, __LINE__); - - PLOG((1, "PIOc_def_var_bzip2 ncid = %d varid = %d level = %d", - ncid, varid, level)); - - /* If async is in use, and this is not an IO task, bcast the parameters. */ - if (ios->async) - { - if (!ios->ioproc) - { - int msg = PIO_MSG_DEF_VAR_BZIP2; - - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(&level, 1, MPI_INT, ios->compmain, ios->intercomm); - } - - /* Handle MPI errors from computation tasks. */ - if ((mpierr2 = MPI_Bcast(&mpierr, 1, MPI_INT, ios->comproot, ios->my_comm))) - return check_mpi(NULL, file, mpierr2, __FILE__, __LINE__); - if (mpierr) - return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); - } - - if (ios->ioproc) - { -#ifdef _NETCDF4 - if (file->do_io) - ierr = nc_def_var_bzip2(file->fh, varid, level); -#endif - } - - /* Broadcast and check the return code. */ - if ((mpierr = MPI_Bcast(&ierr, 1, MPI_INT, ios->ioroot, ios->my_comm))) - return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); - if (ierr) - return check_netcdf(file, ierr, __FILE__, __LINE__); - - return PIO_NOERR; -} -#endif - -#ifdef NC_HAS_ZSTD -/** - * Set zstandard settings for a variable. - * - * This function only applies to netCDF-4 files. When used with netCDF - * classic files, the error PIO_ENOTNC4 will be returned. - * - * See the netCDF - * variable documentation for details about the operation of this - * function. - * - * @param ncid the ncid of the open file. - * @param varid the ID of the variable. - * @param zstandard_level 1 to 9, with 1 being faster and 9 being more - * compressed. - * @return PIO_NOERR for success, otherwise an error code. - * @ingroup PIO_def_var_c - * @author Jim Edwards, Ed Hartnett - */ -int -PIOc_def_var_zstandard(int ncid, int varid, int level) -{ - iosystem_desc_t *ios; /* Pointer to io system information. */ - file_desc_t *file; /* Pointer to file information. */ - int ierr = PIO_NOERR; /* Return code from function calls. */ - int mpierr = MPI_SUCCESS, mpierr2; /* Return code from MPI function codes. */ - - /* Get the file info. */ - if ((ierr = pio_get_file(ncid, &file))) - return pio_err(NULL, NULL, ierr, __FILE__, __LINE__); - ios = file->iosystem; - - /* Only netCDF-4 files can use this feature. */ - if (file->iotype != PIO_IOTYPE_NETCDF4P && file->iotype != PIO_IOTYPE_NETCDF4C) - return pio_err(ios, file, PIO_ENOTNC4, __FILE__, __LINE__); - - PLOG((1, "PIOc_def_var_zstandard ncid = %d varid = %d level = %d", - ncid, varid, level)); - - /* If async is in use, and this is not an IO task, bcast the parameters. */ - if (ios->async) - { - if (!ios->ioproc) - { - int msg = PIO_MSG_DEF_VAR_ZSTANDARD; - - if (ios->compmain == MPI_ROOT) - mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm); - + mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&shuffle, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&deflate, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&level, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&deflate_level, 1, MPI_INT, ios->compmaster, ios->intercomm); } /* Handle MPI errors from computation tasks. */ @@ -336,8 +83,8 @@ PIOc_def_var_zstandard(int ncid, int varid, int level) if (ios->ioproc) { #ifdef _NETCDF4 - if (file->do_io) - ierr = nc_def_var_zstandard(file->fh, varid, level); + if (file->do_io) + ierr = nc_def_var_deflate(file->fh, varid, shuffle, deflate, deflate_level); #endif } @@ -349,7 +96,6 @@ PIOc_def_var_zstandard(int ncid, int varid, int level) return PIO_NOERR; } -#endif /** * This function only applies to netCDF-4 files. When used with netCDF @@ -405,25 +151,25 @@ PIOc_inq_var_deflate(int ncid, int varid, int *shufflep, int *deflatep, char deflate_present = deflatep ? true : false; char deflate_level_present = deflate_levelp ? true : false; - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&shuffle_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&shuffle_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (shuffle_present && !mpierr) - mpierr = MPI_Bcast(shufflep, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(shufflep, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&deflate_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&deflate_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (deflate_present && !mpierr) - mpierr = MPI_Bcast(deflatep, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(deflatep, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&deflate_level_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&deflate_level_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (deflate_level_present && !mpierr) - mpierr = MPI_Bcast(deflate_levelp, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(deflate_levelp, 1, MPI_INT, ios->compmaster, ios->intercomm); PLOG((2, "PIOc_inq_var_deflate ncid = %d varid = %d shuffle_present = %d deflate_present = %d " "deflate_level_present = %d", ncid, varid, shuffle_present, deflate_present, deflate_level_present)); @@ -525,21 +271,21 @@ PIOc_def_var_chunking(int ncid, int varid, int storage, const PIO_Offset *chunks int msg = PIO_MSG_DEF_VAR_CHUNKING; char chunksizes_present = chunksizesp ? true : false; - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&storage, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&storage, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&ndims, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ndims, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&chunksizes_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&chunksizes_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr && chunksizes_present) - mpierr = MPI_Bcast((PIO_Offset *)chunksizesp, ndims, MPI_OFFSET, ios->compmain, + mpierr = MPI_Bcast((PIO_Offset *)chunksizesp, ndims, MPI_OFFSET, ios->compmaster, ios->intercomm); PLOG((2, "PIOc_def_var_chunking ncid = %d varid = %d storage = %d ndims = %d chunksizes_present = %d", ncid, varid, storage, ndims, chunksizes_present)); @@ -650,19 +396,19 @@ PIOc_inq_var_chunking(int ncid, int varid, int *storagep, PIO_Offset *chunksizes char storage_present = storagep ? true : false; char chunksizes_present = chunksizesp ? true : false; - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&storage_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&storage_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&ndims, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ndims, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&chunksizes_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&chunksizes_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); PLOG((2, "PIOc_inq_var_chunking ncid = %d varid = %d storage_present = %d chunksizes_present = %d", ncid, varid, storage_present, chunksizes_present)); } @@ -765,15 +511,15 @@ PIOc_def_var_endian(int ncid, int varid, int endian) if (!ios->ioproc) { int msg = PIO_MSG_DEF_VAR_ENDIAN; - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&endian, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&endian, 1, MPI_INT, ios->compmaster, ios->intercomm); } /* Handle MPI errors. */ @@ -846,15 +592,15 @@ PIOc_inq_var_endian(int ncid, int varid, int *endianp) int msg = PIO_MSG_INQ_VAR_ENDIAN; char endian_present = endianp ? true : false; - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&endian_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&endian_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); } /* Handle MPI errors. */ @@ -939,19 +685,19 @@ PIOc_set_chunk_cache(int iosysid, int iotype, PIO_Offset size, PIO_Offset nelems { int msg = PIO_MSG_SET_CHUNK_CACHE; /* Message for async notification. */ - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&iosysid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&iosysid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&iotype, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&iotype, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&size, 1, MPI_OFFSET, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&size, 1, MPI_OFFSET, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&nelems, 1, MPI_OFFSET, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&nelems, 1, MPI_OFFSET, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&preemption, 1, MPI_FLOAT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&preemption, 1, MPI_FLOAT, ios->compmaster, ios->intercomm); } /* Handle MPI errors. */ @@ -1043,19 +789,19 @@ PIOc_get_chunk_cache(int iosysid, int iotype, PIO_Offset *sizep, PIO_Offset *nel char nelems_present = nelemsp ? true : false; char preemption_present = preemptionp ? true : false; - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&iosysid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&iosysid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&iotype, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&iotype, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&size_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&size_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&nelems_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&nelems_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&preemption_present, 1, MPI_CHAR, ios->compmain, + mpierr = MPI_Bcast(&preemption_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); PLOG((2, "PIOc_get_chunk_cache size_present = %d nelems_present = %d " "preemption_present = %d ", size_present, nelems_present, preemption_present)); @@ -1160,19 +906,19 @@ PIOc_set_var_chunk_cache(int ncid, int varid, PIO_Offset size, PIO_Offset nelems { int msg = PIO_MSG_SET_VAR_CHUNK_CACHE; - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&size, 1, MPI_OFFSET, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&size, 1, MPI_OFFSET, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&nelems, 1, MPI_OFFSET, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&nelems, 1, MPI_OFFSET, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&preemption, 1, MPI_FLOAT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&preemption, 1, MPI_FLOAT, ios->compmaster, ios->intercomm); } /* Handle MPI errors. */ @@ -1231,7 +977,7 @@ PIOc_get_var_chunk_cache(int ncid, int varid, PIO_Offset *sizep, PIO_Offset *nel int ierr; /* Return code from function calls. */ int mpierr = MPI_SUCCESS, mpierr2; /* Return code from MPI function codes. */ - PLOG((1, "PIOc_get_var_chunk_cache ncid = %d varid = %d", ncid, varid)); + PLOG((1, "PIOc_get_var_chunk_cache ncid = %d varid = %d")); /* Get the file info. */ if ((ierr = pio_get_file(ncid, &file))) @@ -1252,19 +998,19 @@ PIOc_get_var_chunk_cache(int ncid, int varid, PIO_Offset *sizep, PIO_Offset *nel char nelems_present = nelemsp ? true : false; char preemption_present = preemptionp ? true : false; - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&size_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&size_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&nelems_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&nelems_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&preemption_present, 1, MPI_CHAR, ios->compmain, + mpierr = MPI_Bcast(&preemption_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); PLOG((2, "PIOc_get_var_chunk_cache size_present = %d nelems_present = %d " "preemption_present = %d ", size_present, nelems_present, preemption_present)); @@ -1306,759 +1052,3 @@ PIOc_get_var_chunk_cache(int ncid, int varid, PIO_Offset *sizep, PIO_Offset *nel return PIO_NOERR; } -/* use this variable in the NETCDF library (introduced in v4.9.0) to determine if the following - functions are available */ -#ifdef NC_HAS_MULTIFILTERS -/** - * Set the variable filter ids - * - * This function only applies to netCDF-4 files. When used with netCDF - * classic files, the error PIO_ENOTNC4 will be returned. - * - * See the netCDF - * variable documentation for details about the operation of this - * function. - * - * @param ncid the ncid of the open file. - * @param varid the ID of the variable. - * @param id set the filter id. - * @return PIO_NOERR for success, otherwise an error code. - * @ingroup PIO_filters - * @author Jim Edwards/Ed Hartnett - */ -int -PIOc_def_var_filter(int ncid, int varid, unsigned int id, size_t nparams, unsigned int* params) -{ - iosystem_desc_t *ios; /* Pointer to io system information. */ - file_desc_t *file; /* Pointer to file information. */ - int ierr; /* Return code from function calls. */ - int mpierr = MPI_SUCCESS, mpierr2; /* Return code from MPI function codes. */ - - PLOG((1, "PIOc_def_var_filter ncid = %d varid = %d id = %d nparams = %d", ncid, varid, id, nparams)); -#ifdef DEBUG - for(i=0; iiosystem; - - /* Only netCDF-4 files can use this feature. */ - if (file->iotype != PIO_IOTYPE_NETCDF4P && file->iotype != PIO_IOTYPE_NETCDF4C) - return pio_err(ios, file, PIO_ENOTNC4, __FILE__, __LINE__); - - /* If async is in use, and this is not an IO task, bcast the parameters. */ - if (ios->async) - { - if (!ios->ioproc) - { - int msg = PIO_MSG_DEF_VAR_FILTER; /* Message for async notification. */ - - if (ios->compmain == MPI_ROOT) - mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); - - if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(&id, 1, MPI_INT, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(&nparams, 1, PIO_MPI_SIZE_T, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(params, nparams, MPI_UNSIGNED, ios->compmain, ios->intercomm); - - } - - /* Handle MPI errors. */ - if ((mpierr2 = MPI_Bcast(&mpierr, 1, MPI_INT, ios->comproot, ios->my_comm))) - return check_mpi(ios, NULL, mpierr2, __FILE__, __LINE__); - if (mpierr) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - } - - /* If this is an IO task, then call the netCDF function. */ - if (ios->ioproc) - { - if (file->do_io) - ierr = nc_def_var_filter(file->fh, varid, id, nparams, params); - } - - /* Broadcast and check the return code. */ - if ((mpierr = MPI_Bcast(&ierr, 1, MPI_INT, ios->ioroot, ios->my_comm))) - return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); - if (ierr) - return check_netcdf(file, ierr, __FILE__, __LINE__); - - return PIO_NOERR; -} -#ifdef PIO_HAS_PAR_FILTERS -/** - * Get the variable filter ids if any - * - * This function only applies to netCDF-4 files. When used with netCDF - * classic files, the error PIO_ENOTNC4 will be returned. - * - * Note that these settings are not part of the data file - they apply - * only to the open file as long as it is open. - * - * See the netCDF - * variable documentation for details about the operation of this - * function. - * - * @param ncid the ncid of the open file. - * @param varid the ID of the variable. - * @param nfiltersp Pointer to the number of filters; may be 0. - * @param ids return the filter ids. - * @return PIO_NOERR for success, otherwise an error code. - * @ingroup PIO_filters - * @author Jim Edwards/Ed Hartnett - */ -int -PIOc_inq_var_filter_ids(int ncid, int varid, size_t *nfiltersp, unsigned int *ids) -{ - iosystem_desc_t *ios; /* Pointer to io system information. */ - file_desc_t *file; /* Pointer to file information. */ - int ierr; /* Return code from function calls. */ - int mpierr = MPI_SUCCESS, mpierr2; /* Return code from MPI function codes. */ - - PLOG((1, "PIOc_inq_var_filter_ids ncid = %d varid = %d", ncid, varid)); - - /* Get the file info. */ - if ((ierr = pio_get_file(ncid, &file))) - return pio_err(NULL, NULL, ierr, __FILE__, __LINE__); - ios = file->iosystem; - - /* Only netCDF-4 files can use this feature. */ - if (file->iotype != PIO_IOTYPE_NETCDF4P && file->iotype != PIO_IOTYPE_NETCDF4C) - return pio_err(ios, file, PIO_ENOTNC4, __FILE__, __LINE__); - - /* If async is in use, and this is not an IO task, bcast the parameters. */ - if (ios->async) - { - if (!ios->ioproc) - { - int msg = PIO_MSG_INQ_VAR_FILTER_IDS; /* Message for async notification. */ - char cnt_present = nfiltersp ? true : false; - char ids_present = ids ? true : false; - - if (ios->compmain == MPI_ROOT) - mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); - - if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(&cnt_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(&ids_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); - if(!mpierr && ids_present){ - size_t idcnt; - idcnt = sizeof(ids); - mpierr = MPI_Bcast(&idcnt, 1, PIO_MPI_SIZE_T, ios->compmain, ios->intercomm); - } - - PLOG((2, "PIOc_inq_var_filter_ids cnt_present = %d ids_present = %d", - cnt_present, ids_present)); - } - - /* Handle MPI errors. */ - if ((mpierr2 = MPI_Bcast(&mpierr, 1, MPI_INT, ios->comproot, ios->my_comm))) - return check_mpi(ios, NULL, mpierr2, __FILE__, __LINE__); - if (mpierr) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - } - - /* If this is an IO task, then call the netCDF function. */ - if (ios->ioproc) - { - if (file->do_io) - ierr = nc_inq_var_filter_ids(file->fh, varid, nfiltersp, ids); - } - - /* Broadcast and check the return code. */ - if ((mpierr = MPI_Bcast(&ierr, 1, MPI_INT, ios->ioroot, ios->my_comm))) - return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); - if (ierr) - return check_netcdf(file, ierr, __FILE__, __LINE__); - - /* Broadcast results to all tasks. */ - if (nfiltersp && !ierr) - if ((mpierr = MPI_Bcast(nfiltersp, 1, MPI_OFFSET, ios->ioroot, ios->my_comm))) - return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); - if ((*nfiltersp)> 0 && ids && !ierr) - if ((mpierr = MPI_Bcast(ids, *nfiltersp, MPI_UNSIGNED, ios->ioroot, ios->my_comm))) - return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); - - return PIO_NOERR; -} - -/** - * Get the variable filter info if any - * - * This function only applies to netCDF-4 files. When used with netCDF - * classic files, the error PIO_ENOTNC4 will be returned. - * - * Note that these settings are not part of the data file - they apply - * only to the open file as long as it is open. - * - * See the netCDF - * variable documentation for details about the operation of this - * function. - * - * @param ncid the ncid of the open file. - * @param varid the ID of the variable. - * @param id The filter id of interest - * @param nparamsp (OUT) Storage which will get the number of parameters to the filter - * @param params (OUT) Storage which will get the associated parameters. - * @return PIO_NOERR for success, otherwise an error code. - * @ingroup PIO_filters - * @author Jim Edwards/Ed Hartnett - */ -int -PIOc_inq_var_filter_info(int ncid, int varid, unsigned int id, size_t *nparamsp, unsigned int *params ) -{ - iosystem_desc_t *ios; /* Pointer to io system information. */ - file_desc_t *file; /* Pointer to file information. */ - int ierr; /* Return code from function calls. */ - int mpierr = MPI_SUCCESS, mpierr2; /* Return code from MPI function codes. */ - - PLOG((1, "PIOc_inq_var_filter_info ncid = %d varid = %d id=%d", ncid, varid, id)); - - /* Get the file info. */ - if ((ierr = pio_get_file(ncid, &file))) - return pio_err(NULL, NULL, ierr, __FILE__, __LINE__); - ios = file->iosystem; - - /* Only netCDF-4 files can use this feature. */ - if (file->iotype != PIO_IOTYPE_NETCDF4P && file->iotype != PIO_IOTYPE_NETCDF4C) - return pio_err(ios, file, PIO_ENOTNC4, __FILE__, __LINE__); - - /* If async is in use, and this is not an IO task, bcast the parameters. */ - if (ios->async) - { - if (!ios->ioproc) - { - int msg = PIO_MSG_INQ_VAR_FILTER_INFO; /* Message for async notification. */ - char nparamsp_present = nparamsp ? true : false; - char params_present = params ? true : false; - - if (ios->compmain == MPI_ROOT) - mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); - - if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(&id, 1, MPI_UNSIGNED, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(&nparamsp_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(¶ms_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); - if(!mpierr && params_present){ - size_t paramsize; - paramsize = sizeof(params); - mpierr = MPI_Bcast(¶msize, 1, PIO_MPI_SIZE_T, ios->compmain, ios->intercomm); - } - PLOG((2, "PIOc_inq_var_filter_info nparamsp_present = %d params_present = %d ", - nparamsp_present, params_present)); - } - - /* Handle MPI errors. */ - if ((mpierr2 = MPI_Bcast(&mpierr, 1, MPI_INT, ios->comproot, ios->my_comm))) - return check_mpi(ios, NULL, mpierr2, __FILE__, __LINE__); - if (mpierr) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - } - - /* If this is an IO task, then call the netCDF function. */ - if (ios->ioproc) - { - if (file->do_io) - ierr = nc_inq_var_filter_info(file->fh, varid, id, nparamsp, params); - } - - /* Broadcast and check the return code. */ - if ((mpierr = MPI_Bcast(&ierr, 1, MPI_INT, ios->ioroot, ios->my_comm))) - return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); - if (ierr) - return check_netcdf(file, ierr, __FILE__, __LINE__); - - /* Broadcast results to all tasks. */ - if (nparamsp && !ierr) - if ((mpierr = MPI_Bcast(nparamsp, 1, MPI_OFFSET, ios->ioroot, ios->my_comm))) - return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); - if ((*nparamsp)> 0 && params && !ierr) - if ((mpierr = MPI_Bcast(params, *(nparamsp), MPI_UNSIGNED, ios->ioroot, ios->my_comm))) - return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); - - return PIO_NOERR; -} - -#ifdef NC_HAS_BZ2 -/** - * Get the variable bzip2 filter info if any - * - * This function only applies to netCDF-4 files. When used with netCDF - * classic files, the error PIO_ENOTNC4 will be returned. - * - * - * See the netCDF - * variable documentation for details about the operation of this - * function. - * - * @param ncid the ncid of the open file. - * @param varid the ID of the variable. - * @param hasfilterp (OUT) Pointer that gets a 0 if bzip2 is not in use for this var and a 1 if it is. Ignored if NULL - * @param levelp (OUT) Pointer that gets the level setting (1 - 9) Ignored if NULL - * @return PIO_NOERR for success, otherwise an error code. - * @ingroup PIO_filters - * @author Jim Edwards/Ed Hartnett - */ -int -PIOc_inq_var_bzip2(int ncid, int varid, int* hasfilterp, int *levelp) -{ - iosystem_desc_t *ios; /* Pointer to io system information. */ - file_desc_t *file; /* Pointer to file information. */ - int ierr; /* Return code from function calls. */ - int mpierr = MPI_SUCCESS, mpierr2; /* Return code from MPI function codes. */ - - PLOG((1, "PIOc_inq_var_bzip2 ncid = %d varid = %d", ncid, varid)); - - /* Get the file info. */ - if ((ierr = pio_get_file(ncid, &file))) - return pio_err(NULL, NULL, ierr, __FILE__, __LINE__); - ios = file->iosystem; - - /* Only netCDF-4 files can use this feature. */ - if (file->iotype != PIO_IOTYPE_NETCDF4P && file->iotype != PIO_IOTYPE_NETCDF4C) - return pio_err(ios, file, PIO_ENOTNC4, __FILE__, __LINE__); - - /* If async is in use, and this is not an IO task, bcast the parameters. */ - if (ios->async) - { - if (!ios->ioproc) - { - int msg = PIO_MSG_INQ_VAR_BZIP2; /* Message for async notification. */ - char hasfilterp_present = hasfilterp ? true : false; - char levelp_present = levelp ? true : false; - - if (ios->compmain == MPI_ROOT) - mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); - - if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(&hasfilterp_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(&levelp_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); - PLOG((2, "PIOc_inq_var_bzip2 hasfilterp_present = %d levelp_present = %d ", - hasfilterp_present, levelp_present)); - } - - /* Handle MPI errors. */ - if ((mpierr2 = MPI_Bcast(&mpierr, 1, MPI_INT, ios->comproot, ios->my_comm))) - return check_mpi(ios, NULL, mpierr2, __FILE__, __LINE__); - if (mpierr) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - } - - /* If this is an IO task, then call the netCDF function. */ - if (ios->ioproc) - { - if (file->do_io) - ierr = nc_inq_var_bzip2(file->fh, varid, hasfilterp, levelp); - } - - /* Broadcast and check the return code. */ - if ((mpierr = MPI_Bcast(&ierr, 1, MPI_INT, ios->ioroot, ios->my_comm))) - return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); - if (ierr) - return check_netcdf(file, ierr, __FILE__, __LINE__); - - /* Broadcast results to all tasks. */ - if (hasfilterp && !ierr) - if ((mpierr = MPI_Bcast(hasfilterp, 1, MPI_INT, ios->ioroot, ios->my_comm))) - return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); - - if (levelp && !ierr) - if ((mpierr = MPI_Bcast(levelp, 1, MPI_INT, ios->ioroot, ios->my_comm))) - return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); - - return PIO_NOERR; -} -#endif -#ifdef NC_HAS_ZSTD -/** - * Get the variable zstandard filter info if any - * - * This function only applies to netCDF-4 files. When used with netCDF - * classic files, the error PIO_ENOTNC4 will be returned. - * - * - * See the netCDF - * variable documentation for details about the operation of this - * function. - * - * @param ncid the ncid of the open file. - * @param varid the ID of the variable. - * @param hasfilterp (OUT) Pointer that gets a 0 if zstandard is not in use for this var and a 1 if it is. Ignored if NULL - * @param levelp (OUT) Pointer that gets the level setting (1 - 9) Ignored if NULL - * @return PIO_NOERR for success, otherwise an error code. - * @ingroup PIO_filters - * @author Jim Edwards/Ed Hartnett - */ -int -PIOc_inq_var_zstandard(int ncid, int varid, int* hasfilterp, int *levelp) -{ - iosystem_desc_t *ios; /* Pointer to io system information. */ - file_desc_t *file; /* Pointer to file information. */ - int ierr; /* Return code from function calls. */ - int mpierr = MPI_SUCCESS, mpierr2; /* Return code from MPI function codes. */ - - PLOG((1, "PIOc_inq_var_zstandard ncid = %d varid = %d", ncid, varid)); - - /* Get the file info. */ - if ((ierr = pio_get_file(ncid, &file))) - return pio_err(NULL, NULL, ierr, __FILE__, __LINE__); - ios = file->iosystem; - - /* Only netCDF-4 files can use this feature. */ - if (file->iotype != PIO_IOTYPE_NETCDF4P && file->iotype != PIO_IOTYPE_NETCDF4C) - return pio_err(ios, file, PIO_ENOTNC4, __FILE__, __LINE__); - - /* If async is in use, and this is not an IO task, bcast the parameters. */ - if (ios->async) - { - if (!ios->ioproc) - { - int msg = PIO_MSG_INQ_VAR_ZSTANDARD; /* Message for async notification. */ - char hasfilterp_present = hasfilterp ? true : false; - char levelp_present = levelp ? true : false; - - if (ios->compmain == MPI_ROOT) - mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); - - if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(&hasfilterp_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(&levelp_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); - PLOG((2, "PIOc_inq_var_zstandard hasfilterp_present = %d levelp_present = %d ", - hasfilterp_present, levelp_present)); - } - - /* Handle MPI errors. */ - if ((mpierr2 = MPI_Bcast(&mpierr, 1, MPI_INT, ios->comproot, ios->my_comm))) - return check_mpi(ios, NULL, mpierr2, __FILE__, __LINE__); - if (mpierr) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - } - - /* If this is an IO task, then call the netCDF function. */ - if (ios->ioproc) - { - if (file->do_io) - ierr = nc_inq_var_zstandard(file->fh, varid, hasfilterp, levelp); - } - - /* Broadcast and check the return code. */ - if ((mpierr = MPI_Bcast(&ierr, 1, MPI_INT, ios->ioroot, ios->my_comm))) - return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); - if (ierr) - return check_netcdf(file, ierr, __FILE__, __LINE__); - - /* Broadcast results to all tasks. */ - if (hasfilterp && !ierr) - if ((mpierr = MPI_Bcast(hasfilterp, 1, MPI_INT, ios->ioroot, ios->my_comm))) - return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); - - if (levelp && !ierr) - if ((mpierr = MPI_Bcast(levelp, 1, MPI_INT, ios->ioroot, ios->my_comm))) - return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); - - return PIO_NOERR; -} -// NC_HAS_ZSTD -#endif -#endif -#ifdef PIO_HAS_PAR_FILTERS -/** - * - * - * This function only applies to netCDF-4 files. When used with netCDF - * classic files, the error PIO_ENOTNC4 will be returned. - * - * Note that these settings are not part of the data file - they apply - * only to the open file as long as it is open. - * - * See the netCDF - * variable documentation for details about the operation of this - * function. - * - * @param ncid the ncid of the open file. - * @param id the filter of interest - * @return PIO_NOERR if the filter is available, PIO_ENOFILTER if unavailable - * @ingroup PIO_filters - * @author Jim Edwards/Ed Hartnett - */ -int -PIOc_inq_filter_avail(int ncid, unsigned int id ) -{ - iosystem_desc_t *ios; /* Pointer to io system information. */ - file_desc_t *file; /* Pointer to file information. */ - int ierr; /* Return code from function calls. */ - int mpierr = MPI_SUCCESS, mpierr2; /* Return code from MPI function codes. */ - - PLOG((1, "PIOc_inq_filter_avail ncid = %d id = %d ", ncid, id)); - - /* Get the file info. */ - if ((ierr = pio_get_file(ncid, &file))) - return pio_err(NULL, NULL, ierr, __FILE__, __LINE__); - ios = file->iosystem; - - /* Only netCDF-4 files can use this feature. */ - if (file->iotype != PIO_IOTYPE_NETCDF4P && file->iotype != PIO_IOTYPE_NETCDF4C) - return pio_err(ios, file, PIO_ENOTNC4, __FILE__, __LINE__); - - /* If async is in use, and this is not an IO task, bcast the parameters. */ - if (ios->async) - { - if (!ios->ioproc) - { - int msg = PIO_MSG_INQ_FILTER_AVAIL; /* Message for async notification. */ - - if (ios->compmain == MPI_ROOT) - mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); - - if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(&id, 1, MPI_INT, ios->compmain, ios->intercomm); - } - - /* Handle MPI errors. */ - if ((mpierr2 = MPI_Bcast(&mpierr, 1, MPI_INT, ios->comproot, ios->my_comm))) - return check_mpi(ios, NULL, mpierr2, __FILE__, __LINE__); - if (mpierr) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - } - - /* If this is an IO task, then call the netCDF function. */ - if (ios->ioproc) - { - if (file->do_io) - ierr = nc_inq_filter_avail(file->fh, id); - } - - /* Broadcast and check the return code. */ - if ((mpierr = MPI_Bcast(&ierr, 1, MPI_INT, ios->ioroot, ios->my_comm))) - return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); - if (ierr && ierr !=NC_ENOFILTER) - return check_netcdf(file, ierr, __FILE__, __LINE__); - - /* Broadcast results to all tasks. */ - - return ierr; -} -// PIO_HAS_PAR_FILTERS -#endif -// NC_HAS_MULTIFILTERS -#endif -#ifdef NC_HAS_QUANTIZE -/** - * Turn on quantization for a variable - * - * This function only applies to netCDF-4 files. When used with netCDF - * classic files, the error PIO_ENOTNC4 will be returned. - * - * Note that these settings are not part of the data file - they apply - * only to the open file as long as it is open. - * - * See the netCDF - * variable documentation for details about the operation of this - * function. - * - * @param ncid the ncid of the open file. - * @param varid the ID of the variable. - * @param quantize_mode - * @param nsd Number of significant digits. - * @return PIO_NOERR for success, otherwise an error code. - * @ingroup PIO_inq_var_c - * @author Jim Edwards/Ed Hartnett - */ -int -PIOc_def_var_quantize(int ncid, int varid, int quantize_mode, int nsd ) -{ - iosystem_desc_t *ios; /* Pointer to io system information. */ - file_desc_t *file; /* Pointer to file information. */ - int ierr; /* Return code from function calls. */ - int mpierr = MPI_SUCCESS, mpierr2; /* Return code from MPI function codes. */ - - PLOG((1, "PIOc_def_var_quantize ncid = %d varid = %d quantize_mode=%d nsd=%d", ncid, varid, quantize_mode, nsd)); - - /* Get the file info. */ - if ((ierr = pio_get_file(ncid, &file))) - return pio_err(NULL, NULL, ierr, __FILE__, __LINE__); - ios = file->iosystem; - - /* Only netCDF-4 files can use this feature. */ - if (file->iotype != PIO_IOTYPE_NETCDF4P && file->iotype != PIO_IOTYPE_NETCDF4C) - return pio_err(ios, file, PIO_ENOTNC4, __FILE__, __LINE__); - - /* If async is in use, and this is not an IO task, bcast the parameters. */ - if (ios->async) - { - if (!ios->ioproc) - { - int msg = PIO_MSG_DEF_VAR_QUANTIZE; /* Message for async notification. */ - - if (ios->compmain == MPI_ROOT) - mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); - - if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(&quantize_mode, 1, MPI_INT, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(&nsd, 1, MPI_INT, ios->compmain, ios->intercomm); - } - - /* Handle MPI errors. */ - if ((mpierr2 = MPI_Bcast(&mpierr, 1, MPI_INT, ios->comproot, ios->my_comm))) - return check_mpi(ios, NULL, mpierr2, __FILE__, __LINE__); - if (mpierr) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - } - - /* If this is an IO task, then call the netCDF function. */ - if (ios->ioproc) - { - if (file->do_io) - ierr = nc_def_var_quantize(file->fh, varid, quantize_mode, nsd); - } - - /* Broadcast and check the return code. */ - if ((mpierr = MPI_Bcast(&ierr, 1, MPI_INT, ios->ioroot, ios->my_comm))) - return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); - if (ierr) - return check_netcdf(file, ierr, __FILE__, __LINE__); - - return PIO_NOERR; -} - -/** - * Learn whether quantization is on for a variable, and, if so, the NSD setting. - * - * This function only applies to netCDF-4 files. When used with netCDF - * classic files, the error PIO_ENOTNC4 will be returned. - * - * Note that these settings are not part of the data file - they apply - * only to the open file as long as it is open. - * - * See the netCDF - * variable documentation for details about the operation of this - * function. - * - * @param ncid the ncid of the open file. - * @param varid the ID of the variable. - * @param quantize_modep Pointer that gets a 0 if quantization is not in use for this var, and a 1 if it is. Ignored if NULL. - * @param nsdp Pointer that gets the NSD setting (from 1 to 15), if quantization is in use. Ignored if NULL. - * @return PIO_NOERR for success, otherwise an error code. - * @ingroup PIO_inq_var_c - * @author Jim Edwards/Ed Hartnett - */ -int -PIOc_inq_var_quantize(int ncid, int varid, int *quantize_mode, int *nsdp ) -{ - iosystem_desc_t *ios; /* Pointer to io system information. */ - file_desc_t *file; /* Pointer to file information. */ - int ierr; /* Return code from function calls. */ - int mpierr = MPI_SUCCESS, mpierr2; /* Return code from MPI function codes. */ - - PLOG((1, "PIOc_inq_var_quantize ncid = %d varid = %d ", ncid, varid)); - - /* Get the file info. */ - if ((ierr = pio_get_file(ncid, &file))) - return pio_err(NULL, NULL, ierr, __FILE__, __LINE__); - ios = file->iosystem; - - /* Only netCDF-4 files can use this feature. */ - if (file->iotype != PIO_IOTYPE_NETCDF4P && file->iotype != PIO_IOTYPE_NETCDF4C) - return pio_err(ios, file, PIO_ENOTNC4, __FILE__, __LINE__); - - /* If async is in use, and this is not an IO task, bcast the parameters. */ - if (ios->async) - { - if (!ios->ioproc) - { - int msg = PIO_MSG_INQ_VAR_QUANTIZE; /* Message for async notification. */ - char qmode_present = quantize_mode ? true : false; - char nsdp_present = nsdp ? true : false; - - if (ios->compmain == MPI_ROOT) - mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); - - if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(&qmode_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); - if (!mpierr) - mpierr = MPI_Bcast(&nsdp_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); - - PLOG((2, "PIOc_inq_var_quantize qmode_present = %d nsdp_present = %d ", - qmode_present, nsdp_present)); - } - - /* Handle MPI errors. */ - if ((mpierr2 = MPI_Bcast(&mpierr, 1, MPI_INT, ios->comproot, ios->my_comm))) - return check_mpi(ios, NULL, mpierr2, __FILE__, __LINE__); - if (mpierr) - return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); - } - - /* If this is an IO task, then call the netCDF function. */ - if (ios->ioproc) - { - if (file->do_io) - ierr = nc_inq_var_quantize(file->fh, varid, quantize_mode, nsdp); - } - - /* Broadcast and check the return code. */ - if ((mpierr = MPI_Bcast(&ierr, 1, MPI_INT, ios->ioroot, ios->my_comm))) - return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); - if (ierr) - return check_netcdf(file, ierr, __FILE__, __LINE__); - - /* Broadcast results to all tasks. */ - if (quantize_mode && !ierr) - if ((mpierr = MPI_Bcast(quantize_mode, 1, MPI_INT, ios->ioroot, ios->my_comm))) - return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); - if (nsdp && !ierr) - if ((mpierr = MPI_Bcast(nsdp, 1, MPI_INT, ios->ioroot, ios->my_comm))) - return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); - - return PIO_NOERR; -} -#endif diff --git a/src/clib/pio_rearrange.c b/src/clib/pio_rearrange.c index 2aabacb5bd..fb174c3a3f 100644 --- a/src/clib/pio_rearrange.c +++ b/src/clib/pio_rearrange.c @@ -11,7 +11,7 @@ #if PIO_USE_MPISERIAL #define MPI_Type_create_hvector MPI_Type_hvector #endif - +#define SIZEOF_MPI_OFFSET sizeof(MPI_Offset) /** * Convert a 1-D index into a coordinate value in an arbitrary * dimension space. E.g., for index 4 into a array defined as a[3][2], @@ -35,7 +35,7 @@ idx_to_dim_list(int ndims, const int *gdimlen, PIO_Offset idx, /* Check inputs. */ pioassert(ndims >= 0 && gdimlen && idx >= -1 && dim_list, "invalid input", __FILE__, __LINE__); - PLOG((3, "idx_to_dim_list ndims = %d idx = %d", ndims, idx)); + PLOG((2, "idx_to_dim_list ndims = %d idx = %d", ndims, idx)); /* Easiest to start from the right and move left. */ for (int i = ndims - 1; i >= 0; --i) @@ -314,7 +314,7 @@ create_mpi_datatypes(MPI_Datatype mpitype, int msgcnt, if (mindex) { for(int j=0; jrearranger == PIO_REARR_SUBSET ? iodesc->rfrom : NULL; - + /* Create the MPI datatypes. */ PLOG((2, "Calling create_mpi_datatypes at line %d ",__LINE__)); if ((ret = create_mpi_datatypes(iodesc->mpitype, iodesc->nrecvs, iodesc->rindex, @@ -510,7 +510,7 @@ define_iodesc_datatypes(iosystem_desc_t *ios, io_desc_t *iodesc) /* Remember how many types we created for the send side. */ iodesc->num_stypes = ntypes; - + /* Create the MPI data types. */ PLOG((2, "Calling create_mpi_datatypes at line %d",__LINE__)); if ((ret = create_mpi_datatypes(iodesc->mpitype, ntypes, iodesc->sindex, @@ -1113,7 +1113,7 @@ 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. */ - + 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__); @@ -2260,6 +2260,7 @@ subset_rearrange_create(iosystem_desc_t *ios, int maplen, PIO_Offset *compmap, PIO_Offset soffset; /* we only want a single copy of each source point in the iobuffer but it may be sent to multiple destinations in a read operation */ + int k=0; // PIO_Offset previomap[ntasks]; // for (i = 0; i < ntasks; i++) // previomap[i] = -1; diff --git a/src/clib/pio_spmd.c b/src/clib/pio_spmd.c index 68ee05fd1d..090e08ff82 100644 --- a/src/clib/pio_spmd.c +++ b/src/clib/pio_spmd.c @@ -364,13 +364,12 @@ int pio_swapm(void *sendbuf, int *sendcounts, int *sdispls, MPI_Datatype *sendty * them here. */ if (steps > 0) { - MPI_Status statuses[steps]; - PLOG((2, "Waiting for outstanding msgs")); - if ((mpierr = MPI_Waitall(steps, rcvids, statuses))) - return check_mpi(NULL, NULL, mpierr, __FILE__, __LINE__); - if (fc->isend) - if ((mpierr = MPI_Waitall(steps, sndids, statuses))) - return check_mpi(NULL, NULL, mpierr, __FILE__, __LINE__); + PLOG((2, "Waiting for outstanding msgs")); + if ((mpierr = MPI_Waitall(steps, rcvids, MPI_STATUSES_IGNORE))) + return check_mpi(NULL, NULL, mpierr, __FILE__, __LINE__); + if (fc->isend) + if ((mpierr = MPI_Waitall(steps, sndids, MPI_STATUSES_IGNORE))) + return check_mpi(NULL, NULL, mpierr, __FILE__, __LINE__); } return PIO_NOERR; diff --git a/src/clib/pioc.c b/src/clib/pioc.c index 1be5923457..5ff24c7da9 100644 --- a/src/clib/pioc.c +++ b/src/clib/pioc.c @@ -207,13 +207,13 @@ PIOc_advanceframe(int ncid, int varid) { int msg = PIO_MSG_ADVANCEFRAME; - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmaster, ios->intercomm); } /* Handle MPI errors. */ @@ -269,15 +269,15 @@ PIOc_setframe(int ncid, int varid, int frame) { int msg = PIO_MSG_SETFRAME; - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&frame, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&frame, 1, MPI_INT, ios->compmaster, ios->intercomm); } /* Handle MPI errors. */ @@ -352,8 +352,14 @@ PIOc_get_local_array_size(int ioid) int PIOc_Set_IOSystem_Error_Handling(int iosysid, int method) { + iosystem_desc_t *ios; int oldmethod; + /* Get the iosystem info. */ + if (iosysid != PIO_DEFAULT) + if (!(ios = pio_get_iosystem_from_id(iosysid))) + piodie("Could not find IO system.", __FILE__, __LINE__); + /* Set the error handler. */ if (PIOc_set_iosystem_error_handling(iosysid, method, &oldmethod)) piodie("Could not set the IOSystem error hanlder", __FILE__, __LINE__); @@ -402,13 +408,13 @@ PIOc_set_iosystem_error_handling(int iosysid, int method, int *old_method) int msg = PIO_MSG_SETERRORHANDLING; char old_method_present = old_method ? true : false; - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&method, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&method, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&old_method_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&old_method_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); } /* Handle MPI errors. */ @@ -535,37 +541,37 @@ PIOc_InitDecomp(int iosysid, int pio_type, int ndims, const int *gdimlen, int ma char rearranger_present = rearranger ? true : false; char iostart_present = iostart ? true : false; char iocount_present = iocount ? true : false; - if (ios->compmain == MPI_ROOT){ + if (ios->compmaster == MPI_ROOT){ PLOG((1, "about to sent msg %d union_comm %d",msg,ios->union_comm)); mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); } if (!mpierr) - mpierr = MPI_Bcast(&iosysid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&iosysid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&pio_type, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&pio_type, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&ndims, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ndims, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast((int *)gdimlen, ndims, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((int *)gdimlen, ndims, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&maplen, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&maplen, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast((PIO_Offset *)compmap, maplen, MPI_OFFSET, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((PIO_Offset *)compmap, maplen, MPI_OFFSET, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&rearranger_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&rearranger_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (rearranger_present && !mpierr) - mpierr = MPI_Bcast((int *)rearranger, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((int *)rearranger, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&iostart_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&iostart_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (iostart_present && !mpierr) - mpierr = MPI_Bcast((PIO_Offset *)iostart, ndims, MPI_OFFSET, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((PIO_Offset *)iostart, ndims, MPI_OFFSET, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&iocount_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&iocount_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (iocount_present && !mpierr) - mpierr = MPI_Bcast((PIO_Offset *)iocount, ndims, MPI_OFFSET, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((PIO_Offset *)iocount, ndims, MPI_OFFSET, ios->compmaster, ios->intercomm); PLOG((2, "PIOc_InitDecomp iosysid = %d pio_type = %d ndims = %d maplen = %d rearranger_present = %d iostart_present = %d " "iocount_present = %d ", iosysid, pio_type, ndims, maplen, rearranger_present, iostart_present, iocount_present)); } @@ -850,37 +856,37 @@ PIOc_InitDecomp_ReadOnly(int iosysid, int pio_type, int ndims, const int *gdimle char rearranger_present = rearranger ? true : false; char iostart_present = iostart ? true : false; char iocount_present = iocount ? true : false; - if (ios->compmain == MPI_ROOT){ + if (ios->compmaster == MPI_ROOT){ PLOG((1, "about to sent msg %d union_comm %d",msg,ios->union_comm)); mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); } if (!mpierr) - mpierr = MPI_Bcast(&iosysid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&iosysid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&pio_type, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&pio_type, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&ndims, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ndims, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast((int *)gdimlen, ndims, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((int *)gdimlen, ndims, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&maplen, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&maplen, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast((PIO_Offset *)compmap, maplen, MPI_OFFSET, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((PIO_Offset *)compmap, maplen, MPI_OFFSET, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&rearranger_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&rearranger_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (rearranger_present && !mpierr) - mpierr = MPI_Bcast((int *)rearranger, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((int *)rearranger, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&iostart_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&iostart_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (iostart_present && !mpierr) - mpierr = MPI_Bcast((PIO_Offset *)iostart, ndims, MPI_OFFSET, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((PIO_Offset *)iostart, ndims, MPI_OFFSET, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&iocount_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&iocount_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (iocount_present && !mpierr) - mpierr = MPI_Bcast((PIO_Offset *)iocount, ndims, MPI_OFFSET, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((PIO_Offset *)iocount, ndims, MPI_OFFSET, ios->compmaster, ios->intercomm); PLOG((2, "PIOc_InitDecomp iosysid = %d pio_type = %d ndims = %d maplen = %d rearranger_present = %d iostart_present = %d " "iocount_present = %d ", iosysid, pio_type, ndims, maplen, rearranger_present, iostart_present, iocount_present)); } @@ -968,6 +974,7 @@ PIOc_InitDecomp_ReadOnly(int iosysid, int pio_type, int ndims, const int *gdimle return pio_err(ios, NULL, PIO_EINVAL, __FILE__, __LINE__); } + PLOG((2, "iodesc->rearranger = %d", iodesc->rearranger)); /* Is this the subset rearranger? */ @@ -1133,7 +1140,7 @@ PIOc_init_decomp(int iosysid, int pio_type, int ndims, const int *gdimlen, int m /* Add 1 to all elements in compmap. */ for (int e = 0; e < maplen; e++) { - PLOG((5, "zero-based compmap[%d] = %d", e, compmap[e])); + PLOG((3, "zero-based compmap[%d] = %d", e, compmap[e])); compmap_1_based[e] = compmap[e] + 1; } @@ -1351,9 +1358,9 @@ PIOc_Init_Intracomm(MPI_Comm comp_comm, int num_iotasks, int stride, int base, for (int i = 0; i < ios->num_comptasks; i++) ios->compranks[i] = i; - /* Is this the comp main? */ + /* Is this the comp master? */ if (ios->comp_rank == 0) - ios->compmain = MPI_ROOT; + ios->compmaster = MPI_ROOT; PLOG((2, "comp_rank = %d num_comptasks = %d", ios->comp_rank, ios->num_comptasks)); /* Create an array that holds the ranks of the tasks to be used @@ -1374,7 +1381,7 @@ PIOc_Init_Intracomm(MPI_Comm comp_comm, int num_iotasks, int stride, int base, /* Identify the task that will be the root of the IO communicator. */ if (ios->comp_rank == ios->ioranks[0]) - ios->iomain = MPI_ROOT; + ios->iomaster = MPI_ROOT; /* Create a group for the computation tasks. */ if ((mpierr = MPI_Comm_group(ios->comp_comm, &compgroup))) @@ -1532,7 +1539,7 @@ PIOc_free_iosystem(int iosysid) return pio_err(NULL, NULL, PIO_EBADID, __FILE__, __LINE__); /* If asynch IO is in use, send the PIO_MSG_EXIT message from the - * comp main to the IO processes. This may be called by + * comp master to the IO processes. This may be called by * componets for other components iosysid. So don't send unless * there is a valid union_comm. */ if (ios->async && ios->union_comm != MPI_COMM_NULL) @@ -1547,12 +1554,12 @@ PIOc_free_iosystem(int iosysid) ios->ioroot, ios->union_comm)); /* Send the message to the message handler. */ - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); /* Send the parameters of the function call. */ if (!mpierr) - mpierr = MPI_Bcast((int *)&iosysid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((int *)&iosysid, 1, MPI_INT, ios->compmaster, ios->intercomm); } /* Handle MPI errors. */ @@ -1684,6 +1691,7 @@ PIOc_iotype_available(int iotype) #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: return 1; + break; #endif default: return 0; diff --git a/src/clib/pioc_async.c b/src/clib/pioc_async.c index 4ac8e68fd6..7927fb34d7 100644 --- a/src/clib/pioc_async.c +++ b/src/clib/pioc_async.c @@ -30,6 +30,7 @@ extern int diosysid; #endif /* NETCDF_INTEGRATION */ extern int default_error_handler; /* defined in pioc.c */ + /** * @defgroup PIO_init_async Initialize an ASYNC IO System * Initialize the IOSystem, including specifying number of IO and @@ -197,9 +198,9 @@ PIOc_init_async(MPI_Comm world, int num_io_procs, int *io_proc_list, /* Rank of current process in IO communicator. */ int io_rank = -1; - /* Set to MPI_ROOT on main process, MPI_PROC_NULL on other + /* Set to MPI_ROOT on master process, MPI_PROC_NULL on other * processes. */ - int iomain; + int iomaster; /* Create a group for the IO component. */ if ((ret = MPI_Group_incl(world_group, num_io_procs, my_io_proc_list, &io_group))) @@ -227,9 +228,9 @@ PIOc_init_async(MPI_Comm world, int num_io_procs, int *io_proc_list, PLOG((3, "about to get io rank")); if ((ret = MPI_Comm_rank(io_comm, &io_rank))) return check_mpi(NULL, NULL, ret, __FILE__, __LINE__); - iomain = !io_rank ? MPI_ROOT : MPI_PROC_NULL; + iomaster = !io_rank ? MPI_ROOT : MPI_PROC_NULL; PLOG((3, "intracomm created for io_comm = %d io_rank = %d IO %s", - io_comm, io_rank, iomain == MPI_ROOT ? "main" : "SERVANT")); + io_comm, io_rank, iomaster == MPI_ROOT ? "MASTER" : "SERVANT")); } /* We will create a group for each computational component. */ @@ -378,14 +379,14 @@ PIOc_init_async(MPI_Comm world, int num_io_procs, int *io_proc_list, if ((ret = MPI_Comm_rank(my_iosys->comp_comm, &my_iosys->comp_rank))) return check_mpi(NULL, NULL, ret, __FILE__, __LINE__); - /* Set comp_rank 0 to be the compmain. It will have a + /* Set comp_rank 0 to be the compmaster. It will have a * setting of MPI_ROOT, all other tasks will have a * setting of MPI_PROC_NULL. */ - my_iosys->compmain = my_iosys->comp_rank ? MPI_PROC_NULL : MPI_ROOT; + my_iosys->compmaster = my_iosys->comp_rank ? MPI_PROC_NULL : MPI_ROOT; PLOG((3, "intracomm created for cmp = %d comp_comm = %d comp_rank = %d comp %s", cmp, my_iosys->comp_comm, my_iosys->comp_rank, - my_iosys->compmain == MPI_ROOT ? "main" : "SERVANT")); + my_iosys->compmaster == MPI_ROOT ? "MASTER" : "SERVANT")); } /* If this is the IO component, make a copy of the IO comm for @@ -396,7 +397,7 @@ PIOc_init_async(MPI_Comm world, int num_io_procs, int *io_proc_list, if ((ret = MPI_Comm_dup(io_comm, &my_iosys->io_comm))) return check_mpi(NULL, NULL, ret, __FILE__, __LINE__); PLOG((3, "dup of io_comm = %d io_rank = %d", my_iosys->io_comm, io_rank)); - my_iosys->iomain = iomain; + my_iosys->iomaster = iomaster; my_iosys->io_rank = io_rank; my_iosys->ioroot = 0; my_iosys->comp_idx = cmp; diff --git a/src/clib/pioc_support.c b/src/clib/pioc_support.c index 9d44d1ee7f..2da40df7b1 100644 --- a/src/clib/pioc_support.c +++ b/src/clib/pioc_support.c @@ -204,10 +204,10 @@ int PIOc_set_global_log_level(int iosysid, int level) if(!ios->ioproc) { int msg = PIO_MSG_SETLOGLEVEL; - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&iosysid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&iosysid, 1, MPI_INT, ios->compmaster, ios->intercomm); } } @@ -755,10 +755,11 @@ pio_err(iosystem_desc_t *ios, file_desc_t *file, int err_num, const char *fname, MPI_Abort(MPI_COMM_WORLD, -1); } - /* Do nothing, error is bcast to all tasks and application will handle */ -// if (err_handler == PIO_BCAST_ERROR) -// { -// } + /* What should we do here??? */ + if (err_handler == PIO_BCAST_ERROR) + { + /* ??? */ + } /* If abort was not called, we'll get here. */ return err_num; @@ -872,11 +873,11 @@ find_mpi_type(int pio_type, MPI_Datatype *mpi_type, int *type_size) my_mpi_type = MPI_UNSIGNED_LONG_LONG; my_type_size = NETCDF_DOUBLE_INT64_SIZE; break; +#endif /* _NETCDF4 */ case PIO_STRING: my_mpi_type = MPI_CHAR; my_type_size = NETCDF_CHAR_SIZE; break; -#endif /* _NETCDF4 */ default: return PIO_EBADTYPE; } @@ -1015,13 +1016,13 @@ PIOc_freedecomp(int iosysid, int ioid) { int msg = PIO_MSG_FREEDECOMP; /* Message for async notification. */ - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); if (!mpierr) - mpierr = MPI_Bcast(&iosysid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&iosysid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&ioid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ioid, 1, MPI_INT, ios->compmaster, ios->intercomm); PLOG((2, "PIOc_freedecomp iosysid = %d ioid = %d", iosysid, ioid)); } @@ -1684,8 +1685,8 @@ pioc_read_nc_decomp_int(int iosysid, const char *filename, int *ndims, int **glo return pio_err(ios, NULL, PIO_EINVAL, __FILE__, __LINE__); PLOG((1, "pioc_read_nc_decomp_int iosysid = %d filename = %s", iosysid, filename)); - - + + /* Open the netCDF decomp file. */ if ((ret = PIOc_open(iosysid, filename, NC_WRITE, &ncid))) return pio_err(ios, NULL, ret, __FILE__, __LINE__); @@ -2092,28 +2093,28 @@ PIOc_createfile_int(int iosysid, int *ncidp, int *iotype, const char *filename, /* Send the message to the message handler. */ PLOG((3, "msg %d ios->union_comm %d MPI_COMM_NULL %d", msg, ios->union_comm, MPI_COMM_NULL)); - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); /* Send the parameters of the function call. */ if (!mpierr) - mpierr = MPI_Bcast(&len, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&len, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast((void *)filename, len + 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((void *)filename, len + 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&file->iotype, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&file->iotype, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&mode, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&mode, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&use_ext_ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&use_ext_ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&ncidp_present, 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncidp_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (ncidp_present) if (!mpierr) - mpierr = MPI_Bcast(ncidp, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(ncidp, 1, MPI_INT, ios->compmaster, ios->intercomm); #ifdef NETCDF_INTEGRATION if (!mpierr) - mpierr = MPI_Bcast(&diosysid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&diosysid, 1, MPI_INT, ios->compmaster, ios->intercomm); #endif /* NETCDF_INTEGRATION */ PLOG((2, "len %d filename %s iotype %d mode %d use_ext_ncid %d " "ncidp_present %d", len, filename, file->iotype, mode, @@ -2147,10 +2148,8 @@ PIOc_createfile_int(int iosysid, int *ncidp, int *iotype, const char *filename, case PIO_IOTYPE_NETCDF: if (!ios->io_rank) { -// PIOc_set_log_level(3); PLOG((2, "Calling nc_create mode = %d", mode)); ierr = nc_create(filename, mode, &file->fh); - PLOG((2, "Called nc_create mode = %d %d %s", mode, ierr, filename)); } break; #ifdef _PNETCDF @@ -2331,7 +2330,7 @@ inq_file_metadata(file_desc_t *file, int ncid, int iotype, int *nvars, /* Check inputs. */ pioassert(rec_var && pio_type && pio_type_size && mpi_type && mpi_type_size, "pointers must be provided", __FILE__, __LINE__); - ret = PIO_NOERR; + /* How many vars in the file? */ if (iotype == PIO_IOTYPE_PNETCDF) { @@ -2385,6 +2384,7 @@ inq_file_metadata(file_desc_t *file, int ncid, int iotype, int *nvars, return pio_err(NULL, file, ret, __FILE__, __LINE__); #endif /* _NETCDF4 */ } + /* Learn the unlimited dimension ID(s), if there are any. */ if (nunlimdims) { @@ -2542,6 +2542,7 @@ find_iotype_from_omode(int mode, int *iotype) else *iotype = PIO_IOTYPE_NETCDF; } + return PIO_NOERR; } @@ -2622,12 +2623,12 @@ PIOc_openfile_retry(int iosysid, int *ncidp, int *iotype, const char *filename, int *mpi_type_size = NULL; int *ndims = NULL; int mpierr = MPI_SUCCESS, mpierr2; /** Return code from MPI function codes. */ - int ierr; /* Return code from function calls. */ + int ierr = PIO_NOERR; /* Return code from function calls. */ #ifdef USE_MPE pio_start_mpe_log(OPEN); #endif /* USE_MPE */ - ierr = PIO_NOERR; /* Return code from function calls. */ + /* Get the IO system info from the iosysid. */ if (!(ios = pio_get_iosystem_from_id(iosysid))) return pio_err(NULL, NULL, PIO_EBADID, __FILE__, __LINE__); @@ -2638,8 +2639,8 @@ PIOc_openfile_retry(int iosysid, int *ncidp, int *iotype, const char *filename, if (*iotype < PIO_IOTYPE_PNETCDF || *iotype > PIO_IOTYPE_NETCDF4P) return pio_err(ios, NULL, PIO_EINVAL, __FILE__, __LINE__); - PLOG((2, "PIOc_openfile_retry iosysid = %d iotype = %d filename = %s mode = %d retry = %d ierr=%d", - iosysid, *iotype, filename, mode, retry, ierr)); + PLOG((2, "PIOc_openfile_retry iosysid = %d iotype = %d filename = %s mode = %d retry = %d", + iosysid, *iotype, filename, mode, retry)); /* Allocate space for the file info. */ if (!(file = calloc(sizeof(*file), 1))) @@ -2666,23 +2667,23 @@ PIOc_openfile_retry(int iosysid, int *ncidp, int *iotype, const char *filename, if (!ios->ioproc) { /* Send the message to the message handler. */ - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); /* Send the parameters of the function call. */ if (!mpierr) - mpierr = MPI_Bcast(&len, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&len, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast((void *)filename, len + 1, MPI_CHAR, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast((void *)filename, len + 1, MPI_CHAR, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&file->iotype, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&file->iotype, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&mode, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&mode, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) - mpierr = MPI_Bcast(&use_ext_ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&use_ext_ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); #ifdef NETCDF_INTEGRATION if (!mpierr) - mpierr = MPI_Bcast(&diosysid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&diosysid, 1, MPI_INT, ios->compmaster, ios->intercomm); #endif /* NETCDF_INTEGRATION */ } @@ -2692,8 +2693,6 @@ PIOc_openfile_retry(int iosysid, int *ncidp, int *iotype, const char *filename, if (mpierr) return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); } - PLOG((2, "%d: PIOc_openfile_retry ierr=%d",__LINE__,ierr)); - /* If this is an IO task, then call the netCDF function. */ if (ios->ioproc) @@ -2708,11 +2707,9 @@ PIOc_openfile_retry(int iosysid, int *ncidp, int *iotype, const char *filename, #else imode = mode | NC_MPIIO; if ((ierr = nc_open_par(filename, imode, ios->io_comm, ios->info, - &file->fh))){ - PLOG((2, "%d: PIOc_openfile_retry nc_open_par ierr=%d",__LINE__,ierr)); + &file->fh))) + break; - break; - } /* Check the vars for valid use of unlim dims. */ if ((ierr = check_unlim_use(file->fh))) break; @@ -2730,15 +2727,11 @@ PIOc_openfile_retry(int iosysid, int *ncidp, int *iotype, const char *filename, case PIO_IOTYPE_NETCDF4C: if (ios->io_rank == 0) { - if ((ierr = nc_open(filename, mode, &file->fh))){ - PLOG((2, "%d: PIOc_openfile_retry ierr=%d filename=%s mode=%d",__LINE__,ierr, filename, mode)); + if ((ierr = nc_open(filename, mode, &file->fh))) break; - } /* Check the vars for valid use of unlim dims. */ - if ((ierr = check_unlim_use(file->fh))){ - PLOG((2, "%d: PIOc_openfile_retry ierr=%d",__LINE__,ierr)); + if ((ierr = check_unlim_use(file->fh))) break; - } ierr = inq_file_metadata(file, file->fh, PIO_IOTYPE_NETCDF4C, &nvars, &rec_var, &pio_type, &pio_type_size, &mpi_type, @@ -2746,7 +2739,6 @@ PIOc_openfile_retry(int iosysid, int *ncidp, int *iotype, const char *filename, PLOG((2, "PIOc_openfile_retry:nc_open for 4C filename = %s mode = %d " "ierr = %d", filename, mode, ierr)); } - PLOG((2, "%d: PIOc_openfile_retry ierr=%d",__LINE__,ierr)); break; #endif /* _NETCDF4 */ @@ -2771,7 +2763,7 @@ PIOc_openfile_retry(int iosysid, int *ncidp, int *iotype, const char *filename, // This should only be done with a file opened to append if (ierr == PIO_NOERR && (mode & PIO_WRITE)) { - if (ios->iomain == MPI_ROOT) + if (ios->iomaster == MPI_ROOT) PLOG((2, "%d Setting IO buffer %ld", __LINE__, pio_pnetcdf_buffer_size_limit)); ierr = ncmpi_buffer_attach(file->fh, pio_pnetcdf_buffer_size_limit); @@ -2790,17 +2782,15 @@ PIOc_openfile_retry(int iosysid, int *ncidp, int *iotype, const char *filename, return pio_err(ios, file, PIO_EBADIOTYPE, __FILE__, __LINE__); } - PLOG((2, "%d: PIOc_openfile_retry ierr=%d",__LINE__,ierr)); - /* If the caller requested a retry, and we failed to open a file due to an incompatible type of NetCDF, try it once with just plain old basic NetCDF. */ if (retry) { PLOG((2, "retry error code ierr = %d io_rank %d", ierr, ios->io_rank)); - if ((ierr == NC_ENOTNC || ierr == NC_EINVAL || ierr == NC_ENOTBUILT) && (file->iotype != PIO_IOTYPE_NETCDF)) + if ((ierr == NC_ENOTNC || ierr == NC_EINVAL) && (file->iotype != PIO_IOTYPE_NETCDF)) { - if (ios->iomain == MPI_ROOT) + if (ios->iomaster == MPI_ROOT) printf("PIO2 pio_file.c retry NETCDF\n"); /* reset ierr on all tasks */ @@ -2831,7 +2821,6 @@ PIOc_openfile_retry(int iosysid, int *ncidp, int *iotype, const char *filename, if (ios->ioroot == ios->union_rank) PLOG((2, "Bcasting error code ierr %d ios->ioroot %d ios->my_comm %d", ierr, ios->ioroot, ios->my_comm)); - if ((mpierr = MPI_Bcast(&ierr, 1, MPI_INT, ios->ioroot, ios->my_comm))) return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); PLOG((2, "Bcast openfile_retry error code ierr = %d", ierr)); @@ -3037,13 +3026,13 @@ pioc_change_def(int ncid, int is_enddef) if (!ios->ioproc) { int msg = is_enddef ? PIO_MSG_ENDDEF : PIO_MSG_REDEF; - if (ios->compmain == MPI_ROOT) + if (ios->compmaster == MPI_ROOT) { PLOG((2, "pioc_change_def request sent")); mpierr = MPI_Send(&msg, 1, MPI_INT, ios->ioroot, 1, ios->union_comm); } if (!mpierr) - mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmain, ios->intercomm); + mpierr = MPI_Bcast(&ncid, 1, MPI_INT, ios->compmaster, ios->intercomm); PLOG((3, "pioc_change_def ncid = %d mpierr = %d", ncid, mpierr)); } @@ -3111,17 +3100,20 @@ iotype_is_valid(int iotype) ret++; /* Some builds include netCDF-4. */ -#ifdef NC_HAS_NC4 +#ifdef _NETCDF4 if (iotype == PIO_IOTYPE_NETCDF4C || iotype == PIO_IOTYPE_NETCDF4P) ret++; #endif /* _NETCDF4 */ /* Some builds include pnetcdf. */ -#ifdef _PNETCDF if (iotype == PIO_IOTYPE_PNETCDF) ret++; +#ifdef _PNETCDF #endif /* _PNETCDF */ + if (iotype == PIO_IOTYPE_GDAL) + ret++; + return ret; } @@ -3261,7 +3253,7 @@ determine_procs(int num_io_procs, int component_count, int *num_procs_per_comp, /** * Used in check_compmap to sort the compmap in accending order. - * + * * @param a pointer to an offset * @param b pointer to another offset * @returns 0 if offsets are the same or if either pointer is NULL @@ -3275,7 +3267,7 @@ int offsetsort(const void *a,const void *b) /** * check_compmap gathers the entire compmap to comp task 0, sorts it into accending order - * then looks for repeated values > 0. If any repeated values are found the iodesc is marked + * then looks for repeated values > 0. If any repeated values are found the iodesc is marked * read only. * * @param ios pointer to the iosystem_desc_t struct. @@ -3293,11 +3285,11 @@ bool check_compmap(iosystem_desc_t *ios, io_desc_t *iodesc,const PIO_Offset *com int ierr; bool readonly = 0; - if(ios->compproc) + if(ios->compproc) { #ifdef OLDWAY int *gmaplen; - if(ios->compmain == MPI_ROOT) + if(ios->compmaster == MPI_ROOT) gmaplen = malloc(ios->num_comptasks * sizeof(int)); else gmaplen = NULL; @@ -3334,7 +3326,7 @@ bool check_compmap(iosystem_desc_t *ios, io_desc_t *iodesc,const PIO_Offset *com int *displs; int gcompmaplen=0; int *gcompmaps; - if(ios->compmain == MPI_ROOT) + if(ios->compmaster == MPI_ROOT) { displs = malloc(ios->num_comptasks * sizeof(int)); displs[0] = 0; @@ -3343,7 +3335,7 @@ bool check_compmap(iosystem_desc_t *ios, io_desc_t *iodesc,const PIO_Offset *com displs[i] = displs[i-1] + gmaplen[i-1]; } gcompmaplen = displs[ios->num_comptasks-1] + gmaplen[ios->num_comptasks-1]; - gcompmaps = malloc(gcompmaplen * sizeof(PIO_Offset)); + gcompmaps = malloc(gcompmaplen * sizeof(PIO_Offset)); // printf("gcompmaplen %d\n",gcompmaplen); // for(int i=0;inum_comptasks; i++) // printf("gmaplen=%d displs[%d]=%d\n",gmaplen[i], i,displs[i]); @@ -3353,7 +3345,7 @@ bool check_compmap(iosystem_desc_t *ios, io_desc_t *iodesc,const PIO_Offset *com if ((ierr = MPI_Gatherv(compmap, iodesc->maplen, MPI_OFFSET, gcompmaps, gmaplen, displs, MPI_OFFSET, 0, ios->comp_comm))) return check_mpi(ios, NULL, ierr, __FILE__,__LINE__); - if(ios->compmain == MPI_ROOT) + if(ios->compmaster == MPI_ROOT) { /* sort */ qsort(gcompmaps, gcompmaplen, sizeof(MPI_OFFSET), offsetsort); @@ -3370,7 +3362,7 @@ bool check_compmap(iosystem_desc_t *ios, io_desc_t *iodesc,const PIO_Offset *com free(displs); free(gcompmaps); } - + } MPI_Bcast(&readonly, 1, MPI_CHAR, ios->comproot, ios->my_comm); #else diff --git a/src/flib/CMakeLists.txt b/src/flib/CMakeLists.txt index 11b60e7db1..d168039951 100644 --- a/src/flib/CMakeLists.txt +++ b/src/flib/CMakeLists.txt @@ -200,7 +200,6 @@ else () target_compile_definitions (gptl PUBLIC NO_MPIMOD) endif() - target_compile_definitions (piof PUBLIC NO_MPIMOD) endif () #===== GPTL ===== diff --git a/src/flib/pio.F90 b/src/flib/pio.F90 index f94ed7ce11..fabe61a7e9 100644 --- a/src/flib/pio.F90 +++ b/src/flib/pio.F90 @@ -7,7 +7,6 @@ !> !! @defgroup PIO_set_blocksize Box Rearranger Settings !! Set the box rearranger blocksize in Fortran. -#include #include "config.h" module pio @@ -17,14 +16,6 @@ module pio use pio_kinds, only : pio_offset_kind - use pionfatt_mod, only : PIO_put_att => put_att, & - PIO_get_att => get_att, & - PIO_inq_var_fill => inq_var_fill - use pionfput_mod, only : PIO_put_var => put_var - use pionfget_mod, only : PIO_get_var => get_var - use pio_support, only: pio_writedof, pio_readdof, pio_write_nc_dof, pio_read_nc_dof - use iso_c_binding - use piolib_mod, only : pio_initdecomp, & pio_openfile, pio_closefile, pio_createfile, pio_setdebuglevel, & pio_seterrorhandling, pio_setframe, pio_init, pio_get_local_array_size, & @@ -50,11 +41,8 @@ module pio pio_max_name, pio_max_var_dims, pio_rearr_subset, pio_rearr_box, & pio_nofill, pio_unlimited, pio_fill_int, pio_fill_double, pio_fill_float, & pio_64bit_offset, pio_64bit_data, pio_fill, & -#ifdef NC_HAS_QUANTIZE - PIO_NOQUANTIZE, PIO_QUANTIZE_BITGROOM, PIO_QUANTIZE_GRANULARBR, PIO_QUANTIZE_BITROUND, & -#endif - ! last line of use clause needs to be outside of macro pio_internal_error, pio_bcast_error, pio_return_error, pio_default + use piodarray, only : pio_read_darray, pio_write_darray, pio_set_buffer_size_limit use pio_nf, only: & @@ -76,25 +64,7 @@ module pio PIO_inq_unlimdim, & PIO_def_dim , & PIO_def_var , & -#ifdef PIO_HAS_PAR_FILTERS -#ifdef NC_HAS_BZ - PIO_def_var_bzip2, & -#endif -#ifdef NC_HAS_ZSTD - PIO_def_var_zstandard, & -#endif -#ifdef NC_HAS_QUANTIZE - PIO_def_var_quantize , & - PIO_inq_var_quantize , & -#endif - PIO_inq_var_filter_ids , & - PIO_inq_var_filter_info , & - PIO_inq_filter_avail , & - PIO_def_var_szip, & -#endif - PIO_def_var_deflate ,& - PIO_def_var_chunking, & - PIO_inq_var_chunking, & + PIO_def_var_deflate , & PIO_redef , & PIO_set_log_level, & PIO_inquire_variable , & @@ -106,6 +76,13 @@ module pio PIO_set_fill, & PIO_strerror + use pionfatt_mod, only : PIO_put_att => put_att, & + PIO_get_att => get_att, & + PIO_inq_var_fill => inq_var_fill + use pionfput_mod, only : PIO_put_var => put_var + use pionfget_mod, only : PIO_get_var => get_var + use pio_support, only: pio_writedof, pio_readdof, pio_write_nc_dof, pio_read_nc_dof + use iso_c_binding implicit none public diff --git a/src/flib/pio_nf.F90 b/src/flib/pio_nf.F90 index db08a7725b..f08ff754cc 100644 --- a/src/flib/pio_nf.F90 +++ b/src/flib/pio_nf.F90 @@ -1,4 +1,3 @@ -#include #include "config.h" !> !! @file @@ -135,26 +134,6 @@ module pio_nf pio_redef , & pio_set_log_level , & pio_strerror , & -#ifdef PIO_HAS_PAR_FILTERS -#ifdef NC_HAS_QUANTIZE - pio_def_var_quantize , & - pio_inq_var_quantize , & -#endif -#ifdef NC_HAS_MULTIFILTERS -#ifdef NC_HAS_BZ - pio_inq_var_bzip2 , & - pio_def_var_bzip2 , & -#endif -#ifdef NC_HAS_ZSTD - pio_inq_var_zstandard , & - pio_def_var_zstandard , & -#endif - pio_def_var_szip , & - pio_inq_var_filter_ids , & - pio_inq_var_filter_info , & - pio_inq_filter_avail , & -#endif -#endif pio_set_fill ! pio_copy_att to be done @@ -172,46 +151,8 @@ module pio_nf end interface pio_def_var_deflate interface pio_def_var_chunking module procedure & - def_var_chunking_desc, & - def_var_chunking_int, & - def_var_chunking_vid + def_var_chunking_desc end interface pio_def_var_chunking -#ifdef PIO_HAS_PAR_FILTERS -#ifdef NC_HAS_BZ - interface pio_def_var_bzip2 - module procedure & - def_var_bzip2_desc, & - def_var_bzip2_int, & - def_var_bzip2_vid - end interface pio_def_var_bzip2 - interface pio_inq_var_bzip2 - module procedure & - inq_var_bzip2_desc , & - inq_var_bzip2_vid , & - inq_var_bzip2_id - end interface pio_inq_var_bzip2 -#endif - interface pio_def_var_szip - module procedure & - def_var_szip_desc, & - def_var_szip_int, & - def_var_szip_vid - end interface pio_def_var_szip -#ifdef NC_HAS_ZSTD - interface pio_def_var_zstandard - module procedure & - def_var_zstandard_desc, & - def_var_zstandard_int, & - def_var_zstandard_vid - end interface pio_def_var_zstandard - interface pio_inq_var_zstandard - module procedure & - inq_var_zstandard_desc , & - inq_var_zstandard_vid , & - inq_var_zstandard_id - end interface pio_inq_var_zstandard -#endif -#endif interface pio_inq_attname module procedure & inq_attname_desc , & @@ -274,7 +215,6 @@ module pio_nf inq_var_deflate_vid , & inq_var_deflate_id end interface pio_inq_var_deflate - interface pio_inq_var_chunking module procedure & inq_var_chunking_desc , & @@ -397,35 +337,7 @@ module pio_nf get_var_chunk_cache_desc , & get_var_chunk_cache_id end interface pio_get_var_chunk_cache -#ifdef NC_HAS_QUANTIZE - interface pio_def_var_quantize - module procedure & - def_var_quantize_desc , & - def_var_quantize_id - end interface pio_def_var_quantize - interface pio_inq_var_quantize - module procedure & - inq_var_quantize_desc , & - inq_var_quantize_id - end interface pio_inq_var_quantize -#endif -#ifdef PIO_HAS_PAR_FILTERS - interface pio_inq_var_filter_ids - module procedure & - inq_var_filter_ids_desc , & - inq_var_filter_ids_id - end interface pio_inq_var_filter_ids - interface pio_inq_var_filter_info - module procedure & - inq_var_filter_info_desc , & - inq_var_filter_info_id - end interface pio_inq_var_filter_info - interface pio_inq_filter_avail - module procedure & - inq_filter_avail_desc , & - inq_filter_avail_id - end interface pio_inq_filter_avail -#endif + contains !> @@ -1548,146 +1460,7 @@ end function PIOc_inq_var_chunking enddo end function inq_var_chunking_id -#ifdef PIO_HAS_PAR_FILTERS -#ifdef NC_HAS_BZ - !> - !! @public - !! @ingroup PIO_inquire_variable - !! Gets metadata information for netcdf file. - !! - !! @param File @copydoc file_desc_t - !! @param vardesc @copydoc var_desc_t - !! @param storage 0 for chunked, 1 for contiguous - !! @param chunksizes Array of chunk sizes. - !! @retval ierr @copydoc error_return - !! @author Ed Hartnett - !< - integer function inq_var_bzip2_desc(File, vardesc, hasfilter, level) result(ierr) - - type (File_desc_t), intent(in) :: File - type (Var_desc_t), intent(in) :: vardesc - logical, intent(out) :: hasfilter - integer, intent(out) :: level - - ierr = pio_inq_var_bzip2(File%fh, vardesc%varid, hasfilter, level) - end function inq_var_bzip2_desc - - !> - !! @public - !! @ingroup PIO_inquire_variable - !! Gets metadata information for netcdf file. - !! @author Ed Hartnett - !< - integer function inq_var_bzip2_vid(File, varid, hasfilter, level) result(ierr) - - type (File_desc_t), intent(in) :: File - integer, intent(in) :: varid - logical, intent(out) :: hasfilter - integer, intent(out) :: level - - ierr = pio_inq_var_bzip2(File%fh, varid, hasfilter, level) - end function inq_var_bzip2_vid - !> - !! @public - !! @ingroup PIO_inquire_variable - !! Gets metadata information for netcdf file. - !! @author Ed Hartnett - !< - integer function inq_var_bzip2_id(ncid, varid, hasfilter, level) result(ierr) - integer, intent(in) :: ncid - integer, intent(in) :: varid - logical, intent(out) :: hasfilter - integer, intent(out) :: level - - integer :: hasfilterp - interface - integer(C_INT) function PIOc_inq_var_bzip2(ncid, varid, hasfilterp, levelp) & - bind(C, name="PIOc_inq_var_bzip2") - use iso_c_binding - integer(C_INT), value :: ncid - integer(C_INT), value :: varid - integer(C_INT) :: hasfilterp - integer(C_INT) :: levelp - end function PIOc_inq_var_bzip2 - end interface - - ierr = PIOc_inq_var_bzip2(ncid, varid-1, hasfilterp, level) - hasfilter = .false. - if(hasfilterp .ne. 0) hasfilter = .true. - - end function inq_var_bzip2_id -#endif -#ifdef NC_HAS_ZSTD - !> - !! @public - !! @ingroup PIO_inquire_variable - !! Gets metadata information for netcdf file. - !! - !! @param File @copydoc file_desc_t - !! @param vardesc @copydoc var_desc_t - !! @param storage 0 for chunked, 1 for contiguous - !! @param chunksizes Array of chunk sizes. - !! @retval ierr @copydoc error_return - !! @author Ed Hartnett - !< - integer function inq_var_zstandard_desc(File, vardesc, hasfilter, level) result(ierr) - - type (File_desc_t), intent(in) :: File - type (Var_desc_t), intent(in) :: vardesc - logical, intent(out) :: hasfilter - integer, intent(out) :: level - - ierr = pio_inq_var_zstandard(File%fh, vardesc%varid, hasfilter, level) - end function inq_var_zstandard_desc - - !> - !! @public - !! @ingroup PIO_inquire_variable - !! Gets metadata information for netcdf file. - !! @author Ed Hartnett - !< - integer function inq_var_zstandard_vid(File, varid, hasfilter, level) result(ierr) - - type (File_desc_t), intent(in) :: File - integer, intent(in) :: varid - logical, intent(out) :: hasfilter - integer, intent(out) :: level - - ierr = pio_inq_var_zstandard(File%fh, varid, hasfilter, level) - end function inq_var_zstandard_vid - - !> - !! @public - !! @ingroup PIO_inquire_variable - !! Gets metadata information for netcdf file. - !! @author Ed Hartnett - !< - integer function inq_var_zstandard_id(ncid, varid, hasfilter, level) result(ierr) - integer, intent(in) :: ncid - integer, intent(in) :: varid - logical, intent(out) :: hasfilter - integer, intent(out) :: level - - integer :: hasfilterp - interface - integer(C_INT) function PIOc_inq_var_zstandard(ncid, varid, hasfilterp, levelp) & - bind(C, name="PIOc_inq_var_zstandard") - use iso_c_binding - integer(C_INT), value :: ncid - integer(C_INT), value :: varid - integer(C_INT) :: hasfilterp - integer(C_INT) :: levelp - end function PIOc_inq_var_zstandard - end interface - - ierr = PIOc_inq_var_zstandard(ncid, varid-1, hasfilterp, level) - hasfilter = .false. - if(hasfilterp .ne. 0) hasfilter = .true. - - end function inq_var_zstandard_id -#endif -#endif !> !! @public !! @ingroup PIO_inquire_variable @@ -2158,32 +1931,6 @@ integer function def_var_chunking_desc(file, vardesc, storage, chunksizes) resul type (var_desc_t), intent(in) :: vardesc integer, intent(in) :: storage integer, intent(in) :: chunksizes(:) - - ierr = pio_def_var_chunking(file%fh, vardesc%varid, storage, chunksizes) - end function def_var_chunking_desc - !> - !! @ingroup PIO_def_var_chunking - !! Changes chunking settings for a netCDF-4/HDF5 variable. - !! @author Ed Hartnett - !< - integer function def_var_chunking_vid(file, varid, storage, chunksizes) result(ierr) - type (File_desc_t), intent(in) :: file - integer, intent(in) :: varid - integer, intent(in) :: storage - integer, intent(in) :: chunksizes(:) - - ierr = pio_def_var_chunking(file%fh, varid, storage, chunksizes) - end function def_var_chunking_vid - !> - !! @ingroup PIO_def_var_chunking - !! Changes chunking settings for a netCDF-4/HDF5 variable. - !! @author Ed Hartnett - !< - integer function def_var_chunking_int(ncid, varid, storage, chunksizes) result(ierr) - integer, intent(in) :: ncid - integer, intent(in) :: varid - integer, intent(in) :: storage - integer, intent(in) :: chunksizes(:) integer(kind=PIO_OFFSET_KIND) :: cchunksizes(PIO_MAX_VAR_DIMS) integer :: ndims, i @@ -2202,156 +1949,9 @@ end function PIOc_def_var_chunking cchunksizes(i) = chunksizes(ndims-i+1) enddo - ierr = PIOc_def_var_chunking(ncid, varid-1, storage, cchunksizes) - end function def_var_chunking_int -#ifdef PIO_HAS_PAR_FILTERS -#ifdef NC_HAS_BZ - !> - !! @ingroup PIO_def_var_bzip2 - !! Changes bzip2 settings for a netCDF-4/HDF5 variable. - !! @author Ed Hartnett - !< - integer function def_var_bzip2_desc(file, vardesc, level) result(ierr) - type (File_desc_t), intent(in) :: file - type (var_desc_t), intent(in) :: vardesc - integer, intent(in) :: level - - ierr = pio_def_var_bzip2(file%fh, vardesc%varid, level) - end function def_var_bzip2_desc - !> - !! @ingroup PIO_def_var_bzip2 - !! Changes chunking settings for a netCDF-4/HDF5 variable. - !! @author Ed Hartnett - !< - integer function def_var_bzip2_vid(file, varid, level) result(ierr) - type (File_desc_t), intent(in) :: file - integer, intent(in) :: varid - integer, intent(in) :: level - - ierr = pio_def_var_bzip2(file%fh, varid, level) - end function def_var_bzip2_vid - !> - !! @ingroup PIO_def_var_bzip2 - !! Changes chunking settings for a netCDF-4/HDF5 variable. - !! @author Ed Hartnett - !< - integer function def_var_bzip2_int(ncid, varid, level) result(ierr) - integer, intent(in) :: ncid - integer, intent(in) :: varid - integer, intent(in) :: level - - interface - integer (C_INT) function PIOc_def_var_bzip2(ncid, varid, level) & - bind(c,name="PIOc_def_var_bzip2") - use iso_c_binding - integer(c_int), value :: ncid - integer(c_int), value :: varid - integer(c_int), value :: level - end function PIOc_def_var_bzip2 - end interface - - ierr = PIOc_def_var_bzip2(ncid, varid-1, level) - end function def_var_bzip2_int -#endif -#ifdef NC_HAS_ZSTD - !> - !! @ingroup PIO_def_var_zstandard - !! Changes chunking settings for a netCDF-4/HDF5 variable. - !! @author Ed Hartnett - !< - integer function def_var_zstandard_desc(file, vardesc, level) result(ierr) - type (File_desc_t), intent(in) :: file - type (var_desc_t), intent(in) :: vardesc - integer, intent(in) :: level - - ierr = pio_def_var_zstandard(file%fh, vardesc%varid, level) - end function def_var_zstandard_desc - !> - !! @ingroup PIO_def_var_zstandard - !! Changes zstandard settings for a netCDF-4/HDF5 variable. - !! @author Ed Hartnett - !< - integer function def_var_zstandard_vid(file, varid, level) result(ierr) - type (File_desc_t), intent(in) :: file - integer, intent(in) :: varid - integer, intent(in) :: level - - ierr = pio_def_var_zstandard(file%fh, varid, level) - end function def_var_zstandard_vid - !> - !! @ingroup PIO_def_var_zstandard - !! Changes chunking settings for a netCDF-4/HDF5 variable. - !! @author Ed Hartnett - !< - integer function def_var_zstandard_int(ncid, varid, level) result(ierr) - integer, intent(in) :: ncid - integer, intent(in) :: varid - integer, intent(in) :: level - - interface - integer (C_INT) function PIOc_def_var_zstandard(ncid, varid, level) & - bind(c,name="PIOc_def_var_zstandard") - use iso_c_binding - integer(c_int), value :: ncid - integer(c_int), value :: varid - integer(c_int), value :: level - end function PIOc_def_var_zstandard - end interface - - ierr = PIOc_def_var_zstandard(ncid, varid-1, level) - end function def_var_zstandard_int -#endif - !> - !! @ingroup PIO_def_var_szip - !! Changes chunking settings for a netCDF-4/HDF5 variable. - !! @author Ed Hartnett - !< - integer function def_var_szip_desc(file, vardesc, mask, ppb) result(ierr) - type (File_desc_t), intent(in) :: file - type (var_desc_t), intent(in) :: vardesc - integer, intent(in) :: mask - integer, intent(in) :: ppb - - ierr = pio_def_var_szip(file%fh, vardesc%varid, mask, ppb) - end function def_var_szip_desc - !> - !! @ingroup PIO_def_var_szip - !! Changes szip settings for a netCDF-4/HDF5 variable. - !! @author Jim Edwards, Ed Hartnett - !< - integer function def_var_szip_vid(file, varid, mask, ppb) result(ierr) - type (File_desc_t), intent(in) :: file - integer, intent(in) :: varid - integer, intent(in) :: mask - integer, intent(in) :: ppb - - ierr = pio_def_var_szip(file%fh, varid, mask, ppb) - end function def_var_szip_vid - !> - !! @ingroup PIO_def_var_szip - !! Changes chunking settings for a netCDF-4/HDF5 variable. - !! @author Ed Hartnett - !< - integer function def_var_szip_int(ncid, varid, mask, ppb) result(ierr) - integer, intent(in) :: ncid - integer, intent(in) :: varid - integer, intent(in) :: mask - integer, intent(in) :: ppb - - interface - integer (C_INT) function PIOc_def_var_szip(ncid, varid, options_mask, pixels_per_block) & - bind(c,name="PIOc_def_var_szip") - use iso_c_binding - integer(c_int), value :: ncid - integer(c_int), value :: varid - integer(c_int), value :: options_mask - integer(c_int), value :: pixels_per_block - end function PIOc_def_var_szip - end interface + ierr = PIOc_def_var_chunking(file%fh, vardesc%varid-1, storage, cchunksizes) + end function def_var_chunking_desc - ierr = PIOc_def_var_szip(ncid, varid-1, mask, ppb) - end function def_var_szip_int -#endif !> !! @ingroup PIO_set_chunk_cache !! Changes chunk cache settings for netCDF-4/HDF5 files created after this call. @@ -2505,189 +2105,5 @@ end function PIOc_get_var_chunk_cache ierr = PIOc_get_var_chunk_cache(file%fh, varid-1, chunk_cache_size, & chunk_cache_nelems, chunk_cache_preemption) end function get_var_chunk_cache_id -#ifdef NC_HAS_QUANTIZE - !> - !! @ingroup PIO_def_var_quantize - !! Set quantize level for a netCDF-4/HDF5 variable - !! @author Jim Edwards, Ed Hartnett - !< - integer function def_var_quantize_desc(file, vardesc, quantize_mode, nsd) result(ierr) - type (File_desc_t), intent(in) :: file - type (var_desc_t), intent(in) :: vardesc - integer, intent(in) :: quantize_mode - integer, intent(in) :: nsd - - ierr = def_var_quantize_id(file%fh, vardesc%varid, quantize_mode, nsd) - end function def_var_quantize_desc - !> - !! @ingroup PIO_def_var_quantize - !! Set quantize level for a netCDF-4/HDF5 variable. - !! @author Jim Edwards, Ed Hartnett - !< - integer function def_var_quantize_id(ncid, varid, quantize_mode , nsd) result(ierr) - integer, intent(in) :: ncid - integer, intent(in) :: varid - integer, intent(in) :: quantize_mode - integer, intent(in) :: nsd - - interface - integer (C_INT) function PIOc_def_var_quantize(ncid, varid, quantize_mode, nsd) & - bind(c,name="PIOc_def_var_quantize") - use iso_c_binding - integer(c_int), value :: ncid - integer(c_int), value :: varid - integer(c_int), value :: quantize_mode - integer(c_int), value :: nsd - end function PIOc_def_var_quantize - end interface - - ierr = PIOc_def_var_quantize(ncid, varid-1, quantize_mode, nsd) - end function def_var_quantize_id - !> - !! @ingroup PIO_inq_var_quantize - !! Set quantize level for a netCDF-4/HDF5 variable - !! @author Jim Edwards, Ed Hartnett - !< - integer function inq_var_quantize_desc(file, vardesc, quantize_mode, nsd) result(ierr) - type (File_desc_t), intent(in) :: file - type (var_desc_t), intent(in) :: vardesc - integer, intent(out) :: quantize_mode - integer, intent(out) :: nsd - - ierr = inq_var_quantize_id(file%fh, vardesc%varid, quantize_mode, nsd) - end function inq_var_quantize_desc - !> - !! @ingroup PIO_inq_var_quantize - !! Set quantize level for a netCDF-4/HDF5 variable. - !! @author Jim Edwards, Ed Hartnett - !< - integer function inq_var_quantize_id(ncid, varid, quantize_mode , nsd) result(ierr) - integer, intent(in) :: ncid - integer, intent(in) :: varid - integer, intent(out) :: quantize_mode - integer, intent(out) :: nsd - - interface - integer (C_INT) function PIOc_inq_var_quantize(ncid, varid, quantize_mode, nsd) & - bind(c,name="PIOc_inq_var_quantize") - use iso_c_binding - integer(c_int), value :: ncid - integer(c_int), value :: varid - integer(c_int) :: quantize_mode - integer(c_int) :: nsd - end function PIOc_inq_var_quantize - end interface - - ierr = PIOc_inq_var_quantize(ncid, varid-1, quantize_mode, nsd) - end function inq_var_quantize_id -#endif -#ifdef PIO_HAS_PAR_FILTERS - !> - !! @ingroup PIO_inq_var_filter_ids - !! Inquire filter ids for a netCDF-4/HDF5 variable. - !! @author Jim Edwards, Ed Hartnett - !< - integer function inq_var_filter_ids_id(ncid, varid, nfilters, filterids) result(ierr) - integer, intent(in) :: ncid - integer, intent(in) :: varid - integer, intent(out) :: nfilters - integer, intent(out) :: filterids(:) - - interface - integer (C_INT) function PIOc_inq_var_filter_ids(ncid, varid, nfiltersp, filterids) & - bind(c,name="PIOc_inq_var_filter_ids") - use iso_c_binding - integer(c_int), value :: ncid - integer(c_int), value :: varid - integer(c_int) :: nfiltersp - integer(c_int) :: filterids(:) - end function PIOc_inq_var_filter_ids - end interface - - ierr = PIOc_inq_var_filter_ids(ncid, varid-1, nfilters, filterids) - end function inq_var_filter_ids_id - !> - !! @ingroup PIO_inq_var_filter_ids - !! Inquire filter ids for a netCDF-4/HDF5 variable. - !! @author Jim Edwards, Ed Hartnett - !< - integer function inq_var_filter_ids_desc(file, vardesc, nfilters, filterids) result(ierr) - type (File_desc_t), intent(in) :: file - type (var_desc_t), intent(in) :: vardesc - integer, intent(out) :: nfilters - integer, intent(out) :: filterids(:) - - ierr = inq_var_filter_ids_id(file%fh, vardesc%varid, nfilters, filterids) - end function inq_var_filter_ids_desc - !> - !! @ingroup PIO_inq_var_filter_info - !! Inquire filter ids for a netCDF-4/HDF5 variable. - !! @author Jim Edwards, Ed Hartnett - !< - integer function inq_var_filter_info_id(ncid, varid, id, params) result(ierr) - integer, intent(in) :: ncid - integer, intent(in) :: varid - integer, intent(in) :: id - integer, intent(out) :: params(:) - interface - integer (C_INT) function PIOc_inq_var_filter_info(ncid, varid, id, params) & - bind(c,name="PIOc_inq_var_filter_info") - use iso_c_binding - integer(c_int), value :: ncid - integer(c_int), value :: varid - integer(c_int), value :: id - integer(c_int) :: params(:) - end function PIOc_inq_var_filter_info - end interface - - ierr = PIOc_inq_var_filter_info(ncid, varid-1, id, params) - end function inq_var_filter_info_id - !> - !! @ingroup PIO_inq_var_filter_info - !! Inquire filter ids for a netCDF-4/HDF5 variable. - !! @author Jim Edwards, Ed Hartnett - !< - integer function inq_var_filter_info_desc(file, vardesc, id, params) result(ierr) - type (File_desc_t), intent(in) :: file - type (var_desc_t), intent(in) :: vardesc - integer, intent(in) :: id - integer, intent(out) :: params(:) - - ierr = inq_var_filter_info_id(file%fh, vardesc%varid, id, params) - end function inq_var_filter_info_desc -#ifdef PIO_HAS_PAR_FILTERS - !> - !! @ingroup PIO_inq_filter_avail_id - !! Inquire filter available for a netCDF-4/HDF5 file. - !! @author Jim Edwards, Ed Hartnett - !< - integer function inq_filter_avail_id(ncid, id) result(ierr) - integer, intent(in) :: ncid - integer, intent(in) :: id - - interface - integer (C_INT) function PIOc_inq_filter_avail(ncid, id) & - bind(c,name="PIOc_inq_filter_avail") - use iso_c_binding - integer(c_int), value :: ncid - integer(c_int), value :: id - end function PIOc_inq_filter_avail - end interface - - ierr = PIOc_inq_filter_avail(ncid, id) - end function inq_filter_avail_id - !> - !! @ingroup PIO_inq_var_filter_info - !! Inquire filter ids for a netCDF-4/HDF5 variable. - !! @author Jim Edwards, Ed Hartnett - !< - integer function inq_filter_avail_desc(file, id) result(ierr) - type (File_desc_t), intent(in) :: file - integer, intent(in) :: id - - ierr = inq_filter_avail_id(file%fh, id) - end function inq_filter_avail_desc -#endif -#endif end module pio_nf diff --git a/src/flib/pio_support.F90 b/src/flib/pio_support.F90 index 773aa18364..95405b83c4 100644 --- a/src/flib/pio_support.F90 +++ b/src/flib/pio_support.F90 @@ -93,9 +93,9 @@ subroutine piodie (file,line, msg, ival1, msg2, ival2, msg3, ival3, mpirank) call xl__trbk() #endif - ! passing an argument of 1 to mpi_abort will lead to a STOPALL output + ! passing an argument of 1 to mpi_abort will lead to a STOPALL output ! error code of 257 - call mpi_abort (MPI_COMM_WORLD, 1, ierr) + call mpi_abort (MPI_COMM_WORLD, 1, ierr) #ifdef CPRNAG stop @@ -162,7 +162,7 @@ integer(c_int) function PIOc_writemap_from_f90(file, ndims, gdims, maplen, map, character(C_CHAR), intent(in) :: file integer(C_INT), value, intent(in) :: ndims integer(C_INT), intent(in) :: gdims(*) - integer(C_SIZE_T), value, intent(in) :: maplen + integer(C_SIZE_T), value, intent(in) :: maplen integer(C_SIZE_T), intent(in) :: map(*) integer(C_INT), value, intent(in) :: f90_comm end function PIOc_writemap_from_f90 @@ -195,11 +195,11 @@ subroutine pio_write_nc_dof(ios, filename, cmode, iodesc, ret, title, history, f character(len=*), optional :: title character(len=*), optional :: history logical, optional :: fortran_order - + interface integer(c_int) function PIOc_write_nc_decomp(iosysid, filename, cmode, & ioid, title, history, fortran_order) & - bind(C,name="PIOc_write_nc_decomp") + bind(C,name="PIOc_write_nc_decomp") use iso_c_binding integer(C_INT), value :: iosysid character(kind=c_char) :: filename @@ -213,17 +213,19 @@ end function PIOc_write_nc_decomp character(len=:), allocatable :: ctitle, chistory integer :: nl integer :: forder + integer :: i + if(present(title)) then - ctitle(1:len_trim(title)+1) = trim(title)//C_NULL_CHAR + ctitle = trim(title)//C_NULL_CHAR else - ctitle(1:1) = C_NULL_CHAR + ctitle = C_NULL_CHAR endif if(present(history)) then - chistory(1:len_trim(history)+1) = trim(history)//C_NULL_CHAR + chistory = trim(history)//C_NULL_CHAR else - chistory(1:1) = C_NULL_CHAR + chistory = C_NULL_CHAR endif if(present(fortran_order)) then @@ -235,6 +237,7 @@ end function PIOc_write_nc_decomp endif nl = len_trim(filename) ret = PIOc_write_nc_decomp(ios%iosysid, filename(:nl)//C_NULL_CHAR, cmode, iodesc%ioid, ctitle, chistory, forder) + end subroutine pio_write_nc_dof @@ -263,7 +266,7 @@ subroutine pio_readdof (file, ndims, gdims, DOF, comm) type(C_PTR) :: tgdims, tmap interface integer(C_INT) function PIOc_readmap_from_f90(file, ndims, gdims, maplen, map, f90_comm) & - bind(C,name="PIOc_readmap_from_f90") + bind(C,name="PIOc_readmap_from_f90") use iso_c_binding character(C_CHAR), intent(in) :: file integer(C_INT), intent(out) :: ndims @@ -300,11 +303,11 @@ subroutine pio_read_nc_dof(ios, filename, iodesc, ret, title, history, fortran_o character(len=*), optional :: title character(len=*), optional :: history logical, optional :: fortran_order - + interface integer(c_int) function PIOc_read_nc_decomp(iosysid, filename, ioid, & title, history, fortran_order) & - bind(C,name="PIOc_read_nc_decomp") + bind(C,name="PIOc_read_nc_decomp") use iso_c_binding integer(C_INT), value :: iosysid character(kind=c_char) :: filename @@ -314,17 +317,17 @@ integer(c_int) function PIOc_read_nc_decomp(iosysid, filename, ioid, & integer(c_int), value :: fortran_order end function PIOc_read_nc_decomp end interface + character(len=:), allocatable :: ctitle, chistory integer :: nl integer :: forder nl = len_trim(filename) - forder = 0 ret = PIOc_read_nc_decomp(ios%iosysid, filename(:nl)//C_NULL_CHAR, iodesc%ioid, title, history, forder) if(present(fortran_order)) then if(forder /= 0) then fortran_order = .true. else - fortran_order = .false. + fortran_order = .true. endif endif end subroutine pio_read_nc_dof diff --git a/src/flib/pio_types.F90 b/src/flib/pio_types.F90 index 7dc88ebec1..dad1b49944 100644 --- a/src/flib/pio_types.F90 +++ b/src/flib/pio_types.F90 @@ -1,5 +1,4 @@ #include "config.h" -#include !> !! @file !! Derived datatypes and constants for PIO Fortran API. @@ -154,26 +153,6 @@ module pio_types enumerator :: PIO_rearr_comm_p2p = 0 !< do point-to-point communications using mpi send and recv calls. enumerator :: PIO_rearr_comm_coll !< use the MPI_ALLTOALLW function of the mpi library end enum -#ifdef NC_HAS_QUANTIZE - enum, bind(c) - enumerator :: PIO_NOQUANTIZE = 0 - enumerator :: PIO_QUANTIZE_BITGROOM - enumerator :: PIO_QUANTIZE_GRANULARBR - enumerator :: PIO_QUANTIZE_BITROUND - end enum -#endif -#ifdef NC_HAS_MULTIFILTERS - enum, bind(c) - enumerator :: PIO_FILTER_NONE = 0 - enumerator :: PIO_FILTER_DEFLATE - enumerator :: PIO_FILTER_SHUFFLE - enumerator :: PIO_FILTER_FLETCHER32 - enumerator :: PIO_FILTER_SZIP - enumerator :: PIO_FILTER_NBIT - enumerator :: PIO_FILTER_SCALEOFFSET - end ENUM -#endif - !> !! @defgroup PIO_rearr_comm_t Rearranger Communication @@ -227,9 +206,6 @@ module pio_types end type PIO_rearr_opt_t public :: PIO_rearr_comm_p2p, PIO_rearr_comm_coll,& -#ifdef NC_HAS_QUANTIZE - PIO_NOQUANTIZE, PIO_QUANTIZE_BITGROOM, PIO_QUANTIZE_GRANULARBR, PIO_QUANTIZE_BITROUND, & -#endif PIO_rearr_comm_fc_2d_enable, PIO_rearr_comm_fc_1d_comp2io,& PIO_rearr_comm_fc_1d_io2comp, PIO_rearr_comm_fc_2d_disable diff --git a/src/flib/piolib_mod.F90 b/src/flib/piolib_mod.F90 index 265a0e102d..908af2cfea 100644 --- a/src/flib/piolib_mod.F90 +++ b/src/flib/piolib_mod.F90 @@ -1343,7 +1343,8 @@ end function pio_iotype_available !! @param file The returned file descriptor !! @param iotype @copydoc PIO_iotype !! @param fname The name of the file to open - !! @param amode_in The NetCDF creation mode flag: PIO_CLOBBER, PIO_NOCLOBBER, PIO_64BIT_OFFSET, PIO_64BIT_DATA + !! @param amode_in The NetCDF creation mode flag - NC_NOWRITE for + !! read-only access or NC_WRITE for read-write access. !! @retval ierr @copydoc error_return !! @author Jim Edwards !< diff --git a/src/gptl/ChangeLog b/src/gptl/ChangeLog index 8bbbbcfe4f..3d11911e6b 100644 --- a/src/gptl/ChangeLog +++ b/src/gptl/ChangeLog @@ -2,15 +2,15 @@ timing_120921: Add code for cmake build, should not have any affect otherwise timing_120803: Bug fix in setting timing_detail_limit default. [Patrick Worley] timing_120731: Correction in Makefile for serial build [Jim Edwards] -timing_120728: Replace process subset optional parameter in t_prf with - outpe_thispe optional parameter. Change def_perf_outpe_num to 0. +timing_120728: Replace process subset optional parameter in t_prf with + outpe_thispe optional parameter. Change def_perf_outpe_num to 0. [Patrick Worley] timing_120717: Retain timestamp on cp in Makefile [Jim Edwards] timing_120710: Correct issue in Makefile [Jim Edwards] timing_120709: Change for BGP to measure on compute nodes rather than IO nodes only, minor Change in Makefile so that gptl can build seperate from csm_share in cesm [Jim Edwards] -timing_120512: Bug fix in global statistics logic for when a thread has no events +timing_120512: Bug fix in global statistics logic for when a thread has no events to contribute to the merge (mods to gptl.c) [Patrick Worley] timing_120419: Minor changes for mpi-serial compile (jedwards) @@ -18,7 +18,7 @@ timing_120408: Make HAVE_COMM_F2C default to true. (jedwards) timing_120110: Update to GPTL 4.1 source (mods to gptl.c and GPTLprint_memusage) [Jim Rosinski (GPTL 4.1), Patrick Worley] timing_120109: Bug fix (adding shr_kind_i8 to shr_kind_mod list) -timing_111205: Update to gptl 4.0 (introducing CESM customizations); +timing_111205: Update to gptl 4.0 (introducing CESM customizations); support for handles in t_startf/t_stopf; support for restricting output to explicitly named process subsets [Jim Rosinski (gptl 4.0), Patrick Worley] @@ -29,7 +29,7 @@ timing_101210: Fix interface to cesm build system, add workaround for xlf bug timing_101202: updated get_memusage and print_memusage from GPTL version 3.7; adds improved support for MacOS and SLASHPROC [Jim Rosinski, Chuck Bardeen (integrated by P. Worley)] -timing_091021: update to GPTL version 3.5; rewrite of GPTLpr_summary: much faster, merging +timing_091021: update to GPTL version 3.5; rewrite of GPTLpr_summary: much faster, merging events from all processes and all threads (not just process 0/thread 0); miscellaneous fixes [Jim Rosinski (gptl 3.5), Joseph Singh, Patrick Worley] @@ -39,7 +39,7 @@ timing_090929: added explicit support for the GPTL-native token HAVE_MPI (indica timing_081221: restore default assumption that gettimeofday available timing_081028: bug fix in include order in gptl_papi.c timing_081026: change in output format to make postprocessing simpler -timing_081024: support for up to one million processes and writing timing files to +timing_081024: support for up to one million processes and writing timing files to subdirectories timing_081017: updated to gptl version 3_4_2. Changed some defaults. [Jim Rosinski, Patrick Worley] @@ -57,8 +57,8 @@ timing_071023: updated to gptl version 2.16, added support for output of global statistics; removed dependencies on shr and CAM routines; renamed gptlutil.c to GPTLutil.c [Patrick Worley, Jim Rosinski] -timing_071019: modified namelist logic to abort if try to set unknown namelist parameters; - changed default number of reporting processes to 1; +timing_071019: modified namelist logic to abort if try to set unknown namelist parameters; + changed default number of reporting processes to 1; reversed meaning and changed names of CPP tokens to NO_C99_INLINE and NO_VPRINTF [Patrick Worley] timing_071010: modified gptl.c to remove the 'inline' specification unless the @@ -67,75 +67,75 @@ timing_071010: modified gptl.c to remove the 'inline' specification unless the timing_070810: added ChangeLog updated to latest version of GPTL (from Jim Rosinski) modified perf_mod.F90: - - added perf_outpe_num and perf_outpe_stride to perf_inparm + - added perf_outpe_num and perf_outpe_stride to perf_inparm namelist to control which processes output timing data - added perf_papi_enable to perf_inparm namelist to enable - PAPI counters + PAPI counters - added papi_inparm namelist and papi_ctr1,2,3,4 namelist parameters to specify PAPI counters [Patrick Worley, Jim Rosinski] -timing_070525: bug fix in gptl.c +timing_070525: bug fix in gptl.c - unitialized pointer, testing for null pter before traversing [Patrick Worley] timing_070328: modified perf_mod.F90 - deleted HIDE_MPI cpp token [Erik Kluzek] -timing_070327: bug fixes in gptl.c - - testing for null pters before traversing +timing_070327: bug fixes in gptl.c + - testing for null pters before traversing links; added missing type declaration to GPTLallocate for sum - bug fixes in perf_mod.F90 - - fixed OMP-related logic, modified settings reporting, + bug fixes in perf_mod.F90 + - fixed OMP-related logic, modified settings reporting, modified to work when namelist input is missing; moved timer depth logic back into gptl.c [Patrick Worley] -timing_070308: added perf_mod.F90 - - defines all t_xxx entry points - calling gptlxxx directly +timing_070308: added perf_mod.F90 + - defines all t_xxx entry points - calling gptlxxx directly and removing all external gptlxxx dependencies, added detail option as an alternative way to disable event timing, added runtime selection of timing_disable, perf_timer, timer_depth_limit, timing_detail_limit, timing_barrier, perf_single_file via namelist parameters - modified f_wrappers.c - - replaced all t_xxx entry points with gptlxxx entry points, + modified f_wrappers.c + - replaced all t_xxx entry points with gptlxxx entry points, added new gptlxxx entry points, deleted _fcd support - modified gptl.c + modified gptl.c - deleted DISABLE_TIMERS cpp token, modified GPTLpr call and logic to move some of support for concatenating timing output into a single file to perf_mod.F90 - modified gptl.h - - exposed gptlxxx entry points and to add support for choice + modified gptl.h + - exposed gptlxxx entry points and to add support for choice of GPTL timer modified gptl.inc - removed t_xxx entry points and expose gptlxxx entry points [Patrick Worley] -timing_061207: modified gptl.c - - improved event output ordering +timing_061207: modified gptl.c + - improved event output ordering [Jim Edwards] -timing_061124: modified gptl.c +timing_061124: modified gptl.c - modified GPTLpr to add option to concatenate all timing data in a single output file, added GPTL_enable - and GPTL_disable as runtime control of event timing, + and GPTL_disable as runtime control of event timing, process 0-only reporting of timing options - unless DEBUG cpp token defined - modified gptl.h + modified gptl.h - redefined GPTLpr parameters - modified f_wrappers.c - - added t_enablef and t_disablef to call GPTL_enable and + modified f_wrappers.c + - added t_enablef and t_disablef to call GPTL_enable and GPTL_disable, added t_pr_onef, added string.h include - bug fix in f_wrappers.c + bug fix in f_wrappers.c - changed character string size declaration from int to size_t - bug fix in gptl_papi.c + bug fix in gptl_papi.c - modified error message - from Jim Edwards modified private.h - increased maximum event name length [Patrick Worley] -timing_061028: modified f_wrappers.c +timing_061028: modified f_wrappers.c - deleted dependency on cfort.h [Patrick Worley] -timing_060524: modified f_wrappers.c - - added support for CRAY cpp token and fixed routine +timing_060524: modified f_wrappers.c + - added support for CRAY cpp token and fixed routine type declarations [Patrick Worley] -timing_051212: original subversion version +timing_051212: original subversion version - see CAM ChangeLog for earlier history diff --git a/src/gptl/GPTLget_memusage.c b/src/gptl/GPTLget_memusage.c index 4b0d138b2b..4ccdef8b2a 100644 --- a/src/gptl/GPTLget_memusage.c +++ b/src/gptl/GPTLget_memusage.c @@ -4,7 +4,7 @@ ** Author: Jim Rosinski ** Credit to Chuck Bardeen for MACOS section (__APPLE__ ifdef) ** -** get_memusage: +** get_memusage: ** ** Designed to be called from Fortran, returns information about memory ** usage in each of 5 input int* args. On Linux read from the /proc @@ -63,7 +63,7 @@ int GPTLget_memusage (int *size, int *rss, int *share, int *text, int *datastack long long total; int node_config; - + /* memory available */ Kernel_GetPersonality(&pers, sizeof(pers)); total = BGP_Personality_DDRSizeMB(&pers); @@ -116,7 +116,7 @@ int GPTLget_memusage (int *size, int *rss, int *share, int *text, int *datastack ** arguments, close the file and return. */ - ret = fscanf (fd, "%d %d %d %d %d %d %d", + ret = fscanf (fd, "%d %d %d %d %d %d %d", size, rss, share, text, datastack, &dum, &dum); ret = fclose (fd); return 0; @@ -124,9 +124,9 @@ int GPTLget_memusage (int *size, int *rss, int *share, int *text, int *datastack #elif (defined __APPLE__) FILE *fd; - char cmd[60]; + char cmd[60]; int pid = (int) getpid (); - + sprintf (cmd, "ps -o vsz -o rss -o tsiz -p %d | grep -v RSS", pid); fd = popen (cmd, "r"); @@ -145,7 +145,7 @@ int GPTLget_memusage (int *size, int *rss, int *share, int *text, int *datastack if (getrusage (RUSAGE_SELF, &usage) < 0) return -1; - + *size = -1; *rss = usage.ru_maxrss; *share = -1; diff --git a/src/gptl/GPTLprint_memusage.c b/src/gptl/GPTLprint_memusage.c index a185d61100..5ab873dccb 100644 --- a/src/gptl/GPTLprint_memusage.c +++ b/src/gptl/GPTLprint_memusage.c @@ -30,13 +30,13 @@ int GPTLprint_memusage (const char *str) static const int nbytes = 1024*1024*10; /* allocate 10 MB */ static double blockstomb; /* convert blocks to MB */ void *space; /* allocated space */ - + if (GPTLget_memusage (&size, &rss, &share, &text, &datastack) < 0) return -1; #if (defined HAVE_SLASHPROC || defined __APPLE__) /* - ** Determine size in bytes of memory usage info presented by the OS. Method: allocate a + ** Determine size in bytes of memory usage info presented by the OS. Method: allocate a ** known amount of memory and see how much bigger the process becomes. */ @@ -47,7 +47,7 @@ int GPTLprint_memusage (const char *str) /* ** Estimate bytes per block, then refine to nearest power of 2. ** The assumption is that the OS presents memory usage info in - ** units that are a power of 2. + ** units that are a power of 2. */ bytesperblock = (int) ((nbytes / (double) (size2 - size)) + 0.5); bytesperblock = nearest_powerof2 (bytesperblock); @@ -57,19 +57,19 @@ int GPTLprint_memusage (const char *str) } free (space); } - + if (bytesperblock > 0) - printf ("%s size=%.1f MB rss=%.1f MB share=%.1f MB text=%.1f MB datastack=%.1f MB\n", - str, size*blockstomb, rss*blockstomb, share*blockstomb, + printf ("%s size=%.1f MB rss=%.1f MB share=%.1f MB text=%.1f MB datastack=%.1f MB\n", + str, size*blockstomb, rss*blockstomb, share*blockstomb, text*blockstomb, datastack*blockstomb); else - printf ("%s size=%d rss=%d share=%d text=%d datastack=%d\n", + printf ("%s size=%d rss=%d share=%d text=%d datastack=%d\n", str, size, rss, share, text, datastack); #else /* - ** Use max rss as returned by getrusage. If someone knows how to + ** Use max rss as returned by getrusage. If someone knows how to ** get the process size under AIX please tell me. */ @@ -85,7 +85,7 @@ int GPTLprint_memusage (const char *str) } /* -** nearest_powerof2: +** nearest_powerof2: ** Determine nearest integer which is a power of 2. ** Note: algorithm can't use anything that requires -lm because this is a library, ** and we don't want to burden the user with having to add extra libraries to the @@ -112,7 +112,7 @@ static int nearest_powerof2 (const int val) delta1 = val - lower; delta2 = higher - val; - + if (delta1 < delta2) return lower; else diff --git a/src/gptl/GPTLutil.c b/src/gptl/GPTLutil.c index d9a1a93866..b1c7cf80df 100644 --- a/src/gptl/GPTLutil.c +++ b/src/gptl/GPTLutil.c @@ -25,10 +25,10 @@ static int max_error = 500; /* max number of error print msgs */ int GPTLerror (const char *fmt, ...) { va_list args; - + va_start (args, fmt); static int num_error = 0; - + if (fmt != NULL && num_error < max_error) { #ifndef NO_VPRINTF (void) vfprintf (stderr, fmt, args); @@ -39,10 +39,10 @@ int GPTLerror (const char *fmt, ...) (void) fprintf (stderr, "Truncating further error print now after %d msgs", num_error); ++num_error; - } - + } + va_end (args); - + if (abort_on_error) exit (-1); @@ -79,3 +79,4 @@ void *GPTLallocate (const int nbytes) return ptr; } + diff --git a/src/gptl/README b/src/gptl/README index f8f3f7f7a0..2f0991da21 100644 --- a/src/gptl/README +++ b/src/gptl/README @@ -18,7 +18,7 @@ Of course these events can only be enabled if the PAPI counters they require are available on the target architecture. -Using GPTL +Using GPTL ---------- C codes making GPTL library calls should #include . Fortran codes @@ -63,7 +63,7 @@ GPTLfinalize() can be called to clean up the GPTL environment. All space malloc'ed by the GPTL library will be freed by this call. -Example +Example ------- From "man GPTLstart", a simple example calling sequence to time a couple of @@ -86,7 +86,7 @@ do_work(); /* do some work */ (void) GPTLpr (mympitaskid); /* print the results to timing. */ -Auto-instrumentation +Auto-instrumentation -------------------- If the regions to be timed are defined by function entry and exit points, and @@ -128,7 +128,7 @@ Running hex2name.pl converts the function addresses back to human-readable function names. It uses the UNIX "nm" utility to do this. -Multi-processor instrumented codes +Multi-processor instrumented codes ---------------------------------- For instrumented codes which make use of threading and/or MPI, a diff --git a/src/gptl/f_wrappers.c b/src/gptl/f_wrappers.c index b1da29ec4e..02f4b75678 100644 --- a/src/gptl/f_wrappers.c +++ b/src/gptl/f_wrappers.c @@ -2,7 +2,7 @@ ** $Id: f_wrappers.c,v 1.56 2010-12-29 18:46:42 rosinski Exp $ ** ** Author: Jim Rosinski -** +** ** Fortran wrappers for timing library routines */ @@ -175,12 +175,12 @@ int gptlsetoption (int *option, int *val); int gptlenable (void); int gptldisable (void); int gptlsetutr (int *option); -int gptlquery (const char *name, int *t, int *count, int *onflg, double *wallclock, - double *usr, double *sys, long long *papicounters_out, int *maxcounters, +int gptlquery (const char *name, int *t, int *count, int *onflg, double *wallclock, + double *usr, double *sys, long long *papicounters_out, int *maxcounters, int nc); int gptlquerycounters (const char *name, int *t, long long *papicounters_out, int nc); int gptlget_wallclock (const char *name, int *t, double *value, int nc); -int gptlget_eventvalue (const char *timername, const char *eventname, int *t, double *value, +int gptlget_eventvalue (const char *timername, const char *eventname, int *t, double *value, int nc1, int nc2); int gptlget_nregions (int *t, int *nregions); int gptlget_regionname (int *t, int *region, char *name, int nc); @@ -258,7 +258,7 @@ int gptlpr_summary (int *fcomm) #endif #else int ccomm = 0; -#endif +#endif return GPTLpr_summary (ccomm); } @@ -278,7 +278,7 @@ int gptlpr_summary_file (int *fcomm, char *file, int nc1) #endif #else int ccomm = 0; -#endif +#endif if ( ! (locfile = (char *) malloc (nc1+1))) return GPTLerror ("gptlpr_summary_file: malloc error\n"); @@ -304,7 +304,7 @@ int gptlbarrier (int *fcomm, char *name, int nc1) #endif #else int ccomm = 0; -#endif +#endif numchars = MIN (nc1, MAX_CHARS); strncpy (cname, name, numchars); @@ -394,8 +394,8 @@ int gptlsetutr (int *option) return GPTLsetutr (*option); } -int gptlquery (const char *name, int *t, int *count, int *onflg, double *wallclock, - double *usr, double *sys, long long *papicounters_out, int *maxcounters, +int gptlquery (const char *name, int *t, int *count, int *onflg, double *wallclock, + double *usr, double *sys, long long *papicounters_out, int *maxcounters, int nc) { char cname[MAX_CHARS+1]; @@ -430,7 +430,7 @@ int gptlget_wallclock (const char *name, int *t, double *value, int nc) return GPTLget_wallclock (cname, *t, value); } -int gptlget_eventvalue (const char *timername, const char *eventname, int *t, double *value, +int gptlget_eventvalue (const char *timername, const char *eventname, int *t, double *value, int nc1, int nc2) { char ctimername[MAX_CHARS+1]; diff --git a/src/gptl/gptl.c b/src/gptl/gptl.c index a038422fc9..d06d33f088 100644 --- a/src/gptl/gptl.c +++ b/src/gptl/gptl.c @@ -17,7 +17,7 @@ #include #ifndef HAVE_C99_INLINE -#define inline +#define inline #endif #ifdef HAVE_PAPI @@ -134,7 +134,7 @@ static char **timerlist; /* list of all timers */ typedef struct { int val; /* depth in calling tree */ int padding[31]; /* padding is to mitigate false cache sharing */ -} Nofalse; +} Nofalse; static Timer ***callstack; /* call stack */ static Nofalse *stackidx; /* index into callstack: */ @@ -260,7 +260,7 @@ int GPTLsetoption (const int option, /* option */ switch (option) { case GPTLcpu: #ifdef HAVE_TIMES - cpustats.enabled = (bool) val; + cpustats.enabled = (bool) val; if (verbose) printf ("%s: cpustats = %d\n", thisfunc, val); #else @@ -268,56 +268,56 @@ int GPTLsetoption (const int option, /* option */ return GPTLerror ("%s: times() not available\n", thisfunc); #endif return 0; - case GPTLwall: - wallstats.enabled = (bool) val; + case GPTLwall: + wallstats.enabled = (bool) val; if (verbose) printf ("%s: boolean wallstats = %d\n", thisfunc, val); return 0; - case GPTLoverhead: - overheadstats.enabled = (bool) val; + case GPTLoverhead: + overheadstats.enabled = (bool) val; if (verbose) printf ("%s: boolean overheadstats = %d\n", thisfunc, val); return 0; - case GPTLdepthlimit: - depthlimit = val; + case GPTLdepthlimit: + depthlimit = val; if (verbose) printf ("%s: depthlimit = %d\n", thisfunc, val); return 0; - case GPTLverbose: - verbose = (bool) val; + case GPTLverbose: + verbose = (bool) val; #ifdef HAVE_PAPI (void) GPTL_PAPIsetoption (GPTLverbose, val); #endif if (verbose) printf ("%s: boolean verbose = %d\n", thisfunc, val); return 0; - case GPTLpercent: - percent = (bool) val; + case GPTLpercent: + percent = (bool) val; if (verbose) printf ("%s: boolean percent = %d\n", thisfunc, val); return 0; - case GPTLdopr_preamble: - dopr_preamble = (bool) val; + case GPTLdopr_preamble: + dopr_preamble = (bool) val; if (verbose) printf ("%s: boolean dopr_preamble = %d\n", thisfunc, val); return 0; - case GPTLdopr_threadsort: - dopr_threadsort = (bool) val; + case GPTLdopr_threadsort: + dopr_threadsort = (bool) val; if (verbose) printf ("%s: boolean dopr_threadsort = %d\n", thisfunc, val); return 0; - case GPTLdopr_multparent: - dopr_multparent = (bool) val; + case GPTLdopr_multparent: + dopr_multparent = (bool) val; if (verbose) printf ("%s: boolean dopr_multparent = %d\n", thisfunc, val); return 0; - case GPTLdopr_collision: - dopr_collision = (bool) val; + case GPTLdopr_collision: + dopr_collision = (bool) val; if (verbose) printf ("%s: boolean dopr_collision = %d\n", thisfunc, val); return 0; case GPTLprint_method: - method = (Method) val; + method = (Method) val; if (verbose) printf ("%s: print_method = %s\n", thisfunc, methodstr (method)); return 0; @@ -338,8 +338,8 @@ int GPTLsetoption (const int option, /* option */ printf ("%s: boolean sync_mpi = %d\n", thisfunc, val); return 0; - /* - ** Allow GPTLmultiplex to fall through because it will be handled by + /* + ** Allow GPTLmultiplex to fall through because it will be handled by ** GPTL_PAPIsetoption() */ @@ -405,7 +405,7 @@ int GPTLsetutr (const int option) ** GPTLinitialize (): Initialization routine must be called from single-threaded ** region before any other timing routines may be called. The need for this ** routine could be eliminated if not targetting timing library for threaded -** capability. +** capability. ** ** return value: 0 (success) or GPTLerror (failure) */ @@ -469,12 +469,12 @@ int GPTLinitialize (void) return GPTLerror ("%s: Failure from GPTL_PAPIinitialize\n", thisfunc); #endif - /* + /* ** Call init routine for underlying timing routine. */ if ((*funclist[funcidx].funcinit)() < 0) { - fprintf (stderr, "%s: Failure initializing %s. Reverting underlying timer to %s\n", + fprintf (stderr, "%s: Failure initializing %s. Reverting underlying timer to %s\n", thisfunc, funclist[funcidx].name, funclist[0].name); funcidx = 0; } @@ -620,12 +620,12 @@ int GPTLstart_instr (void *self) ptr = getentry_instr (hashtable[t], self, &indx); - /* - ** Recursion => increment depth in recursion and return. We need to return + /* + ** Recursion => increment depth in recursion and return. We need to return ** because we don't want to restart the timer. We want the reported time for ** the timer to reflect the outermost layer of recursion. */ - + if (ptr && ptr->onflg) { ++ptr->recurselvl; return 0; @@ -662,7 +662,7 @@ int GPTLstart_instr (void *self) return GPTLerror ("%s: update_ptr error\n", thisfunc); return (0); -} +} /* ** GPTLstart: start a timer @@ -700,15 +700,15 @@ int GPTLstart (const char *name) /* timer name */ return 0; } - /* + /* ** ptr will point to the requested timer in the current list, - ** or NULL if this is a new entry + ** or NULL if this is a new entry */ ptr = getentry (hashtable[t], name, &indx); - /* - ** Recursion => increment depth in recursion and return. We need to return + /* + ** Recursion => increment depth in recursion and return. We need to return ** because we don't want to restart the timer. We want the reported time for ** the timer to reflect the outermost layer of recursion. */ @@ -786,7 +786,7 @@ int GPTLstart_handle (const char *name, /* timer name */ } /* - ** If on input, handle references a non-zero value, assume it's a previously returned Timer* + ** If on input, handle references a non-zero value, assume it's a previously returned Timer* ** passed in by the user. If zero, generate the hash entry and return it to the user. */ @@ -795,9 +795,9 @@ int GPTLstart_handle (const char *name, /* timer name */ } else { ptr = getentry (hashtable[t], name, &indx); } - - /* - ** Recursion => increment depth in recursion and return. We need to return + + /* + ** Recursion => increment depth in recursion and return. We need to return ** because we don't want to restart the timer. We want the reported time for ** the timer to reflect the outermost layer of recursion. */ @@ -869,7 +869,7 @@ static int update_ll_hash (Timer *ptr, const int t, const unsigned int indx) last[t] = ptr; ++hashtable[t][indx].nument; nument = hashtable[t][indx].nument; - + eptr = (Timer **) realloc (hashtable[t][indx].entries, nument * sizeof (Timer *)); if ( ! eptr) return GPTLerror ("update_ll_hash: realloc error\n"); @@ -898,7 +898,7 @@ static inline int update_ptr (Timer *ptr, const int t) if (cpustats.enabled && get_cpustamp (&ptr->cpu.last_utime, &ptr->cpu.last_stime) < 0) return GPTLerror ("update_ptr: get_cpustamp error"); - + if (wallstats.enabled) { tp2 = (*ptr2wtimefunc) (); ptr->wall.last = tp2; @@ -922,9 +922,9 @@ static inline int update_ptr (Timer *ptr, const int t) ** Return value: 0 (success) or GPTLerror (failure) */ -static inline int update_parent_info (Timer *ptr, - Timer **callstackt, - int stackidxt) +static inline int update_parent_info (Timer *ptr, + Timer **callstackt, + int stackidxt) { int n; /* loop index through known parents */ Timer *pptr; /* pointer to parent in callstack */ @@ -941,7 +941,7 @@ static inline int update_parent_info (Timer *ptr, callstackt[stackidxt] = ptr; - /* + /* ** If the region has no parent, bump its orphan count ** (should never happen since "GPTL_ROOT" added). */ @@ -1010,7 +1010,7 @@ int GPTLstop_instr (void *self) return GPTLerror ("%s: GPTLinitialize has not been called\n", thisfunc); /* Get the timestamp */ - + if (wallstats.enabled) { tp1 = (*ptr2wtimefunc) (); } @@ -1033,7 +1033,7 @@ int GPTLstop_instr (void *self) ptr = getentry_instr (hashtable[t], self, &indx); - if ( ! ptr) + if ( ! ptr) return GPTLerror ("%s: timer for %p had not been started.\n", thisfunc, self); if ( ! ptr->onflg ) @@ -1041,7 +1041,7 @@ int GPTLstop_instr (void *self) ++ptr->count; - /* + /* ** Recursion => decrement depth in recursion and return. We need to return ** because we don't want to stop the timer. We want the reported time for ** the timer to reflect the outermost layer of recursion. @@ -1085,7 +1085,7 @@ int GPTLstop (const char *name) /* timer name */ return GPTLerror ("%s: GPTLinitialize has not been called\n", thisfunc); /* Get the timestamp */ - + if (wallstats.enabled) { tp1 = (*ptr2wtimefunc) (); } @@ -1114,7 +1114,7 @@ int GPTLstop (const char *name) /* timer name */ ++ptr->count; - /* + /* ** Recursion => decrement depth in recursion and return. We need to return ** because we don't want to stop the timer. We want the reported time for ** the timer to reflect the outermost layer of recursion. @@ -1160,7 +1160,7 @@ int GPTLstop_handle (const char *name, /* timer name */ return GPTLerror ("%s: GPTLinitialize has not been called\n", thisfunc); /* Get the timestamp */ - + if (wallstats.enabled) { tp1 = (*ptr2wtimefunc) (); } @@ -1182,7 +1182,7 @@ int GPTLstop_handle (const char *name, /* timer name */ } /* - ** If on input, handle references a non-zero value, assume it's a previously returned Timer* + ** If on input, handle references a non-zero value, assume it's a previously returned Timer* ** passed in by the user. If zero, generate the hash entry and return it to the user. */ @@ -1198,7 +1198,7 @@ int GPTLstop_handle (const char *name, /* timer name */ ++ptr->count; - /* + /* ** Recursion => decrement depth in recursion and return. We need to return ** because we don't want to stop the timer. We want the reported time for ** the timer to reflect the outermost layer of recursion. @@ -1224,7 +1224,7 @@ int GPTLstop_handle (const char *name, /* timer name */ } /* -** update_stats: update stats inside ptr. Called by GPTLstop, GPTLstop_instr, +** update_stats: update stats inside ptr. Called by GPTLstop, GPTLstop_instr, ** GPTLstop_handle ** ** Input arguments: @@ -1237,9 +1237,9 @@ int GPTLstop_handle (const char *name, /* timer name */ ** Return value: 0 (success) or GPTLerror (failure) */ -static inline int update_stats (Timer *ptr, - const double tp1, - const long usr, +static inline int update_stats (Timer *ptr, + const double tp1, + const long usr, const long sys, const int t) { @@ -1375,7 +1375,7 @@ int GPTLreset (void) return 0; } -/* +/* ** GPTLpr_set_append: set GPTLpr_file and GPTLpr_summary_file ** to use append mode */ @@ -1386,20 +1386,20 @@ int GPTLpr_set_append (void) return 0; } -/* +/* ** GPTLpr_query_append: query whether GPTLpr_file and GPTLpr_summary_file ** use append mode */ int GPTLpr_query_append (void) { - if (pr_append) + if (pr_append) return 1; - else + else return 0; } -/* +/* ** GPTLpr_set_write: set GPTLpr_file and GPTLpr_summary_file ** to use write mode */ @@ -1410,20 +1410,20 @@ int GPTLpr_set_write (void) return 0; } -/* +/* ** GPTLpr_query_write: query whether GPTLpr_file and GPTLpr_summary_file ** use write mode */ int GPTLpr_query_write (void) { - if (pr_append) + if (pr_append) return 0; - else + else return 1; } -/* +/* ** GPTLpr: Print values of all timers ** ** Input arguments: @@ -1448,7 +1448,7 @@ int GPTLpr (const int id) /* output file will be named "timing." */ return 0; } -/* +/* ** GPTLpr_file: Print values of all timers ** ** Input arguments: @@ -1500,9 +1500,9 @@ int GPTLpr_file (const char *outfile) /* output file to write */ /* 2 is for "/" plus null */ if (outdir) - totlen = strlen (outdir) + strlen (outfile) + 2; + totlen = strlen (outdir) + strlen (outfile) + 2; else - totlen = strlen (outfile) + 2; + totlen = strlen (outfile) + 2; outpath = (char *) GPTLallocate (totlen); @@ -1619,11 +1619,11 @@ int GPTLpr_file (const char *outfile) /* output file to write */ } sum = (float *) GPTLallocate (nthreads * sizeof (float)); - + for (t = 0; t < nthreads; ++t) { /* - ** Construct tree for printing timers in parent/child form. get_max_depth() must be called + ** Construct tree for printing timers in parent/child form. get_max_depth() must be called ** AFTER construct_tree() because it relies on the per-parent children arrays being complete. */ @@ -1671,7 +1671,7 @@ int GPTLpr_file (const char *outfile) /* output file to write */ printself_andchildren (timers[t], fp, t, -1, tot_overhead); - /* + /* ** Sum of overhead across timers is meaningful. ** Factor of 2 is because there are 2 utr calls per start/stop pair. */ @@ -1721,8 +1721,8 @@ int GPTLpr_file (const char *outfile) /* output file to write */ /* Start at next to skip dummy */ for (ptr = timers[0]->next; ptr; ptr = ptr->next) { - - /* + + /* ** To print sum stats, first create a new timer then copy thread 0 ** stats into it. then sum using "add", and finally print. */ @@ -1874,7 +1874,7 @@ int GPTLpr_file (const char *outfile) /* output file to write */ totmem += gptlmem; fprintf (fp, "\n"); fprintf (fp, "Thread %d total memory usage = %g KB\n", t, gptlmem*.001); - fprintf (fp, " Hashmem = %g KB\n" + fprintf (fp, " Hashmem = %g KB\n" " Regionmem = %g KB (papimem portion = %g KB)\n" " Parent/child arrays = %g KB\n", hashmem*.001, regionmem*.001, papimem*.001, pchmem*.001); @@ -1892,7 +1892,7 @@ int GPTLpr_file (const char *outfile) /* output file to write */ return 0; } -/* +/* ** construct_tree: Build the parent->children tree starting with knowledge of ** parent list for each child. ** @@ -1944,7 +1944,7 @@ int construct_tree (Timer *timerst, Method method) } break; case GPTLfull_tree: - /* + /* ** Careful: this one can create *lots* of output! */ for (n = 0; n < ptr->nparent; ++n) { @@ -1959,7 +1959,7 @@ int construct_tree (Timer *timerst, Method method) return 0; } -/* +/* ** methodstr: Return a pointer to a string which represents the method ** ** Input arguments: @@ -1980,9 +1980,9 @@ static char *methodstr (Method method) return "Unknown"; } -/* +/* ** newchild: Add an entry to the children list of parent. Use function -** is_descendant() to prevent infinite loops. +** is_descendant() to prevent infinite loops. ** ** Input arguments: ** parent: parent node @@ -2017,7 +2017,7 @@ static int newchild (Timer *parent, Timer *child) } /* - ** To guarantee no loops, ensure that proposed parent isn't already a descendant of + ** To guarantee no loops, ensure that proposed parent isn't already a descendant of ** proposed child */ @@ -2040,13 +2040,13 @@ static int newchild (Timer *parent, Timer *child) return 0; } -/* +/* ** get_max_depth: Determine the maximum call tree depth by traversing the ** tree recursively ** ** Input arguments: ** ptr: Starting timer -** startdepth: current depth when function invoked +** startdepth: current depth when function invoked ** ** Return value: maximum depth */ @@ -2064,7 +2064,7 @@ static int get_max_depth (const Timer *ptr, const int startdepth) return maxdepth; } -/* +/* ** num_descendants: Determine the number of descendants of a timer by traversing ** the tree recursively. This function is not currently used. It could be ** useful in a pruning algorithm @@ -2086,7 +2086,7 @@ static int num_descendants (Timer *ptr) return ptr->num_desc; } -/* +/* ** is_descendant: Determine whether node2 is in the descendant list for ** node1 ** @@ -2114,7 +2114,7 @@ static int is_descendant (const Timer *node1, const Timer *node2) return 0; } -/* +/* ** printstats: print a single timer ** ** Input arguments: @@ -2224,7 +2224,7 @@ static void printstats (const Timer *timer, else fprintf (fp, "%13.3e ", timer->nbytes / timer->count); #endif - + #ifdef HAVE_PAPI GPTL_PAPIpr (fp, &timer->aux, t, timer->count, timer->wall.accum); #endif @@ -2232,13 +2232,13 @@ static void printstats (const Timer *timer, fprintf (fp, "\n"); } -/* -** print_multparentinfo: +/* +** print_multparentinfo: ** ** Input arguments: ** Input/output arguments: */ -void print_multparentinfo (FILE *fp, +void print_multparentinfo (FILE *fp, Timer *ptr) { int n; @@ -2263,7 +2263,7 @@ void print_multparentinfo (FILE *fp, fprintf (fp, "%8.1e %-32s\n\n", (float) ptr->count, ptr->name); } -/* +/* ** add: add the contents of tin to tout ** ** Input arguments: @@ -2272,14 +2272,14 @@ void print_multparentinfo (FILE *fp, ** tout: output timer summed into */ -static void add (Timer *tout, +static void add (Timer *tout, const Timer *tin) { tout->count += tin->count; if (wallstats.enabled) { tout->wall.accum += tin->wall.accum; - + tout->wall.max = MAX (tout->wall.max, tin->wall.max); tout->wall.min = MIN (tout->wall.min, tin->wall.min); } @@ -2293,8 +2293,8 @@ static void add (Timer *tout, #endif } -/* -** GPTLpr_summary: Gather and print summary stats across +/* +** GPTLpr_summary: Gather and print summary stats across ** threads and MPI tasks ** ** Input arguments: @@ -2315,10 +2315,10 @@ int GPTLpr_summary (int comm) } #ifdef HAVE_MPI -int GPTLpr_summary_file (MPI_Comm comm, +int GPTLpr_summary_file (MPI_Comm comm, const char *outfile) #else -int GPTLpr_summary_file (int comm, +int GPTLpr_summary_file (int comm, const char *outfile) #endif { @@ -2362,7 +2362,7 @@ int GPTLpr_summary_file (int comm, return GPTLerror ("%s: GPTLinitialize() has not been called\n", thisfunc); /* - ** Each process gathers stats for its threads. + ** Each process gathers stats for its threads. ** Binary tree used combine results. ** Master prints results. */ @@ -2411,7 +2411,7 @@ int GPTLpr_summary_file (int comm, /* allocate storage for data for all timers */ if( !( storage = malloc( sizeof(Summarystats) * count ) ) && count ) return GPTLerror ("%s: memory allocation failed\n", thisfunc); - + if ( (ret = collect_data( iam, comm, &count, &storage) ) != 0 ) return GPTLerror ("%s: master collect_data failed\n", thisfunc); @@ -2526,7 +2526,7 @@ static int merge_thread_data() /* count timers for thread 0 */ count_r = 0; - for (ptr = timers[0]->next; ptr; ptr = ptr->next) count_r++; + for (ptr = timers[0]->next; ptr; ptr = ptr->next) count_r++; timerlist = (char **) GPTLallocate( sizeof (char *)); if( !( timerlist[0] = (char *)malloc( count_r * length * sizeof (char)) ) && count_r) @@ -2551,7 +2551,7 @@ static int merge_thread_data() /* count timers for thread */ count[t] = 0; - for (ptr = timers[t]->next; ptr; ptr = ptr->next) count[t]++; + for (ptr = timers[t]->next; ptr; ptr = ptr->next) count[t]++; if( count[t] > max_count || max_count == 0 ) max_count = count[t]; @@ -2587,24 +2587,24 @@ static int merge_thread_data() k = 0; n = 0; num_newtimers = 0; - while( k < count[0] && n < count[t] ) { + while( k < count[0] && n < count[t] ) { /* linear comparison of timers */ compare = strcmp( sort[0][k], sort[t][n] ); - if( compare == 0 ) { + if( compare == 0 ) { /* both have, nothing needs to be done */ k++; n++; continue; } - if( compare < 0 ) { + if( compare < 0 ) { /* event that only master has, nothing needs to be done */ k++; continue; } - if( compare > 0 ) { + if( compare > 0 ) { /* event that only slave thread has, need to add */ newtimers[num_newtimers] = sort[t][n]; n++; @@ -2612,8 +2612,8 @@ static int merge_thread_data() } } - while( n < count[t] ) { - /* adds any remaining timers, since we know that all the rest + while( n < count[t] ) { + /* adds any remaining timers, since we know that all the rest are new since have checked all master thread timers */ newtimers[num_newtimers] = sort[t][n]; num_newtimers++; @@ -2622,7 +2622,7 @@ static int merge_thread_data() if( num_newtimers ) { /* sorts by memory address to restore original order */ - qsort( newtimers, num_newtimers, sizeof(char*), ncmp ); + qsort( newtimers, num_newtimers, sizeof(char*), ncmp ); /* reallocate memory to hold additional timers */ if( !( sort[0] = realloc( sort[0], (count[0] + num_newtimers) * sizeof (char *)) ) ) @@ -2631,7 +2631,7 @@ static int merge_thread_data() return GPTLerror ("%s: memory reallocation failed\n", thisfunc); k = count[0]; - for (n = 0; n < num_newtimers; n++) { + for (n = 0; n < num_newtimers; n++) { /* add new found timers */ memcpy( timerlist[0] + (count[0] + n) * length, newtimers[n], length * sizeof (char) ); } @@ -2639,7 +2639,7 @@ static int merge_thread_data() count[0] += num_newtimers; /* reassign pointers in sort since realloc will have broken them if it moved the memory. */ - x = 0; + x = 0; for (k = 0; k < count[0]; k++) { sort[0][k] = timerlist[0] + x; x += length; @@ -2649,7 +2649,7 @@ static int merge_thread_data() } } - free(sort[0]); + free(sort[0]); /* don't free timerlist[0], since needed for subsequent steps in gathering global statistics */ for (t = 1; t < nthreads; t++) { free(sort[t]); @@ -2679,14 +2679,14 @@ static int merge_thread_data() */ #ifdef HAVE_MPI -static int collect_data(const int iam, +static int collect_data(const int iam, MPI_Comm comm, - int *count, + int *count, Summarystats **summarystats_cumul ) #else -static int collect_data(const int iam, +static int collect_data(const int iam, int comm, - int *count, + int *count, Summarystats **summarystats_cumul ) #endif { @@ -2809,11 +2809,11 @@ static int collect_data(const int iam, { compare = strcmp(sort_master[k], sort_slave[n]); - if (compare == 0) { + if (compare == 0) { /* matching timers found */ /* find element number of the name in original timerlist so that it can be matched with its summarystats */ - m_index = get_index( timerlist[0], sort_master[k] ); + m_index = get_index( timerlist[0], sort_master[k] ); s_index = get_index( timers_slave, sort_slave[n] ); get_summarystats (&summarystats[m_index], &summarystats_slave[s_index]); @@ -2822,7 +2822,7 @@ static int collect_data(const int iam, continue; } - if (compare > 0) { + if (compare > 0) { /* s1 >s2 . slave has event; master does not */ newtimers[num_newtimers] = sort_slave[n]; num_newtimers++; @@ -2834,7 +2834,7 @@ static int collect_data(const int iam, k++; } - while (n < count_slave) { + while (n < count_slave) { /* add all remaining timers which only the slave has */ newtimers[num_newtimers] = sort_slave[n]; num_newtimers++; @@ -2842,7 +2842,7 @@ static int collect_data(const int iam, } /* sort by memory address to get original order */ - qsort (newtimers, num_newtimers, sizeof(char*), ncmp); + qsort (newtimers, num_newtimers, sizeof(char*), ncmp); /* reallocate to hold new timer names and summary stats from slave */ if (!(timerlist[0] = realloc( timerlist[0], length * (*count + num_newtimers) * sizeof (char) ) )) @@ -2922,7 +2922,7 @@ static int collect_data(const int iam, ** Return value: index of element in list */ -int get_index( const char * list, +int get_index( const char * list, const char * element ) { return (( element - list ) / ( MAX_CHARS + 1 )); @@ -2957,7 +2957,7 @@ static int ncmp( const void *x, const void *y ) GPTLerror("%s: shared memory address between timers\n", thisfunc); } -/* +/* ** get_threadstats: gather stats for timer "name" over all threads ** ** Input arguments: @@ -2967,7 +2967,7 @@ static int ncmp( const void *x, const void *y ) ** summarystats: max/min stats over all threads */ -void get_threadstats (const int iam, +void get_threadstats (const int iam, const char *name, Summarystats *summarystats) { @@ -3019,7 +3019,7 @@ void get_threadstats (const int iam, summarystats->papimax[n] = value; summarystats->papimax_t[n] = t; } - + if (value < summarystats->papimin[n] || summarystats->papimin[n] == 0.) { summarystats->papimin[n] = value; summarystats->papimin_t[n] = t; @@ -3032,7 +3032,7 @@ void get_threadstats (const int iam, if ( summarystats->count ) summarystats->processes = 1; } -/* +/* ** get_summarystats: write max/min stats into mpistats based on comparison ** with summarystats_slave ** @@ -3042,7 +3042,7 @@ void get_threadstats (const int iam, ** summarystats: stats (starts out as master stats) */ -void get_summarystats (Summarystats *summarystats, +void get_summarystats (Summarystats *summarystats, const Summarystats *summarystats_slave) { if (summarystats_slave->count == 0) return; @@ -3053,7 +3053,7 @@ void get_summarystats (Summarystats *summarystats, summarystats->wallmax_t = summarystats_slave->wallmax_t; } - if ((summarystats_slave->wallmin < summarystats->wallmin) || + if ((summarystats_slave->wallmin < summarystats->wallmin) || (summarystats->count == 0)){ summarystats->wallmin = summarystats_slave->wallmin; summarystats->wallmin_p = summarystats_slave->wallmin_p; @@ -3070,7 +3070,7 @@ void get_summarystats (Summarystats *summarystats, summarystats->papimax_t[n] = summarystats_slave->papimax_t[n]; } - if ((summarystats_slave->papimin[n] < summarystats->papimin[n]) || + if ((summarystats_slave->papimin[n] < summarystats->papimin[n]) || (summarystats->count == 0)){ summarystats->papimin[n] = summarystats_slave->papimin[n]; summarystats->papimin_p[n] = summarystats_slave->papimin_p[n]; @@ -3087,7 +3087,7 @@ void get_summarystats (Summarystats *summarystats, summarystats->threads += summarystats_slave->threads; } -/* +/* ** GPTLbarrier: When MPI enabled, set and time an MPI barrier ** ** Input arguments: @@ -3140,10 +3140,10 @@ static inline int get_cpustamp (long *usr, long *sys) } /* -** GPTLquery: return current status info about a timer. If certain stats are not +** GPTLquery: return current status info about a timer. If certain stats are not ** enabled, they should just have zeros in them. If PAPI is not enabled, input ** counter info is ignored. -** +** ** Input args: ** name: timer name ** maxcounters: max number of PAPI counters to get info for @@ -3158,7 +3158,7 @@ static inline int get_cpustamp (long *usr, long *sys) ** papicounters_out: accumulated PAPI counters */ -int GPTLquery (const char *name, +int GPTLquery (const char *name, int t, int *count, int *onflg, @@ -3171,14 +3171,14 @@ int GPTLquery (const char *name, Timer *ptr; /* linked list pointer */ unsigned int indx; /* linked list index returned from getentry (unused) */ static const char *thisfunc = "GPTLquery"; - + if ( ! initialized) return GPTLerror ("%s: GPTLinitialize has not been called\n", thisfunc); - + /* ** If t is < 0, assume the request is for the current thread */ - + if (t < 0) { if ((t = get_thread_num ()) < 0) return GPTLerror ("%s: get_thread_num failure\n", thisfunc); @@ -3186,7 +3186,7 @@ int GPTLquery (const char *name, if (t >= maxthreads) return GPTLerror ("%s: requested thread %d is too big\n", thisfunc, t); } - + ptr = getentry (hashtable[t], name, &indx); if ( !ptr) return GPTLerror ("%s: requested timer %s does not have a name hash\n", thisfunc, name); @@ -3205,7 +3205,7 @@ int GPTLquery (const char *name, /* ** GPTLquerycounters: return current PAPI counters for a timer. ** THIS ROUTINE ID DEPRECATED. USE GPTLget_eventvalue() instead -** +** ** Input args: ** name: timer name ** t: thread number (if < 0, the request is for the current thread) @@ -3214,21 +3214,21 @@ int GPTLquery (const char *name, ** papicounters_out: accumulated PAPI counters */ -int GPTLquerycounters (const char *name, +int GPTLquerycounters (const char *name, int t, long long *papicounters_out) { Timer *ptr; /* linked list pointer */ unsigned int indx; /* hash index returned from getentry */ static const char *thisfunc = "GPTLquery_counters"; - + if ( ! initialized) return GPTLerror ("%s: GPTLinitialize has not been called\n", thisfunc); - + /* ** If t is < 0, assume the request is for the current thread */ - + if (t < 0) { if ((t = get_thread_num ()) < 0) return GPTLerror ("%s: get_thread_num failure\n", thisfunc); @@ -3236,7 +3236,7 @@ int GPTLquerycounters (const char *name, if (t >= maxthreads) return GPTLerror ("%s: requested thread %d is too big\n", thisfunc, t); } - + ptr = getentry (hashtable[t], name, &indx); if ( !ptr) return GPTLerror ("%s: requested timer %s does not have a name hash\n", thisfunc, name); @@ -3250,7 +3250,7 @@ int GPTLquerycounters (const char *name, /* ** GPTLget_wallclock: return wallclock accumulation for a timer. -** +** ** Input args: ** timername: timer name ** t: thread number (if < 0, the request is for the current thread) @@ -3267,17 +3267,17 @@ int GPTLget_wallclock (const char *timername, Timer *ptr; /* linked list pointer */ unsigned int indx; /* hash index returned from getentry (unused) */ static const char *thisfunc = "GPTLget_wallclock"; - + if ( ! initialized) return GPTLerror ("%s: GPTLinitialize has not been called\n", thisfunc); if ( ! wallstats.enabled) return GPTLerror ("%s: wallstats not enabled\n", thisfunc); - + /* ** If t is < 0, assume the request is for the current thread */ - + if (t < 0) { if ((t = get_thread_num ()) < 0) return GPTLerror ("%s: bad return from get_thread_num\n", thisfunc); @@ -3285,9 +3285,9 @@ int GPTLget_wallclock (const char *timername, if (t >= maxthreads) return GPTLerror ("%s: requested thread %d is too big\n", thisfunc, t); } - - /* - ** Don't know whether hashtable entry for timername was generated with + + /* + ** Don't know whether hashtable entry for timername was generated with ** *_instr() or not, so try both possibilities */ @@ -3307,7 +3307,7 @@ int GPTLget_wallclock (const char *timername, /* ** GPTLget_eventvalue: return PAPI-based event value for a timer. All values will be ** returned as doubles, even if the event is not derived. -** +** ** Input args: ** timername: timer name ** eventname: event name (must be currently enabled) @@ -3326,14 +3326,14 @@ int GPTLget_eventvalue (const char *timername, Timer *ptr; /* linked list pointer */ unsigned int indx; /* hash index returned from getentry (unused) */ static const char *thisfunc = "GPTLget_eventvalue"; - + if ( ! initialized) return GPTLerror ("%s: GPTLinitialize has not been called\n", thisfunc); - + /* ** If t is < 0, assume the request is for the current thread */ - + if (t < 0) { if ((t = get_thread_num ()) < 0) return GPTLerror ("%s: get_thread_num failure\n", thisfunc); @@ -3341,9 +3341,9 @@ int GPTLget_eventvalue (const char *timername, if (t >= maxthreads) return GPTLerror ("%s: requested thread %d is too big\n", thisfunc, t); } - - /* - ** Don't know whether hashtable entry for timername was generated with + + /* + ** Don't know whether hashtable entry for timername was generated with ** *_instr() or not, so try both possibilities */ @@ -3359,13 +3359,13 @@ int GPTLget_eventvalue (const char *timername, #ifdef HAVE_PAPI return GPTL_PAPIget_eventvalue (eventname, &ptr->aux, value); #else - return GPTLerror ("%s: PAPI not enabled\n", thisfunc); + return GPTLerror ("%s: PAPI not enabled\n", thisfunc); #endif } /* ** GPTLget_nregions: return number of regions (i.e. timer names) for this thread -** +** ** Input args: ** t: thread number (if < 0, the request is for the current thread) ** @@ -3373,7 +3373,7 @@ int GPTLget_eventvalue (const char *timername, ** nregions: number of regions */ -int GPTLget_nregions (int t, +int GPTLget_nregions (int t, int *nregions) { Timer *ptr; /* walk through linked list */ @@ -3381,11 +3381,11 @@ int GPTLget_nregions (int t, if ( ! initialized) return GPTLerror ("%s: GPTLinitialize has not been called\n", thisfunc); - + /* ** If t is < 0, assume the request is for the current thread */ - + if (t < 0) { if ((t = get_thread_num ()) < 0) return GPTLerror ("%s: get_thread_num failure\n", thisfunc); @@ -3393,9 +3393,9 @@ int GPTLget_nregions (int t, if (t >= maxthreads) return GPTLerror ("%s: requested thread %d is too big\n", thisfunc, t); } - + *nregions = 0; - for (ptr = timers[t]->next; ptr; ptr = ptr->next) + for (ptr = timers[t]->next; ptr; ptr = ptr->next) ++*nregions; return 0; @@ -3403,7 +3403,7 @@ int GPTLget_nregions (int t, /* ** GPTLget_regionname: return region name for this thread -** +** ** Input args: ** t: thread number (if < 0, the request is for the current thread) ** region: region number @@ -3425,11 +3425,11 @@ int GPTLget_regionname (int t, /* thread number */ if ( ! initialized) return GPTLerror ("%s: GPTLinitialize has not been called\n", thisfunc); - + /* ** If t is < 0, assume the request is for the current thread */ - + if (t < 0) { if ((t = get_thread_num ()) < 0) return GPTLerror ("%s: get_thread_num failure\n", thisfunc); @@ -3437,7 +3437,7 @@ int GPTLget_regionname (int t, /* thread number */ if (t >= maxthreads) return GPTLerror ("%s: requested thread %d is too big\n", thisfunc, t); } - + ptr = timers[t]->next; for (i = 0; i < region; i++) { if ( ! ptr) @@ -3448,7 +3448,7 @@ int GPTLget_regionname (int t, /* thread number */ if (ptr) { ncpy = MIN (nc, strlen (ptr->name)); strncpy (name, ptr->name, ncpy); - + /* ** Adding the \0 is only important when called from C */ @@ -3525,7 +3525,7 @@ static inline Timer *getentry (const Hashentry *hashtable, /* hash table */ const unsigned char *c; /* pointer to elements of "name" */ Timer *ptr = 0; /* return value when entry not found */ - /* + /* ** Hash value is sum of: chars times their 1-based position index, modulo tablesize */ @@ -3537,7 +3537,7 @@ static inline Timer *getentry (const Hashentry *hashtable, /* hash table */ *indx %= tablesize; - /* + /* ** If nument exceeds 1 there was a hash collision and we must search ** linearly through an array for a match */ @@ -3725,7 +3725,7 @@ static int init_papitime () return GPTLerror ("%s: not enabled\n", thisfunc); #endif } - + static inline double utr_papitime () { #ifdef HAVE_PAPI @@ -3737,8 +3737,8 @@ static inline double utr_papitime () #endif } -/* -** Probably need to link with -lrt for this one to work +/* +** Probably need to link with -lrt for this one to work */ static int init_clock_gettime () @@ -3833,7 +3833,7 @@ static inline double utr_gettimeofday () #endif } -/* +/* ** Determine underlying timing routine overhead: call it 1000 times. */ @@ -3854,7 +3854,7 @@ static double utr_getoverhead () */ static void printself_andchildren (const Timer *ptr, - FILE *fp, + FILE *fp, const int t, const int depth, const double tot_overhead) @@ -3870,9 +3870,9 @@ static void printself_andchildren (const Timer *ptr, #ifdef ENABLE_PMPI /* -** GPTLgetentry: called ONLY from pmpi.c (i.e. not a public entry point). Returns a pointer to the +** GPTLgetentry: called ONLY from pmpi.c (i.e. not a public entry point). Returns a pointer to the ** requested timer name by calling internal function getentry() -** +** ** Return value: 0 (NULL) or the return value of getentry() */ @@ -3896,7 +3896,7 @@ Timer *GPTLgetentry (const char *name) } /* -** GPTLpr_file_has_been_called: Called ONLY from pmpi.c (i.e. not a public entry point). Return +** GPTLpr_file_has_been_called: Called ONLY from pmpi.c (i.e. not a public entry point). Return ** whether GPTLpr_file has been called. MPI_Finalize wrapper needs ** to know whether it needs to call GPTLpr. */ @@ -3919,7 +3919,7 @@ int GPTLpr_has_been_called (void) ** $Id: gptl.c,v 1.157 2011-03-28 20:55:18 rosinski Exp $ ** ** Author: Jim Rosinski -** +** ** Utility functions handle thread-based GPTL needs. */ @@ -3927,7 +3927,7 @@ int GPTLpr_has_been_called (void) #define MAX_THREADS 128 /**********************************************************************************/ -/* +/* ** 3 sets of routines: OMP threading, PTHREADS, unthreaded */ @@ -3953,13 +3953,13 @@ static int threadinit (void) if (omp_get_thread_num () != 0) return GPTLerror ("OMP %s: MUST only be called by the master thread\n", thisfunc); - /* - ** Allocate the threadid array which maps physical thread IDs to logical IDs + /* + ** Allocate the threadid array which maps physical thread IDs to logical IDs ** For OpenMP this will be just threadid_omp[iam] = iam; */ - if (threadid_omp) - return GPTLerror ("OMP %s: has already been called.\nMaybe mistakenly called by multiple threads?", + if (threadid_omp) + return GPTLerror ("OMP %s: has already been called.\nMaybe mistakenly called by multiple threads?", thisfunc); maxthreads = MAX ((1), (omp_get_max_threads ())); @@ -3977,7 +3977,7 @@ static int threadinit (void) #ifdef VERBOSE printf ("OMP %s: Set maxthreads=%d\n", thisfunc, maxthreads); #endif - + return 0; } @@ -4020,7 +4020,7 @@ static inline int get_thread_num (void) if (t == threadid_omp[t]) return t; - /* + /* ** Thread id not found. Modify threadid_omp with our ID, then start PAPI events if required. ** Due to the setting of threadid_omp, everything below here will only execute once per thread. */ @@ -4051,7 +4051,7 @@ static inline int get_thread_num (void) /* ** nthreads = maxthreads based on setting in threadinit */ - + nthreads = maxthreads; #ifdef VERBOSE printf ("OMP %s: nthreads=%d\n", thisfunc, nthreads); @@ -4071,7 +4071,7 @@ static void print_threadmapping (FILE *fp) } /**********************************************************************************/ -/* +/* ** PTHREADS */ @@ -4098,7 +4098,7 @@ static int threadinit (void) static const char *thisfunc = "threadinit"; /* - ** The following test is not rock-solid, but it's pretty close in terms of guaranteeing that + ** The following test is not rock-solid, but it's pretty close in terms of guaranteeing that ** threadinit gets called by only 1 thread. Problem is, mutex hasn't yet been initialized ** so we can't use it. */ @@ -4114,7 +4114,7 @@ static int threadinit (void) ** Previously, t_mutex = PTHREAD_MUTEX_INITIALIZER on the static declaration line was ** adequate to initialize the mutex. But this failed in programs that invoked ** GPTLfinalize() followed by GPTLinitialize(). - ** "man pthread_mutex_init" indicates that passing NULL as the second argument to + ** "man pthread_mutex_init" indicates that passing NULL as the second argument to ** pthread_mutex_init() should appropriately initialize the mutex, assuming it was ** properly destroyed by a previous call to pthread_mutex_destroy(); */ @@ -4123,16 +4123,16 @@ static int threadinit (void) if ((ret = pthread_mutex_init ((pthread_mutex_t *) &t_mutex, NULL)) != 0) return GPTLerror ("PTHREADS %s: mutex init failure: ret=%d\n", thisfunc, ret); #endif - - /* - ** Allocate the threadid array which maps physical thread IDs to logical IDs + + /* + ** Allocate the threadid array which maps physical thread IDs to logical IDs */ - if (threadid) + if (threadid) return GPTLerror ("PTHREADS %s: threadid not null\n", thisfunc); else if ( ! (threadid = (pthread_t *) GPTLallocate (MAX_THREADS * sizeof (pthread_t)))) return GPTLerror ("PTHREADS %s: malloc failure for %d elements of threadid\n", thisfunc, MAX_THREADS); - + maxthreads = MAX_THREADS; /* @@ -4177,7 +4177,7 @@ static void threadfinalize () ** ** Output results: ** nthreads: Updated number of threads -** threadid: Our thread id added to list on 1st call +** threadid: Our thread id added to list on 1st call ** ** Return value: thread number (success) or GPTLerror (failure) */ @@ -4212,7 +4212,7 @@ static inline int get_thread_num (void) return t; #endif - /* + /* ** Thread id not found. Define a critical region, then start PAPI counters if ** necessary and modify threadid[] with our id. */ @@ -4236,7 +4236,7 @@ static inline int get_thread_num (void) threadid[nthreads] = mythreadid; #ifdef VERBOSE - printf ("PTHREADS %s: 1st call threadid=%lu maps to location %d\n", + printf ("PTHREADS %s: 1st call threadid=%lu maps to location %d\n", thisfunc, (unsigned long) mythreadid, nthreads); #endif @@ -4249,14 +4249,14 @@ static inline int get_thread_num (void) if (GPTLget_npapievents () > 0) { #ifdef VERBOSE - printf ("PTHREADS get_thread_num: Starting EventSet threadid=%lu location=%d\n", + printf ("PTHREADS get_thread_num: Starting EventSet threadid=%lu location=%d\n", (unsigned long) mythreadid, nthreads); #endif if (GPTLcreate_and_start_events (nthreads) < 0) { if (unlock_mutex () < 0) fprintf (stderr, "PTHREADS %s: mutex unlock failure\n", thisfunc); - return GPTLerror ("PTHREADS %s: error from GPTLcreate_and_start_events for thread %d\n", + return GPTLerror ("PTHREADS %s: error from GPTLcreate_and_start_events for thread %d\n", thisfunc, nthreads); } } diff --git a/src/gptl/gptl.inc b/src/gptl/gptl.inc index 2ed2ca5c07..4d9d782a79 100644 --- a/src/gptl/gptl.inc +++ b/src/gptl/gptl.inc @@ -97,7 +97,7 @@ integer gptlstart_handle integer gptlstop integer gptlstop_handle - integer gptlstamp + integer gptlstamp integer gptlpr_set_append integer gptlpr_query_append integer gptlpr_set_write @@ -107,7 +107,7 @@ integer gptlpr_summary integer gptlpr_summary_file integer gptlbarrier - integer gptlreset + integer gptlreset integer gptlfinalize integer gptlget_memusage integer gptlprint_memusage @@ -130,7 +130,7 @@ external gptlstart_handle external gptlstop external gptlstop_handle - external gptlstamp + external gptlstamp external gptlpr_set_append external gptlpr_query_append external gptlpr_set_write @@ -140,7 +140,7 @@ external gptlpr_summary external gptlpr_summary_file external gptlbarrier - external gptlreset + external gptlreset external gptlfinalize external gptlget_memusage external gptlprint_memusage diff --git a/src/gptl/gptl_papi.c b/src/gptl/gptl_papi.c index 1f701cb897..a8e42fd132 100644 --- a/src/gptl/gptl_papi.c +++ b/src/gptl/gptl_papi.c @@ -5,7 +5,7 @@ ** ** Contains routines which interface to PAPI library */ - + #include "private.h" #include "gptl.h" @@ -149,8 +149,8 @@ static const Entry derivedtable [] = { }; static const int nderivedentries = sizeof (derivedtable) / sizeof (Entry); -static int npapievents = 0; /* number of PAPI events: initialize to 0 */ -static int nevents = 0; /* number of events: initialize to 0 */ +static int npapievents = 0; /* number of PAPI events: initialize to 0 */ +static int nevents = 0; /* number of events: initialize to 0 */ static int *EventSet; /* list of events to be counted by PAPI */ static long_long **papicounters; /* counters returned from PAPI */ @@ -171,11 +171,11 @@ static int enable (int); static int getderivedidx (int); /* -** GPTL_PAPIsetoption: enable or disable PAPI event defined by "counter". Called +** GPTL_PAPIsetoption: enable or disable PAPI event defined by "counter". Called ** from GPTLsetoption. Since all events are off by default, val=false degenerates ** to a no-op. Coded this way to be consistent with the rest of GPTL ** -** Input args: +** Input args: ** counter: PAPI counter ** val: true or false for enable or disable ** @@ -219,7 +219,7 @@ int GPTL_PAPIsetoption (const int counter, /* PAPI counter (or option) */ break; } - /* + /* ** If val is false, return an error if the event has already been enabled. ** Otherwise just warn that attempting to disable a PAPI-based event ** that has already been enabled doesn't work--for now it's just a no-op @@ -238,10 +238,10 @@ int GPTL_PAPIsetoption (const int counter, /* PAPI counter (or option) */ /* If the event has already been enabled for printing, exit */ if (already_enabled (counter)) - return GPTLerror ("GPTL_PAPIsetoption: counter %d has already been enabled\n", + return GPTLerror ("GPTL_PAPIsetoption: counter %d has already been enabled\n", counter); - /* + /* ** Initialize PAPI if it hasn't already been done. ** From here on down we can assume the intent is to enable (not disable) an option */ @@ -267,7 +267,7 @@ int GPTL_PAPIsetoption (const int counter, /* PAPI counter (or option) */ pr_event[nevents].numidx = enable (PAPI_TOT_INS); pr_event[nevents].denomidx = enable (PAPI_TOT_CYC); if (verbose) - printf ("GPTL_PAPIsetoption: enabling derived event %s = PAPI_TOT_INS / PAPI_TOT_CYC\n", + printf ("GPTL_PAPIsetoption: enabling derived event %s = PAPI_TOT_INS / PAPI_TOT_CYC\n", pr_event[nevents].event.namestr); ++nevents; return 0; @@ -278,18 +278,18 @@ int GPTL_PAPIsetoption (const int counter, /* PAPI counter (or option) */ pr_event[nevents].numidx = enable (PAPI_FP_OPS); pr_event[nevents].denomidx = enable (PAPI_LST_INS); if (verbose) - printf ("GPTL_PAPIsetoption: enabling derived event %s = PAPI_FP_OPS / PAPI_LST_INS\n", + printf ("GPTL_PAPIsetoption: enabling derived event %s = PAPI_FP_OPS / PAPI_LST_INS\n", pr_event[nevents].event.namestr); } else if (canenable2 (PAPI_FP_OPS, PAPI_L1_DCA)) { pr_event[nevents].event = derivedtable[idx]; pr_event[nevents].numidx = enable (PAPI_FP_OPS); pr_event[nevents].denomidx = enable (PAPI_L1_DCA); #ifdef DEBUG - printf ("GPTL_PAPIsetoption: pr_event %d is derived and will be PAPI event %d / %d\n", + printf ("GPTL_PAPIsetoption: pr_event %d is derived and will be PAPI event %d / %d\n", nevents, pr_event[nevents].numidx, pr_event[nevents].denomidx); #endif if (verbose) - printf ("GPTL_PAPIsetoption: enabling derived event %s = PAPI_FP_OPS / PAPI_L1_DCA\n", + printf ("GPTL_PAPIsetoption: enabling derived event %s = PAPI_FP_OPS / PAPI_L1_DCA\n", pr_event[nevents].event.namestr); } else { return GPTLerror ("GPTL_PAPIsetoption: GPTL_CI unavailable\n"); @@ -305,7 +305,7 @@ int GPTL_PAPIsetoption (const int counter, /* PAPI counter (or option) */ pr_event[nevents].numidx = enable (PAPI_FP_OPS); pr_event[nevents].denomidx = enable (PAPI_TOT_CYC); if (verbose) - printf ("GPTL_PAPIsetoption: enabling derived event %s = PAPI_FP_OPS / PAPI_TOT_CYC\n", + printf ("GPTL_PAPIsetoption: enabling derived event %s = PAPI_FP_OPS / PAPI_TOT_CYC\n", pr_event[nevents].event.namestr); ++nevents; return 0; @@ -318,7 +318,7 @@ int GPTL_PAPIsetoption (const int counter, /* PAPI counter (or option) */ pr_event[nevents].numidx = enable (PAPI_FP_OPS); pr_event[nevents].denomidx = enable (PAPI_TOT_INS); if (verbose) - printf ("GPTL_PAPIsetoption: enabling derived event %s = PAPI_FP_OPS / PAPI_TOT_INS\n", + printf ("GPTL_PAPIsetoption: enabling derived event %s = PAPI_FP_OPS / PAPI_TOT_INS\n", pr_event[nevents].event.namestr); ++nevents; return 0; @@ -329,14 +329,14 @@ int GPTL_PAPIsetoption (const int counter, /* PAPI counter (or option) */ pr_event[nevents].numidx = enable (PAPI_LST_INS); pr_event[nevents].denomidx = enable (PAPI_TOT_INS); if (verbose) - printf ("GPTL_PAPIsetoption: enabling derived event %s = PAPI_LST_INS / PAPI_TOT_INS\n", + printf ("GPTL_PAPIsetoption: enabling derived event %s = PAPI_LST_INS / PAPI_TOT_INS\n", pr_event[nevents].event.namestr); } else if (canenable2 (PAPI_L1_DCA, PAPI_TOT_INS)) { pr_event[nevents].event = derivedtable[idx]; pr_event[nevents].numidx = enable (PAPI_L1_DCA); pr_event[nevents].denomidx = enable (PAPI_TOT_INS); if (verbose) - printf ("GPTL_PAPIsetoption: enabling derived event %s = PAPI_L1_DCA / PAPI_TOT_INS\n", + printf ("GPTL_PAPIsetoption: enabling derived event %s = PAPI_L1_DCA / PAPI_TOT_INS\n", pr_event[nevents].event.namestr); } else { return GPTLerror ("GPTL_PAPIsetoption: GPTL_LSTPI unavailable\n"); @@ -352,7 +352,7 @@ int GPTL_PAPIsetoption (const int counter, /* PAPI counter (or option) */ pr_event[nevents].numidx = enable (PAPI_L1_DCM); pr_event[nevents].denomidx = enable (PAPI_L1_DCA); if (verbose) - printf ("GPTL_PAPIsetoption: enabling derived event %s = PAPI_L1_DCM / PAPI_L1_DCA\n", + printf ("GPTL_PAPIsetoption: enabling derived event %s = PAPI_L1_DCM / PAPI_L1_DCA\n", pr_event[nevents].event.namestr); ++nevents; return 0; @@ -363,14 +363,14 @@ int GPTL_PAPIsetoption (const int counter, /* PAPI counter (or option) */ pr_event[nevents].numidx = enable (PAPI_LST_INS); pr_event[nevents].denomidx = enable (PAPI_L1_DCM); if (verbose) - printf ("GPTL_PAPIsetoption: enabling derived event %s = PAPI_LST_INS / PAPI_L1_DCM\n", + printf ("GPTL_PAPIsetoption: enabling derived event %s = PAPI_LST_INS / PAPI_L1_DCM\n", pr_event[nevents].event.namestr); } else if (canenable2 (PAPI_L1_DCA, PAPI_L1_DCM)) { pr_event[nevents].event = derivedtable[idx]; pr_event[nevents].numidx = enable (PAPI_L1_DCA); pr_event[nevents].denomidx = enable (PAPI_L1_DCM); if (verbose) - printf ("GPTL_PAPIsetoption: enabling derived event %s = PAPI_L1_DCA / PAPI_L1_DCM\n", + printf ("GPTL_PAPIsetoption: enabling derived event %s = PAPI_L1_DCA / PAPI_L1_DCM\n", pr_event[nevents].event.namestr); } else { return GPTLerror ("GPTL_PAPIsetoption: GPTL_LSTPDCM unavailable\n"); @@ -389,7 +389,7 @@ int GPTL_PAPIsetoption (const int counter, /* PAPI counter (or option) */ pr_event[nevents].numidx = enable (PAPI_L2_TCM); pr_event[nevents].denomidx = enable (PAPI_L2_TCA); if (verbose) - printf ("GPTL_PAPIsetoption: enabling derived event %s = PAPI_L2_TCM / PAPI_L2_TCA\n", + printf ("GPTL_PAPIsetoption: enabling derived event %s = PAPI_L2_TCM / PAPI_L2_TCA\n", pr_event[nevents].event.namestr); ++nevents; return 0; @@ -400,14 +400,14 @@ int GPTL_PAPIsetoption (const int counter, /* PAPI counter (or option) */ pr_event[nevents].numidx = enable (PAPI_LST_INS); pr_event[nevents].denomidx = enable (PAPI_L2_TCM); if (verbose) - printf ("GPTL_PAPIsetoption: enabling derived event %s = PAPI_LST_INS / PAPI_L2_TCM\n", + printf ("GPTL_PAPIsetoption: enabling derived event %s = PAPI_LST_INS / PAPI_L2_TCM\n", pr_event[nevents].event.namestr); } else if (canenable2 (PAPI_L1_DCA, PAPI_L2_TCM)) { pr_event[nevents].event = derivedtable[idx]; pr_event[nevents].numidx = enable (PAPI_L1_DCA); pr_event[nevents].denomidx = enable (PAPI_L2_TCM); if (verbose) - printf ("GPTL_PAPIsetoption: enabling derived event %s = PAPI_L1_DCA / PAPI_L2_TCM\n", + printf ("GPTL_PAPIsetoption: enabling derived event %s = PAPI_L1_DCA / PAPI_L2_TCM\n", pr_event[nevents].event.namestr); } else { return GPTLerror ("GPTL_PAPIsetoption: GPTL_LSTPL2M unavailable\n"); @@ -423,7 +423,7 @@ int GPTL_PAPIsetoption (const int counter, /* PAPI counter (or option) */ pr_event[nevents].numidx = enable (PAPI_L3_TCM); pr_event[nevents].denomidx = enable (PAPI_L3_TCR); if (verbose) - printf ("GPTL_PAPIsetoption: enabling derived event %s = PAPI_L3_TCM / PAPI_L3_TCR\n", + printf ("GPTL_PAPIsetoption: enabling derived event %s = PAPI_L3_TCM / PAPI_L3_TCR\n", pr_event[nevents].event.namestr); ++nevents; return 0; @@ -444,11 +444,11 @@ int GPTL_PAPIsetoption (const int counter, /* PAPI counter (or option) */ pr_event[nevents].numidx = enable (counter); pr_event[nevents].denomidx = -1; /* flag says not derived (no denominator) */ } else { - return GPTLerror ("GPTL_PAPIsetoption: Can't enable event \n", + return GPTLerror ("GPTL_PAPIsetoption: Can't enable event \n", papitable[n].longstr); } if (verbose) - printf ("GPTL_PAPIsetoption: enabling PAPI preset event %s\n", + printf ("GPTL_PAPIsetoption: enabling PAPI preset event %s\n", pr_event[nevents].event.namestr); ++nevents; return 0; @@ -458,9 +458,9 @@ int GPTL_PAPIsetoption (const int counter, /* PAPI counter (or option) */ /* ** Check native events last: If PAPI_event_code_to_name fails, give up */ - + if ((ret = PAPI_event_code_to_name (counter, eventname)) != PAPI_OK) - return GPTLerror ("GPTL_PAPIsetoption: name not found for counter %d: PAPI_strerror: %s\n", + return GPTLerror ("GPTL_PAPIsetoption: name not found for counter %d: PAPI_strerror: %s\n", counter, PAPI_strerror (ret)); /* @@ -514,12 +514,12 @@ int GPTL_PAPIsetoption (const int counter, /* PAPI counter (or option) */ /* ** canenable: determine whether a PAPI counter can be enabled ** -** Input args: +** Input args: ** counter: PAPI counter ** ** Return value: 0 (success) or non-zero (failure) */ - + int canenable (int counter) { char eventname[PAPI_MAX_STR_LEN]; /* returned from PAPI_event_code_to_name */ @@ -539,13 +539,13 @@ int canenable (int counter) /* ** canenable2: determine whether 2 PAPI counters can be enabled ** -** Input args: +** Input args: ** counter1: PAPI counter ** counter2: PAPI counter ** ** Return value: 0 (success) or non-zero (failure) */ - + int canenable2 (int counter1, int counter2) { char eventname[PAPI_MAX_STR_LEN]; /* returned from PAPI_event_code_to_name */ @@ -573,12 +573,12 @@ int canenable2 (int counter1, int counter2) ** well as output directly. E.g. PAPI_FP_OPS is used to compute ** computational intensity, and floating point ops per instruction. ** -** Input args: +** Input args: ** counter: PAPI counter ** ** Return value: index into papieventlist (success) or negative (not found) */ - + int papievent_is_enabled (int counter) { int n; @@ -591,14 +591,14 @@ int papievent_is_enabled (int counter) /* ** already_enabled: determine whether a PAPI-based event has already been -** enabled for printing. +** enabled for printing. ** -** Input args: +** Input args: ** counter: PAPI or derived counter ** ** Return value: 1 (true) or 0 (false) */ - + int already_enabled (int counter) { int n; @@ -613,12 +613,12 @@ int already_enabled (int counter) ** enable: enable a PAPI event. ASSUMES that canenable() has already determined ** that the event can be enabled. ** -** Input args: +** Input args: ** counter: PAPI counter ** ** Return value: index into papieventlist */ - + int enable (int counter) { int n; @@ -643,7 +643,7 @@ int enable (int counter) /* ** getderivedidx: find the table index of a derived counter ** -** Input args: +** Input args: ** counter: derived counter ** ** Return value: index into derivedtable (success) or GPTLerror (failure) @@ -672,7 +672,7 @@ int GPTL_PAPIlibraryinit () if ((ret = PAPI_is_initialized ()) == PAPI_NOT_INITED) { if ((ret = PAPI_library_init (PAPI_VER_CURRENT)) != PAPI_VER_CURRENT) { - fprintf (stderr, "GPTL_PAPIlibraryinit: ret=%d PAPI_VER_CURRENT=%d\n", + fprintf (stderr, "GPTL_PAPIlibraryinit: ret=%d PAPI_VER_CURRENT=%d\n", ret, (int) PAPI_VER_CURRENT); return GPTLerror ("GPTL_PAPIlibraryinit: PAPI_library_init failure:%s\n", PAPI_strerror (ret)); @@ -683,16 +683,16 @@ int GPTL_PAPIlibraryinit () /* ** GPTL_PAPIinitialize(): Initialize the PAPI interface. Called from GPTLinitialize. -** PAPI_library_init must be called before any other PAPI routines. +** PAPI_library_init must be called before any other PAPI routines. ** PAPI_thread_init is called subsequently if threading is enabled. ** Finally, allocate space for PAPI counters and start them. ** -** Input args: +** Input args: ** maxthreads: number of threads ** ** Return value: 0 (success) or GPTLerror or -1 (failure) */ - + int GPTL_PAPIinitialize (const int maxthreads, /* number of threads */ const bool verbose_flag, /* output verbosity */ int *nevents_out, /* nevents needed by gptl.c */ @@ -748,8 +748,8 @@ int GPTL_PAPIinitialize (const int maxthreads, /* number of threads */ ** Threaded routine to create the "event set" (PAPI terminology) and start ** the counters. This is only done once, and is called from get_thread_num ** for the first time for the thread. -** -** Input args: +** +** Input args: ** t: thread number ** ** Return value: 0 (success) or GPTLerror (failure) @@ -764,7 +764,7 @@ int GPTLcreate_and_start_events (const int t) /* thread number */ /* Create the event set */ if ((ret = PAPI_create_eventset (&EventSet[t])) != PAPI_OK) - return GPTLerror ("GPTLcreate_and_start_events: thread %d failure creating eventset: %s\n", + return GPTLerror ("GPTLcreate_and_start_events: thread %d failure creating eventset: %s\n", t, PAPI_strerror (ret)); if (verbose) @@ -797,20 +797,20 @@ int GPTLcreate_and_start_events (const int t) /* thread number */ if ((ret = PAPI_cleanup_eventset (EventSet[t])) != PAPI_OK) return GPTLerror ("GPTLcreate_and_start_events: %s\n", PAPI_strerror (ret)); - + if ((ret = PAPI_destroy_eventset (&EventSet[t])) != PAPI_OK) return GPTLerror ("GPTLcreate_and_start_events: %s\n", PAPI_strerror (ret)); if ((ret = PAPI_create_eventset (&EventSet[t])) != PAPI_OK) - return GPTLerror ("GPTLcreate_and_start_events: failure creating eventset: %s\n", + return GPTLerror ("GPTLcreate_and_start_events: failure creating eventset: %s\n", PAPI_strerror (ret)); if ((ret = PAPI_multiplex_init ()) != PAPI_OK) - return GPTLerror ("GPTLcreate_and_start_events: failure from PAPI_multiplex_init%s\n", + return GPTLerror ("GPTLcreate_and_start_events: failure from PAPI_multiplex_init%s\n", PAPI_strerror (ret)); if ((ret = PAPI_set_multiplex (EventSet[t])) != PAPI_OK) - return GPTLerror ("GPTLcreate_and_start_events: failure from PAPI_set_multiplex: %s\n", + return GPTLerror ("GPTLcreate_and_start_events: failure from PAPI_set_multiplex: %s\n", PAPI_strerror (ret)); for (n = 0; n < npapievents; n++) { @@ -825,20 +825,20 @@ int GPTLcreate_and_start_events (const int t) /* thread number */ /* Start the event set. It will only be read from now on--never stopped */ if ((ret = PAPI_start (EventSet[t])) != PAPI_OK) - return GPTLerror ("GPTLcreate_and_start_events: failed to start event set: %s\n", + return GPTLerror ("GPTLcreate_and_start_events: failed to start event set: %s\n", PAPI_strerror (ret)); return 0; } /* -** GPTL_PAPIstart: Start the PAPI counters (actually they are just read). +** GPTL_PAPIstart: Start the PAPI counters (actually they are just read). ** Called from GPTLstart. ** -** Input args: +** Input args: ** t: thread number ** -** Output args: +** Output args: ** aux: struct containing the counters ** ** Return value: 0 (success) or GPTLerror (failure) @@ -849,7 +849,7 @@ int GPTL_PAPIstart (const int t, /* thread number */ { int ret; /* return code from PAPI lib calls */ int n; /* loop index */ - + /* If no events are to be counted just return */ if (npapievents == 0) @@ -860,25 +860,25 @@ int GPTL_PAPIstart (const int t, /* thread number */ if ((ret = PAPI_read (EventSet[t], papicounters[t])) != PAPI_OK) return GPTLerror ("GPTL_PAPIstart: %s\n", PAPI_strerror (ret)); - /* + /* ** Store the counter values. When GPTL_PAPIstop is called, the counters ** will again be read, and differenced with the values saved here. */ for (n = 0; n < npapievents; n++) aux->last[n] = papicounters[t][n]; - + return 0; } /* -** GPTL_PAPIstop: Stop the PAPI counters (actually they are just read). +** GPTL_PAPIstop: Stop the PAPI counters (actually they are just read). ** Called from GPTLstop. ** ** Input args: ** t: thread number ** -** Input/output args: +** Input/output args: ** aux: struct containing the counters ** ** Return value: 0 (success) or GPTLerror (failure) @@ -900,8 +900,8 @@ int GPTL_PAPIstop (const int t, /* thread number */ if ((ret = PAPI_read (EventSet[t], papicounters[t])) != PAPI_OK) return GPTLerror ("GPTL_PAPIstop: %s\n", PAPI_strerror (ret)); - - /* + + /* ** Accumulate the difference since timer start in aux. ** Negative accumulation can happen when multiplexing is enabled, so don't ** set count to BADCOUNT in that case. @@ -924,14 +924,14 @@ int GPTL_PAPIstop (const int t, /* thread number */ ** GPTL_PAPIprstr: Print the descriptive string for all enabled PAPI events. ** Called from GPTLpr. ** -** Input args: +** Input args: ** fp: file descriptor */ void GPTL_PAPIprstr (FILE *fp) { int n; - + if (narrowprint) { for (n = 0; n < nevents; n++) { fprintf (fp, "%8.8s ", pr_event[n].event.str8); @@ -957,7 +957,7 @@ void GPTL_PAPIprstr (FILE *fp) ** GPTL_PAPIpr: Print PAPI counter values for all enabled events, including ** derived events. Called from GPTLpr. ** -** Input args: +** Input args: ** fp: file descriptor ** aux: struct containing the counters */ @@ -989,7 +989,7 @@ void GPTL_PAPIpr (FILE *fp, /* file descriptor to write denomidx = pr_event[n].denomidx; #ifdef DEBUG - printf ("GPTL_PAPIpr: derived event: numidx=%d denomidx=%d values = %ld %ld\n", + printf ("GPTL_PAPIpr: derived event: numidx=%d denomidx=%d values = %ld %ld\n", numidx, denomidx, (long) aux->accum[numidx], (long) aux->accum[denomidx]); #endif /* Protect against divide by zero */ @@ -1003,7 +1003,7 @@ void GPTL_PAPIpr (FILE *fp, /* file descriptor to write } else { /* Raw PAPI event */ #ifdef DEBUG - printf ("GPTL_PAPIpr: raw event: numidx=%d value = %ld\n", + printf ("GPTL_PAPIpr: raw event: numidx=%d value = %ld\n", numidx, (long) aux->accum[numidx]); #endif if (aux->accum[numidx] < PRTHRESH) @@ -1055,12 +1055,12 @@ void GPTL_PAPIprintenabled (FILE *fp) fprintf (fp, " %s\n", eventname); fprintf (fp, "\n"); } -} +} /* ** GPTL_PAPIadd: Accumulate PAPI counters. Called from add. ** -** Input/Output args: +** Input/Output args: ** auxout: auxout = auxout + auxin ** ** Input args: @@ -1071,7 +1071,7 @@ void GPTL_PAPIadd (Papistats *auxout, /* output struct */ const Papistats *auxin) /* input struct */ { int n; - + for (n = 0; n < npapievents; n++) if (auxin->accum[n] == BADCOUNT || auxout->accum[n] == BADCOUNT) auxout->accum[n] = BADCOUNT; @@ -1229,7 +1229,7 @@ int GPTLevent_name_to_code (const char *name, int *code) int n; /* loop over derived entries */ /* - ** First check derived events + ** First check derived events */ for (n = 0; n < nderivedentries; ++n) { @@ -1272,7 +1272,7 @@ int GPTLevent_code_to_name (const int code, char *name) int n; /* loop over derived entries */ /* - ** First check derived events + ** First check derived events */ for (n = 0; n < nderivedentries; ++n) { @@ -1323,3 +1323,4 @@ int GPTLevent_code_to_name (int code, char *name) } #endif /* HAVE_PAPI */ + diff --git a/src/gptl/perf_mod.F90 b/src/gptl/perf_mod.F90 index 8490a35d26..622d5cf2c1 100644 --- a/src/gptl/perf_mod.F90 +++ b/src/gptl/perf_mod.F90 @@ -1,14 +1,14 @@ module perf_mod -!----------------------------------------------------------------------- -! +!----------------------------------------------------------------------- +! ! Purpose: This module is responsible for controlling the performance ! timer logic. -! +! ! Author: P. Worley, January 2007 ! ! $Id$ -! +! !----------------------------------------------------------------------- !----------------------------------------------------------------------- @@ -62,7 +62,7 @@ module perf_mod !----------------------------------------------------------------------- !- include statements -------------------------------------------------- !----------------------------------------------------------------------- -#include +#include #include "gptl.inc" !----------------------------------------------------------------------- @@ -93,7 +93,7 @@ module perf_mod integer, parameter :: def_timer_depth_limit = 99999 ! default integer, private :: timer_depth_limit = def_timer_depth_limit ! integer indicating maximum number of levels of - ! timer nesting + ! timer nesting integer, parameter :: def_timing_detail_limit = 1 ! default integer, private :: timing_detail_limit = def_timing_detail_limit @@ -111,19 +111,19 @@ module perf_mod logical, parameter :: def_perf_single_file = .false. ! default logical, private :: perf_single_file = def_perf_single_file ! flag indicating whether the performance timer - ! output should be written to a single file - ! (per component communicator) or to a + ! output should be written to a single file + ! (per component communicator) or to a ! separate file for each process integer, parameter :: def_perf_outpe_num = 0 ! default integer, private :: perf_outpe_num = def_perf_outpe_num - ! maximum number of processes writing out + ! maximum number of processes writing out ! timing data (for this component communicator) integer, parameter :: def_perf_outpe_stride = 1 ! default integer, private :: perf_outpe_stride = def_perf_outpe_stride ! separation between process ids for processes - ! that are writing out timing data + ! that are writing out timing data ! (for this component communicator) logical, parameter :: def_perf_global_stats = .true. ! default @@ -176,9 +176,9 @@ module perf_mod !======================================================================== ! subroutine t_getLogUnit(LogUnit) -!----------------------------------------------------------------------- +!----------------------------------------------------------------------- ! Purpose: Get log unit number. -! Author: P. Worley +! Author: P. Worley !----------------------------------------------------------------------- !---------------------------Input arguments----------------------------- ! @@ -193,9 +193,9 @@ end subroutine t_getLogUnit !======================================================================== ! subroutine t_setLogUnit(LogUnit) -!----------------------------------------------------------------------- +!----------------------------------------------------------------------- ! Purpose: Set log unit number. -! Author: P. Worley +! Author: P. Worley !----------------------------------------------------------------------- !---------------------------Input arguments----------------------------- ! @@ -222,9 +222,9 @@ subroutine perf_defaultopts(timing_disable_out, & perf_single_file_out, & perf_global_stats_out, & perf_papi_enable_out ) -!----------------------------------------------------------------------- +!----------------------------------------------------------------------- ! Purpose: Return default runtime options -! Author: P. Worley +! Author: P. Worley !----------------------------------------------------------------------- !---------------------------Input arguments----------------------------- ! timers disable/enable option @@ -296,16 +296,16 @@ subroutine perf_setopts(mastertask, & perf_single_file_in, & perf_global_stats_in, & perf_papi_enable_in ) -!----------------------------------------------------------------------- +!----------------------------------------------------------------------- ! Purpose: Set runtime options -! Author: P. Worley +! Author: P. Worley !----------------------------------------------------------------------- !---------------------------Input arguments---------------------------- ! ! master process? logical, intent(in) :: mastertask ! Print out to log file? - logical, intent(IN) :: LogPrint + logical, intent(IN) :: LogPrint ! timers disable/enable option logical, intent(in), optional :: timing_disable_in ! performance timer option @@ -337,7 +337,7 @@ subroutine perf_setopts(mastertask, & timing_disable = timing_disable_in if (timing_disable) then ierr = GPTLdisable() - else + else ierr = GPTLenable() endif endif @@ -392,17 +392,17 @@ subroutine perf_setopts(mastertask, & endif ! if (mastertask .and. LogPrint) then - write(p_logunit,*) '(t_initf) Using profile_disable=', timing_disable, & + write(p_logunit,*) '(t_initf) Using profile_disable=', timing_disable, & ' profile_timer=', perf_timer - write(p_logunit,*) '(t_initf) profile_depth_limit=', timer_depth_limit, & + write(p_logunit,*) '(t_initf) profile_depth_limit=', timer_depth_limit, & ' profile_detail_limit=', timing_detail_limit write(p_logunit,*) '(t_initf) profile_barrier=', timing_barrier, & ' profile_outpe_num=', perf_outpe_num write(p_logunit,*) '(t_initf) profile_outpe_stride=', perf_outpe_stride , & ' profile_single_file=', perf_single_file write(p_logunit,*) '(t_initf) profile_global_stats=', perf_global_stats , & - ' profile_papi_enable=', perf_papi_enable - endif + ' profile_papi_enable=', perf_papi_enable + endif ! #ifdef DEBUG else @@ -420,9 +420,9 @@ subroutine papi_defaultopts(papi_ctr1_out, & papi_ctr2_out, & papi_ctr3_out, & papi_ctr4_out ) -!----------------------------------------------------------------------- +!----------------------------------------------------------------------- ! Purpose: Return default runtime PAPI counter options -! Author: P. Worley +! Author: P. Worley !----------------------------------------------------------------------- !---------------------------Input arguments----------------------------- ! PAPI counter option #1 @@ -456,9 +456,9 @@ subroutine papi_setopts(papi_ctr1_in, & papi_ctr2_in, & papi_ctr3_in, & papi_ctr4_in ) -!----------------------------------------------------------------------- +!----------------------------------------------------------------------- ! Purpose: Set runtime PAPI counter options -! Author: P. Worley +! Author: P. Worley !----------------------------------------------------------------------- !---------------------------Input arguments---------------------------- ! @@ -518,12 +518,12 @@ end subroutine papi_setopts !======================================================================== ! logical function t_profile_onf() -!----------------------------------------------------------------------- +!----------------------------------------------------------------------- ! Purpose: Return flag indicating whether profiling is currently active. ! Part of workaround to implement FVbarrierclock before ! communicators exposed in Pilgrim. Does not check level of ! event nesting. -! Author: P. Worley +! Author: P. Worley !----------------------------------------------------------------------- if ((.not. timing_initialized) .or. & @@ -539,10 +539,10 @@ end function t_profile_onf !======================================================================== ! logical function t_barrier_onf() -!----------------------------------------------------------------------- -! Purpose: Return timing_barrier. Part of workaround to implement -! FVbarrierclock before communicators exposed in Pilgrim. -! Author: P. Worley +!----------------------------------------------------------------------- +! Purpose: Return timing_barrier. Part of workaround to implement +! FVbarrierclock before communicators exposed in Pilgrim. +! Author: P. Worley !----------------------------------------------------------------------- t_barrier_onf = timing_barrier @@ -552,10 +552,10 @@ end function t_barrier_onf !======================================================================== ! logical function t_single_filef() -!----------------------------------------------------------------------- +!----------------------------------------------------------------------- ! Purpose: Return perf_single_file. Used to control output of other ! performance data, only spmdstats currently. -! Author: P. Worley +! Author: P. Worley !----------------------------------------------------------------------- t_single_filef = perf_single_file @@ -565,9 +565,9 @@ end function t_single_filef !======================================================================== ! subroutine t_stampf(wall, usr, sys) -!----------------------------------------------------------------------- +!----------------------------------------------------------------------- ! Purpose: Record wallclock, user, and system times (seconds). -! Author: P. Worley +! Author: P. Worley !----------------------------------------------------------------------- !---------------------------Output arguments----------------------------- ! @@ -596,14 +596,14 @@ end subroutine t_stampf !======================================================================== ! subroutine t_startf(event, handle) -!----------------------------------------------------------------------- +!----------------------------------------------------------------------- ! Purpose: Start an event timer -! Author: P. Worley +! Author: P. Worley !----------------------------------------------------------------------- !---------------------------Input arguments----------------------------- ! ! performance timer event name - character(len=*), intent(in) :: event + character(len=*), intent(in) :: event ! !---------------------------Input/Output arguments---------------------- ! @@ -634,14 +634,14 @@ end subroutine t_startf !======================================================================== ! subroutine t_stopf(event, handle) -!----------------------------------------------------------------------- +!----------------------------------------------------------------------- ! Purpose: Stop an event timer -! Author: P. Worley +! Author: P. Worley !----------------------------------------------------------------------- !---------------------------Input arguments----------------------------- ! ! performance timer event name - character(len=*), intent(in) :: event + character(len=*), intent(in) :: event ! !---------------------------Input/Output arguments---------------------- ! @@ -672,10 +672,10 @@ end subroutine t_stopf !======================================================================== ! subroutine t_enablef() -!----------------------------------------------------------------------- +!----------------------------------------------------------------------- ! Purpose: Enable t_startf, t_stopf, t_stampf, and t_barrierf. Ignored ! in threaded regions. -! Author: P. Worley +! Author: P. Worley !----------------------------------------------------------------------- !---------------------------Local workspace----------------------------- ! @@ -709,10 +709,10 @@ end subroutine t_enablef !======================================================================== ! subroutine t_disablef() -!----------------------------------------------------------------------- +!----------------------------------------------------------------------- ! Purpose: Disable t_startf, t_stopf, t_stampf, and t_barrierf. Ignored ! in threaded regions. -! Author: P. Worley +! Author: P. Worley !----------------------------------------------------------------------- !---------------------------Local workspace----------------------------- ! @@ -744,9 +744,9 @@ end subroutine t_disablef !======================================================================== ! subroutine t_adj_detailf(detail_adjustment) -!----------------------------------------------------------------------- +!----------------------------------------------------------------------- ! Purpose: Modify current detail level. Ignored in threaded regions. -! Author: P. Worley +! Author: P. Worley !----------------------------------------------------------------------- !---------------------------Input arguments----------------------------- ! @@ -776,11 +776,11 @@ end subroutine t_adj_detailf !======================================================================== ! subroutine t_barrierf(event, mpicom) -!----------------------------------------------------------------------- +!----------------------------------------------------------------------- ! Purpose: Call (and time) mpi_barrier. Ignored inside OpenMP ! threaded regions. Note that barrier executed even if ! event not recorded because of level of timer event nesting. -! Author: P. Worley +! Author: P. Worley !----------------------------------------------------------------------- !---------------------------Input arguments----------------------------- ! mpi communicator id @@ -835,9 +835,9 @@ end subroutine t_barrierf ! subroutine t_prf(filename, mpicom, num_outpe, stride_outpe, & single_file, global_stats, output_thispe) -!----------------------------------------------------------------------- +!----------------------------------------------------------------------- ! Purpose: Write out performance timer data -! Author: P. Worley +! Author: P. Worley !----------------------------------------------------------------------- !---------------------------Input arguments----------------------------- ! @@ -847,7 +847,7 @@ subroutine t_prf(filename, mpicom, num_outpe, stride_outpe, & integer, intent(in), optional :: mpicom ! maximum number of processes writing out timing data integer, intent(in), optional :: num_outpe - ! separation between process ids for processes writing out data + ! separation between process ids for processes writing out data integer, intent(in), optional :: stride_outpe ! enable/disable the writing of data to a single file logical, intent(in), optional :: single_file @@ -862,7 +862,7 @@ subroutine t_prf(filename, mpicom, num_outpe, stride_outpe, & ! all data to a single file logical glb_stats ! flag indicting whether to compute ! global statistics - logical pr_write ! flag indicating whether the current + logical pr_write ! flag indicating whether the current ! GPTL output mode is write logical write_data ! flag indicating whether this process ! should output its timing data @@ -1113,8 +1113,8 @@ end subroutine t_prf !======================================================================== ! subroutine t_initf(NLFilename, LogPrint, LogUnit, mpicom, MasterTask) -!----------------------------------------------------------------------- -! Purpose: Set default values of runtime timing options +!----------------------------------------------------------------------- +! Purpose: Set default values of runtime timing options ! before namelists prof_inparm and papi_inparm are read, ! read namelists (and broadcast, if SPMD), ! then initialize timing library. @@ -1224,12 +1224,12 @@ subroutine t_initf(NLFilename, LogPrint, LogUnit, mpicom, MasterTask) open( unitn, file=trim(NLFilename), status='old', iostat=ierr ) if (ierr .eq. 0) then - ! Look for prof_inparm group name in the input file. + ! Look for prof_inparm group name in the input file. ! If found, leave the file positioned at that namelist group. call find_group_name(unitn, 'prof_inparm', status=ierr) if (ierr == 0) then ! found prof_inparm - read(unitn, nml=prof_inparm, iostat=ierr) + read(unitn, nml=prof_inparm, iostat=ierr) if (ierr /= 0) then call shr_sys_abort( subname//':: namelist read returns an'// & ' error condition for prof_inparm' ) @@ -1291,12 +1291,12 @@ subroutine t_initf(NLFilename, LogPrint, LogUnit, mpicom, MasterTask) ierr = 1 open( unitn, file=trim(NLFilename), status='old', iostat=ierr ) if (ierr .eq. 0) then - ! Look for papi_inparm group name in the input file. + ! Look for papi_inparm group name in the input file. ! If found, leave the file positioned at that namelist group. call find_group_name(unitn, 'papi_inparm', status=ierr) if (ierr == 0) then ! found papi_inparm - read(unitn, nml=papi_inparm, iostat=ierr) + read(unitn, nml=papi_inparm, iostat=ierr) if (ierr /= 0) then call shr_sys_abort( subname//':: namelist read returns an'// & ' error condition for papi_inparm' ) @@ -1355,12 +1355,12 @@ subroutine t_initf(NLFilename, LogPrint, LogUnit, mpicom, MasterTask) !$OMP MASTER ! - ! Set options and initialize timing library. - ! + ! Set options and initialize timing library. + ! ! Set timer if (gptlsetutr (perf_timer) < 0) call shr_sys_abort (subname//':: gptlsetutr') ! - ! For logical settings, 2nd arg 0 + ! For logical settings, 2nd arg 0 ! to gptlsetoption means disable, non-zero means enable ! ! Turn off CPU timing (expensive) @@ -1404,9 +1404,9 @@ end subroutine t_initf !======================================================================== ! subroutine t_finalizef() -!----------------------------------------------------------------------- +!----------------------------------------------------------------------- ! Purpose: shut down timing library -! Author: P. Worley +! Author: P. Worley !----------------------------------------------------------------------- !---------------------------Local workspace----------------------------- ! diff --git a/src/gptl/perf_utils.F90 b/src/gptl/perf_utils.F90 index 88fab3c5f5..b0e722567e 100644 --- a/src/gptl/perf_utils.F90 +++ b/src/gptl/perf_utils.F90 @@ -1,15 +1,15 @@ module perf_utils -!----------------------------------------------------------------------- -! +!----------------------------------------------------------------------- +! ! Purpose: This module supplies the csm_share and CAM utilities ! needed by perf_mod.F90 (when the csm_share and CAM utilities ! are not available). -! +! ! Author: P. Worley, October 2007 ! ! $Id$ -! +! !----------------------------------------------------------------------- #ifndef NO_MPIMOD use mpi @@ -49,7 +49,7 @@ module perf_utils !- include statements -------------------------------------------------- !----------------------------------------------------------------------- #ifdef NO_MPIMOD -#include +#include #endif #include "gptl.inc" @@ -82,9 +82,9 @@ module perf_utils !======================================================================== ! subroutine perfutils_setunit(LogUnit) -!----------------------------------------------------------------------- +!----------------------------------------------------------------------- ! Purpose: Set log unit number. -! Author: P. Worley +! Author: P. Worley !----------------------------------------------------------------------- !---------------------------Input arguments----------------------------- ! @@ -317,7 +317,7 @@ END SUBROUTINE shr_mpi_bcastl0 !================== Routines from csm_share/shr/shr_file_mod.F90 =============== !=============================================================================== -!=========================================================================== +!BOPI =========================================================================== ! ! !IROUTINE: shr_file_getUnit -- Get a free FORTRAN unit number ! @@ -327,13 +327,13 @@ END SUBROUTINE shr_mpi_bcastl0 ! 2005-Dec-14 - E. Kluzek - creation ! 2007-Oct-21 - P. Worley - dumbed down for use in perf_mod ! -! !INTERFACE: ------------------------------------------------------------------ +! !INTERFACE: ------------------------------------------------------------------ INTEGER FUNCTION shr_file_getUnit () implicit none -! +!EOPI !----- local parameters ----- integer(SHR_KIND_IN),parameter :: shr_file_minUnit = 10 ! Min unit number to give @@ -367,7 +367,7 @@ END FUNCTION shr_file_getUnit !=============================================================================== !=============================================================================== -!=============================================================================== +!BOPI =========================================================================== ! ! !IROUTINE: shr_file_freeUnit -- Free up a FORTRAN unit number ! @@ -377,7 +377,7 @@ END FUNCTION shr_file_getUnit ! 2005-Dec-14 - E. Kluzek - creation ! 2007-Oct-21 - P. Worley - dumbed down for use in perf_mod ! -! !INTERFACE: ------------------------------------------------------------------ +! !INTERFACE: ------------------------------------------------------------------ SUBROUTINE shr_file_freeUnit ( unit) @@ -387,7 +387,7 @@ SUBROUTINE shr_file_freeUnit ( unit) integer(SHR_KIND_IN),intent(in) :: unit ! unit number to be freed -! +!EOPI !----- local parameters ----- integer(SHR_KIND_IN),parameter :: shr_file_minUnit = 10 ! Min unit number to give @@ -418,12 +418,12 @@ END SUBROUTINE shr_file_freeUnit subroutine find_group_name(unit, group, status) !--------------------------------------------------------------------------------------- -! Purpose: +! Purpose: ! Search a file that contains namelist input for the specified namelist group name. ! Leave the file positioned so that the current record is the first record of the ! input for the specified group. -! -! Method: +! +! Method: ! Read the file line by line. Each line is searched for an '&' which may only ! be preceded by blanks, immediately followed by the group name which is case ! insensitive. If found then backspace the file so the current record is the @@ -489,17 +489,17 @@ end subroutine find_group_name function to_lower(str) -!----------------------------------------------------------------------- -! Purpose: +!----------------------------------------------------------------------- +! Purpose: ! Convert character string to lower case. -! -! Method: +! +! Method: ! Use achar and iachar intrinsics to ensure use of ascii collating sequence. ! ! Author: B. Eaton, July 2001 -! +! ! $Id$ -!----------------------------------------------------------------------- +!----------------------------------------------------------------------- implicit none character(len=*), intent(in) :: str ! String to convert to lower case @@ -518,7 +518,7 @@ function to_lower(str) ctmp = str(i:i) aseq = iachar(ctmp) if ( aseq >= iachar("A") .and. aseq <= iachar("Z") ) & - ctmp = achar(aseq + upper_to_lower) + ctmp = achar(aseq + upper_to_lower) to_lower(i:i) = ctmp end do diff --git a/src/gptl/private.h b/src/gptl/private.h index c8a52a9f35..8d14b1479a 100644 --- a/src/gptl/private.h +++ b/src/gptl/private.h @@ -32,7 +32,7 @@ /* longest timer name allowed (probably safe to just change) */ #define MAX_CHARS 63 -/* +/* ** max allowable number of PAPI counters, or derived events. For convenience, ** set to max (# derived events, # papi counters required) so "avail" lists ** all available options. @@ -61,7 +61,7 @@ typedef struct { long long last[MAX_AUX]; /* array of saved counters from "start" */ long long accum[MAX_AUX]; /* accumulator for counters */ } Papistats; - + typedef struct { int counter; /* PAPI or Derived counter */ char *namestr; /* PAPI or Derived counter as string */ @@ -84,7 +84,7 @@ typedef struct TIMER { #endif #ifdef HAVE_PAPI Papistats aux; /* PAPI stats */ -#endif +#endif Wallstats wall; /* wallclock stats */ Cpustats cpu; /* cpu stats */ unsigned long count; /* number of start/stop calls */ @@ -127,7 +127,7 @@ extern void __cyg_profile_func_exit (void *, void *); }; #endif -/* +/* ** These are needed for communication between gptl.c and gptl_papi.c */ diff --git a/src/gptl/threadutil.c b/src/gptl/threadutil.c index 86e4681c1c..85d9c52d15 100644 --- a/src/gptl/threadutil.c +++ b/src/gptl/threadutil.c @@ -2,7 +2,7 @@ ** $Id: threadutil.c,v 1.28 2009/12/31 01:51:59 rosinski Exp $ ** ** Author: Jim Rosinski -** +** ** Utility functions handle thread-based GPTL needs. */ @@ -21,7 +21,7 @@ static bool first = true; /**********************************************************************************/ -/* +/* ** 3 sets of routines: OMP threading, PTHREADS, unthreaded */ @@ -62,7 +62,7 @@ int threadinit (int *nthreads, int *maxthreads) #ifdef VERBOSE printf ("OMP threadinit: Set *maxthreads=%d *nthreads=%d\n", *maxthreads, *nthreads); #endif - + return 0; } @@ -138,7 +138,7 @@ void print_threadmapping (int nthreads, FILE *fp) } /**********************************************************************************/ -/* +/* ** PTHREADS */ @@ -179,7 +179,7 @@ int threadinit (int *nthreads, int *maxthreads) first = false; /* - ** Initialize nthreads to 0 and define the threadid array now that initialization + ** Initialize nthreads to 0 and define the threadid array now that initialization ** is done. The actual value will be determined as get_thread_num is called. */ @@ -228,8 +228,8 @@ int get_thread_num (int *nthreads, int *maxthreads) return GPTLerror ("get_thread_num: mutex lock failure\n"); /* - ** Loop over known physical thread IDs. When my id is found, map it - ** to logical thread id for indexing. If not found return a negative + ** Loop over known physical thread IDs. When my id is found, map it + ** to logical thread id for indexing. If not found return a negative ** number. ** A critical region is necessary because acess to ** the array threadid must be by only one thread at a time. @@ -251,7 +251,7 @@ int get_thread_num (int *nthreads, int *maxthreads) return GPTLerror ("get_thread_num: nthreads=%d is too big Recompile " "with larger value of MAX_THREADS\n", *nthreads); - } + } threadid[n] = mythreadid; @@ -268,7 +268,7 @@ int get_thread_num (int *nthreads, int *maxthreads) if (GPTLget_npapievents () > 0) { #ifdef VERBOSE - printf ("PTHREADS get_thread_num: Starting EventSet threadid=%lu location=%d\n", + printf ("PTHREADS get_thread_num: Starting EventSet threadid=%lu location=%d\n", (unsigned long) mythreadid, n); #endif if (GPTLcreate_and_start_events (n) < 0) { @@ -286,7 +286,7 @@ int get_thread_num (int *nthreads, int *maxthreads) printf ("PTHREADS get_thread_num: *nthreads=%d\n", *nthreads); #endif } - + if (unlock_mutex () < 0) return GPTLerror ("get_thread_num: mutex unlock failure\n"); diff --git a/src/ncint/ncint_pio.c b/src/ncint/ncint_pio.c index e4a59bad28..a8c606dd80 100644 --- a/src/ncint/ncint_pio.c +++ b/src/ncint/ncint_pio.c @@ -25,16 +25,14 @@ nc_def_iosystem(MPI_Comm comp_comm, int num_iotasks, int stride, int base, int ret; /* Make sure PIO was initialized. */ - if ((ret = PIO_NCINT_initialize())){ - //printf("%s %d ret=%d\n",__FILE__,__LINE__,ret); + if ((ret = PIO_NCINT_initialize())) return ret; - } + /* Call the PIOc_ function to initialize the intracomm. */ if ((ret = PIOc_Init_Intracomm(comp_comm, num_iotasks, stride, base, rearr, - iosysidp))){ - //printf("%s %d ret=%d\n",__FILE__,__LINE__,ret); + iosysidp))) return ret; - } + /* Remember the io system id. */ diosysid = *iosysidp; diff --git a/src/ncint/ncintdispatch.c b/src/ncint/ncintdispatch.c index 30ec267816..db442a8c7f 100644 --- a/src/ncint/ncintdispatch.c +++ b/src/ncint/ncintdispatch.c @@ -25,18 +25,18 @@ int diosysid; int ncint_initialized = 0; /** Version of dispatch table. */ -#define DISPATCH_VERSION NC_DISPATCH_VERSION +#define DISPATCH_VERSION 2 /* Internal filter actions - copied from nc4internal.h */ -#define NCFILTER_DEF 1 -#define NCFILTER_REMOVE 2 -#define NCFILTER_INQ 3 +#define NCFILTER_DEF 1 +#define NCFILTER_REMOVE 2 +#define NCFILTER_INQ 3 #define NCFILTER_FILTERIDS 4 -#define NCFILTER_INFO 5 -#define NCFILTER_FREESPEC 6 -#define NCFILTER_CLIENT_REG 10 -#define NCFILTER_CLIENT_UNREG 11 -#define NCFILTER_CLIENT_INQ 12 +#define NCFILTER_INFO 5 +#define NCFILTER_FREESPEC 6 +#define NCFILTER_CLIENT_REG 10 +#define NCFILTER_CLIENT_UNREG 11 +#define NCFILTER_CLIENT_INQ 12 /* This is the dispatch object that holds pointers to all the * functions that make up the NCINT dispatch interface. */ @@ -127,22 +127,7 @@ NC_Dispatch NCINT_dispatcher = { NC_NOTNC4_def_var_filter, NC_NOTNC4_set_var_chunk_cache, NC_NOTNC4_get_var_chunk_cache, -#ifdef PIO_HAS_PAR_FILTERS -#if NC_DISPATCH_VERSION == 2 - PIO_NCINT_filter_actions, -#endif -#if NC_DISPATCH_VERSION >= 3 - PIOc_inq_var_filter_ids, - PIOc_inq_var_filter_info, -#endif -#if NC_DISPATCH_VERSION >= 4 - PIOc_def_var_quantize, - PIOc_inq_var_quantize, -#endif -#if NC_DISPATCH_VERSION >= 5 - PIOc_inq_filter_avail, -#endif -#endif + PIO_NCINT_filter_actions }; /** @@ -221,8 +206,9 @@ PIO_NCINT_create(const char *path, int cmode, size_t initialsz, int basepe, if (!(ios = pio_get_iosystem_from_id(diosysid))) return pio_err(NULL, NULL, PIO_EBADID, __FILE__, __LINE__); - /* Turn off NC_UDF0 in the mode flag. */ - cmode = ((cmode) & ~(NC_UDF0)); + /* Turn of NC_UDF0 in the mode flag. */ + cmode = cmode & ~NC_UDF0; + /* Find the IOTYPE from the mode flag. */ if ((ret = find_iotype_from_omode(cmode, &iotype))) return pio_err(ios, NULL, ret, __FILE__, __LINE__); @@ -231,11 +217,10 @@ PIO_NCINT_create(const char *path, int cmode, size_t initialsz, int basepe, if ((ret = nc4_file_list_add(ncid, path, cmode, NULL))) return ret; - /* Create the file with PIO. The final parameter tells + /* Create the file with PIO. The final parameter tests * createfile_int to accept the externally assigned ncid. */ if ((ret = PIOc_createfile_int(diosysid, &ncid, &iotype, path, cmode, 1))) return ret; - return PIO_NOERR; } @@ -272,8 +257,8 @@ PIO_NCINT_open(const char *path, int mode, int basepe, size_t *chunksizehintp, if (!(ios = pio_get_iosystem_from_id(diosysid))) return pio_err(NULL, NULL, PIO_EBADID, __FILE__, __LINE__); - /* Turn off NC_UDF0 in the mode flag. */ - mode = (mode) & ~(NC_UDF0); + /* Turn of NC_UDF0 in the mode flag. */ + mode = mode & ~NC_UDF0; /* Find the IOTYPE from the mode flag. */ if ((ret = find_iotype_from_omode(mode, &iotype))) @@ -281,11 +266,11 @@ PIO_NCINT_open(const char *path, int mode, int basepe, size_t *chunksizehintp, /* Add necessary structs to hold netcdf-4 file data. */ if ((ret = nc4_file_list_add(ncid, path, mode, NULL))) - return ret; + return ret; /* Open the file with PIO. Tell openfile_retry to accept the * externally assigned ncid. */ - if ((ret = PIOc_openfile_retry(diosysid, &ncid, &iotype, path, mode, 1, 1))) + if ((ret = PIOc_openfile_retry(diosysid, &ncid, &iotype, path, mode, 0, 1))) return ret; return NC_NOERR; @@ -432,8 +417,8 @@ PIO_NCINT_inq_format_extended(int ncid, int *formatp, int *modep) PLOG((2, "%s: ncid 0x%x", __func__, ncid)); - if ((retval = PIOc_inq_format(ncid, &my_mode))) - return retval; + if ((retval = nc4_file_list_get(ncid, NULL, &my_mode, NULL))) + return NC_EBADID; if (modep) *modep = my_mode|NC_UDF0; @@ -898,22 +883,18 @@ PIO_NCINT_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep, unsigned int *idp, size_t *nparamsp, unsigned int *params) { int ret; - int format; ret = PIOc_inq_var(ncid, varid, name, xtypep, ndimsp, dimidsp, nattsp); -#ifdef _NETCDF4 - ret = PIOc_inq_format(ncid, &format); - if (!ret && (format == NC_FORMAT_NETCDF4 || format == NC_FORMAT_NETCDF4_CLASSIC) ){ - if (!ret && contiguousp && chunksizesp) - ret = PIOc_inq_var_chunking(ncid, varid, contiguousp, (MPI_Offset *)chunksizesp); - if (!ret && shufflep && deflatep && deflate_levelp) - ret = PIOc_inq_var_deflate(ncid, varid, shufflep, deflatep, deflate_levelp); + if (!ret) + ret = PIOc_inq_var_chunking(ncid, varid, contiguousp, (MPI_Offset *)chunksizesp); - if (!ret && endiannessp) - ret = PIOc_inq_var_endian(ncid, varid, endiannessp); - } -#endif + if (!ret) + ret = PIOc_inq_var_deflate(ncid, varid, shufflep, deflatep, deflate_levelp); + + if (!ret) + ret = PIOc_inq_var_endian(ncid, varid, endiannessp); + return ret; } @@ -1012,7 +993,7 @@ PIO_NCINT_inq_type_equal(int ncid1, nc_type typeid1, int ncid2, */ int PIO_NCINT_def_var_deflate(int ncid, int varid, int shuffle, int deflate, - int deflate_level) + int deflate_level) { return PIOc_def_var_deflate(ncid, varid, shuffle, deflate, deflate_level); } @@ -1047,7 +1028,6 @@ PIO_NCINT_def_var_chunking(int ncid, int varid, int storage, const size_t *chunk return PIOc_def_var_chunking(ncid, varid, storage, (const PIO_Offset *)chunksizesp); } -#if NC_DISPATCH_VERSION == 2 /** * @internal Carry out one of several filter actions * @@ -1063,8 +1043,7 @@ PIO_NCINT_filter_actions(int ncid, int varid, int action, struct NC_Filterobject { if (action == NCFILTER_INFO) { - + } return PIO_NOERR; } -#endif diff --git a/src/ncint/ncintdispatch.h b/src/ncint/ncintdispatch.h index 26764726dc..8934740f55 100644 --- a/src/ncint/ncintdispatch.h +++ b/src/ncint/ncintdispatch.h @@ -147,15 +147,15 @@ extern "C" { extern int PIO_NCINT_def_var_deflate(int ncid, int varid, int shuffle, int deflate, - int deflate_level); + int deflate_level); extern int PIO_NCINT_def_var_chunking(int ncid, int varid, int storage, const size_t *chunksizesp); -#if NC_DISPATCH_VERSION == 2 + extern int PIO_NCINT_filter_actions(int ncid, int varid, int action, struct NC_Filterobject* spec); -#endif + #if defined(__cplusplus) } #endif