mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-03-25 17:40:27 +08:00
cleanup and squash changes vav master
This commit is contained in:
parent
4d82140a5b
commit
2bfe9bba32
13
Makefile.am
13
Makefile.am
@ -122,6 +122,19 @@ endif # BUILD_DLL
|
||||
settingsdir=$(libdir)
|
||||
settings_DATA=libnetcdf.settings
|
||||
|
||||
####
|
||||
# Provide an entry to rebuild all the m4 generated files
|
||||
|
||||
# List of files to create: WARNING leave off the extension
|
||||
MM4= ./nc_test/test_put ./nc_test/test_get \
|
||||
./libsrc/netcdf ./libsrc/putget ./libsrc/ncx \
|
||||
./libsrc/t_ncxx ./libsrc/attr
|
||||
|
||||
mm4::
|
||||
for m in ${MM4} ; do m4 -s $${m}.m4 > $${m}.c ; done
|
||||
####
|
||||
|
||||
|
||||
#####
|
||||
# If ENABLE_FORTRAN was turned on,
|
||||
# we have new make targets, build-netcdf-fortran and
|
||||
|
@ -59,13 +59,14 @@
|
||||
#define T_ulong ulongtype
|
||||
|
||||
/**************************************************/
|
||||
#if 0
|
||||
/* Define the known classes of dispatchers */
|
||||
/* Flags may be or'd => powers of 2*/
|
||||
#if 0
|
||||
#define NC_DISPATCH_NC3 1
|
||||
#define NC_DISPATCH_NC4 2
|
||||
#define NC_DISPATCH_NCD 4
|
||||
#define NC_DISPATCH_NCP 8
|
||||
#endif
|
||||
|
||||
/* Define a type for use when doing e.g. nc_get_vara_long, etc. */
|
||||
/* Should matche values in libsrc4/netcdf.h */
|
||||
@ -135,10 +136,10 @@ extern int NCP_finalize(void);
|
||||
#endif
|
||||
|
||||
#ifdef USE_NETCDF4
|
||||
|
||||
extern NC_Dispatch* NC4_dispatch_table;
|
||||
extern int NC4_initialize(void);
|
||||
extern int NC4_finalize(void);
|
||||
#endif
|
||||
|
||||
#ifdef USE_DAP
|
||||
extern NC_Dispatch* NCD4_dispatch_table;
|
||||
@ -146,8 +147,6 @@ extern int NCD4_initialize(void);
|
||||
extern int NCD4_finalize(void);
|
||||
#endif
|
||||
|
||||
#endif /*USE_NETCDF4*/
|
||||
|
||||
/* Vectors of ones and zeros */
|
||||
extern size_t nc_sizevector0[NC_MAX_VAR_DIMS];
|
||||
extern size_t nc_sizevector1[NC_MAX_VAR_DIMS];
|
||||
|
26957
libsrc/ncx.c
26957
libsrc/ncx.c
File diff suppressed because it is too large
Load Diff
@ -1636,7 +1636,6 @@ static NCX_GET1F(double, longlong)
|
||||
static NCX_GET1F(double, uchar)
|
||||
static NCX_GET1F(double, ushort)
|
||||
static NCX_GET1F(double, uint)
|
||||
static NCX_GET1F(double, ulonglong)
|
||||
|
||||
int
|
||||
ncx_get_double_ulonglong(const void *xp, unsigned long long *ip)
|
||||
|
@ -1,6 +1,6 @@
|
||||
/********************************************************************* * Copyright 1993, UCAR/Unidata
|
||||
/*********************************************************************
|
||||
* Copyright 1993, UCAR/Unidata
|
||||
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
||||
* $Header: /upc/share/CVS/netcdf-3/libsrc4/NCPdispatch.c,v 1.5 2010/05/27 02:19:37 dmh Exp $
|
||||
*********************************************************************/
|
||||
|
||||
/* WARNING: Order of mpi.h, nc.h, and pnetcdf.h is important */
|
||||
@ -29,9 +29,10 @@ typedef struct NCP_INFO
|
||||
#define NCP_DATA(nc) ((NCP_INFO*)(nc)->dispatchdata)
|
||||
#define NCP_DATA_SET(nc,data) ((nc)->dispatchdata = (void*)(data))
|
||||
|
||||
#define LEGAL_CREATE_FLAGS (NC_NOCLOBBER | NC_64BIT_OFFSET | NC_CLASSIC_MODEL | NC_SHARE | NC_MPIIO | NC_MPIPOSIX | NC_LOCK | NC_PNETCDF)
|
||||
/* Cannot have NC_MPIPOSIX flag, ignore NC_MPIIO as PnetCDF use MPIIO */
|
||||
static const int LEGAL_CREATE_FLAGS = (NC_NOCLOBBER | NC_64BIT_OFFSET | NC_CLASSIC_MODEL | NC_SHARE | NC_LOCK | NC_64BIT_DATA | NC_MPIIO);
|
||||
|
||||
#define LEGAL_OPEN_FLAGS (NC_WRITE | NC_NOCLOBBER | NC_SHARE | NC_MPIIO | NC_MPIPOSIX | NC_LOCK | NC_PNETCDF | NC_CLASSIC_MODEL | NC_64BIT_OFFSET)
|
||||
static const int LEGAL_OPEN_FLAGS = (NC_WRITE | NC_NOCLOBBER | NC_SHARE | NC_LOCK | NC_CLASSIC_MODEL | NC_64BIT_OFFSET | NC_64BIT_DATA | NC_MPIIO);
|
||||
|
||||
|
||||
/**************************************************/
|
||||
@ -42,8 +43,8 @@ NCP_create(const char *path, int cmode,
|
||||
int use_parallel, void* mpidata,
|
||||
struct NC_Dispatch* table, NC* nc)
|
||||
{
|
||||
int res;
|
||||
NCP_INFO* ncp;
|
||||
int res, default_format;
|
||||
NCP_INFO* nc5;
|
||||
MPI_Comm comm = MPI_COMM_WORLD;
|
||||
MPI_Info info = MPI_INFO_NULL;
|
||||
|
||||
@ -55,42 +56,50 @@ NCP_create(const char *path, int cmode,
|
||||
if((cmode & (NC_MPIIO|NC_MPIPOSIX)) == (NC_MPIIO|NC_MPIPOSIX))
|
||||
return NC_EINVAL;
|
||||
|
||||
/* Appears that this comment is wrong; allow 64 bit offset*/
|
||||
/* Cannot have 64 bit offset flag */
|
||||
/*if(cmode & (NC_64BIT_OFFSET)) return NC_EINVAL;*/
|
||||
/* Cannot have both NC_64BIT_OFFSET & NC_64BIT_DATA */
|
||||
if((cmode & (NC_64BIT_OFFSET|NC_64BIT_DATA)) == (NC_64BIT_OFFSET|NC_64BIT_DATA))
|
||||
return NC_EINVAL;
|
||||
|
||||
default_format = nc_get_default_format();
|
||||
/* if (default_format == NC_FORMAT_CLASSIC) then we respect the format set in cmode */
|
||||
if (default_format == NC_FORMAT_64BIT_OFFSET) {
|
||||
if (! (cmode & NC_64BIT_OFFSET)) /* check if cmode has NC_64BIT_OFFSET already */
|
||||
cmode |= NC_64BIT_OFFSET;
|
||||
}
|
||||
else if (default_format == NC_FORMAT_CDF5) {
|
||||
if (! (cmode & NC_64BIT_DATA)) /* check if cmode has NC_64BIT_DATA already */
|
||||
cmode |= NC_64BIT_DATA;
|
||||
}
|
||||
|
||||
/* No MPI environment initialized */
|
||||
if (mpidata == NULL) return NC_ENOPAR;
|
||||
|
||||
comm = ((NC_MPI_INFO *)mpidata)->comm;
|
||||
info = ((NC_MPI_INFO *)mpidata)->info;
|
||||
|
||||
/* Create our specific NCP_INFO instance */
|
||||
ncp = (NCP_INFO*)calloc(1,sizeof(NCP_INFO));
|
||||
if(ncp == NULL) return NC_ENOMEM;
|
||||
nc5 = (NCP_INFO*)calloc(1,sizeof(NCP_INFO));
|
||||
if(nc5 == NULL) return NC_ENOMEM;
|
||||
|
||||
/* Link ncp and nc */
|
||||
NCP_DATA_SET(nc,ncp);
|
||||
/* Link nc5 and nc */
|
||||
NCP_DATA_SET(nc,nc5);
|
||||
|
||||
/* Fix up the cmode by keeping only essential flags;
|
||||
these are the flags that are the same in netcf.h and pnetcdf.h
|
||||
*/
|
||||
#if 0
|
||||
cmode &= (NC_WRITE | NC_NOCLOBBER | NC_LOCK | NC_SHARE | NC_64BIT_OFFSET);
|
||||
#else
|
||||
cmode &= (NC_WRITE | NC_NOCLOBBER | NC_LOCK | NC_SHARE );
|
||||
#endif
|
||||
|
||||
/* It turns out that pnetcdf.h defines a flag called
|
||||
NC_64BIT_DATA (not to be confused with NC_64BIT_OFFSET).
|
||||
This flag is essential to getting ncmpi_create to create
|
||||
a proper pnetcdf format file.
|
||||
It just happens that the value of NC_64BIT_DATA is the same
|
||||
as the netcdf NC_NETCDF4 flag value. This is probably no accident.
|
||||
|
||||
We have set the value of NC_64BIT_DATA to be the same as in pnetcdf.h
|
||||
(as of pnetcdf version 1.6.0) to avoid conflicts.
|
||||
In any case, this flag must be set.
|
||||
*/
|
||||
cmode |= (NC_NETCDF4);
|
||||
/* PnetCDF recognizes the flags below for create and ignores NC_LOCK and NC_SHARE */
|
||||
cmode &= (NC_WRITE | NC_NOCLOBBER | NC_SHARE | NC_64BIT_OFFSET | NC_64BIT_DATA);
|
||||
res = ncmpi_create(comm, path, cmode, info, &(nc->int_ncid));
|
||||
|
||||
if(res && ncp != NULL) free(ncp); /* reclaim allocated space */
|
||||
if(res && nc5 != NULL) free(nc5); /* reclaim allocated space */
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -101,7 +110,7 @@ NCP_open(const char *path, int cmode,
|
||||
struct NC_Dispatch* table, NC* nc)
|
||||
{
|
||||
int res;
|
||||
NCP_INFO* ncp;
|
||||
NCP_INFO* nc5;
|
||||
MPI_Comm comm = MPI_COMM_WORLD;
|
||||
MPI_Info info = MPI_INFO_NULL;
|
||||
|
||||
@ -125,26 +134,28 @@ NCP_open(const char *path, int cmode,
|
||||
info = MPI_INFO_NULL;
|
||||
}
|
||||
|
||||
/* Fix up the cmode by keeping only essential flags;
|
||||
these are the flags that are the same in netcf.h and pnetcdf.h
|
||||
*/
|
||||
cmode &= (NC_WRITE | NC_NOCLOBBER | NC_LOCK | NC_SHARE | NC_64BIT_OFFSET);
|
||||
/* PnetCDF recognizes the flags NC_WRITE and NC_NOCLOBBER for file open
|
||||
* and ignores NC_LOCK, NC_SHARE, NC_64BIT_OFFSET, and NC_64BIT_DATA.
|
||||
* Ignoring the NC_64BIT_OFFSET and NC_64BIT_DATA flags is because the
|
||||
* file is already in one of the CDF-formats, and setting these 2 flags
|
||||
* will not change the format of that file.
|
||||
*/
|
||||
|
||||
cmode |= (NC_NETCDF4); /* see comment in NCP_create */
|
||||
cmode &= (NC_WRITE | NC_NOCLOBBER);
|
||||
|
||||
/* Create our specific NCP_INFO instance */
|
||||
ncp = (NCP_INFO*)calloc(1,sizeof(NCP_INFO));
|
||||
if(ncp == NULL) return NC_ENOMEM;
|
||||
nc5 = (NCP_INFO*)calloc(1,sizeof(NCP_INFO));
|
||||
if(nc5 == NULL) return NC_ENOMEM;
|
||||
|
||||
/* Link ncp and nc */
|
||||
NCP_DATA_SET(nc,ncp);
|
||||
/* Link nc5 and nc */
|
||||
NCP_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);
|
||||
ncp->pnetcdf_access_mode = NC_INDEPENDENT;
|
||||
nc5->pnetcdf_access_mode = NC_INDEPENDENT;
|
||||
}
|
||||
|
||||
return res;
|
||||
@ -160,33 +171,39 @@ NCP_redef(int ncid)
|
||||
}
|
||||
|
||||
static int
|
||||
NCP_enddef(int ncid)
|
||||
NCP__enddef(int ncid, size_t h_minfree, size_t v_align, size_t v_minfree, size_t r_align)
|
||||
{
|
||||
int status;
|
||||
NC* nc;
|
||||
NCP_INFO* ncp;
|
||||
NCP_INFO* nc5;
|
||||
MPI_Offset mpi_h_minfree = h_minfree;
|
||||
MPI_Offset mpi_v_align = v_align;
|
||||
MPI_Offset mpi_v_minfree = v_minfree;
|
||||
MPI_Offset mpi_r_align = r_align;
|
||||
|
||||
status = NC_check_id(ncid, &nc);
|
||||
if(status != NC_NOERR)
|
||||
return status;
|
||||
|
||||
ncp = NCP_DATA(nc);
|
||||
assert(ncp);
|
||||
nc5 = NCP_DATA(nc);
|
||||
assert(nc5);
|
||||
|
||||
/* causes implicitly defined warning; may be because of old installed pnetcdf? */
|
||||
#if 0
|
||||
/* In PnetCDF ncmpi__enddef() is only implemented in v1.5.0 and later */
|
||||
status = ncmpi__enddef(nc->int_ncid, mpi_h_minfree, mpi_v_align,
|
||||
mpi_v_minfree, mpi_r_align);
|
||||
#else
|
||||
status = ncmpi_enddef(nc->int_ncid);
|
||||
#endif
|
||||
|
||||
if(!status) {
|
||||
if (ncp->pnetcdf_access_mode == NC_INDEPENDENT)
|
||||
if (nc5->pnetcdf_access_mode == NC_INDEPENDENT)
|
||||
status = ncmpi_begin_indep_data(nc->int_ncid);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
static int
|
||||
NCP__enddef(int ncid, size_t h_minfree, size_t v_align, size_t v_minfree, size_t r_align)
|
||||
{
|
||||
return NCP_enddef(ncid);
|
||||
}
|
||||
|
||||
static int
|
||||
NCP_sync(int ncid)
|
||||
{
|
||||
@ -200,15 +217,15 @@ static int
|
||||
NCP_abort(int ncid)
|
||||
{
|
||||
NC* nc;
|
||||
NCP_INFO* ncp;
|
||||
NCP_INFO* nc5;
|
||||
int status = NC_check_id(ncid, &nc);
|
||||
if(status != NC_NOERR) goto done;
|
||||
|
||||
status = ncmpi_abort(nc->int_ncid);
|
||||
|
||||
done:
|
||||
ncp = NCP_DATA(nc);
|
||||
if(ncp != NULL) free(ncp); /* reclaim allocated space */
|
||||
nc5 = NCP_DATA(nc);
|
||||
if(nc5 != NULL) free(nc5); /* reclaim allocated space */
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -217,15 +234,15 @@ static int
|
||||
NCP_close(int ncid)
|
||||
{
|
||||
NC* nc;
|
||||
NCP_INFO* ncp;
|
||||
NCP_INFO* nc5;
|
||||
int status = NC_check_id(ncid, &nc);
|
||||
if(status != NC_NOERR) goto done;
|
||||
|
||||
status = ncmpi_close(nc->int_ncid);
|
||||
|
||||
done:
|
||||
ncp = NCP_DATA(nc);
|
||||
if(ncp != NULL) free(ncp); /* reclaim allocated space */
|
||||
nc5 = NCP_DATA(nc);
|
||||
if(nc5 != NULL) free(nc5); /* reclaim allocated space */
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -257,7 +274,8 @@ NCP_inq_format(int ncid, int* formatp)
|
||||
NC* nc;
|
||||
int status = NC_check_id(ncid, &nc);
|
||||
if(status != NC_NOERR) return status;
|
||||
return ncmpi_inq_format(nc->int_ncid,formatp);
|
||||
status = ncmpi_inq_format(nc->int_ncid,formatp);
|
||||
return status;
|
||||
}
|
||||
|
||||
static int
|
||||
@ -267,7 +285,8 @@ NCP_inq_format_extended(int ncid, int* formatp, int *modep)
|
||||
int status = NC_check_id(ncid, &nc);
|
||||
if(status != NC_NOERR) return status;
|
||||
if(modep) *modep = nc->mode;
|
||||
if(formatp) *formatp = NC_FORMAT_PNETCDF;
|
||||
/* Note that we do not use NC_FORMAT_CDF5 because PNETCDF has a dispatch table */
|
||||
if(formatp) *formatp = NC_FORMATX_PNETCDF;
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
@ -284,28 +303,17 @@ NCP_inq(int ncid,
|
||||
return ncmpi_inq(nc->int_ncid,ndimsp,nvarsp,nattsp,unlimp);
|
||||
}
|
||||
|
||||
static int
|
||||
atomic_size[6] = {
|
||||
1, 1, 2, 4, 4, 8
|
||||
};
|
||||
static char
|
||||
atomic_name[6][NC_MAX_NAME + 1] = {
|
||||
"byte", "char", "short","int", "float", "double"
|
||||
};
|
||||
|
||||
static int
|
||||
NCP_inq_type(int ncid, nc_type typeid, char* name, size_t* size)
|
||||
{
|
||||
if(typeid < NC_BYTE || typeid > NC_DOUBLE)
|
||||
return NC_EBADTYPE;
|
||||
|
||||
/* Give the user the values they want. Subtract one because types
|
||||
* are numbered starting at 1, not 0. */
|
||||
if(name)
|
||||
strcpy(name, atomic_name[typeid - 1]);
|
||||
if(size)
|
||||
*size = atomic_size[typeid - 1];
|
||||
|
||||
/* Assert mode & NC_FORMAT_CDF5 */
|
||||
if (typeid < NC_BYTE || typeid >= NC_STRING)
|
||||
return NC_EBADTYPE;
|
||||
if(name)
|
||||
strcpy(name, NC_atomictypename(typeid));
|
||||
if(size)
|
||||
*size = NC_atomictypelen(typeid);
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
@ -313,15 +321,15 @@ static int
|
||||
NCP_def_dim(int ncid, const char* name, size_t len, int* idp)
|
||||
{
|
||||
int status;
|
||||
NCP_INFO* ncp;
|
||||
NCP_INFO* nc5;
|
||||
NC* nc;
|
||||
|
||||
status = NC_check_id(ncid, &nc);
|
||||
if(status != NC_NOERR)
|
||||
return status;
|
||||
|
||||
ncp = NCP_DATA(nc);
|
||||
assert(ncp);
|
||||
nc5 = NCP_DATA(nc);
|
||||
assert(nc5);
|
||||
|
||||
return ncmpi_def_dim(nc->int_ncid, name, len, idp);
|
||||
}
|
||||
@ -372,6 +380,7 @@ NCP_inq_att(int ncid, int varid, const char* name, nc_type* xtypep, size_t* lenp
|
||||
NC* nc;
|
||||
MPI_Offset mpilen;
|
||||
int status = NC_check_id(ncid, &nc);
|
||||
if(status != NC_NOERR) return status;
|
||||
status = ncmpi_inq_att(nc->int_ncid,varid,name,xtypep,&mpilen);
|
||||
if(status != NC_NOERR) return status;
|
||||
if(lenp) *lenp = mpilen;
|
||||
@ -448,10 +457,16 @@ NCP_get_att(
|
||||
return ncmpi_get_att_float(nc->int_ncid, varid, name, (float*)ip);
|
||||
case NC_DOUBLE:
|
||||
return ncmpi_get_att_double(nc->int_ncid, varid, name, (double*)ip);
|
||||
case NC_INT64: /* synthetic */
|
||||
return ncmpi_get_att_long(nc->int_ncid, varid, name, (long*)ip);
|
||||
case NC_UBYTE: /* Synthetic */
|
||||
return ncmpi_get_att_uchar(nc->int_ncid, varid, name, (unsigned char*)ip);
|
||||
case NC_UBYTE:
|
||||
return ncmpi_get_att_uchar(nc->int_ncid, varid, name, (unsigned char*)ip);
|
||||
case NC_USHORT:
|
||||
return ncmpi_get_att_ushort(nc->int_ncid, varid, name, (unsigned short*)ip);
|
||||
case NC_UINT:
|
||||
return ncmpi_get_att_uint(nc->int_ncid, varid, name, (unsigned int*)ip);
|
||||
case NC_INT64:
|
||||
return ncmpi_get_att_longlong(nc->int_ncid, varid, name, (long long*)ip);
|
||||
case NC_UINT64:
|
||||
return ncmpi_get_att_ulonglong(nc->int_ncid, varid, name, (unsigned long long*)ip);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -498,10 +513,16 @@ NCP_put_att(
|
||||
return ncmpi_put_att_float(nc->int_ncid, varid, name, xtype, mpilen, (float*)ip);
|
||||
case NC_DOUBLE:
|
||||
return ncmpi_put_att_double(nc->int_ncid, varid, name, xtype, mpilen, (double*)ip);
|
||||
case NC_INT64: /* synthetic */
|
||||
return ncmpi_put_att_long(nc->int_ncid, varid, name, xtype, mpilen, (long*)ip);
|
||||
case NC_UBYTE: /* Synthetic */
|
||||
return ncmpi_put_att_uchar(nc->int_ncid, varid, name, xtype, mpilen, (unsigned char*)ip);
|
||||
case NC_UBYTE:
|
||||
return ncmpi_put_att_uchar(nc->int_ncid, varid, name, xtype, mpilen, (unsigned char*)ip);
|
||||
case NC_USHORT:
|
||||
return ncmpi_put_att_ushort(nc->int_ncid, varid, name, xtype, mpilen, (unsigned short*)ip);
|
||||
case NC_UINT:
|
||||
return ncmpi_put_att_uint(nc->int_ncid, varid, name, xtype, mpilen, (unsigned int*)ip);
|
||||
case NC_INT64:
|
||||
return ncmpi_put_att_longlong(nc->int_ncid, varid, name, xtype, mpilen, (long long*)ip);
|
||||
case NC_UINT64:
|
||||
return ncmpi_put_att_ulonglong(nc->int_ncid, varid, name, xtype, mpilen, (unsigned long long*)ip);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -513,13 +534,13 @@ NCP_def_var(int ncid, const char *name, nc_type xtype,
|
||||
int ndims, const int *dimidsp, int *varidp)
|
||||
{
|
||||
NC* nc;
|
||||
NCP_INFO* ncp;
|
||||
NCP_INFO* nc5;
|
||||
int status;
|
||||
|
||||
status = NC_check_id(ncid, &nc);
|
||||
if(status != NC_NOERR) return status;
|
||||
ncp = NCP_DATA(nc);
|
||||
assert(ncp);
|
||||
nc5 = NCP_DATA(nc);
|
||||
assert(nc5);
|
||||
|
||||
status = ncmpi_def_var(nc->int_ncid,name,xtype,ndims,dimidsp,varidp);
|
||||
return status;
|
||||
@ -552,7 +573,7 @@ NCP_get_vara(int ncid,
|
||||
nc_type memtype)
|
||||
{
|
||||
NC* nc;
|
||||
NCP_INFO* ncp;
|
||||
NCP_INFO* nc5;
|
||||
int status;
|
||||
MPI_Offset mpi_start[NC_MAX_VAR_DIMS], mpi_count[NC_MAX_VAR_DIMS];
|
||||
int d;
|
||||
@ -561,20 +582,25 @@ NCP_get_vara(int ncid,
|
||||
status = NC_check_id(ncid, &nc);
|
||||
if(status != NC_NOERR) return status;
|
||||
|
||||
ncp = NCP_DATA(nc);
|
||||
assert(ncp);
|
||||
nc5 = NCP_DATA(nc);
|
||||
assert(nc5);
|
||||
|
||||
/* get variable's 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. */
|
||||
/* We must convert the start and count arrays to MPI_Offset type. */
|
||||
for (d = 0; d < rank; d++) {
|
||||
mpi_start[d] = startp[d];
|
||||
mpi_count[d] = countp[d];
|
||||
}
|
||||
|
||||
if(ncp->pnetcdf_access_mode == NC_INDEPENDENT) {
|
||||
if (memtype == NC_NAT) {
|
||||
status = ncmpi_inq_vartype(nc->int_ncid, varid, &memtype);
|
||||
if (status) return status;
|
||||
}
|
||||
|
||||
if(nc5->pnetcdf_access_mode == NC_INDEPENDENT) {
|
||||
switch(memtype) {
|
||||
case NC_BYTE:
|
||||
status=ncmpi_get_vara_schar(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
@ -588,10 +614,16 @@ NCP_get_vara(int ncid,
|
||||
status=ncmpi_get_vara_float(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
case NC_DOUBLE:
|
||||
status=ncmpi_get_vara_double(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
case NC_UBYTE: /* synthetic */
|
||||
status=ncmpi_get_vara_uchar(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
case NC_INT64: /* synthetic */
|
||||
status=ncmpi_get_vara_long(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
case NC_UBYTE:
|
||||
status=ncmpi_get_vara_uchar(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
case NC_USHORT:
|
||||
status=ncmpi_get_vara_ushort(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
case NC_UINT:
|
||||
status=ncmpi_get_vara_uint(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
case NC_INT64:
|
||||
status=ncmpi_get_vara_longlong(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
case NC_UINT64:
|
||||
status=ncmpi_get_vara_ulonglong(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
default:
|
||||
status = NC_EBADTYPE;
|
||||
}
|
||||
@ -611,8 +643,14 @@ NCP_get_vara(int ncid,
|
||||
status=ncmpi_get_vara_double_all(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
case NC_UBYTE:
|
||||
status=ncmpi_get_vara_uchar_all(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
case NC_INT64:
|
||||
status=ncmpi_get_vara_long_all(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
case NC_USHORT:
|
||||
status=ncmpi_get_vara_ushort_all(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
case NC_UINT:
|
||||
status=ncmpi_get_vara_uint_all(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
case NC_INT64:
|
||||
status=ncmpi_get_vara_longlong_all(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
case NC_UINT64:
|
||||
status=ncmpi_get_vara_ulonglong_all(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
default:
|
||||
status = NC_EBADTYPE;
|
||||
}
|
||||
@ -629,7 +667,7 @@ NCP_put_vara(int ncid,
|
||||
nc_type memtype)
|
||||
{
|
||||
NC* nc;
|
||||
NCP_INFO* ncp;
|
||||
NCP_INFO* nc5;
|
||||
int status;
|
||||
MPI_Offset mpi_start[NC_MAX_VAR_DIMS], mpi_count[NC_MAX_VAR_DIMS];
|
||||
int d;
|
||||
@ -638,20 +676,25 @@ NCP_put_vara(int ncid,
|
||||
status = NC_check_id(ncid, &nc);
|
||||
if(status != NC_NOERR) return status;
|
||||
|
||||
ncp = NCP_DATA(nc);
|
||||
assert(ncp);
|
||||
nc5 = NCP_DATA(nc);
|
||||
assert(nc5);
|
||||
|
||||
/* get variable's 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. */
|
||||
/* We must convert the start and count arrays to MPI_Offset type. */
|
||||
for (d = 0; d < rank; d++) {
|
||||
mpi_start[d] = startp[d];
|
||||
mpi_count[d] = countp[d];
|
||||
}
|
||||
|
||||
if(ncp->pnetcdf_access_mode == NC_INDEPENDENT) {
|
||||
if (memtype == NC_NAT) {
|
||||
status = ncmpi_inq_vartype(nc->int_ncid, varid, &memtype);
|
||||
if (status) return status;
|
||||
}
|
||||
|
||||
if(nc5->pnetcdf_access_mode == NC_INDEPENDENT) {
|
||||
switch(memtype) {
|
||||
case NC_BYTE:
|
||||
status = ncmpi_put_vara_schar(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
@ -667,8 +710,15 @@ NCP_put_vara(int ncid,
|
||||
status = ncmpi_put_vara_double(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
case NC_UBYTE:
|
||||
status = ncmpi_put_vara_uchar(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
case NC_USHORT:
|
||||
status = ncmpi_put_vara_ushort(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
case NC_UINT:
|
||||
status = ncmpi_put_vara_uint(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
case NC_INT64:
|
||||
status = ncmpi_put_vara_long(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
status = ncmpi_put_vara_longlong(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
case NC_UINT64:
|
||||
status = ncmpi_put_vara_ulonglong(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
default:
|
||||
status = NC_EBADTYPE;
|
||||
}
|
||||
@ -688,8 +738,402 @@ NCP_put_vara(int ncid,
|
||||
status = ncmpi_put_vara_double_all(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
case NC_UBYTE:
|
||||
status = ncmpi_put_vara_uchar_all(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
case NC_USHORT:
|
||||
status = ncmpi_put_vara_ushort_all(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
case NC_UINT:
|
||||
status = ncmpi_put_vara_uint_all(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
case NC_INT64:
|
||||
status = ncmpi_put_vara_longlong_all(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
case NC_UINT64:
|
||||
status = ncmpi_put_vara_ulonglong_all(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
default:
|
||||
status = NC_EBADTYPE;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
static int
|
||||
NCP_get_vars(int ncid,
|
||||
int varid,
|
||||
const size_t* startp,
|
||||
const size_t* countp,
|
||||
const ptrdiff_t* stridep,
|
||||
void* ip,
|
||||
nc_type memtype)
|
||||
{
|
||||
NC* nc;
|
||||
NCP_INFO* nc5;
|
||||
int status;
|
||||
MPI_Offset mpi_start[NC_MAX_VAR_DIMS], mpi_count[NC_MAX_VAR_DIMS], mpi_stride[NC_MAX_VAR_DIMS];
|
||||
int d;
|
||||
int rank = 0;
|
||||
|
||||
status = NC_check_id(ncid, &nc);
|
||||
if(status != NC_NOERR) return status;
|
||||
|
||||
nc5 = NCP_DATA(nc);
|
||||
assert(nc5);
|
||||
|
||||
/* get variable's 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++) {
|
||||
mpi_start[d] = startp[d];
|
||||
mpi_count[d] = countp[d];
|
||||
mpi_stride[d] = stridep[d];
|
||||
}
|
||||
|
||||
if (memtype == NC_NAT) {
|
||||
status = ncmpi_inq_vartype(nc->int_ncid, varid, &memtype);
|
||||
if (status) return status;
|
||||
}
|
||||
|
||||
if(nc5->pnetcdf_access_mode == NC_INDEPENDENT) {
|
||||
switch(memtype) {
|
||||
case NC_BYTE:
|
||||
status=ncmpi_get_vars_schar(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_CHAR:
|
||||
status=ncmpi_get_vars_text(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_SHORT:
|
||||
status=ncmpi_get_vars_short(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_INT:
|
||||
status=ncmpi_get_vars_int(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_FLOAT:
|
||||
status=ncmpi_get_vars_float(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_DOUBLE:
|
||||
status=ncmpi_get_vars_double(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_UBYTE:
|
||||
status=ncmpi_get_vars_uchar(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_USHORT:
|
||||
status=ncmpi_get_vars_ushort(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_UINT:
|
||||
status=ncmpi_get_vars_uint(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_INT64:
|
||||
status = ncmpi_put_vara_long_all(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
|
||||
status=ncmpi_get_vars_longlong(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_UINT64:
|
||||
status=ncmpi_get_vars_ulonglong(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
default:
|
||||
status = NC_EBADTYPE;
|
||||
}
|
||||
} else {
|
||||
switch(memtype) {
|
||||
case NC_BYTE:
|
||||
status=ncmpi_get_vars_schar_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_CHAR:
|
||||
status=ncmpi_get_vars_text_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_SHORT:
|
||||
status=ncmpi_get_vars_short_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_INT:
|
||||
status=ncmpi_get_vars_int_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_FLOAT:
|
||||
status=ncmpi_get_vars_float_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_DOUBLE:
|
||||
status=ncmpi_get_vars_double_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_UBYTE:
|
||||
status=ncmpi_get_vars_uchar_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_USHORT:
|
||||
status=ncmpi_get_vars_ushort_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_UINT:
|
||||
status=ncmpi_get_vars_uint_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_INT64:
|
||||
status=ncmpi_get_vars_longlong_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_UINT64:
|
||||
status=ncmpi_get_vars_ulonglong_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
default:
|
||||
status = NC_EBADTYPE;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
static int
|
||||
NCP_put_vars(int ncid,
|
||||
int varid,
|
||||
const size_t* startp,
|
||||
const size_t* countp,
|
||||
const ptrdiff_t* stridep,
|
||||
const void*ip,
|
||||
nc_type memtype)
|
||||
{
|
||||
NC* nc;
|
||||
NCP_INFO* nc5;
|
||||
int status;
|
||||
MPI_Offset mpi_start[NC_MAX_VAR_DIMS], mpi_count[NC_MAX_VAR_DIMS], mpi_stride[NC_MAX_VAR_DIMS];
|
||||
int d;
|
||||
int rank;
|
||||
|
||||
status = NC_check_id(ncid, &nc);
|
||||
if(status != NC_NOERR) return status;
|
||||
|
||||
nc5 = NCP_DATA(nc);
|
||||
assert(nc5);
|
||||
|
||||
/* get variable's 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++) {
|
||||
mpi_start[d] = startp[d];
|
||||
mpi_count[d] = countp[d];
|
||||
mpi_stride[d] = stridep[d];
|
||||
}
|
||||
|
||||
if (memtype == NC_NAT) {
|
||||
status = ncmpi_inq_vartype(nc->int_ncid, varid, &memtype);
|
||||
if (status) return status;
|
||||
}
|
||||
|
||||
if(nc5->pnetcdf_access_mode == NC_INDEPENDENT) {
|
||||
switch(memtype) {
|
||||
case NC_BYTE:
|
||||
status = ncmpi_put_vars_schar(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_CHAR:
|
||||
status = ncmpi_put_vars_text(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_SHORT:
|
||||
status = ncmpi_put_vars_short(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_INT:
|
||||
status = ncmpi_put_vars_int(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_FLOAT:
|
||||
status = ncmpi_put_vars_float(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_DOUBLE:
|
||||
status = ncmpi_put_vars_double(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_UBYTE:
|
||||
status = ncmpi_put_vars_uchar(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_USHORT:
|
||||
status = ncmpi_put_vars_ushort(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_UINT:
|
||||
status = ncmpi_put_vars_uint(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_INT64:
|
||||
status = ncmpi_put_vars_longlong(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_UINT64:
|
||||
status = ncmpi_put_vars_ulonglong(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
default:
|
||||
status = NC_EBADTYPE;
|
||||
}
|
||||
} else {
|
||||
switch(memtype) {
|
||||
case NC_BYTE:
|
||||
status = ncmpi_put_vars_schar_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_CHAR:
|
||||
status = ncmpi_put_vars_text_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_SHORT:
|
||||
status = ncmpi_put_vars_short_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_INT:
|
||||
status = ncmpi_put_vars_int_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_FLOAT:
|
||||
status = ncmpi_put_vars_float_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_DOUBLE:
|
||||
status = ncmpi_put_vars_double_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_UBYTE:
|
||||
status = ncmpi_put_vars_uchar_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_USHORT:
|
||||
status = ncmpi_put_vars_ushort_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_UINT:
|
||||
status = ncmpi_put_vars_uint_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_INT64:
|
||||
status = ncmpi_put_vars_longlong_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
case NC_UINT64:
|
||||
status = ncmpi_put_vars_ulonglong_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
|
||||
default:
|
||||
status = NC_EBADTYPE;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
static int
|
||||
NCP_get_varm(int ncid,
|
||||
int varid,
|
||||
const size_t* startp,
|
||||
const size_t* countp,
|
||||
const ptrdiff_t* stridep,
|
||||
const ptrdiff_t* imapp,
|
||||
void* ip,
|
||||
nc_type memtype)
|
||||
{
|
||||
NC* nc;
|
||||
NCP_INFO* nc5;
|
||||
int status;
|
||||
MPI_Offset mpi_start[NC_MAX_VAR_DIMS], mpi_count[NC_MAX_VAR_DIMS], mpi_stride[NC_MAX_VAR_DIMS], mpi_imap[NC_MAX_VAR_DIMS];
|
||||
int d;
|
||||
int rank = 0;
|
||||
|
||||
status = NC_check_id(ncid, &nc);
|
||||
if(status != NC_NOERR) return status;
|
||||
|
||||
nc5 = NCP_DATA(nc);
|
||||
assert(nc5);
|
||||
|
||||
/* get variable's rank */
|
||||
status= ncmpi_inq_varndims(nc->int_ncid, varid, &rank);
|
||||
if(status) return status;
|
||||
|
||||
/* We must convert the start, count, stride, and imap arrays to MPI_Offset type. */
|
||||
for (d = 0; d < rank; d++) {
|
||||
mpi_start[d] = startp[d];
|
||||
mpi_count[d] = countp[d];
|
||||
mpi_stride[d] = stridep[d];
|
||||
mpi_imap[d] = imapp[d];
|
||||
}
|
||||
|
||||
if (memtype == NC_NAT) {
|
||||
status = ncmpi_inq_vartype(nc->int_ncid, varid, &memtype);
|
||||
if (status) return status;
|
||||
}
|
||||
|
||||
if(nc5->pnetcdf_access_mode == NC_INDEPENDENT) {
|
||||
switch(memtype) {
|
||||
case NC_BYTE:
|
||||
status=ncmpi_get_varm_schar(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_CHAR:
|
||||
status=ncmpi_get_varm_text(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_SHORT:
|
||||
status=ncmpi_get_varm_short(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_INT:
|
||||
status=ncmpi_get_varm_int(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_FLOAT:
|
||||
status=ncmpi_get_varm_float(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_DOUBLE:
|
||||
status=ncmpi_get_varm_double(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_UBYTE:
|
||||
status=ncmpi_get_varm_uchar(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_USHORT:
|
||||
status=ncmpi_get_varm_ushort(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_UINT:
|
||||
status=ncmpi_get_varm_uint(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_INT64:
|
||||
status=ncmpi_get_varm_longlong(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_UINT64:
|
||||
status=ncmpi_get_varm_ulonglong(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
default:
|
||||
status = NC_EBADTYPE;
|
||||
}
|
||||
} else {
|
||||
switch(memtype) {
|
||||
case NC_BYTE:
|
||||
status=ncmpi_get_varm_schar_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_CHAR:
|
||||
status=ncmpi_get_varm_text_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_SHORT:
|
||||
status=ncmpi_get_varm_short_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_INT:
|
||||
status=ncmpi_get_varm_int_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_FLOAT:
|
||||
status=ncmpi_get_varm_float_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_DOUBLE:
|
||||
status=ncmpi_get_varm_double_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_UBYTE:
|
||||
status=ncmpi_get_varm_uchar_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_USHORT:
|
||||
status=ncmpi_get_varm_ushort_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_UINT:
|
||||
status=ncmpi_get_varm_uint_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_INT64:
|
||||
status=ncmpi_get_varm_longlong_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_UINT64:
|
||||
status=ncmpi_get_varm_ulonglong_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
default:
|
||||
status = NC_EBADTYPE;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
static int
|
||||
NCP_put_varm(int ncid,
|
||||
int varid,
|
||||
const size_t* startp,
|
||||
const size_t* countp,
|
||||
const ptrdiff_t* stridep,
|
||||
const ptrdiff_t* imapp,
|
||||
const void*ip,
|
||||
nc_type memtype)
|
||||
{
|
||||
NC* nc;
|
||||
NCP_INFO* nc5;
|
||||
int status;
|
||||
MPI_Offset mpi_start[NC_MAX_VAR_DIMS], mpi_count[NC_MAX_VAR_DIMS], mpi_stride[NC_MAX_VAR_DIMS], mpi_imap[NC_MAX_VAR_DIMS];
|
||||
int d;
|
||||
int rank;
|
||||
|
||||
status = NC_check_id(ncid, &nc);
|
||||
if(status != NC_NOERR) return status;
|
||||
|
||||
nc5 = NCP_DATA(nc);
|
||||
assert(nc5);
|
||||
|
||||
/* get variable's rank */
|
||||
status = ncmpi_inq_varndims(nc->int_ncid, varid, &rank);
|
||||
if(status) return status;
|
||||
|
||||
/* We must convert the start, count, stride, and imap arrays to MPI_Offset type. */
|
||||
for (d = 0; d < rank; d++) {
|
||||
mpi_start[d] = startp[d];
|
||||
mpi_count[d] = countp[d];
|
||||
mpi_stride[d] = stridep[d];
|
||||
mpi_imap[d] = imapp[d];
|
||||
}
|
||||
|
||||
if (memtype == NC_NAT) {
|
||||
status = ncmpi_inq_vartype(nc->int_ncid, varid, &memtype);
|
||||
if (status) return status;
|
||||
}
|
||||
|
||||
if(nc5->pnetcdf_access_mode == NC_INDEPENDENT) {
|
||||
switch(memtype) {
|
||||
case NC_BYTE:
|
||||
status = ncmpi_put_varm_schar(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_CHAR:
|
||||
status = ncmpi_put_varm_text(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_SHORT:
|
||||
status = ncmpi_put_varm_short(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_INT:
|
||||
status = ncmpi_put_varm_int(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_FLOAT:
|
||||
status = ncmpi_put_varm_float(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_DOUBLE:
|
||||
status = ncmpi_put_varm_double(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_UBYTE:
|
||||
status = ncmpi_put_varm_uchar(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_USHORT:
|
||||
status = ncmpi_put_varm_ushort(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_UINT:
|
||||
status = ncmpi_put_varm_uint(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_INT64:
|
||||
status = ncmpi_put_varm_longlong(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_UINT64:
|
||||
status = ncmpi_put_varm_ulonglong(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
default:
|
||||
status = NC_EBADTYPE;
|
||||
}
|
||||
} else {
|
||||
switch(memtype) {
|
||||
case NC_BYTE:
|
||||
status = ncmpi_put_varm_schar_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_CHAR:
|
||||
status = ncmpi_put_varm_text_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_SHORT:
|
||||
status = ncmpi_put_varm_short_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_INT:
|
||||
status = ncmpi_put_varm_int_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_FLOAT:
|
||||
status = ncmpi_put_varm_float_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_DOUBLE:
|
||||
status = ncmpi_put_varm_double_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_UBYTE:
|
||||
status = ncmpi_put_varm_uchar_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_USHORT:
|
||||
status = ncmpi_put_varm_ushort_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_UINT:
|
||||
status = ncmpi_put_varm_uint_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_INT64:
|
||||
status = ncmpi_put_varm_longlong_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
case NC_UINT64:
|
||||
status = ncmpi_put_varm_ulonglong_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
|
||||
default:
|
||||
status = NC_EBADTYPE;
|
||||
}
|
||||
@ -727,7 +1171,7 @@ static int
|
||||
NCP_var_par_access(int ncid, int varid, int par_access)
|
||||
{
|
||||
NC *nc;
|
||||
NCP_INFO* ncp;
|
||||
NCP_INFO* nc5;
|
||||
int status;
|
||||
|
||||
if (par_access != NC_INDEPENDENT && par_access != NC_COLLECTIVE)
|
||||
@ -736,12 +1180,12 @@ NCP_var_par_access(int ncid, int varid, int par_access)
|
||||
status = NC_check_id(ncid, &nc);
|
||||
if(status != NC_NOERR) return status;
|
||||
|
||||
ncp = NCP_DATA(nc);
|
||||
assert(ncp);
|
||||
nc5 = NCP_DATA(nc);
|
||||
assert(nc5);
|
||||
|
||||
if(par_access == ncp->pnetcdf_access_mode)
|
||||
if(par_access == nc5->pnetcdf_access_mode)
|
||||
return NC_NOERR;
|
||||
ncp->pnetcdf_access_mode = par_access;
|
||||
nc5->pnetcdf_access_mode = par_access;
|
||||
if (par_access == NC_INDEPENDENT)
|
||||
return ncmpi_begin_indep_data(nc->int_ncid);
|
||||
else
|
||||
@ -792,7 +1236,7 @@ NCP_inq_type_equal(int ncid1, nc_type typeid1, int ncid2, nc_type typeid2, int*
|
||||
}
|
||||
|
||||
/* If both are atomic types, the answer is easy. */
|
||||
if (typeid1 <= ATOMICTYPEMAX) {
|
||||
if (typeid1 <= ATOMICTYPEMAX5) {
|
||||
if (equalp) {
|
||||
if (typeid1 == typeid2)
|
||||
*equalp = 1;
|
||||
@ -894,7 +1338,7 @@ static int
|
||||
NCP_inq_typeid(int ncid, const char *name, nc_type *typeidp)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i <= ATOMICTYPEMAX; i++)
|
||||
for (i = 0; i <= ATOMICTYPEMAX5; i++)
|
||||
if(!strcmp(name, NC_atomictypename(i))) {
|
||||
if(typeidp) *typeidp = i;
|
||||
return NC_NOERR;
|
||||
@ -1055,7 +1499,7 @@ NCP_def_var_endian(int ncid, int varid, int endianness)
|
||||
|
||||
NC_Dispatch NCP_dispatcher = {
|
||||
|
||||
NC_DISPATCH_NCP,
|
||||
NC_FORMATX_PNETCDF,
|
||||
|
||||
NCP_create,
|
||||
NCP_open,
|
||||
@ -1093,10 +1537,10 @@ NCP_inq_varid,
|
||||
NCP_rename_var,
|
||||
NCP_get_vara,
|
||||
NCP_put_vara,
|
||||
NCDEFAULT_get_vars,
|
||||
NCDEFAULT_put_vars,
|
||||
NCDEFAULT_get_varm,
|
||||
NCDEFAULT_put_varm,
|
||||
NCP_get_vars,
|
||||
NCP_put_vars,
|
||||
NCP_get_varm,
|
||||
NCP_put_varm,
|
||||
|
||||
NCP_inq_var_all,
|
||||
|
||||
@ -1153,3 +1597,9 @@ NCP_initialize(void)
|
||||
NCP_dispatch_table = &NCP_dispatcher;
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
int
|
||||
NCP_finalize(void)
|
||||
{
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
@ -110,6 +110,8 @@ EXTRA_DIST += ref_tst_diskless2.cdl CMakeLists.txt tst_swap4b.c
|
||||
all:
|
||||
cp $(top_srcdir)/libsrc/ncx.c .
|
||||
|
||||
CLEANFILES += ncx.c
|
||||
|
||||
# This rule tells make how to turn our .m4 files into .c files.
|
||||
.m4.c:
|
||||
m4 $(AM_M4FLAGS) $(M4FLAGS) -s $< >$@
|
||||
|
@ -3606,11 +3606,7 @@ makespecial(int tag, Symbol* vsym, Symbol* tsym, void* data, int isconst)
|
||||
}
|
||||
attr = makeattribute(install("_FillValue"),vsym,tsym,list,ATTRVAR);
|
||||
} else switch (tag) {
|
||||
<<<<<<< HEAD
|
||||
// These will be output as attributes later
|
||||
=======
|
||||
/* These will be output as attributes later */
|
||||
>>>>>>> cdf-5
|
||||
case _STORAGE_FLAG:
|
||||
if(!sdata)
|
||||
derror("_Storage: illegal NULL value");
|
||||
|
Loading…
x
Reference in New Issue
Block a user