-
Notifications
You must be signed in to change notification settings - Fork 58
Prelim GDAL enabled PIO #1980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prelim GDAL enabled PIO #1980
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for correcting. |
||
| * 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,29 +189,29 @@ 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__); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is wrong, mpierr is an input to check_mpi. |
||
|
|
||
| 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); | ||
|
|
||
| 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<size; r++) | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,16 +17,9 @@ | |
| #include <uthash.h> | ||
|
|
||
| #include <netcdf.h> | ||
| #include <netcdf_meta.h> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was this removed? |
||
|
|
||
| #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 <gdal.h> | ||
| //#include <ogr_api.h> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the commented 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; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no longer used, should be removed. |
||
|
|
||
| /** 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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case it should be main and not master, I think maybe you started with an older pio tag but somehow broke the history so git is trying to bring in a bunch of old code along with your changes. A straightforward way to fix this might be to do a git diff in the esmf version then add only the diffs to the ParallelIO branch. |
||
| * 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 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid adding unneeded whitespace.