Skip to content

Commit f128dbd

Browse files
authored
Merge pull request #2 from NetCDF-World-Domination-Council/ejh_wkliao
wkliao changes
2 parents 2076a5d + d99bd5e commit f128dbd

28 files changed

+698
-187
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,6 +1303,11 @@ IF(SIZEOF_UINT)
13031303
SET(HAVE_UINT TRUE)
13041304
ENDIF(SIZEOF_UINT)
13051305

1306+
CHECK_TYPE_SIZE("schar" SIZEOF_SCHAR)
1307+
IF(SIZEOF_SCHAR)
1308+
SET(HAVE_SCHAR TRUE)
1309+
ENDIF(SIZEOF_SCHAR)
1310+
13061311
CHECK_TYPE_SIZE("long" SIZEOF_LONG)
13071312
CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG)
13081313
IF(SIZEOF_LONG_LONG)

configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -882,8 +882,8 @@ $SLEEPCMD
882882
AC_CHECK_SIZEOF(size_t)
883883
$SLEEPCMD
884884
AC_CHECK_SIZEOF(unsigned long long)
885-
$SLEEPCMD
886-
AC_CHECK_SIZEOF(unsigned long long)
885+
886+
AM_CONDITIONAL(ENABLE_CDF5, [test "$ac_cv_sizeof_size_t" -ge "8"])
887887

888888
$SLEEPCMD
889889
if test "$ac_cv_type_uchar" = yes ; then

include/nc3dispatch.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,17 @@ NC3_def_var(int ncid, const char *name,
158158

159159
extern int
160160
NC3_inq_var(int ncid, int varid, char *name,
161-
nc_type *xtypep, int *ndimsp, int *dimidsp, int *nattsp);
161+
nc_type *xtypep, int *ndimsp, int *dimidsp, int *nattsp,
162+
int *no_fill, void *fill_valuep);
162163

163164
extern int
164165
NC3_inq_varid(int ncid, const char *name, int *varidp);
165166

166167
extern int
167168
NC3_rename_var(int ncid, int varid, const char *name);
168169

170+
extern int
171+
NC3_def_var_fill(int,int,int,const void*);
169172

