mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-18 15:55:12 +08:00
1. Moved all the PNETCDF code
(primarily from libsrc4) into its own dispatch library called libsrc5. 2. Fixed part of Jira NCF-253 by removing the need for the pnetcdf_ndims field. For some reason, the original code tried to cache the variable ranks rather than computing them as needed. Fixed by doing an ...inq_varndims call as needed. 3. found some places where NC_MAX_DIMS was being stack allocated and changed to heap allocation. Still some cases in nc_test4.
This commit is contained in:
parent
de34ed2d5b
commit
5be772b6c0
2
cf
2
cf
@ -6,7 +6,7 @@ if test $# != 0 ; then
|
||||
cmds=$@
|
||||
fi
|
||||
|
||||
#HDF5=1
|
||||
HDF5=1
|
||||
DAP=1
|
||||
PNETCDF=1
|
||||
#HDF4=1
|
||||
|
@ -415,6 +415,17 @@ NCSUB_inq_var_all(int ncid, int varid, char* name, nc_type* xtypep,
|
||||
options_maskp,pixels_per_blockp);
|
||||
}
|
||||
|
||||
static int
|
||||
NCSUB_var_par_access(int ncid, int a1, int a2)
|
||||
{
|
||||
NC *nc, *ncsub;
|
||||
int ncstat = NC_check_id(ncid, &nc);
|
||||
if(ncstat != NC_NOERR) return ncstat;
|
||||
ncstat = NC_check_id(nc->substrate, &ncsub);
|
||||
if(ncstat != NC_NOERR) return ncstat;
|
||||
return ncsub->dispatch->var_par_access(nc->substrate,a1,a2);
|
||||
}
|
||||
|
||||
#ifdef USE_NETCDF4
|
||||
|
||||
static int
|
||||
@ -439,17 +450,6 @@ NCSUB_inq_unlimdims(int ncid, int* a1, int* a2)
|
||||
return ncsub->dispatch->inq_unlimdims(nc->substrate,a1,a2);
|
||||
}
|
||||
|
||||
static int
|
||||
NCSUB_var_par_access(int ncid, int a1, int a2)
|
||||
{
|
||||
NC *nc, *ncsub;
|
||||
int ncstat = NC_check_id(ncid, &nc);
|
||||
if(ncstat != NC_NOERR) return ncstat;
|
||||
ncstat = NC_check_id(nc->substrate, &ncsub);
|
||||
if(ncstat != NC_NOERR) return ncstat;
|
||||
return ncsub->dispatch->var_par_access(nc->substrate,a1,a2);
|
||||
}
|
||||
|
||||
static int
|
||||
NCSUB_inq_ncid(int ncid, const char* a1, int* a2)
|
||||
{
|
||||
|
@ -86,9 +86,7 @@ NC5_create(const char *path, int cmode,
|
||||
cmode |= (NC_NETCDF4);
|
||||
res = ncmpi_create(comm, path, cmode, info, &(nc->int_ncid));
|
||||
|
||||
done:
|
||||
|
||||
if(res && nc5 != null) free(nc5); /* reclaim allocated space */
|
||||
if(res && nc5 != NULL) free(nc5); /* reclaim allocated space */
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -102,7 +100,6 @@ NC5_open(const char *path, int cmode,
|
||||
NC5_INFO* nc5;
|
||||
MPI_Comm comm = 0;
|
||||
MPI_Info info = 0;
|
||||
int pnetcdf_nvars, i;
|
||||
|
||||
/* Check the cmode for only valid flags*/
|
||||
if(cmode & ~LEGAL_OPEN_FLAGS)
|
||||
@ -126,8 +123,6 @@ NC5_open(const char *path, int cmode,
|
||||
|
||||
cmode |= (NC_NETCDF4); /* see comment in NC5_create */
|
||||
|
||||
res = ncmpi_open(comm, path, cmode, info, &(nc->int_ncid));
|
||||
|
||||
/* Create our specific NC5_INFO instance */
|
||||
nc5 = (NC5_INFO*)calloc(1,sizeof(NC5_INFO));
|
||||
if(nc5 == NULL) return NC_ENOMEM;
|
||||
@ -135,14 +130,14 @@ NC5_open(const char *path, int cmode,
|
||||
/* Link nc5 and nc */
|
||||
NC5_DATA_SET(nc,nc5);
|
||||
|
||||
res = ncmpi_open(comm, path, cmode, info, &(nc->int_ncid));
|
||||
|
||||
/* Default to independent access, like netCDF-4/HDF5 files. */
|
||||
if(!res) {
|
||||
res = ncmpi_begin_indep_data(nc->int_ncid);
|
||||
nc5->pnetcdf_access_mode = NC_INDEPENDENT;
|
||||
}
|
||||
|
||||
done:
|
||||
if(res && nc5 != null) free(nc5); /* reclaim allocated space */
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -204,14 +199,13 @@ NC5_abort(int ncid)
|
||||
|
||||
done:
|
||||
nc5 = NC5_DATA(nc);
|
||||
if(nc5 != null) free(nc5); /* reclaim allocated space */
|
||||
if(nc5 != NULL) free(nc5); /* reclaim allocated space */
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
NC5_close(int ncid)
|
||||
{
|
||||
{
|
||||
NC* nc;
|
||||
NC5_INFO* nc5;
|
||||
@ -222,7 +216,7 @@ NC5_close(int ncid)
|
||||
|
||||
done:
|
||||
nc5 = NC5_DATA(nc);
|
||||
if(nc5 != null) free(nc5); /* reclaim allocated space */
|
||||
if(nc5 != NULL) free(nc5); /* reclaim allocated space */
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -555,7 +549,8 @@ NC5_get_vara(int ncid,
|
||||
return NC_EINVAL;
|
||||
|
||||
/* get variable's rank */
|
||||
res = ncmpi_inq_varndims(nc->int_ncid, varid, &rank);
|
||||
status= ncmpi_inq_varndims(nc->int_ncid, varid, &rank);
|
||||
if(status) return status;
|
||||
|
||||
/* We must convert the start, count, and stride arrays to MPI_Offset type. */
|
||||
for (d = 0; d < rank; d++) {
|
||||
@ -635,7 +630,8 @@ NC5_put_vara(int ncid,
|
||||
return NC_EINVAL;
|
||||
|
||||
/* get variable's rank */
|
||||
res = ncmpi_inq_varndims(nc->int_ncid, varid, &rank);
|
||||
status = ncmpi_inq_varndims(nc->int_ncid, varid, &rank);
|
||||
if(status) return status;
|
||||
|
||||
/* We must convert the start, count, and stride arrays to MPI_Offset type. */
|
||||
for (d = 0; d < rank; d++) {
|
||||
|
Loading…
Reference in New Issue
Block a user