mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-11-27 07:30:33 +08:00
Merged latest trunk into branch
This commit is contained in:
commit
235fc6bb13
@ -10,7 +10,7 @@ LFLAG=-L/upc/share/ed/local/${HOST}/lib
|
||||
else
|
||||
# !CYGWIN
|
||||
ifneq ($(HDF),1)
|
||||
HDF5LIB=/share/ed/local/${HOST}/lib/libhdf5_hl.a /share/ed/local/${HOST}/lib/libhdf5.a
|
||||
#HDF5LIB=/share/ed/local/${HOST}/lib/libhdf5_hl.a /share/ed/local/${HOST}/lib/libhdf5.a
|
||||
endif
|
||||
endif
|
||||
|
||||
|
24
libdap2/env
24
libdap2/env
@ -1,32 +1,30 @@
|
||||
PARMS=""; ARGS=""; CON="" ; CE=""; OCON="" ; VAR=""
|
||||
alias q0=;alias qq=;alias qv=;alias q=;alias qh=;alias qqh=;alias qall=;alias qv=;alias qo=;
|
||||
|
||||
TOP="/home/dmh/mach/trunk"
|
||||
#TOP="/home/dmh/mach/trunk"
|
||||
#TOP="/cygdrive/f/svn/trunk"
|
||||
TOP="/cygdrive/c/Users/dmh/svn/trunk"
|
||||
|
||||
PROG=./ncd
|
||||
#PROG="$TOP/ncdump/ncdump"
|
||||
#PROG=./ncd
|
||||
PROG="$TOP/ncdump/ncdump"
|
||||
|
||||
P=`pwd`
|
||||
|
||||
T="test.01"
|
||||
|
||||
T="1990-S1700101.HDF.WVC_Lat"
|
||||
|
||||
F="file://$TOP/ncdap_test/testdata3/$T"
|
||||
F="http://motherlode.ucar.edu:8081/dts/$T?f64"
|
||||
#F="http://motherlode.ucar.edu:8081/dts/$T?f64"
|
||||
#F="http://motherlode.ucar.edu:8080/thredds/dodsC/testdods/coads_climatology.nc"
|
||||
#F="http://nomads.ncep.noaa.gov:9090/dods/gfs_hd/gfs_hd20120801/gfs_hd_00z"
|
||||
#F="http://hycom.coaps.fsu.edu/thredds/dodsC/atl_ops"
|
||||
#VAR=f64
|
||||
|
||||
F="http://phy-51.io-warnemuende.de/thredds/dodsC/baltic/region_test_2005_netcdf3.nc"
|
||||
CON="temp[9:9][0:0][55:153][180:180]"
|
||||
|
||||
|
||||
#PARMS="[log]"
|
||||
VAR=f64
|
||||
|
||||
PARMS="[log]"
|
||||
#PARMS="${PARMS}[netcdf3]"
|
||||
#PARMS="${PARMS}[fetch=disk]"
|
||||
#PARMS="${PARMS}[cache]"
|
||||
PARMS="${PARMS}[cache]"
|
||||
#PARMS="${PARMS}[prefetch]"
|
||||
#PARMS="${PARMS}[nocache]"
|
||||
#PARMS="${PARMS}[noprefetch]"
|
||||
@ -102,8 +100,6 @@ F="http://motherlode.ucar.edu:8080/thredds/dodsC/station/metar/Surface_METAR_201
|
||||
CON="weather[0:10]"
|
||||
F="http://nomad1.ncep.noaa.gov:9090/dods/reanalyses/reanalysis-1/6hr/pgb/pgb"
|
||||
VAR=hgtprs
|
||||
F="http://ferret.pmel.noaa.gov/geoide/dodsC/PSDgriddedData/ncep.reanalysis.dailyavgs/surface/slp_aggregated"
|
||||
CON="slp.slp[23255:23316][29:29][88:88]"
|
||||
fi
|
||||
|
||||
|
||||
|
@ -1004,7 +1004,7 @@ nc4_get_vara(NC_FILE_INFO_T *nc, int ncid, int varid, const size_t *startp,
|
||||
H5Tget_size(var->type_info->hdf_typeid) > 1 &&
|
||||
!H5Tis_variable_str(var->type_info->hdf_typeid)) {
|
||||
hsize_t fstring_len;
|
||||
if ((fstring_len = H5Tget_size(var->type_info->hdf_typeid)) < 0)
|
||||
if ((fstring_len = H5Tget_size(var->type_info->hdf_typeid)) == 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
if (!(*(char **)data = malloc(1 + fstring_len)))
|
||||
BAIL(NC_ENOMEM);
|
||||
|
@ -29,7 +29,7 @@
|
||||
#define X_BYTE_MAX 127
|
||||
#define X_SHORT_MIN (-32768)
|
||||
#define X_SHORT_MAX 32767
|
||||
#define X_INT_MIN (-2147483648.)
|
||||
#define X_INT_MIN (-2147483647-1)
|
||||
#define X_INT_MAX 2147483647
|
||||
#if defined(FLT_MAX_EXP) && FLT_MAX_EXP < 128
|
||||
/* FLT_MAX < X_FLOAT_MAX */
|
||||
|
@ -915,7 +915,6 @@ pr_attx(
|
||||
|
||||
NC_CHECK( nc_inq_attname(ncid, varid, ia, att.name) );
|
||||
NC_CHECK( nc_inq_att(ncid, varid, att.name, &att.type, &att.len) );
|
||||
att.tinfo = get_typeinfo(att.type);
|
||||
|
||||
/* Put attribute values into a single string, with blanks in between */
|
||||
|
||||
|
@ -341,7 +341,7 @@ static char* decodelist =
|
||||
char*
|
||||
dapdecode(DAPlexstate* lexstate, char* name)
|
||||
{
|
||||
char* decoded;
|
||||
char* decoded = NULL;
|
||||
#ifdef DECODE_IDENTIFIERS
|
||||
decoded = ocuridecode(name);
|
||||
#else
|
||||
|
@ -285,6 +285,10 @@ ocfetch(OCstate* state, const char* constraint, OCdxd kind, OCflags flags,
|
||||
if((flags & OCONDISK) != 0) {
|
||||
tree->data.xdrs = xxdr_filecreate(tree->data.file,tree->data.bod);
|
||||
} else {
|
||||
#ifdef OCDEBUG
|
||||
fprintf(stderr,"ocfetch.datadds.memory: datasize=%lu bod=%lu\n",
|
||||
(unsigned long)tree->data.datasize,(unsigned long)tree->data.bod);
|
||||
#endif
|
||||
/* Switch to zero based memory */
|
||||
tree->data.xdrs
|
||||
= xxdr_memcreate(tree->data.memory,tree->data.datasize,tree->data.bod);
|
||||
@ -405,17 +409,10 @@ ocextractddsinmemory(OCstate* state, OCtree* tree, OCflags flags)
|
||||
OCerror stat = OC_NOERR;
|
||||
size_t ddslen, bod, bodfound;
|
||||
/* Read until we find the separator (or EOF)*/
|
||||
#ifdef OCDEBUG
|
||||
fprintf(stderr,"ocextractddsinmemory:\n");
|
||||
#endif
|
||||
bodfound = ocfindbod(state->packet,&bod,&ddslen);
|
||||
if(!bodfound) {/* No BOD; pretend */
|
||||
bod = tree->data.bod;
|
||||
ddslen = tree->data.datasize;
|
||||
#ifdef OCDEBUG
|
||||
fprintf(stderr,"missing bod: bod=%lu ddslen=%lu\n",
|
||||
(unsigned long)ddslen,(unsigned long)bod);
|
||||
#endif
|
||||
}
|
||||
tree->data.bod = bod;
|
||||
tree->data.ddslen = ddslen;
|
||||
@ -448,9 +445,6 @@ ocextractddsinfile(OCstate* state, OCtree* tree, OCflags flags)
|
||||
OCerror stat = OC_NOERR;
|
||||
size_t ddslen, bod, bodfound;
|
||||
|
||||
#ifdef OCDEBUG
|
||||
fprintf(stderr,"ocextractddsinfile:\n");
|
||||
#endif
|
||||
/* Read until we find the separator (or EOF)*/
|
||||
ocbytesclear(state->packet);
|
||||
rewind(tree->data.file);
|
||||
@ -468,7 +462,7 @@ fprintf(stderr,"ocextractddsinfile:\n");
|
||||
bod = tree->data.bod;
|
||||
ddslen = tree->data.datasize;
|
||||
#ifdef OCDEBUG
|
||||
fprintf(stderr,"missing bod: bod=%lu ddslen=%lu\n",
|
||||
fprintf(stderr,"missing bod: ddslen=%lu bod=%lu\n",
|
||||
(unsigned long)ddslen,(unsigned long)bod);
|
||||
#endif
|
||||
}
|
||||
|
72
oc2/ocread.c
72
oc2/ocread.c
@ -33,6 +33,9 @@ readDDS(OCstate* state, OCtree* tree)
|
||||
|
||||
ocset_user_password(state);
|
||||
|
||||
#ifdef OCDEBUG
|
||||
fprintf(stderr,"readDDS:\n");
|
||||
#endif
|
||||
stat = readpacket(state,state->uri,state->packet,OCDDS,
|
||||
&lastmodified);
|
||||
if(stat == OC_NOERR) state->ddslastmodified = lastmodified;
|
||||
@ -46,6 +49,9 @@ readDAS(OCstate* state, OCtree* tree)
|
||||
int stat = OC_NOERR;
|
||||
|
||||
ocurisetconstraints(state->uri,tree->constraint);
|
||||
#ifdef OCDEBUG
|
||||
fprintf(stderr,"readDAS:\n");
|
||||
#endif
|
||||
stat = readpacket(state,state->uri,state->packet,OCDAS,NULL);
|
||||
|
||||
return stat;
|
||||
@ -104,6 +110,10 @@ readpacket(OCstate* state, OCURI* url,OCbytes* packet,OCdxd dxd,long* lastmodifi
|
||||
{fprintf(stderr,"fetch complete\n"); fflush(stderr);}
|
||||
}
|
||||
free(fetchurl);
|
||||
#ifdef OCDEBUG
|
||||
fprintf(stderr,"readpacket: packet.size=%lu\n",
|
||||
(unsigned long)ocbyteslength(packet));
|
||||
#endif
|
||||
return OCTHROW(stat);
|
||||
}
|
||||
|
||||
@ -113,6 +123,9 @@ readDATADDS(OCstate* state, OCtree* tree, OCflags flags)
|
||||
int stat = OC_NOERR;
|
||||
long lastmod = -1;
|
||||
|
||||
#ifdef OCDEBUG
|
||||
fprintf(stderr,"readDATADDS:\n");
|
||||
#endif
|
||||
if((flags & OCONDISK) == 0) {
|
||||
ocurisetconstraints(state->uri,tree->constraint);
|
||||
stat = readpacket(state,state->uri,state->packet,OCDATADDS,&lastmod);
|
||||
@ -159,13 +172,23 @@ readfiletofile(const char* path, const char* suffix, FILE* stream, off_t* sizep)
|
||||
/* check for leading file:/// */
|
||||
if(ocstrncmp(path,"file:///",8)==0) path += 7; /* assume absolute path*/
|
||||
stat = readfile(path,suffix,packet);
|
||||
#ifdef OCDEBUG
|
||||
fprintf(stderr,"readfiletofile: packet.size=%lu\n",
|
||||
(unsigned long)ocbyteslength(packet));
|
||||
#endif
|
||||
if(stat != OC_NOERR) goto unwind;
|
||||
len = oclistlength(packet);
|
||||
if(stat == OC_NOERR) {
|
||||
size_t written;
|
||||
fseek(stream,0,SEEK_SET);
|
||||
written = fwrite(ocbytescontents(packet),1,len,stream);
|
||||
if(written != len) stat = OC_EIO;
|
||||
if(written != len) {
|
||||
#ifdef OCDEBUG
|
||||
fprintf(stderr,"readfiletofile: written!=length: %lu :: %lu\n",
|
||||
(unsigned long)written,(unsigned long)len);
|
||||
#endif
|
||||
stat = OC_EIO;
|
||||
}
|
||||
}
|
||||
if(sizep != NULL) *sizep = len;
|
||||
unwind:
|
||||
@ -179,31 +202,58 @@ readfile(const char* path, const char* suffix, OCbytes* packet)
|
||||
int stat = OC_NOERR;
|
||||
char buf[1024];
|
||||
char filename[1024];
|
||||
int count,size,fd;
|
||||
int fd = -1;
|
||||
int flags = 0;
|
||||
off_t filesize = 0;
|
||||
off_t totalread = 0;
|
||||
/* check for leading file:/// */
|
||||
if(ocstrncmp(path,"file://",7)==0) path += 7; /* assume absolute path*/
|
||||
strcpy(filename,path);
|
||||
if(suffix != NULL) strcat(filename,suffix);
|
||||
fd = open(filename,O_RDONLY);
|
||||
flags = O_RDONLY;
|
||||
#ifdef O_BINARY
|
||||
flags |= O_BINARY;
|
||||
#endif
|
||||
fd = open(filename,flags);
|
||||
if(fd < 0) {
|
||||
oclog(OCLOGERR,"open failed:%s",filename);
|
||||
return OCTHROW(OC_EOPEN);
|
||||
}
|
||||
size=0;
|
||||
/* Get the file size */
|
||||
filesize = lseek(fd,0,SEEK_END);
|
||||
if(filesize < 0) {
|
||||
stat = OC_EIO;
|
||||
oclog(OCLOGERR,"lseek failed: %s",filename);
|
||||
goto done;
|
||||
}
|
||||
/* Move file pointer back to the beginning of the file */
|
||||
(void)lseek(fd,0,SEEK_SET);
|
||||
stat = OC_NOERR;
|
||||
for(;;) {
|
||||
count = read(fd,buf,sizeof(buf));
|
||||
for(totalread=0;;) {
|
||||
off_t count = (off_t)read(fd,buf,sizeof(buf));
|
||||
if(count == 0)
|
||||
break;
|
||||
break; /*eof*/
|
||||
else if(count < 0) {
|
||||
stat = OC_EIO;
|
||||
oclog(OCLOGERR,"read failed: %s",filename);
|
||||
break;
|
||||
goto done;
|
||||
}
|
||||
ocbytesappendn(packet,buf,count);
|
||||
size += count;
|
||||
ocbytesappendn(packet,buf,(unsigned long)count);
|
||||
totalread += count;
|
||||
}
|
||||
close(fd);
|
||||
if(totalread < filesize) {
|
||||
stat = OC_EIO;
|
||||
oclog(OCLOGERR,"short read: |%s|=%lu read=%lu\n",
|
||||
filename,(unsigned long)filesize,(unsigned long)totalread);
|
||||
goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
#ifdef OCDEBUG
|
||||
fprintf(stderr,"readfile: filesize=%lu totalread=%lu\n",
|
||||
(unsigned long)filesize,(unsigned long)totalread);
|
||||
#endif
|
||||
if(fd >= 0) close(fd);
|
||||
return OCTHROW(stat);
|
||||
}
|
||||
|
||||
|
@ -134,10 +134,6 @@ ocfindbod(OCbytes* buffer, size_t* bodp, size_t* ddslenp)
|
||||
*ddslenp = i;
|
||||
i += tlen;
|
||||
*bodp = i;
|
||||
#ifdef OCDEBUG
|
||||
fprintf(stderr,"findbod: buf.len=%lu bod=%lu ddslen=%lu\n",
|
||||
(unsigned long)len,(unsigned long)*ddslenp,(unsigned long)*bodp);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user