170173
extern int
171174
NC3_put_vara(int ncid, int varid,

include/nc3internal.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ typedef struct NC_var {
186186
nc_type type; /* the discriminant */
187187
size_t len; /* the total length originally allocated */
188188
off_t begin;
189+
int no_fill; /* whether fill mode is ON or OFF */
189190
} NC_var;
190191

191192
typedef struct NC_vararray {
@@ -427,6 +428,9 @@ nc_put_rec(int ncid, size_t recnum, void *const *datap);
427428
extern int
428429
NC_check_vlens(NC3_INFO *ncp);
429430

431+
extern int
432+
NC_check_voffs(NC3_INFO *ncp);
433+
430434
/* Define accessors for the dispatchdata */
431435
#define NC3_DATA(nc) ((NC3_INFO*)(nc)->dispatchdata)
432436
#define NC3_DATA_SET(nc,data) ((nc)->dispatchdata = (void*)(data))

include/ncdispatch.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
#ifndef _DISPATCH_H
1010
#define _DISPATCH_H
1111

12+
#if HAVE_CONFIG_H
1213
#include "config.h"
14+
#endif
1315
#include <stdlib.h>
1416
#include <stdio.h>
1517
#include <string.h>
@@ -250,6 +252,7 @@ int (*inq_var_all)(int ncid, int varid, char *name, nc_type *xtypep,
250252
);
251253

252254
int (*var_par_access)(int, int, int);
255+
int (*def_var_fill)(int, int, int, const void*);
253256

254257
/* Note the following may still be invoked by netcdf client code
255258
even when the file is a classic file; they will just return an error or
@@ -289,7 +292,6 @@ int (*def_opaque)(int, size_t, const char*, nc_type*);
289292
int (*def_var_deflate)(int, int, int, int, int);
290293
int (*def_var_fletcher32)(int, int, int);
291294
int (*def_var_chunking)(int, int, int, const size_t*);
292-
int (*def_var_fill)(int, int, int, const void*);
293295
int (*def_var_endian)(int, int, int);
294296
int (*def_var_filter)(int, int, unsigned int, size_t, const unsigned int*);
295297
int (*set_var_chunk_cache)(int, int, size_t, size_t, float);

libdap2/ncd2dispatch.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ NCDEFAULT_put_varm,
137137
NCD2_inq_var_all,
138138

139139
NCD2_var_par_access,
140+
NCD2_def_var_fill,
140141

141142
#ifdef USE_NETCDF4
142143
NCD2_show_metadata,
@@ -172,7 +173,6 @@ NCD2_def_opaque,
172173
NCD2_def_var_deflate,
173174
NCD2_def_var_fletcher32,
174175
NCD2_def_var_chunking,
175-
NCD2_def_var_fill,
176176
NCD2_def_var_endian,
177177
NCD2_def_var_filter,
178178
NCD2_set_var_chunk_cache,
@@ -2434,6 +2434,15 @@ NCD2_var_par_access(int ncid, int p2, int p3)
24342434
return THROW(NC_ENOPAR);
24352435
}
24362436

2437+
int
2438+
NCD2_def_var_fill(int ncid, int p2, int p3, const void* p4)
2439+
{
2440+
NC* drno;
2441+
int ret;
2442+
if((ret = NC_check_id(ncid, (NC**)&drno)) != NC_NOERR) return THROW(ret);
2443+
ret = nc_def_var_fill(getnc3id(drno), p2, p3, p4);
2444+
return THROW(ret);
2445+
}
24372446

24382447
#ifdef USE_NETCDF4
24392448

@@ -2763,16 +2772,6 @@ NCD2_def_var_chunking(int ncid, int p2, int p3, const size_t* p4)
27632772
return THROW(ret);
27642773
}
27652774

2766-
int
2767-
NCD2_def_var_fill(int ncid, int p2, int p3, const void* p4)
2768-
{
2769-
NC* drno;
2770-
int ret;
2771-
if((ret = NC_check_id(ncid, (NC**)&drno)) != NC_NOERR) return THROW(ret);
2772-
ret = nc_def_var_fill(getnc3id(drno), p2, p3, p4);
2773-
return THROW(ret);
2774-
}
2775-
27762775
int
27772776
NCD2_def_var_endian(int ncid, int p2, int p3)
27782777
{

libdap2/ncd2dispatch.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ NCD2_rename_var(int ncid, int varid, const char *name);
158158
extern int
159159
NCD2_var_par_access(int, int, int);
160160

161+
extern int
162+
NCD2_def_var_fill(int, int, int, const void *);
163+
161164
/* netCDF4 API only */
162165
#ifdef USE_NETCDF4
163166
extern int
@@ -241,9 +244,6 @@ NCD2_var_par_access(int, int, int);
241244
extern int
242245
NCD2_def_var_chunking(int, int, int, const size_t *);
243246

244-
extern int
245-
NCD2_def_var_fill(int, int, int, const void *);
246-
247247
extern int
248248
NCD2_def_var_endian(int, int, int);
249249

libdap4/ncd4dispatch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,7 @@ NCDEFAULT_put_varm,
853853
NCD4_inq_var_all,
854854

855855
NCD4_var_par_access,
856+
NCD4_def_var_fill,
856857

857858
#ifdef USE_NETCDF4
858859
NCD4_show_metadata,
@@ -888,7 +889,6 @@ NCD4_def_opaque,
888889
NCD4_def_var_deflate,
889890
NCD4_def_var_fletcher32,
890891
NCD4_def_var_chunking,
891-
NCD4_def_var_fill,
892892
NCD4_def_var_endian,
893893
NCD4_def_var_filter,
894894
NCD4_set_var_chunk_cache,

libdispatch/dfile.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#ifdef HAVE_SYS_STAT_H
2222
#include <sys/stat.h>
2323
#endif
24+
#include <unistd.h> /* lseek() */
25+
2426
#include "ncdispatch.h"
2527
#include "netcdf_mem.h"
2628
#include "ncwinpath.h"
@@ -2175,7 +2177,6 @@ openmagic(struct MagicFile* file)
21752177
}
21762178
#ifdef USE_PARALLEL
21772179
if (file->use_parallel) {
2178-
MPI_Status mstatus;
21792180
int retval;
21802181
MPI_Offset size;
21812182
MPI_Comm comm = MPI_COMM_WORLD;
@@ -2206,17 +2207,17 @@ openmagic(struct MagicFile* file)
22062207
{status = errno; goto done;}
22072208
/* Get its length */
22082209
{
2209-
#ifdef _MSC_VER
22102210
int fd = fileno(file->fp);
2211+
#ifdef _MSC_VER
22112212
__int64 len64 = _filelengthi64(fd);
22122213
if(len64 < 0)
22132214
{status = errno; goto done;}
22142215
file->filelen = (long long)len64;
22152216
#else
2216-
long size;
2217-
if((status = fseek(file->fp, 0L, SEEK_END)) < 0)
2217+
off_t size;
2218+
size = lseek(fd, 0, SEEK_END);
2219+
if(size == -1)
22182220
{status = errno; goto done;}
2219-
size = ftell(file->fp);
22202221
file->filelen = (long long)size;
22212222
#endif
22222223
rewind(file->fp);
@@ -2249,12 +2250,8 @@ readmagic(struct MagicFile* file, long pos, char* magic)
22492250
if (file->use_parallel) {
22502251
MPI_Status mstatus;
22512252
int retval;
2252-
MPI_Offset offset;
2253-
offset = pos;
2254-
if((retval = MPI_File_seek(file->fh, offset, MPI_SEEK_SET)) != MPI_SUCCESS)
2255-
{status = NC_EPARINIT; goto done;}
2256-
if((retval = MPI_File_read(file->fh, magic, MAGIC_NUMBER_LEN, MPI_CHAR,
2257-
&mstatus)) != MPI_SUCCESS)
2253+
if((retval = MPI_File_read_at_all(file->fh, pos, magic,
2254+
MAGIC_NUMBER_LEN, MPI_CHAR, &mstatus)) != MPI_SUCCESS)
22582255
{status = NC_EPARINIT; goto done;}
22592256
goto done;
22602257
}
@@ -2293,7 +2290,6 @@ closemagic(struct MagicFile* file)
22932290
if(file->inmemory) goto done; /* noop*/
22942291
#ifdef USE_PARALLEL
22952292
if (file->use_parallel) {
2296-
MPI_Status mstatus;
22972293
int retval;
22982294
if((retval = MPI_File_close(&file->fh)) != MPI_SUCCESS)
22992295
{status = NC_EPARINIT; goto done;}

0 commit comments

Comments
 (0)