Index: libdispatch/dispatch.c =================================================================== --- libdispatch/dispatch.c (revision 13003) +++ libdispatch/dispatch.c (working copy) @@ -109,7 +109,7 @@ model |= protolist->modelflags; if(protolist->substitute) { if(tmpurl->protocol) free(tmpurl->protocol); - tmpurl->protocol = strdup(protolist->substitute); + tmpurl->protocol = nulldup(protolist->substitute); } break; } Index: libdispatch/var1.c =================================================================== --- libdispatch/var1.c (revision 13003) +++ libdispatch/var1.c (working copy) @@ -603,7 +603,7 @@ size_t varshape[NC_MAX_VAR_DIMS]; int isrecvar; size_t numrecs; - int stride1; /* is stride all ones? */ + int stride1=0; /* is stride all ones? */ /* * Verify stride argument. Index: libdispatch/file.c =================================================================== --- libdispatch/file.c (revision 13003) +++ libdispatch/file.c (working copy) @@ -202,7 +202,7 @@ if(stat == NC_NOERR) { ncp->dispatch = dispatcher; if(ncidp) *ncidp = ncp->ext_ncid; - ncp->path = strdup(path); + ncp->path = nulldup(path); if(path == NULL) stat = NC_ENOMEM; } return stat; @@ -330,7 +330,7 @@ if(stat == NC_NOERR) { ncp->dispatch = dispatcher; if(ncidp) *ncidp = ncp->ext_ncid; - ncp->path = strdup(path); + ncp->path = nulldup(path); if(path == NULL) stat = NC_ENOMEM; } return stat; Index: libdispatch/nc_uri.c =================================================================== --- libdispatch/nc_uri.c (revision 13003) +++ libdispatch/nc_uri.c (working copy) @@ -27,12 +27,12 @@ #define NILLEN(s) ((s)==NULL?0:strlen(s)) #endif -#ifndef nulldup -#define nulldup(s) ((s)==NULL?NULL:strdup(s)) -#endif - -#ifndef HAVE_STRDUP -static char* nulldup(char* s) +#ifdef HAVE_STRDUP + #ifndef nulldup + #define nulldup(s) ((s)==NULL?NULL:strdup(s)) + #endif +#else +static char* nulldup(const char* s) { char* dup = NULL; if(s != NULL) { @@ -81,7 +81,7 @@ if(nc_uri == NULL) return 0; /* make local copy of uri */ - uri = strdup(uri0); + uri = nulldup(uri0); /* remove all whitespace*/ p = uri; @@ -151,20 +151,20 @@ /* assemble the component pieces*/ if(uri0 && strlen(uri0) > 0) - nc_uri->uri = strdup(uri0); + nc_uri->uri = nulldup(uri0); if(protocol && strlen(protocol) > 0) { - nc_uri->protocol = strdup(protocol); + nc_uri->protocol = nulldup(protocol); /* remove trailing ':' */ nc_uri->protocol[strlen(protocol)-1] = '\0'; } if(user && strlen(user) > 0) - nc_uri->user = strdup(user); + nc_uri->user = nulldup(user); if(pwd && strlen(pwd) > 0) - nc_uri->password = strdup(pwd); + nc_uri->password = nulldup(pwd); if(host && strlen(host) > 0) - nc_uri->host = strdup(host); + nc_uri->host = nulldup(host); if(port && strlen(port) > 0) - nc_uri->port = strdup(port); + nc_uri->port = nulldup(port); if(file && strlen(file) > 0) { /* Add back the leading / */ nc_uri->file = malloc(strlen(file)+2); @@ -172,7 +172,7 @@ strcat(nc_uri->file,file); } if(constraint && strlen(constraint) > 0) - nc_uri->constraint = strdup(constraint); + nc_uri->constraint = nulldup(constraint); nc_urisetconstraints(nc_uri,constraint); if(params != NULL && strlen(params) > 0) { nc_uri->params = (char*)malloc(1+2+strlen(params)); @@ -239,7 +239,7 @@ if(constraints == NULL || strlen(constraints)==0) return; - duri->constraint = strdup(constraints); + duri->constraint = nulldup(constraints); if(*duri->constraint == '?') strcpy(duri->constraint,duri->constraint+1); @@ -375,15 +375,15 @@ /* Pass 1 to replace beginning '[' and ending ']' */ if(params0[0] == '[') - params = strdup(params0+1); + params = nulldup(params0+1); else - params = strdup(params0); + params = nulldup(params0); if(params[strlen(params)-1] == ']') params[strlen(params)-1] = '\0'; /* Pass 2 to replace "][" pairs with ','*/ - params1 = strdup(params); + params1 = nulldup(params); cp=params; cq = params1; while((c=*cp++)) { if(c == RBRACKET && *cp == LBRACKET) {cp++; c = ',';} @@ -413,8 +413,8 @@ /*break up the ith param*/ vp = strchr(cp,'='); if(vp != NULL) {*vp = '\0'; vp++;} else {vp = "";} - plist[2*i] = strdup(cp); - plist[2*i+1] = strdup(vp); + plist[2*i] = nulldup(cp); + plist[2*i+1] = nulldup(vp); cp = next; } plist[2*nparams] = NULL; @@ -527,8 +527,8 @@ len = sizeof(char*)*((2*i)+1); newp = realloc(params,len+2*sizeof(char*)); memcpy(newp,params,len); - newp[2*i] = strdup(key); - newp[2*i+1] = (value==NULL?NULL:strdup(value)); + newp[2*i] = nulldup(key); + newp[2*i+1] = (value==NULL?NULL:nulldup(value)); return newp; } Index: config.h =================================================================== --- config.h (revision 13003) +++ config.h (working copy) @@ -43,7 +43,9 @@ /* #undef H5_USE_16_API */ /* Define to 1 if you have `alloca', as a function or macro. */ +#if !defined(_WIN32) #define HAVE_ALLOCA 1 +#endif /* Define to 1 if you have and it should be used (not on Ultrix). */ @@ -115,7 +117,9 @@ /* #undef HAVE_HDF5_H */ /* Define to 1 if you have the header file. */ +#if !defined(vxWorks) && !defined(_WIN32) #define HAVE_INTTYPES_H 1 +#endif /* Define to 1 if you have the `curl' library (-lcurl). */ #define HAVE_LIBCURL 1 @@ -172,17 +176,28 @@ #define HAVE_SNPRINTF 1 /* Define to 1 if the system has the type `ssize_t'. */ +#if !defined(_WIN32) #define HAVE_SSIZE_T 1 +#endif /* Define to 1 if you have the header file. */ #define HAVE_STDARG_H 1 /* Define to 1 if stdbool.h conforms to C99. */ +#if !defined(vxWorks) && !defined(_WIN32) #define HAVE_STDBOOL_H 1 +#endif /* Define to 1 if you have the header file. */ +#if !defined(vxWorks) && !defined(_WIN32) #define HAVE_STDINT_H 1 +#endif +/* Define to 1 if you have the header file. */ +#if !defined(vxWorks) && !defined(_WIN32) +#define HAVE_SYS_PARAM_H 1 +#endif + /* Define to 1 if you have the header file. */ #define HAVE_STDIO_H 1 @@ -202,7 +217,9 @@ #define HAVE_STRCPY 1 /* Define to 1 if you have the `strdup' function. */ +#if !defined(vxWorks) #define HAVE_STRDUP 1 +#endif /* Define to 1 if you have the `strerror' function. */ #define HAVE_STRERROR 1 @@ -233,7 +250,9 @@ /* Define to 1 if your `struct stat' has `st_blksize'. Deprecated, use `HAVE_STRUCT_STAT_ST_BLKSIZE' instead. */ +#if !defined(_WIN32) #define HAVE_ST_BLKSIZE 1 +#endif /* Define to 1 if you have the header file, and it defines `DIR'. */ @@ -262,7 +281,9 @@ /* #undef HAVE_UCHAR */ /* Define to 1 if you have the header file. */ +#if !defined(_WIN32) #define HAVE_UNISTD_H 1 +#endif /* Define to 1 if the system has the type `unsigned long long int'. */ /* #undef HAVE_UNSIGNED_LONG_LONG_INT */ @@ -271,7 +292,9 @@ #define HAVE_VPRINTF 1 /* Define to 1 if the system has the type `_Bool'. */ +#if !defined(vxWorks) && !defined(_WIN32) #define HAVE__BOOL 1 +#endif /* do large file tests */ /* #undef LARGE_FILE_TESTS */ @@ -365,7 +388,19 @@ #define SIZEOF_LONG 4 /* The size of `off_t', as computed by sizeof. */ -#define SIZEOF_OFF_T 8 +#if defined(vxWorks) + #define SIZEOF_OFF_T 4 +#elif defined(_WIN32) + #include + #include + #define SIZEOF_OFF_T 8 + #define lseek _lseeki64 + #define off_t __int64 + #define _off_t __int64 + #define _OFF_T_DEFINED +#else + #define SIZEOF_OFF_T 8 +#endif /* The size of `short', as computed by sizeof. */ #define SIZEOF_SHORT 2 @@ -400,7 +435,9 @@ #define USE_EXTREME_NUMBERS 1 /* if true, include experimental fsync code */ +#if !defined(vxWorks) && !defined(_WIN32) #define USE_FSYNC 1 +#endif /* if true, use HDF4 too */ /* #undef USE_HDF4 */ Index: test_big_classic.pro =================================================================== --- test_big_classic.pro (revision 0) +++ test_big_classic.pro (revision 13016) @@ -0,0 +1,44 @@ +; test_big_classic.pro +; Test program to write large (>4GB files in netCDF classic format + +pro test_big_classic, fileName + + MAX_DIMS = 3 + XSIZE = 1024 + YSIZE = 1024 + NUM_RECORDS = 4100 + + dimIds = intarr(MAX_DIMS); + start = [0L, 0L, 0L]; + count = [YSIZE, XSIZE, 1L]; + pData = bytarr(XSIZE, YSIZE); + + ; Create the file. The NC_CLOBBER parameter tells netCDF to + ; overwrite this file, if it already exists. No other flags, so it is classic format. + print, "Creating file ", fileName + ncId = ncdf_create(fileName, /clobber) + ncdf_control, ncId, fill=0 + + ; Define the dimensions + dimIds[2] = ncdf_dimdef(ncId, 'numArrays', /unlimited) + dimIds[1] = ncdf_dimdef(ncId, 'YSize', YSIZE) + dimIds[0] = ncdf_dimdef(ncId, 'XSize', XSIZE) + + ; Define the array data variable + dataId = ncdf_vardef(ncId, 'array_data', dimIds, /BYTE) + + ; End define mode. This tells netCDF we are done defining + ; metadata. + ncdf_control, ncId, /endef + + ; Write data to file + for i=0, NUM_RECORDS-1 do begin + print, "writing record", i+1, "/", NUM_RECORDS + start[2] = i; + ncdf_varput, ncId, dataId, pData, $ + offset=start, count=count + endfor + print, "Closing file", fileName + ncdf_close, ncId +end + Index: Makefile =================================================================== --- Makefile (revision 13003) +++ Makefile (working copy) @@ -5,24 +5,45 @@ #============================= + +LIBRARY_IOC = netCDF +NETCDF = $(TOP)/ADApp/netCDFSrc +USR_INCLUDES += -I$(NETCDF)/include +USR_CFLAGS += -DHAVE_CONFIG_H + +SRC_DIRS += $(NETCDF)/include INC += netcdf.h -LIBRARY_IOC = netCDF +SRC_DIRS += $(NETCDF)/libsrc LIB_SRCS += attr.c LIB_SRCS += dim.c -LIB_SRCS += error.c -LIB_SRCS += libvers.c +LIB_SRCS += lookup3.c LIB_SRCS += nc.c +LIB_SRCS += nc3dispatch.c +LIB_SRCS += nclistmgr.c LIB_SRCS += ncx.c LIB_SRCS += posixio.c LIB_SRCS += putget.c LIB_SRCS += string.c -LIB_SRCS += t_nc.c +LIB_SRCS += utf8proc.c LIB_SRCS += v1hpg.c -LIB_SRCS += v2i.c LIB_SRCS += var.c -LIB_SRCS += utf8proc.c +SRC_DIRS += $(NETCDF)/libdispatch +LIB_SRCS += att.c +LIB_SRCS += dim1.c +LIB_SRCS += dispatch.c +LIB_SRCS += error.c +LIB_SRCS += file.c +LIB_SRCS += nc_uri.c +LIB_SRCS += var1.c + +SRC_DIRS += $(NETCDF)/liblib +LIB_SRCS += stub.c + +PROD_IOC += test_big_classic +PROD_LIBS += netCDF + include $(TOP)/configure/RULES #---------------------------------------- # ADD RULES AFTER THIS LINE Index: test_big_classic.c =================================================================== --- test_big_classic.c (revision 0) +++ test_big_classic.c (revision 13016) @@ -0,0 +1,79 @@ +/* test_big_classic.c + * Test program to write large (>4GB files in netCDF classic format + */ + +#include +#include +#include +#include + +#define MAX_DIMS 3 +#define XSIZE 1024 +#define YSIZE 1024 +#define NUM_RECORDS 4100 + +/* Handle errors by printing an error message and exiting with a + * non-zero status. */ +#define ERR(e) {printf("error=%s\n", \ + nc_strerror(e)); \ + return(-1);} + +int main(int argc, char **argv) +{ + /* When we create netCDF variables and dimensions, we get back an + * ID for each one. */ + int dimIds[MAX_DIMS]; + size_t start[MAX_DIMS] = {0, 0, 0}; + size_t count[MAX_DIMS] = {1, YSIZE, XSIZE}; + int ncId; + int dataId; + int retval; + int i; + char *fileName = argv[1]; + char *pData = calloc(XSIZE, YSIZE); + + if (argc != 2) { + printf("Usage: test_big_classic filename\n"); + return(-1); + } + + /* Create the file. The NC_CLOBBER parameter tells netCDF to + * overwrite this file, if it already exists. No other flags, so it is classic format. */ + printf("Creating file %s\n", fileName); + if ((retval = nc_create(fileName, NC_CLOBBER, &ncId))) + ERR(retval); + + /* Define the dimensions */ + if ((retval = nc_def_dim(ncId, "numArrays", NC_UNLIMITED, &dimIds[0]))) + ERR(retval); + + if ((retval = nc_def_dim(ncId, "YSize", YSIZE, &dimIds[1]))) + ERR(retval); + + if ((retval = nc_def_dim(ncId, "XSize", XSIZE, &dimIds[2]))) + ERR(retval); + + /* Define the array data variable. */ + if ((retval = nc_def_var(ncId, "array_data", NC_BYTE, 3, + dimIds, &dataId))) + ERR(retval); + + /* End define mode. This tells netCDF we are done defining + * metadata. */ + if ((retval = nc_enddef(ncId))) + ERR(retval); + + /* Write data to file */ + for (i=0; i +#ifdef HAVE_INTTYPES_H #include +#else +#include "pstdint.h" +#endif #include #ifndef HAVE_SSIZE_T #define ssize_t int #endif +#ifdef vxWorks +#undef SSIZE_MAX +#define SSIZE_MAX LONG_MAX +#endif + #ifndef SSIZE_MAX #define SSIZE_MAX (SIZE_MAX/2) #endif Index: include/ncdispatch.h =================================================================== --- include/ncdispatch.h (revision 13003) +++ include/ncdispatch.h (working copy) @@ -362,10 +362,15 @@ /* Misc */ -#ifndef nulldup -#define nulldup(s) ((s)==NULL?NULL:strdup(s)) +#ifdef HAVE_STRDUP + #ifndef nulldup + #define nulldup(s) ((s)==NULL?NULL:strdup(s)) + #endif +#else + char *nulldup(const char* s); #endif + #define nulllen(s) (s==NULL?0:strlen(s)) #define nullstring(s) (s==NULL?"(null)":s) Index: libsrc/pstdint.h =================================================================== --- libsrc/pstdint.h (revision 13003) +++ libsrc/pstdint.h (working copy) @@ -303,7 +303,7 @@ #ifndef UINT8_MAX # define UINT8_MAX 0xff #endif -#ifndef uint8_t +#if !defined(uint8_t) && !defined(vxWorks) # if (UCHAR_MAX == UINT8_MAX) || defined (S_SPLINT_S) typedef unsigned char uint8_t; # define UINT8_C(v) ((uint8_t) v) @@ -318,7 +318,7 @@ #ifndef INT8_MIN # define INT8_MIN INT8_C(0x80) #endif -#ifndef int8_t +#if !defined(int8_t) && !defined(vxWorks) # if (SCHAR_MAX == INT8_MAX) || defined (S_SPLINT_S) typedef signed char int8_t; # define INT8_C(v) ((int8_t) v) @@ -330,7 +330,7 @@ #ifndef UINT16_MAX # define UINT16_MAX 0xffff #endif -#ifndef uint16_t +#if !defined(uint16_t) && !defined(vxWorks) #if (UINT_MAX == UINT16_MAX) || defined (S_SPLINT_S) typedef unsigned int uint16_t; # ifndef PRINTF_INT16_MODIFIER @@ -354,7 +354,7 @@ #ifndef INT16_MIN # define INT16_MIN INT16_C(0x8000) #endif -#ifndef int16_t +#if !defined(int16_t) && !defined(vxWorks) #if (INT_MAX == INT16_MAX) || defined (S_SPLINT_S) typedef signed int int16_t; # define INT16_C(v) ((int16_t) (v)) @@ -375,7 +375,7 @@ #ifndef UINT32_MAX # define UINT32_MAX (0xffffffffUL) #endif -#ifndef uint32_t +#if !defined(uint32_t) && !defined(vxWorks) #if (ULONG_MAX == UINT32_MAX) || defined (S_SPLINT_S) typedef unsigned long uint32_t; # define UINT32_C(v) v ## UL @@ -405,7 +405,7 @@ #ifndef INT32_MIN # define INT32_MIN INT32_C(0x80000000) #endif -#ifndef int32_t +#if !defined(int32_t) && !defined(vxWorks) #if (LONG_MAX == INT32_MAX) || defined (S_SPLINT_S) typedef signed long int32_t; # define INT32_C(v) v ## L @@ -451,7 +451,7 @@ #endif #if !defined (stdint_int64_defined) -# if defined(__GNUC__) +# if defined(__GNUC__) && !defined(vxWorks) # define stdint_int64_defined __extension__ typedef long long int64_t; __extension__ typedef unsigned long long uint64_t; @@ -646,7 +646,7 @@ * type limits. */ -#if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__) +#if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__) && !defined(vxWorks) # include # ifndef WCHAR_MIN # define WCHAR_MIN 0 Index: libsrc/lookup3.c =================================================================== --- libsrc/lookup3.c (revision 13003) +++ libsrc/lookup3.c (working copy) @@ -54,7 +54,9 @@ #else # include #endif /* HAVE_STDINT_H */ +#ifdef HAVE_SYS_PARAM_H #include /* attempt to define endianness */ +#endif #ifdef linux # include /* attempt to define endianness */ #endif