-
Notifications
You must be signed in to change notification settings - Fork 53
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
Clean import of code for GDAL in ESMF. Compiles/runs in ESMF #1981
base: main
Are you sure you want to change the base?
Changes from all commits
fd61500
e4f67af
87986f8
1b397a4
bbda042
83907b5
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 |
---|---|---|
|
@@ -19,6 +19,8 @@ | |
#include <netcdf.h> | ||
#include <netcdf_meta.h> | ||
|
||
#include <gdal.h> | ||
|
||
#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)) | ||
|
@@ -606,6 +608,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; | ||
|
||
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. #ifdef here too |
||
/** 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 +633,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 | ||
}; | ||
|
||
/** | ||
|
@@ -1357,6 +1369,15 @@ 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, 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_float_field(int fileid, int varid, const size_t *startp, const size_t *countp, float *ip); | ||
int GDALc_shp_get_double_field(int fileid, int varid, const size_t *startp, const size_t *countp, double *ip); | ||
|
||
#if defined(__cplusplus) | ||
} | ||
#endif | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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])); | ||
|
@@ -949,6 +949,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: | ||
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. Will need #ifdef 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. Hey. Yeah. I tried to set up an #ifdef. It's on the list of to-do |
||
if ((ierr = pio_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__); | ||
} | ||
|
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.
Should also include an #ifdef here.