Merge branch 'master' into max_vars_dims_cleanup

This commit is contained in:
Greg Sjaardema 2015-11-30 10:37:07 -05:00
commit ccb9682288
82 changed files with 4055 additions and 1961 deletions

View File

@ -1,52 +1,17 @@
sudo: false
sudo: required
language: c
compiler:
- gcc
- clang
addons:
apt:
packages:
- libcurl4-openssl-dev
- m4
- wget
- autoconf
- libtool
- gfortran
- git
- doxygen
- graphviz
services:
- docker
env:
matrix:
- DOCKIMG=unidata/nctests:serial USECMAKE=TRUE USEAC=TRUE USE_CC=gcc
- DOCKIMG=unidata/nctests:serial USECMAKE=TRUE USEAC=TRUE USE_CC=clang
- DOCKIMG=unidata/nctests:serial32 USECMAKE=TRUE USEAC=TRUE USE_CC=gcc
- DOCKIMG=unidata/nctests:serial32 USECMAKE=TRUE USEAC=TRUE USE_CC=clang
before_install:
before_script:
###
# Install dependencies from a pre-built binary.
###
- cd $HOME
- wget http://www.unidata.ucar.edu/downloads/netcdf/ftp/travisdeps.tar.bz2
- tar -jxf travisdeps.tar.bz2
- export LD_LIBRARY_PATH=$HOME/usr/lib
- export PATH=$HOME/usr/bin:$PATH
- cd -
- mkdir build-all
- mkdir build-min
- cd build-min
- cmake .. -DENABLE_NETCDF_4=OFF -DENABLE_DAP=OFF -DCMAKE_PREFIX_PATH=$HOME/usr-min
- cd ..
- cd build-all
- cmake .. -DENABLE_MMAP=ON -DENABLE_DOXYGEN=ON -DENABLE_EXTRA_TESTS=ON -DENABLE_HDF4=ON -DCMAKE_PREFIX_PATH=$HOME/usr
- cd ..
- docker pull $DOCKIMG > /dev/null
script:
- cd build-min
- make -j 4
- make test
- cd ../build-all
- make -j 4
- make test
- docker run --rm -it -e USEDASH=OFF -e RUNF=OFF -e RUNCXX=OFF -e RUNP=OFF -e RUNNCO=OFF -e USECMAKE=$USECMAKE -e USEAC=$USEAC -v $(pwd):/netcdf-c $DOCKIMG

52
.travis.yml.old Normal file
View File

@ -0,0 +1,52 @@
sudo: false
language: c
compiler:
- gcc
- clang
addons:
apt:
packages:
- libcurl4-openssl-dev
- m4
- wget
- autoconf
- libtool
- gfortran
- git
- doxygen
- graphviz
before_install:
before_script:
###
# Install dependencies from a pre-built binary.
###
- cd $HOME
- wget http://www.unidata.ucar.edu/downloads/netcdf/ftp/travisdeps.tar.bz2
- tar -jxf travisdeps.tar.bz2
- export LD_LIBRARY_PATH=$HOME/usr/lib
- export PATH=$HOME/usr/bin:$PATH
- cd -
- mkdir build-all
- mkdir build-min
- cd build-min
- cmake .. -DENABLE_NETCDF_4=OFF -DENABLE_DAP=OFF -DCMAKE_PREFIX_PATH=$HOME/usr-min
- cd ..
- cd build-all
- cmake .. -DENABLE_MMAP=ON -DENABLE_DOXYGEN=ON -DENABLE_EXTRA_TESTS=ON -DENABLE_HDF4=ON -DCMAKE_PREFIX_PATH=$HOME/usr
- cd ..
script:
- cd build-min
- make -j 4
- make test
- cd ../build-all
- make -j 4
- make test

View File

@ -454,7 +454,6 @@ IF(ENABLE_NETCDF_4)
SET(USE_NETCDF4 ON CACHE BOOL "")
SET(ENABLE_NETCDF_4 ON CACHE BOOL "")
SET(ENABLE_NETCDF4 ON CACHE BOOL "")
ENDIF()
# Option for building RPC
@ -506,6 +505,8 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4)
CHECK_LIBRARY_EXISTS(hdf5 H5Pget_fapl_mpio "" HDF5_IS_PARALLEL_MPIO)
IF(HDF5_IS_PARALLEL_MPIPOSIX OR HDF5_IS_PARALLEL_MPIO)
SET(HDF5_IS_PARALLEL ON)
ELSE()
SET(HDF5_IS_PARALLEL OFF)
ENDIF()
IF(HDF5_IS_PARALLEL_MPIO)
@ -1604,6 +1605,7 @@ is_enabled(ENABLE_NETCDF_4 HAS_HDF5)
is_enabled(USE_SZIP HAS_SZIP)
is_enabled(STATUS_PNETCDF HAS_PNETCDF)
is_enabled(STATUS_PARALLEL HAS_PARALLEL)
is_enabled(ENABLE_PARALLEL4 HAS_PARALLEL4)
is_enabled(USE_DAP HAS_DAP)
is_enabled(USE_DISKLESS HAS_DISKLESS)
is_enabled(USE_MMAP HAS_MMAP)

View File

@ -7,12 +7,20 @@ This file contains a high-level description of this package's evolution. Release
## 4.4.0 Released TBD
* Modified ncgen to properly handle the L and UL suffixes for integer constants
to keep backward compatibility. Now it is the case the single L suffix
(e.g. 111L) is treated as a 32 bit integer. This makes it consistent with
the fact that NC_LONG (netcdf.h) is an alias for NC_INT. Existing .cdl
files should be examined for occurrences of the L prefix to ensure that
this change will not affect them.
(see Github issue 156[https://github.com/Unidata/netcdf-c/issues/156]).
* Updated documentation to reference the new `NodeJS` interface to netcdf4, by Sven Willner. It is available from [https://www.npmjs.com/package/netcdf4](https://www.npmjs.com/package/netcdf4) or from the GitHub repository at [https://github.com/swillner/netcdf4-js](https://github.com/swillner/netcdf4-js).
* Incorporated pull request https://github.com/Unidata/netcdf-c/pull/150 from Greg Sjaardema to remove the internal hard-wired use of `NC_MAX_DIMS`, instead using a dynamic memory allocation.
### 4.4.0-RC5 Released - November 11, 2015
* Added a fix for https://github.com/Unidata/netcdf-c/issues/149, which was reported several times in quick succession within an hour of the RC4 release.
### 4.4.0-RC4 Released - November 10, 2015

4
cf
View File

@ -7,8 +7,8 @@ FAST=1
FAST=1
#HDF5=1
#DAP=1
HDF5=1
DAP=1
#PNETCDF=1
#PAR4=1

View File

@ -5,7 +5,7 @@ UL=/usr/local
PPATH="$UL"
ZLIB="-DZLIB_LIBRARY=${UL}/lib/libz.so -DZLIB_INCLUDE_DIR=${UL}/include"
HDF5="-DHDF5_LIB=${UL}/lib/libhdf5.so -DHDF5_HL_LIB=${UL}/lib/libhdf5_hl.so -DHDF5_INCLUDE_DIR=${UL}/include"
CURL="-DCURL_LIBRARY=${UL}/lib/libcurl.so -DCURL_INCLUDE_DIR=${UL}/include"
CURL="-DCURL_LIBRARY=${UL}/lib/libcurl.so -DCURL_INCLUDE_DIR=${UL}/include -DCURL_INCLUDE_DIRS=${UL}/include"
FLAGS="-DCMAKE_PREFIX_PATH=$PPATH"
FLAGS="$FLAGS -DCMAKE_INSTALL_PREFIX=${UL}"
FLAGS="$FLAGS -DCMAKE_PREFIX_PATH=$PPATH"

View File

@ -835,20 +835,22 @@ $SLEEPCMD
AC_CHECK_SIZEOF(size_t)
$SLEEPCMD
AC_CHECK_SIZEOF(unsigned long long)
$SLEEPCMD
$SLEEPCMD
if test "$ac_cv_type_ushort" = yes ; then
AC_CHECK_SIZEOF(ushort)
else
AC_CHECK_SIZEOF(unsigned short int)
fi
sleep 3
$SLEEPCMD
if test "$ac_cv_type_uint" = yes ; then
AC_CHECK_SIZEOF(uint)
else
AC_CHECK_SIZEOF(unsigned int)
fi
$SLEEPCMD
AC_CHECK_SIZEOF(unsigned long long)
$SLEEPCMD
@ -929,7 +931,7 @@ if test "x$enable_netcdf_4" = xyes; then
# The user may have built HDF5 with the SZLIB library.
if test "x$ac_cv_func_H5Z_SZIP" = xyes; then
AC_SEARCH_LIBS([SZ_Compress], [szip sz], [], [])
AC_SEARCH_LIBS([SZ_Compress], [szip sz], [], [])
AC_DEFINE([USE_SZIP], [1], [if true, compile in szip compression in netCDF-4 variables])
fi
@ -960,9 +962,9 @@ fi
# Should we suppress parallel io for netcdf-4?
if test "x$enable_netcdf_4" = xyes ; then
AC_MSG_CHECKING([whether parallel I/O is enabled for netcdf-4])
AC_ARG_ENABLE([parallel4], [AS_HELP_STRING([--disable-parallel4],
[disable parallel I/O for netcdf-4, even if it's enabled in libhdf5])])
AC_MSG_CHECKING([whether parallel I/O is enabled for netcdf-4])
AC_ARG_ENABLE([parallel4], [AS_HELP_STRING([--disable-parallel4],
[disable parallel I/O for netcdf-4, even if it's enabled in libhdf5] )])
test "x$enable_parallel4" = xno || enable_parallel4=yes
AC_MSG_RESULT($enable_parallel4)
else
@ -1199,12 +1201,10 @@ if test "x$enable_jna" = xyes ; then
AC_DEFINE([JNA], [1], [if true, include JNA bug fix])
fi
AC_SUBST(NC_LIBS,[$NC_LIBS])
AC_SUBST(HAS_DAP,[$enable_dap])
AC_SUBST(HAS_NC2,[$nc_build_v2])
AC_SUBST(HAS_NC4,[$enable_netcdf_4])
AC_SUBST(HAS_SZIP,[$ac_cv_func_H5Z_SZIP])
AC_SUBST(HAS_HDF4,[$enable_hdf4])
AC_SUBST(HAS_PNETCDF,[$enable_pnetcdf])
AC_SUBST(HAS_HDF5,[$enable_netcdf_4])

View File

@ -16,76 +16,27 @@ Freely Available Software {#freely}
ANDX and ANAX {#ANDX}
------------------------------------
The ARM Program has developed [ANDX (ARM NetCDF Data
eXtract)](http://engineering.arm.gov/~sbeus/andx-web/html/), a
command-line utility designed for routine examination and extraction of
data from netcdf files. Data can be displayed graphically (line-plot,
scatter-plot, overlay, color-intensity, etc.) or extracted as ASCII
data. Whether displayed graphically or extracted as ASCII, results can
be saved to disk or viewed on screen.
The ARM Program has developed [ANDX (ARM NetCDF Data eXtract)](http://engineering.arm.gov/~sbeus/andx-web/html/), a command-line utility designed for routine examination and extraction of data from netcdf files. Data can be displayed graphically (line-plot, scatter-plot, overlay, color-intensity, etc.) or extracted as ASCII data. Whether displayed graphically or extracted as ASCII, results can be saved to disk or viewed on screen.
[ANAX (ARM NetCDF ASCII
eXtract)](http://science.arm.gov/~cflynn/ARM_Tested_Tools/) is a
scaled-down version of ANDX -- it is designed to only extract ASCII
data. All features of ANDX pertaining to non-graphic data extraction are
included in ANAX.
[ANAX (ARM NetCDF ASCII eXtract)](http://science.arm.gov/~cflynn/ARM_Tested_Tools/) is a scaled-down version of ANDX -- it is designed to only extract ASCII data. All features of ANDX pertaining to non-graphic data extraction are included in ANAX.
ANTS {#ANTS}
---------------------------
The ARM Program has developed [ANTS (ARM NetCDF Tool
Suite)](http://science.arm.gov/~cflynn/ANTS/), a collection of netCDF
tools and utilities providing various means of creating and modifying
netcdf files. ANTS is based on nctools written by Chuck Denham. The
utilities within nctools were modified to compile with version 3.5 of
the netCDF library, the command syntax was modified for consistency with
other tools, and changes were made to accommodate ARM standard netCDF.
The ARM Program has developed [ANTS (ARM NetCDF Tool Suite)](http://science.arm.gov/~cflynn/ANTS/), a collection of netCDF tools and utilities providing various means of creating and modifying netcdf files. ANTS is based on nctools written by Chuck Denham. The utilities within nctools were modified to compile with version 3.5 of the netCDF library, the command syntax was modified for consistency with other tools, and changes were made to accommodate ARM standard netCDF.
The original functions from nctools were intended mainly for the
creation, definition, and copying of fundamental netCDF elements. ARM
added others which focus on manipulation of data within existing netCDF
files. Additional functions have special support for multi-dimensional
data such as "slicing" cross sections from multi-dimensional variable
data or joining lesser-dimensional fields to form multi-dimensional
structures. Functions have been added to support execution of arithmetic
and logical operations, bundling or splitting netCDF files, comparing
the structure or content of files, and so on.
The original functions from nctools were intended mainly for the creation, definition, and copying of fundamental netCDF elements. ARM added others which focus on manipulation of data within existing netCDF files. Additional functions have special support for multi-dimensional data such as "slicing" cross sections from multi-dimensional variable data or joining lesser-dimensional fields to form multi-dimensional structures. Functions have been added to support execution of arithmetic and logical operations, bundling or splitting netCDF files, comparing the structure or content of files, and so on.
Essentially every type of netCDF library function call is exercised in
ANTS. In this way then, this open-source collection of tools also
represents a library of coding examples for fundamental netCDF tasks.
See the [website](http://science.arm.gov/~cflynn/ANTS/) for more
information.
Essentially every type of netCDF library function call is exercised in ANTS. In this way then, this open-source collection of tools also represents a library of coding examples for fundamental netCDF tasks. See the [website](http://science.arm.gov/~cflynn/ANTS/) for more information.
ARGOS {#ARGOS}
-----------------------------
[ARGOS](http://www.lapeth.ethz.ch/argos/index.html) (interActive
thRee-dimensional Graphics ObServatory) is a new IDL-based interactive
3D visualization tool, developed by [David N.
Bresch](http://www.lapeth.ethz.ch/~david/index.html) and [Mark A.
Liniger](http://www.lapeth.ethz.ch/~mark/index.html) at the Institute
for Atmospheric Science at the Swiss Federal Institute of Technology,
ETH, Zürich.
[ARGOS](http://www.lapeth.ethz.ch/argos/index.html) (interActive thRee-dimensional Graphics ObServatory) is a new IDL-based interactive 3D visualization tool, developed by [David N. Bresch](http://www.lapeth.ethz.ch/~david/index.html) and [Mark A. Liniger](http://www.lapeth.ethz.ch/~mark/index.html) at the Institute for Atmospheric Science at the Swiss Federal Institute of Technology, ETH, Zürich.
A highly optimized graphical user interface allows quick and elegant
creation of even complex 3D graphics (volume rendering,
isosurfaces,...), including Z-buffered overlays (with hidden lines),
light and data shading, Xray images, 3D trajectories, animations and
virtual flights around your data, all documented in a full on-line
[html-help](http://www.lapeth.ethz.ch/argos/argos_general.html). The
netCDF data format is preferred, but any other format can be read by
providing an IDL (or FORTRAN or C or C++) interface. Some toolboxes (for
atmospheric model output, trajectory display, radar data) have already
been written, others might easily be added (in IDL, FORTRAN or C code).
All interactive activities are tracked in a script, allowing quick
reconstruction of anything done as well as running ARGOS in batch script
mode.
A highly optimized graphical user interface allows quick and elegant creation of even complex 3D graphics (volume rendering, isosurfaces,...), including Z-buffered overlays (with hidden lines), light and data shading, Xray images, 3D trajectories, animations and virtual flights around your data, all documented in a full on-line [html-help](http://www.lapeth.ethz.ch/argos/argos_general.html). The netCDF data format is preferred, but any other format can be read by providing an IDL (or FORTRAN or C or C++) interface. Some toolboxes (for atmospheric model output, trajectory display, radar data) have already been written, others might easily be added (in IDL, FORTRAN or C code). All interactive activities are tracked in a script, allowing quick reconstruction of anything done as well as running ARGOS in batch script mode.
Information about [copyright and licensing
conditions](http://www.lapeth.ethz.ch/argos/argos_copyright.html) are
available. For further information and installation, please E-mail to:
bresch@atmos.umnw.ethz.ch
Information about [copyright and licensing conditions](http://www.lapeth.ethz.ch/argos/argos_copyright.html) are available. For further information and installation, please E-mail to: bresch@atmos.umnw.ethz.ch
CDAT {#CDAT}
---------------------------
@ -1829,6 +1780,32 @@ The SDS project is in beta phase and keeps evolving. You are welcome to
join discussions or report issues at the CodePlex site:
<http://sds.codeplex.com>.
sciNetCDF {#scinetcdf}
-------------------------------------------------------------
[sciNetCDF](https://atoms.scilab.org/toolboxes/scinetcdf)
In the context of the IASI-NG project, CNES is responsible for the development
of a Scilab/NetCDF4 interface, which CNES wanted to make available to the entire
scientific community.
The toolbox sciNetCDF is the result of this collaboration. It can read and write
NetCDF files of any version (version 4 of the format is used by default for
writing).
The toolbox provides high level functions to read/write NetCDF files natively in
Scilab in a friendly manner (data is converted automatically from Scilab to
NetCDF and inversely).
These functions are:
- nccreate
- ncwrite
- ncread
- ncwriteatt
- ncreadatt
- ncdisp
It provides also a low level interface to all the NetCDF C library functions
Apache Spatial Information System (SIS) {#SIS}
-------------------------------------------------------------

View File

@ -177,8 +177,8 @@ Use this in mode flags for both nc_create() and nc_open(). */
Note that the name in the contributed code
NC_FORMAT_64BIT was renamed to NC_FORMAT_CDF2
*/
#define NC_FORMAT_64BIT (2) /**< \deprecated Saved for compatibility. Use NC_FORMAT_64BIT_OFFSET or NC_FORMAT_64BIT_DATA, from netCDF 4.4.0 onwards. */
#define NC_FORMAT_64BIT_OFFSET (2)
#define NC_FORMAT_64BIT (NC_FORMAT_64BIT_OFFSET) /**< \deprecated Saved for compatibility. Use NC_FORMAT_64BIT_OFFSET or NC_FORMAT_64BIT_DATA, from netCDF 4.4.0 onwards. */
#define NC_FORMAT_NETCDF4 (3)
#define NC_FORMAT_NETCDF4_CLASSIC (4)
#define NC_FORMAT_64BIT_DATA (5)

View File

@ -1160,19 +1160,21 @@ fprintf(stderr,"conflict: %s[%lu] %s[%lu]\n",
/* Verify unique and defined names for dimensions*/
for(i=0;i<nclistlength(basedims);i++) {
CDFnode* dim1 = (CDFnode*)nclistget(basedims,i);
CDFnode* dim2 = NULL;
if(dim1->dim.basedim != NULL) PANIC1("nonbase basedim: %s\n",dim1->ncbasename);
if(dim1->ncbasename == NULL || dim1->ncfullname == NULL)
PANIC1("missing dim names: %s",dim1->ocname);
/* search backward so we can delete duplicates */
for(j=nclistlength(basedims)-1;j>i;j--) {
CDFnode* dim2 = (CDFnode*)nclistget(basedims,j);
if(strcmp(dim1->ncfullname,dim2->ncfullname)==0) {
if(!dim1->ncfullname) continue;
dim2 = (CDFnode*)nclistget(basedims,j);
if(strcmp(dim1->ncfullname,dim2->ncfullname)==0) {
/* complain and suppress one of them */
fprintf(stderr,"duplicate dim names: %s[%lu] %s[%lu]\n",
dim1->ncfullname,(unsigned long)dim1->dim.declsize,
dim2->ncfullname,(unsigned long)dim2->dim.declsize);
dim1->ncfullname,(unsigned long)dim1->dim.declsize,
dim2->ncfullname,(unsigned long)dim2->dim.declsize);
nclistremove(basedims,j);
}
}
}
}

View File

@ -25,13 +25,10 @@ Extra libraries: @LIBS@
# Features
--------
NetCDF-2 API: @HAS_NC2@
NetCDF-4 API: @HAS_NC4@
CDF-5 Support: yes
HDF4 Support: @HAS_HDF4@
HDF5 Support: @HAS_HDF5@
HDF5/SZIP Support: @HAS_SZIP@
PNetCDF Support: @HAS_PNETCDF@
NetCDF-4 API: @HAS_NC4@
NC-4 Parallel Support: @HAS_PARALLEL4@
PNetCDF Support: @HAS_PNETCDF@
DAP Support: @HAS_DAP@
Diskless Support: @HAS_DISKLESS@
MMap Support: @HAS_MMAP@

View File

@ -8,7 +8,8 @@ SET(NC4_TESTS tst_dims tst_dims2 tst_dims3 tst_files tst_files4 tst_vars
tst_xplatform tst_xplatform2 tst_h_atts2 tst_endian_fill tst_atts
t_type cdm_sea_soundings tst_vl tst_atts1 tst_atts2
tst_vars2 tst_files5 tst_files6 tst_sync tst_h_strbug tst_h_refs
tst_h_scalar tst_rename tst_h5_endians tst_atts_string_rewrite)
tst_h_scalar tst_rename tst_h5_endians tst_atts_string_rewrite
tst_put_vars_two_unlim_dim)
# Note, renamegroup needs to be compiled before run_grp_rename
build_bin_test(renamegroup)
@ -85,5 +86,3 @@ ENDIF()
FILE(GLOB CUR_EXTRA_DIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.c ${CMAKE_CURRENT_SOURCE_DIR}/*.h ${CMAKE_CURRENT_SOURCE_DIR}/*.sh)
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt Makefile.am)
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} ref_chunks1.cdl ref_chunks2.cdl ref_tst_compounds.nc ref_tst_xplatform2_1.nc ref_tst_xplatform2_2.nc ref_tst_dims.nc ref_tst_interops4.nc ref_grp_rename.cdl ref_tst_nvars.nc contig.hdf4 chunked.hdf4)
ADD_EXTRA_DIST("${CUR_EXTRA_DIST}")

View File

@ -0,0 +1,67 @@
/*
* Test contributed in support of netCDF issue
* https://github.com/Unidata/netcdf-c/issues/160
*/
#include "netcdf.h"
#include <stdio.h>
int main(int argc, char* argv[])
{
int ret;
int ncid;
int dim1id, dim2id;
int var1id, var2id;
size_t start = 0;
size_t count = 5;
double vals[] = { 1.0, 2.0, 3.0, 4.0, 5.0 };
if ((ret = nc_create("tst_put_vars_two_unlim_dim.nc", NC_NETCDF4 | NC_CLOBBER, &ncid))) {
printf("nc_create(...): error code = %d\n", ret);
return -1;
}
if ((ret = nc_def_dim(ncid, "dim1", NC_UNLIMITED, &dim1id))) {
printf("nc_def_dim(...\"dim1\"...): error code = %d\n", ret);
nc_close(ncid);
return -1;
}
if ((ret = nc_def_dim(ncid, "dim2", NC_UNLIMITED, &dim2id))) {
printf("nc_def_dim(...\"dim1\"...): error code = %d\n", ret);
nc_close(ncid);
return -1;
}
if ((ret = nc_def_var(ncid, "var1", NC_DOUBLE, 1, &dim1id, &var1id))) {
printf("nc_def_var(...\"var1\"...): error code = %d\n", ret);
nc_close(ncid);
return -1;
}
if ((ret = nc_def_var(ncid, "var2", NC_DOUBLE, 1, &dim2id, &var2id))) {
printf("nc_def_var(...\"var2\"...): error code = %d\n", ret);
nc_close(ncid);
return -1;
}
if ((ret = nc_put_vars_double(ncid, var1id, &start, &count, NULL, &vals[0]))) {
printf("nc_put_var_double(...var1id...): error code = %d\n", ret);
nc_close(ncid);
return -1;
}
if ((ret = nc_put_vars_double(ncid, var2id, &start, &count, NULL, &vals[0]))) {
printf("nc_put_var_double(...var2id...): error code = %d\n", ret);
nc_close(ncid);
return -1;
}
if ((ret = nc_close(ncid))) {
printf("nc_close(...): error code = %d\n", ret);
return -1;
}
return 0;
}

View File

@ -175,6 +175,11 @@ ENDIF()
add_sh_test(ncdump tst_ncgen4)
ENDIF()
add_sh_test(ncdump tst_inttags)
IF(USE_NETCDF4)
add_sh_test(ncdump tst_inttags4)
ENDIF()
ENDIF()

View File

@ -29,7 +29,7 @@ if BUILD_TESTSETS
#if !BUILD_DLL
# These tests are run for both netCDF-4 and non-netCDF-4 builds.
check_PROGRAMS = rewrite-scalar ctest ctest64 ncdump tst_utf8 bom
TESTS = run_tests.sh tst_64bit.sh ctest ctest64 tst_output.sh \
TESTS = tst_inttags.sh run_tests.sh tst_64bit.sh ctest ctest64 tst_output.sh \
tst_lengths.sh tst_calendars.sh tst_utf8 run_utf8_tests.sh \
tst_nccopy3.sh tst_charfill.sh tst_iter.sh tst_formatx3.sh tst_bom.sh
@ -51,7 +51,7 @@ tst_enum_data tst_opaque_data tst_string_data tst_vlen_data tst_comp \
tst_comp2 tst_nans tst_special_atts tst_unicode tst_fillbug tst_compress \
tst_chunking tst_h_scalar tst_bug324
TESTS += tst_create_files tst_group_data tst_enum_data tst_opaque_data \
TESTS += tst_inttags4.sh tst_create_files tst_group_data tst_enum_data tst_opaque_data \
tst_string_data tst_vlen_data tst_comp tst_comp2 tst_nans \
tst_special_atts tst_netcdf4.sh tst_h_rdc0 tst_unicode tst_fillbug \
tst_fillbug.sh tst_netcdf4_4.sh tst_compress tst_nccopy4.sh \
@ -109,9 +109,10 @@ tst_vlen_data.cdl tst_solar_1.cdl tst_format_att.cdl tst_inflated.nc \
tmp_subset.cdl tst_inflated4.nc tst_deflated.nc tst_chunking.nc tmp*.nc \
tst_charfill.nc tmp_tst_charfill.cdl \
iter.* \
tst_nc_test_netcdf4_4_0.cdl tst_mud4.nc tst_mud4.cdl tst_mud4-bc.cdl \
tst_ncf213.cdl tst_ncf213.nc tst_h_scalar.cdl tst_h_scalar.nc \
tst_mud4_chars.cdl tst_mud4_chars.nc
tst_nc_test_netcdf4_4_0.cdl tst_mud4.nc tst_mud4.cdl tst_mud4-bc.cdl \
tst_ncf213.cdl tst_ncf213.nc tst_h_scalar.cdl tst_h_scalar.nc \
tst_mud4_chars.cdl tst_mud4_chars.nc \
inttags.nc inttags4.nc tst_inttags.cdl tst_inttags4.cdl
# These files all have to be included with the distribution.
EXTRA_DIST = run_tests.sh tst_64bit.sh tst_output.sh test0.cdl \
@ -132,10 +133,12 @@ ref_nc_test_netcdf4.cdl ref_tst_special_atts3.cdl tst_brecs.cdl \
ref_tst_grp_spec0.cdl ref_tst_grp_spec.cdl tst_grp_spec.sh \
ref_tst_charfill.cdl tst_charfill.cdl tst_charfill.sh \
tst_iter.sh tst_mud.sh ref_tst_mud4.cdl ref_tst_mud4-bc.cdl \
ref_tst_mud4_chars.cdl \
ref_tst_mud4_chars.cdl \
inttags.cdl inttags4.cdl ref_inttags.cdl ref_inttags4.cdl \
ref_tst_ncf213.cdl tst_h_scalar.sh \
run_utf8_nc4_tests.sh \
tst_formatx3.sh tst_formatx4.sh ref_tst_utf8_4.cdl \
tst_inttags.sh tst_inttags4.sh \
CMakeLists.txt XGetopt.c tst_bom.sh tst_inmemory_nc3.sh tst_inmemory_nc4.sh
# CDL files and Expected results

View File

@ -4,14 +4,14 @@ dimensions:
// global attributes:
:Number_of_vogons = 2ub, 23ub, 230ub ;
:Number_of_vogon_poems = 23232244UL, 1214124123423UL, 2353424234UL ;
:Number_of_vogon_poems = 23232244ULL, 1214124123423ULL, 2353424234ULL ;
group: solar_system {
group: Earth {
// global attributes:
:alien_concept_number_which_cannot_be_understood_by_humans = -23232244L, 1214124123423L, -2353424234L ;
:alien_concept_number_which_cannot_be_understood_by_humans = -23232244, 1214124123423, -2353424234 ;
group: Luna {
variables:

View File

@ -1,6 +1,6 @@
#!/bin/sh
if test "x$SETX" = x1 ; then echo "file=$0"; set -x ; fi
#set -e
set -x
echo "*** ctests.sh: testing ncgen4 -c"
KFLAG=3

View File

@ -20,7 +20,7 @@ variables:
s:b = 0b, 127b, -128b, -1b ;
s:s = -32768s, 0s, 32767s ;
int i ;
i:i = -2147483647L, 0L, 2147483647L ;
i:i = -2147483647, 0, 2147483647 ;
i:f = -1.e+36f, 0.f, 1.e+36f ;
i:d = -1.e+308, 0., 1.e+308 ;
float f ;
@ -102,7 +102,7 @@ variables:
:Gc = "" ;
:Gb = -128b, 127b ;
:Gs = -32768s, 0s, 32767s ;
:Gi = -2147483647L, 0L, 2147483647L ;
:Gi = -2147483647, 0, 2147483647 ;
:Gf = -1.e+36f, 0.f, 1.e+36f ;
:Gd = -1.e+308, 0., 1.e+308 ;
:Gatt-name-dashes = -1 ;

View File

@ -20,7 +20,7 @@ variables:
s:b = 0b, 127b, -128b, -1b ;
s:s = -32768s, 0s, 32767s ;
int i ;
i:i = -2147483647L, 0L, 2147483647L ;
i:i = -2147483647, 0, 2147483647 ;
i:f = -1.e+36f, 0.f, 1.e+36f ;
i:d = -1.e+308, 0., 1.e+308 ;
float f ;
@ -102,7 +102,7 @@ variables:
:Gc = "" ;
:Gb = -128b, 127b ;
:Gs = -32768s, 0s, 32767s ;
:Gi = -2147483647L, 0L, 2147483647L ;
:Gi = -2147483647, 0, 2147483647 ;
:Gf = -1.e+36f, 0.f, 1.e+36f ;
:Gd = -1.e+308, 0., 1.e+308 ;
:Gatt-name-dashes = -1 ;

View File

@ -20,7 +20,7 @@ variables:
s:b = 0b, 127b, -128b, -1b ;
s:s = -32768s, 0s, 32767s ;
int i ;
i:i = -2147483647L, 0L, 2147483647L ;
i:i = -2147483647, 0, 2147483647 ;
i:f = -1.e+36f, 0.f, 1.e+36f ;
i:d = -1.e+308, 0., 1.e+308 ;
float f ;
@ -102,7 +102,7 @@ variables:
:Gc = "" ;
:Gb = -128b, 127b ;
:Gs = -32768s, 0s, 32767s ;
:Gi = -2147483647L, 0L, 2147483647L ;
:Gi = -2147483647, 0, 2147483647 ;
:Gf = -1.e+36f, 0.f, 1.e+36f ;
:Gd = -1.e+308, 0., 1.e+308 ;
:Gatt-name-dashes = -1 ;

View File

@ -4,14 +4,14 @@ dimensions:
// global attributes:
:Number_of_vogons = 2UB, 23UB, 230UB ;
:Number_of_vogon_poems = 23232244UL, 1214124123423UL, 2353424234UL ;
:Number_of_vogon_poems = 23232244ULL, 1214124123423ULL, 2353424234ULL ;
group: solar_system {
group: Earth {
// group attributes:
:alien_concept_number_which_cannot_be_understood_by_humans = -23232244L, 1214124123423L, -2353424234L ;
:alien_concept_number_which_cannot_be_understood_by_humans = -23232244LL, 1214124123423LL, -2353424234LL ;
group: Luna {
variables:

15
ncdump/inttags.cdl Normal file
View File

@ -0,0 +1,15 @@
netcdf inttags {
dimensions:
d = 3 ;
variables:
byte b(d);
short s(d);
int i(d);
data:
b = -127B, 127b, 255b ;
s = 32767S, -32766s, 65535s;
i = -2147483646L, 2147483647l, 4294967295l;
}

23
ncdump/inttags4.cdl Normal file
View File

@ -0,0 +1,23 @@
netcdf inttags64 {
dimensions:
d = 3 ;
variables:
ubyte ub(d);
ushort us(d);
uint ui(d);
int64 i64(d);
uint64 ui64(d);
// global attributes:
:attrll = -23232244LL, 1214124123423LL, -2353424234LL ;
data:
ub = 255UB, 255ub, 255u ;
us = 65534US, 65534us, 65534u ;
ui = 4294967294UL, 4294967294ul, 4294967294u ;
i64 = 9223372036854775807LL, 9223372036854775807ll, 9223372036854775807 ;
ui64 = 18446744073709551615ULL, 18446744073709551615ull, 18446744073709551615u ;
}

View File

@ -606,11 +606,11 @@ pr_att_valgs(
break;
case NC_INT64:
i64 = ((int64_t *) vals)[iel];
printf ("%lldL%s", i64, delim);
printf ("%lldLL%s", i64, delim);
break;
case NC_UINT64:
ui64 = ((uint64_t *) vals)[iel];
printf ("%lluUL%s", ui64, delim);
printf ("%lluULL%s", ui64, delim);
break;
#ifdef USE_NETCDF4
case NC_STRING:

View File

@ -28,9 +28,9 @@ variables:
double d ;
d:c = "abcd\tZ$&" ;
int64 i64 ;
i64:att_int64 = 1L ;
i64:att_int64 = 1LL ;
uint64 ui64 ;
ui64:att_uint64 = 1UL ;
ui64:att_uint64 = 1ULL ;
char cr(Dr) ;
byte br(Dr) ;
short sr(Dr) ;

15
ncdump/ref_inttags.cdl Normal file
View File

@ -0,0 +1,15 @@
netcdf inttags {
dimensions:
d = 3 ;
variables:
byte b(d) ;
short s(d) ;
int i(d) ;
data:
b = -127, 127, -1 ;
s = 32767, -32766, -1 ;
i = -2147483646, 2147483647, -1 ;
}

24
ncdump/ref_inttags4.cdl Normal file
View File

@ -0,0 +1,24 @@
netcdf inttags4 {
dimensions:
d = 3 ;
variables:
ubyte ub(d) ;
ushort us(d) ;
uint ui(d) ;
int i64(d) ;
uint64 ui64(d) ;
// global attributes:
:attrll = -23232244LL, 1214124123423LL, -2353424234LL ;
data:
ub = 255, 255, 255 ;
us = 65534, 65534, 65534 ;
ui = 4294967294, 4294967294, 4294967294 ;
i64 = -1, -1, -1 ;
ui64 = 18446744073709551615, 18446744073709551615, 18446744073709551615 ;
}

View File

@ -4,14 +4,14 @@ dimensions:
// global attributes:
:Number_of_vogons = 2UB, 23UB, 230UB ;
:Number_of_vogon_poems = 23232244UL, 1214124123423UL, 2353424234UL ;
:Number_of_vogon_poems = 23232244ULL, 1214124123423ULL, 2353424234ULL ;
group: solar_system {
group: Earth {
// group attributes:
:alien_concept_number_which_cannot_be_understood_by_humans = -23232244L, 1214124123423L, -2353424234L ;
:alien_concept_number_which_cannot_be_understood_by_humans = -23232244LL, 1214124123423LL, -2353424234LL ;
group: Luna {
variables:

View File

@ -1,4 +1,5 @@
#!/bin/sh
if test "x$SETX" = x1 ; then echo "file=$0"; set -x ; fi
# This shell script runs the backward compatibility tests.
set -e

View File

@ -1,4 +1,5 @@
#!/bin/sh
if test "x$SETX" = x1 ; then echo "file=$0"; set -x ; fi
# This shell script runs the ncdump tests.
# $Id: run_tests.sh,v 1.18 2010/05/19 13:43:39 ed Exp $

View File

@ -1,4 +1,5 @@
#!/bin/sh
if test "x$SETX" = x1 ; then echo "file=$0"; set -x ; fi
#
# Moving some netcdf-4 only tests here, out of tst_nccopy and run_utf8_tests.
# Without this, the tests fail when netcdf-4 is disabled.

View File

@ -1,4 +1,5 @@
#!/bin/sh
if test "x$SETX" = x1 ; then echo "file=$0"; set -x ; fi
# This shell script runs ncdump tests relating to the new UTF8 name stuff.
# $Id:$

View File

@ -1,4 +1,5 @@
#!/bin/sh
if test "x$SETX" = x1 ; then echo "file=$0"; set -x ; fi
# This shell script runs the ncdump tests.
# $Id: tst_64bit.sh,v 1.9 2006/03/04 18:50:15 ed Exp $

View File

@ -1,4 +1,5 @@
#!/bin/sh
if test "x$SETX" = x1 ; then echo "file=$0"; set -x ; fi
# This shell script tests BOM support in ncgen
set -e

View File

@ -1,4 +1,5 @@
#!/bin/sh
if test "x$SETX" = x1 ; then echo "file=$0"; set -x ; fi
# This shell script tests ncdump -t option for CF calendar attributes
# $Id $

View File

@ -1,4 +1,5 @@
#!/bin/sh
if test "x$SETX" = x1 ; then echo "file=$0"; set -x ; fi
# This shell script runs an ncgen buf in handling character _Fillvalue.
set -e
echo ""

View File

@ -1,4 +1,5 @@
#!/bin/sh
if test "x$SETX" = x1 ; then echo "file=$0"; set -x ; fi
# This shell script runs an ncdump bug test for netcdf-4
# $Id: tst_fillbug.sh,v 1.1 2008/10/02 19:49:52 russ Exp $

View File

@ -1,4 +1,5 @@
#!/bin/sh
if test "x$SETX" = x1 ; then echo "file=$0"; set -x ; fi
# This shell script tests the output several previous tests.
# $Id: tst_output.sh,v 1.17 2010/05/14 16:21:15 ed Exp $

View File

@ -1,4 +1,5 @@
#!/bin/sh
if test "x$SETX" = x1 ; then echo "file=$0"; set -x ; fi
# This shell script tests the output several previous tests.
# $Id: tst_output.sh,v 1.17 2010/05/14 16:21:15 ed Exp $

View File

@ -1,4 +1,5 @@
#!/bin/sh
if test "x$SETX" = x1 ; then echo "file=$0"; set -x ; fi
# This shell script tests ncdump -g option for specifying groups for
# which data is to be output.
# $Id$

View File

@ -1,4 +1,5 @@
#!/bin/sh
if test "x$SETX" = x1 ; then echo "file=$0"; set -x ; fi
# This shell script runs ncdump to verify scalar attribute and variable output
set -e

View File

@ -1,7 +1,7 @@
#!/bin/sh
if test "x$SETX" = x1 ; then echo "file=$0"; set -x ; fi
verbose=1
set -e
set -x
if test "x$builddir" = "x"; then builddir=`pwd`; fi
if test "x$srcdir" = "x"; then srcdir=`dirname $0`; fi

View File

@ -1,7 +1,7 @@
#!/bin/sh
if test "x$SETX" = x1 ; then echo "file=$0"; set -x ; fi
verbose=1
set -e
set -x
if test "x$builddir" = "x"; then builddir=`pwd`; fi
if test "x$srcdir" = "x"; then srcdir=`dirname $0`; fi

20
ncdump/tst_inttags.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/sh
if test "x$SETX" = x1 ; then echo "file=$0"; set -x ; fi
set -e
if test "x$srcdir" = x ; then
srcdir=`pwd`
fi
echo "*** Test integer constant suffixes"
echo "*** creating inttags.nc from inttags.cdl..."
../ncgen/ncgen -lb -o inttags.nc $srcdir/inttags.cdl
echo "*** creating tst_inttags.cdl from inttags.nc..."
./ncdump inttags.nc > tst_inttags.cdl
echo "*** comparing tst_inttags.cdl to ref_inttags.nc..."
diff -b -w tst_inttags.cdl $srcdir/ref_inttags.cdl
rm inttags.nc tst_inttags.cdl
exit 0

21
ncdump/tst_inttags4.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/sh
if test "x$SETX" = x1 ; then echo "file=$0"; set -x ; fi
set -e
if test "x$srcdir" = x ; then
srcdir=`pwd`
fi
echo "*** Test netcdf-4 integer constant suffixes"
echo "*** creating inttags4.nc from inttags4.cdl..."
../ncgen/ncgen -lb -o inttags4.nc $srcdir/inttags4.cdl
echo "*** creating tst_inttags4.cdl from inttags4.nc..."
./ncdump inttags4.nc > tst_inttags4.cdl
echo "*** comparing tst_inttags4.cdl to ref_inttags4.nc..."
diff -b -w tst_inttags4.cdl $srcdir/ref_inttags4.cdl
rm inttags4.nc tst_inttags4.cdl
exit 0

View File

@ -1,4 +1,5 @@
#!/bin/sh
if test "x$SETX" = x1 ; then echo "file=$0"; set -x ; fi
# This shell script runs an ncdump bug test for netcdf
# Test if the nciter code is working [NCF-154]

View File

@ -1,4 +1,5 @@
#!/bin/sh
if test "x$SETX" = x1 ; then echo "file=$0"; set -x ; fi
# This shell script tests lengths of small netcdf files and tests
# that rewriting a numeric value doesn't change file length
# $Id: tst_lengths.sh,v 1.10 2008/08/07 00:07:52 ed Exp $
@ -19,7 +20,6 @@
# }
# EOF
# cat > test-len.sh << 'EOF'
# #!/bin/sh
# # test that length of file $1 is $2
# len=`ls -l $1|awk '{print $5}'`
# if [ $len = $2 ]; then

View File

@ -1,4 +1,5 @@
#!/bin/sh
if test "x$SETX" = x1 ; then echo "file=$0"; set -x ; fi
# This shell script tests ncdump and ncgen on netCDF-4 variables with multiple
# unlimited dimensions.
# $Id $

View File

@ -1,4 +1,5 @@
#!/bin/sh
if test "x$SETX" = x1 ; then echo "file=$0"; set -x ; fi
# For a netCDF-3 build, test nccopy on netCDF files in this directory
set -e

View File

@ -1,4 +1,5 @@
#!/bin/sh
if test "x$SETX" = x1 ; then echo "file=$0"; set -x ; fi
# For a netCDF-4 build, test nccopy on netCDF files in this directory
set -e

View File

@ -1,4 +1,5 @@
#!/bin/sh
if test "x$SETX" = x1 ; then echo "file=$0"; set -x ; fi
verbose=1
set -e

View File

@ -1,4 +1,5 @@
#!/bin/sh
if test "x$SETX" = x1 ; then echo "file=$0"; set -x ; fi
set -e
echo ""

View File

@ -1,4 +1,5 @@
#!/bin/sh
if test "x$SETX" = x1 ; then echo "file=$0"; set -x ; fi
. ${srcdir}/tst_ncgen_shared.sh

View File

@ -1,4 +1,11 @@
#!/bin/sh
if test "x$SETX" = x1 ; then echo "file=$0"; set -x ; fi
if test "x$srcdir" = "x"; then srcdir=`pwd`; fi
if test "x$builddir" = "x"; then builddir=`pwd`; fi
#for sunos
export srcdir;
export builddir;
. ${srcdir}/tst_ncgen_shared.sh
@ -18,7 +25,7 @@ echo "*** Testing ncgen with -k${KFLAG}"
cd ${RESULTSDIR}
for x in ${TESTSET} ; do
test $verbose = 1 && echo "*** Testing: ${x}"
if test $verbose = 1 ; then echo "*** Testing: ${x}" ; fi
# determine if we need the specflag set
specflag=
headflag=
@ -56,7 +63,7 @@ cd ..
totalcount=`expr $passcount + $failcount + $xfailcount`
okcount=`expr $passcount + $xfailcount`
#set -x
echo "*** PASSED: ${okcount}/${totalcount} ; ${xfailcount} expected failures ; ${failcount} unexpected failures"
if test $failcount -gt 0 ; then

View File

@ -1,4 +1,5 @@
#!/bin/sh
if test "x$SETX" = x1 ; then echo "file=$0"; set -x ; fi
# To add a new test,
# 1. put the .cdl file in the 'cdl' directory

View File

@ -1,4 +1,5 @@
#!/bin/sh
if test "x$SETX" = x1 ; then echo "file=$0"; set -x ; fi
# This shell script tests ncdump for netcdf-4
# $Id: tst_netcdf4.sh,v 1.34 2009/09/25 18:22:10 dmh Exp $
@ -14,6 +15,7 @@ echo ""
echo "*** Testing ncgen and ncdump test output for netCDF-4 format."
# echo "*** creating netcdf-4 file c0_4.nc from c0_4.cdl..."
../ncgen/ncgen -k nc4 -b -o c0_4.nc $srcdir/../ncgen/c0_4.cdl
# echo "*** creating c1_4.cdl from c0_4.nc..."
./ncdump -n c1 c0_4.nc | sed 's/e+0/e+/g' > c1_4.cdl
# echo "*** comparing c1_4.cdl with ref_ctest1_nc4.cdl..."

View File

@ -1,4 +1,5 @@
#!/bin/sh
if test "x$SETX" = x1 ; then echo "file=$0"; set -x ; fi
# This shell script runs extra tests ncdump for netcdf-4
# $Id: tst_netcdf4_4.sh,v 1.13 2009/05/06 14:51:52 ed Exp $

View File

@ -1,4 +1,5 @@
#!/bin/sh
if test "x$SETX" = x1 ; then echo "file=$0"; set -x ; fi
# This shell script tests the output from several previous tests.
set -e

16
ncf345-mytest.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
#
# git-bisect script for ncf-345. Note you need to put it outside
# the netcdf directory or it will disappear when git does its thing.
#
mkdir -p build
cd build
cmake .. -DENABLE_TESTS=OFF -DBUILD_SHARED_LIBS=OFF
make -j 4
ncgen/ncgen -b -o ~/Desktop/in.nc ~/Desktop/in.cdl
RES=$?
rm -f ~/Desktop/in.nc
cd ..
echo "Exiting: $RES"
exit $RES

View File

@ -1,4 +1,4 @@
SET(ncgen_FILES generate.c main.c cdata.c bindata.c genchar.c cvt.c data.c debug.c escapes.c genc.c genbin.c generr.c genlib.c getfill.c odom.c offsets.c semantics.c ncgentab.c dump.c util.c bytebuffer.c list.c genf77.c f77data.c genj.c jdata.c nc_iter.c ConvertUTF.c )
SET(ncgen_FILES generate.c main.c cdata.c bindata.c genchar.c cvt.c data.c debug.c escapes.c genc.c genbin.c generr.c genlib.c getfill.c odom.c offsets.c semantics.c ncgeny.c dump.c util.c bytebuffer.c list.c genf77.c f77data.c genj.c jdata.c nc_iter.c ConvertUTF.c )
IF(USE_X_GETOPT)
SET(ncgen_FILES ${ncgen_FILES} XGetopt.c)
@ -14,9 +14,9 @@ TARGET_LINK_LIBRARIES(ncgen netcdf ${ALL_TLL_LIBS})
# test scripts to work.
####
IF(MSVC)
SET_TARGET_PROPERTIES(ncgen PROPERTIES RUNTIME_OUTPUT_DIRECTORY
SET_TARGET_PROPERTIES(ncgen PROPERTIES RUNTIME_OUTPUT_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR})
SET_TARGET_PROPERTIES(ncgen PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG
SET_TARGET_PROPERTIES(ncgen PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG
${CMAKE_CURRENT_BINARY_DIR})
SET_TARGET_PROPERTIES(ncgen PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE
${CMAKE_CURRENT_BINARY_DIR})
@ -31,7 +31,7 @@ FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
# Stuff to build if tests are enabled.
IF(ENABLE_TESTS)
FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cdl ${CMAKE_CURRENT_SOURCE_DIR}/*.sh)
FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/ FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE)
FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/ FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE)
add_sh_test(ncgen run_tests)
IF(USE_NETCDF4)
add_sh_test(ncgen run_nc4_tests)
@ -46,7 +46,7 @@ ENDIF()
SET(CLEANFILES c0.nc c0_64.nc c0_4.nc c0_4c.nc ref_camrun.c)
SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CLEANFILES}")
# These rules are used if someone wants to rebuild ncgenyy.c or ncgentab.c
# These rules are used if someone wants to rebuild ncgeny.c or ncgenl.c
# Otherwise never invoked, but records how to do it.
# BTW: note that renaming is essential because otherwise
# autoconf will forcibly delete files of the name *.tab.*
@ -54,20 +54,20 @@ SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CLEANFILES}")
ADD_CUSTOM_COMMAND(
OUTPUT ncgentab.h
COMMAND flex -Pncg -B ncgen.l
COMMAND rm -f ncgenyy.c
COMMAND mv lex.ncg.c ncgenyy.c
COMMAND rm -f ncgenl.c
COMMAND mv lex.ncg.c ncgenl.c
COMMAND bison -pncg -t -d ncgen.y
COMMAND rm -f ncgentab.c ncgentab.h
COMMAND mv ncgen.tab.c ncgentab.c
COMMAND mv ncgen.tab.h ncgentab.h
COMMAND mv ncgentab.h ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND mv ncgentab.c ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND mv ncgenyy.c ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND rm -f ncgeny.c ncgeny.h
COMMAND mv ncgen.tab.c ncgeny.c
COMMAND mv ncgen.tab.h ncgeny.h
COMMAND mv ncgeny.h ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND mv ncgeny.c ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND mv ncgenl.c ${CMAKE_CURRENT_SOURCE_DIR}
)
ADD_CUSTOM_TARGET(makeparser DEPENDS ncgentab.h)
## Specify files to be distributed by 'make dist'
FILE(GLOB CUR_EXTRA_DIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.c ${CMAKE_CURRENT_SOURCE_DIR}/*.h ${CMAKE_CURRENT_SOURCE_DIR}/*.sh)
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} ncgen.y ncgenyy.c ncgen.l internals.html c0.cdl c0_4.cdl ref_camrun.cdl ncf199.cdl CMakeLists.txt Makefile.am ncgen.1)
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} ncgen.y ncgenl.c ncgen.l internals.html c0.cdl c0_4.cdl ref_camrun.cdl ncf199.cdl CMakeLists.txt Makefile.am ncgen.1)
ADD_EXTRA_DIST("${CUR_EXTRA_DIST}")

View File

@ -11,16 +11,17 @@ bin_PROGRAMS = ncgen
ncgen_SOURCES=generate.c main.c cdata.c bindata.c genchar.c cvt.c data.c debug.c \
escapes.c genc.c genbin.c generr.c genlib.c getfill.c odom.c offsets.c \
semantics.c ncgentab.c dump.c util.c bytebuffer.c list.c data.h \
semantics.c dump.c util.c bytebuffer.c list.c data.h \
debug.h generr.h genlib.h includes.h ncgen.h odom.h offsets.h dump.h \
util.h bytebuffer.h list.h genf77.c f77data.c genj.c jdata.c nc_iter.h \
nc_iter.c ConvertUTF.c ConvertUTF.h
nc_iter.c ConvertUTF.c ConvertUTF.h \
ncgeny.c ncgeny.h
# This is the man page.
man_MANS = ncgen.1
# These files all need to be distributed.
EXTRA_DIST = ncgen.y ncgenyy.c ncgen.l $(man_MANS) internals.html \
EXTRA_DIST = ncgen.y ncgen.l ncgenl.c $(man_MANS) internals.html \
run_tests.sh run_nc4_tests.sh c0.cdl c0_4.cdl ref_camrun.cdl \
ncf199.cdl CMakeLists.txt XGetopt.c c5.cdl
@ -36,16 +37,16 @@ endif # USE_NETCDF4
CLEANFILES = c0.nc c0_64.nc c0_4.nc c0_4c.nc ref_camrun.c \
ncf199.nc c5.nc
# These rules are used if someone wants to rebuild ncgenyy.c or ncgentab.c
# These rules are used if someone wants to rebuild ncgenl.c or ncgeny.c
# Otherwise never invoked, but records how to do it.
# BTW: note that renaming is essential because otherwise
# autoconf will forcibly delete files of the name *.tab.*
makeparser::
flex -Pncg -8 ncgen.l
rm -f ncgenyy.c
sed -e s/lex.ncg.c/ncgenyy.c/g <lex.ncg.c >ncgenyy.c
flex -L -Pncg -8 ncgen.l
rm -f ncgenl.c
sed -e s/lex.ncg.c/ncgenl.c/g <lex.ncg.c >ncgenl.c
bison -pncg -t -d ncgen.y
rm -f ncgentab.c ncgentab.h
sed -e s/ncgen.tab.c/ncgentab.c/g -e s/ncgen.tab.h/ncgentab.h/g <ncgen.tab.c >ncgentab.c
sed -e s/ncgen.tab.c/ncgentab.c/g -e s/ncgen.tab.h/ncgentab.h/g <ncgen.tab.h >ncgentab.h
rm -f ncgeny.c ncgeny.h
sed -e s/ncgen.tab.c/ncgeny.c/g -e s/ncgen.tab.h/ncgeny.h/g <ncgen.tab.c >ncgeny.c
sed -e s/ncgen.tab.c/ncgeny.c/g -e s/ncgen.tab.h/ncgeny.h/g <ncgen.tab.h >ncgeny.h

View File

@ -20,7 +20,7 @@ variables:
s:b = 0b, 127b, -128b, -1b ;
s:s = -32768s, 0s, 32767s ;
int i ;
i:i = -2147483647, 0, 2147483647 ;
i:i = -2147483647, 0, 2147483647L ;
i:f = -1.e+36f, 0.f, 1.e+36f ;
i:d = -1.e+308, 0., 1.e+308 ;
float f ;
@ -28,9 +28,9 @@ variables:
double d ;
d:c = "abcd\tZ$&" ;
int64 i64 ;
i64:att_int64 = 1L ;
i64:att_int64 = 1LL ;
uint64 ui64 ;
ui64:att_uint64 = 1UL ;
ui64:att_uint64 = 1ULL ;
char cr(Dr) ;
byte br(Dr) ;
short sr(Dr) ;
@ -127,9 +127,9 @@ data:
d = -10 ;
i64 = 9223372036854775807L;
i64 = 9223372036854775807LL;
ui64 = 18446744073709551615UL;
ui64 = 18446744073709551615ULL;
cr = "ab" ;

View File

@ -64,10 +64,10 @@ c_constant(Generator* generator, NCConstant* con, Bytebuffer* buf,...)
bbprintf(codetmp,"%lf",con->value.doublev);
break;
case NC_UBYTE:
bbprintf(codetmp,"%hhu",con->value.uint8v);
bbprintf(codetmp,"%hhuU",con->value.uint8v);
break;
case NC_USHORT:
bbprintf(codetmp,"%hu",con->value.uint16v);
bbprintf(codetmp,"%huU",con->value.uint16v);
break;
case NC_UINT:
bbprintf(codetmp,"%uU",con->value.uint32v);
@ -76,7 +76,7 @@ c_constant(Generator* generator, NCConstant* con, Bytebuffer* buf,...)
bbprintf(codetmp,"%lldLL",con->value.int64v);
break;
case NC_UINT64:
bbprintf(codetmp,"%lluLLU",con->value.uint64v);
bbprintf(codetmp,"%lluULL",con->value.uint64v);
break;
case NC_ECONST:
bbprintf(codetmp,"%s",cname(con->value.enumv));

View File

@ -153,6 +153,12 @@ srcpeek(Datasrc* ds)
return NULL;
}
void
srcreset(Datasrc* ds)
{
ds->index = 0;
}
NCConstant*
srcnext(Datasrc* ds)
{

View File

@ -122,6 +122,8 @@ void srcsetfill(Datasrc* ds, Datalist* list);
NCConstant* srcnext(Datasrc*);
int srcmore(Datasrc*);
int srcline(Datasrc* ds);
void srcreset(Datasrc* ds);
#define srclen(s) ((s)==NULL?0:(s)->length)
#define islistconst(con) ((con)!=NULL && (con)->nctype == NC_COMPOUND)
#define isfillconst(con) ((con)!=NULL && (con)->nctype == NC_FILLVALUE)

View File

@ -27,11 +27,27 @@ vderror(const char *fmt, va_list argv)
void
vderror(fmt,va_alist) const char* fmt; va_dcl
#endif
{
(void) vdwarn(fmt,argv);
error_count++;
}
/*
* For logging error conditions.
* Designed to be called by other vararg procedures
*/
#ifndef NO_STDARG
void
vdwarn(const char *fmt, va_list argv)
#else
/* Technically illegal; va_alist should be only arg */
void
vdwarn(fmt,va_alist) const char* fmt; va_dcl
#endif
{
(void) vfprintf(stderr,fmt,argv) ;
(void) fputc('\n',stderr) ;
(void) fflush(stderr); /* to ensure log files are current */
error_count++;
}
#ifndef NO_STDARG
@ -76,7 +92,7 @@ semwarn(lno,fmt,va_alist) const int lno; const char* fmt; va_dcl
va_list argv;
vastart(argv,fmt);
(void)fprintf(stderr,"%s: %s line %d: ", progname, cdlname, lno);
vderror(fmt,argv);
vdwarn(fmt,argv);
}
#ifndef NO_STDARG

View File

@ -19,17 +19,23 @@ extern int error_count;
#ifndef NO_STDARG
#include <stdarg.h>
extern void vderror(const char *fmt, va_list argv);
extern void vdwarn(const char *fmt, va_list argv);
extern void derror(const char *fmt, ...);
extern int panic(const char* fmt, ...);
extern void nprintf(char* buffer, size_t size, const char *fmt, ...);
extern void semerror(const int, const char *fmt, ...);
extern void semwarn(const int, const char *fmt, ...);
#else
#include <varargs.h>
/* Technically illegal; va_alist should be only arg */
extern void vderror(fmt,va_alist) const char* fmt; va_dcl;
extern void vdwarn(fmt,va_alist) const char* fmt; va_dcl;
extern void derror(fmt,va_alist) const char* fmt; va_dcl;
extern void panic(fmt,va_alist) const char* fmt; va_dcl;
extern void nprintf(buffer,size,fmt)
char* buffer; size_t size; const char* fmt; va_dcl;
extern void semerror(lno,fmt,va_alist) const int lno; const char* fmt; va_dcl;
extern void semwarnlno,fmt,va_alist) const int lno; const char* fmt; va_dcl;
#endif
#endif /*GENERR_H*/

View File

@ -97,13 +97,6 @@ extern Symbol* locate(Symbol* refsym);
extern Symbol* lookup(nc_class objectclass, Symbol* pattern);
extern Symbol* lookupingroup(nc_class objectclass, char* name, Symbol* grp);
extern Symbol* lookupgroup(List* prefix);
#ifndef NO_STDARG
extern void semerror(const int, const char *fmt, ...);
extern void semwarn(const int, const char *fmt, ...);
#else
extern void semerror(lno,fmt,va_alist) const int lno; const char* fmt; va_dcl;
extern void semwarnlno,fmt,va_alist) const int lno; const char* fmt; va_dcl;
#endif
extern int nounlimited(Dimset* dimset, int from);
extern int lastunlimited(Dimset* dimset);
extern void padstring(NCConstant* con, size_t desiredlength, int fillchar);

View File

@ -244,7 +244,7 @@ main(
(void) par_io_init(32, 32);
#endif
while ((c = getopt(argc, argv, "134567bB:cdD:fhk:l:M:no:Pv:x")) != EOF)
while ((c = getopt(argc, argv, "134567bB:cdD:fhHk:l:M:no:Pv:x")) != EOF)
switch(c) {
case 'd':
debug = 1;
@ -278,6 +278,9 @@ main(
case 'h':
header_only = 1;
break;
case 'H':
usage();
exit(0);
case 'l': /* specify language, instead of using -c or -f or -b */
{
if(l_flag != 0) {
@ -317,7 +320,7 @@ main(
break;
case 'v': /* a deprecated alias for "kind" option */
/*FALLTHRU*/
case 'k': /* for specifying variant of netCDF format to be generated
case 'k': { /* for specifying variant of netCDF format to be generated
Possible values are:
Format names:
"classic" or "nc3"
@ -333,28 +336,27 @@ main(
4 (=> netCDF-4 classic model)
5 (=> classic 64 bit data aka CDF-5)
*/
{
struct Kvalues* kvalue;
char *kind_name = (optarg != NULL ? (char *) emalloc(strlen(optarg)+1)
: emalloc(1));
if (! kind_name) {
derror ("%s: out of memory", progname);
return(1);
}
if(optarg != NULL)
(void)strcpy(kind_name, optarg);
for(kvalue=legalkinds;kvalue->name;kvalue++) {
if(strcmp(kind_name,kvalue->name) == 0) {
k_flag = kvalue->k_flag;
break;
}
}
if(kvalue->name == NULL) {
derror("Invalid format: %s",kind_name);
return 2;
}
struct Kvalues* kvalue;
char *kind_name = (optarg != NULL
? (char *) emalloc(strlen(optarg)+1)
: emalloc(1));
if (! kind_name) {
derror ("%s: out of memory", progname);
return(1);
}
break;
if(optarg != NULL)
(void)strcpy(kind_name, optarg);
for(kvalue=legalkinds;kvalue->name;kvalue++) {
if(strcmp(kind_name,kvalue->name) == 0) {
k_flag = kvalue->k_flag;
break;
}
}
if(kvalue->name == NULL) {
derror("Invalid format: %s",kind_name);
return 2;
}
} break;
case '3': /* output format is classic (netCDF-3) */
k_flag = NC_FORMAT_CLASSIC;
break;
@ -479,8 +481,6 @@ main(
}
}
/* Standard Unidata java interface => usingclassic */
parse_init();
ncgin = fp;
if(debug >= 2) {ncgdebug=1;}
@ -529,15 +529,32 @@ main(
if(k_flag == 0)
k_flag = 1;
usingclassic = (k_flag <= 2 || k_flag == 4 || k_flag == 5)?1:0;
/* Figure out usingclassic */
switch (k_flag) {
case NC_FORMAT_64BIT_DATA:
case NC_FORMAT_CLASSIC:
case NC_FORMAT_64BIT_OFFSET:
case NC_FORMAT_NETCDF4_CLASSIC:
usingclassic = 1;
break;
case NC_FORMAT_NETCDF4:
default:
usingclassic = 0;
break;
}
/* compute cmode_modifier */
switch (k_flag) {
case 1: cmode_modifier = 0; break;
case 2: cmode_modifier = NC_64BIT_OFFSET; break;
case 3: cmode_modifier = NC_NETCDF4; break;
case 4: cmode_modifier = NC_NETCDF4 | NC_CLASSIC_MODEL; break;
case 5: cmode_modifier = NC_CDF5; break;
case NC_FORMAT_CLASSIC:
cmode_modifier = 0; break;
case NC_FORMAT_64BIT_OFFSET:
cmode_modifier = NC_64BIT_OFFSET; break;
case NC_FORMAT_NETCDF4:
cmode_modifier = NC_NETCDF4; break;
case NC_FORMAT_NETCDF4_CLASSIC:
cmode_modifier = NC_NETCDF4 | NC_CLASSIC_MODEL; break;
case NC_FORMAT_64BIT_DATA:
cmode_modifier = NC_CDF5; break;
default: ASSERT(0); /* cannot happen */
}

1743
ncgen/ncf345.cdl Normal file

File diff suppressed because it is too large Load Diff

View File

@ -490,7 +490,7 @@ except that type suffixes must be appended to shorts and floats to
distinguish them from longs and doubles.
.LP
A \fIbyte\fP constant is represented by
an integer constant with a `b' (or
an integer constant with a `b' (or
`B') appended. In the old netCDF-2 API, byte constants could also be
represented using single characters or standard C character escape
sequences such as `a' or `\n'. This is still supported for backward
@ -520,8 +520,11 @@ begins with `0', it is interpreted as octal, except that if it begins with
.LP
\fIint\fP integer constants are intended for representing 32-bit signed
quantities. The form of an \fIint\fP constant is an ordinary integer
constant, although it is acceptable to append an optional `l' or
`L' (again, deprecated).
constant, although it is acceptable to optionally append a single `l' or
`L' (again, deprecated). Be careful, though, the L suffix is interpreted
as a 32 bit integer, and never as a 64 bit integer. This can be confusing
since the C long type can ambigously be either 32 bit or 64 bit.
.LP
If an \fIint\fP constant begins with `0', it is interpreted as
octal, except that if it begins with `0x', it is interpreted as a hexadecimal
constant (but see opaque constants below).
@ -578,8 +581,9 @@ For example the following are all acceptable \fIdouble\fP constants:
.LP
Unsigned integer constants can be created by appending
the character 'U' or 'u' between the constant and any trailing
size specifier. Thus one could say
10U, 100us, 100000ul, or 1000000ull, for example.
size specifier, or immediately at the end of the size specifier.
Thus one could say
10U, 100su, 100000ul, or 1000000llu, for example.
.LP
Single character constants may be enclosed in single quotes.
If a sequence of one or more characters is enclosed

View File

@ -73,13 +73,17 @@ static unsigned int MAX_UINT = NC_MAX_UINT;
#define NC_MAX_UINT MAX_UINT
#endif
#define TAG "BbSsLl"
#define TAGCHARS "BbSsLlUu"
#define tstdecimal(ch) ((ch) >= '0' && (ch) <= '9')
/*Mnemonics*/
#define ISIDENT 1
/* Define a fake constant indicating that
no tag was specified */
#define NC_NOTAG (-1)
char errstr[100]; /* for short error messages */
int lineno; /* line number for error messages */
@ -106,9 +110,10 @@ unsigned char ubyte_val; /* last byte value read */
static Symbol* makepath(char* text);
static int lexdebug(int);
static unsigned long long parseULL(char* text, int*);
static nc_type downconvert(unsigned long long uint64, int, int, int);
static int tagmatch(nc_type nct, int tag, int hasU);
static nc_type downconvert(unsigned long long uint64, int*, int, int);
static int tagmatch(nc_type nct, int tag);
static int nct2lexeme(nc_type nct);
static int collecttag(char* text, char** stagp);
static struct Specialtoken {
char* name;
@ -196,8 +201,8 @@ OPAQUESTRING (0[xX][0-9A-Fa-f][0-9A-Fa-f]*)
PATH ([/]|([/]{ID})([/]{ID})*)
XUNUMBER {OPAQUESTRING}[SsLl]
NUMBER [+-]?[0-9][0-9]*[Uu]?[BbSsLl]?
XUNUMBER {OPAQUESTRING}([Ss]|[Ll]|[Ll][Ll])?
NUMBER [+-]?[0-9][0-9]*[Uu]?([BbSs]|[Ll]|[Ll][Ll])?
DBLNUMBER [+-]?[0-9]*\.[0-9]*{exp}?[LlDd]?|[+-]?[0-9]*{exp}[LlDd]?
FLTNUMBER [+-]?[0-9]*\.[0-9]*{exp}?[Ff]|[+-]?[0-9]*{exp}[Ff]
@ -246,7 +251,7 @@ yytext[MAXTRST-1] = '\0';
if((len % 2) == 1) bbAppend(lextext,'0');
bbNull(lextext);
/* convert all chars to lower case */
for(p=bbContents(lextext);*p;p++) *p = tolower(*p);
for(p=bbContents(lextext);(int)*p;p++) *p = tolower(*p);
return lexdebug(OPAQUESTRING);
}
@ -364,33 +369,37 @@ NIL|nil|Nil {
}
{NUMBER} {
/*
We need to try to see what size of integer ((u)int).
Technically, the user should specify, but...
If out of any integer range, then complain
*/
/*
We need to try to see what size of integer ((u)int).
Technically, the user should specify, but...
If out of any integer range, then complain
*/
int slen = strlen(ncgtext);
int tag = ncgtext[slen-1];
int hasU = 0;
char* stag = NULL;
int tag = NC_NAT;
int signchar = 0;
int isneg = 0;
int c = ncgtext[0];
int fail = 0;
nc_type nct = 0;
char* pos = NULL;
int hasU = 0;
/* capture the tag string */
tag = collecttag(ncgtext,&stag);
if(tag == NC_NAT) {
sprintf(errstr,"Illegal integer suffix: %s",stag);
yyerror(errstr);
goto done;
}
/* drop the tag from the input text */
ncgtext[slen - strlen(stag)] = '\0';
hasU = isuinttype(tag);
if(!tstdecimal(c)) {
pos = ncgtext+1;
isneg = (c == '-');
} else
pos = ncgtext;
if(tag != '\0' && strchr(TAG,tag) != NULL) {
if(slen > 2) {
c = ncgtext[slen-2];
hasU = (c == 'U' || c == 'u') ? 1 : 0;
}
} else
tag = 0;
if(isneg && hasU) {
sprintf(errstr,"Unsigned integer cannot be signed: %s",ncgtext);
yyerror(errstr);
@ -403,7 +412,7 @@ If out of any integer range, then complain
goto done;
}
/* Down convert to smallest possible range */
nct = downconvert(uint64_val,isneg,tag,hasU);
nct = downconvert(uint64_val,&tag,isneg,hasU);
switch (k_flag) {
case NC_FORMAT_64BIT_DATA:
case NC_FORMAT_NETCDF4:
@ -417,10 +426,9 @@ If out of any integer range, then complain
goto done;
}
}
if(!tagmatch(nct,tag,hasU)) {
sprintf(errstr,"Integer out of range for tag: %s",ncgtext);
yyerror(errstr);
goto done;
if(!tagmatch(nct,tag)) {
semwarn(lineno,"Warning: Integer out of range for tag: %s; tag treated as changed.",ncgtext);
}
return lexdebug(nct2lexeme(nct));
done: return 0;
@ -430,10 +438,20 @@ done: return 0;
int c;
int token = 0;
int slen = strlen(yytext);
int tag = yytext[slen-1];
char* stag = NULL;
int tag = NC_NAT;
char* hex = yytext+2; /* point to first true hex digit */
int xlen = (slen - 3); /* true hex length */
yytext[slen-1] = '\0';
/* capture the tag string */
tag = collecttag(yytext,&stag);
if(tag == NC_NAT) {
sprintf(errstr,"Illegal integer suffix: %s",stag);
yyerror(errstr);
goto done;
}
yytext[slen - strlen(stag)] = '\0';
if(xlen > 16) { /* truncate hi order digits */
hex += (xlen - 16);
}
@ -444,11 +462,14 @@ done: return 0;
uint64_val = ((uint64_val << 4) | hexdigit);
}
switch (tag) {
case 'S': case 's':
case NC_USHORT:
uint16_val = (unsigned short)uint64_val;
token = USHORT_CONST;
break;
case 'L': case 'l':
case NC_UINT:
token = UINT_CONST;
break;
case NC_UINT64:
token = UINT64_CONST;
break;
default: /* should never happen */
@ -624,7 +645,7 @@ makepath(char* text0)
}
/*
Parse a simple string of digitis into an unsigned long long
Parse a simple string of digits into an unsigned long long
Return the value.
*/
static unsigned long long
@ -654,122 +675,114 @@ parseULL(char* text, int* failp)
/**
Given the raw bits, the sign char, the tag, and hasU
fill in the appropriate *_val field
and return the type
and return the type.
Note that we cannot return unsigned types if running pure netcdf classic.
The rule is to pick the smallest enclosing type.
The rule used here is that the tag (the suffix, if any)
always takes precedence and the value is modified to conform
if possible, otherwise out-of-range is signalled.
For historical reasons (ncgen3), values that fit as unsigned
are acceptable for the signed tag and conversion is attempted;
e.g. 65535s; is legal and is return as a negative short.
*/
static nc_type
downconvert(unsigned long long uint64, int isneg, int tag, int hasU)
downconvert(unsigned long long uint64, int* tagp, int isneg, int hasU)
{
nc_type nct = NC_NAT;
int bit64 = (uint64 >> 63);
int allones = (uint64 == 0xffffffffffffffffUL);
int tag = *tagp;
int bit63set = (uint64 >> 63);
long long int64 = *((long long*)&uint64);
if(isneg && hasU)
return NC_NAT;
/* Special cases: all (u)int64 values */
if(allones && (hasU || !isneg)) /* bare max uint64 value */
return NC_UINT64;
if((int64 < NC_MIN_INT) || (int64 > NC_MAX_INT)) {
if(isneg && !hasU) {
int64_val = - int64;
return NC_INT64;
}
if(!isneg && hasU) {
uint64_val = uint64;
return NC_UINT64;
}
/* Bare big integer, assume int64 unless sign bit set */
if(!isneg && !hasU && bit64) {
uint64_val = uint64;
return NC_UINT64;
} else if(!bit64) {
int64_val = int64;
return NC_INT64;
}
/*assert(!isneg)*/
if(isneg && hasU) {
return (*tagp = NC_NAT);
}
/* To simplify the code, we look for special case of NC_UINT64
constants that will not fit into an NC_INT64 constant.
*/
if(tag == NC_UINT64 && bit63set) {
uint64_val = uint64;
return NC_UINT64;
return tag;
}
/* At this point we need deal only with int64 value */
/* Apply the isneg */
if(isneg)
int64 = - int64;
if(isneg) int64 = -int64;
/* special case:
If there is no tag and the size is ok,
then always return NC_INT or NC_UINT.
*/
if(!tag) {
if(!hasU) {
if((int64 >= NC_MIN_INT) && (int64 <= NC_MAX_INT)) {
int32_val = (int)int64;
return NC_INT;
}
}
if(uint64 <= NC_MAX_UINT) {
uint32_val = (unsigned int)uint64;
return NC_INT;
if(tag == NC_NOTAG) {
/* If we have no other info, then assume NC_(U)INT(64) */
if(int64 >= NC_MIN_INT && int64 <= NC_MAX_INT) {
nct = (tag = NC_INT);
int32_val = (signed int)int64;
} else if(int64 >= 0 && int64 <= NC_MAX_UINT) {
nct = (tag = NC_UINT);
uint32_val = (unsigned int)int64;
} else if(int64 < 0) {
nct = (tag = NC_INT64);
int64_val = (signed long long)int64;
} else {
nct = (tag = NC_UINT64);
uint64_val = (unsigned long long)int64;
}
goto done;
}
/* assert (tag != 0) */
/* Pick smallest enclosing type;
for historical reasons (ncgen3), technically out of range
values are allowed and conversion is attempted;
e.g. 65535s; is legal and is return as an unsigned short.
*/
if(hasU) {
switch (tag) {
case 'B': case 'b':
if((int64 >= 0) && (int64 <= NC_MAX_UBYTE)) {
if(isuinttype(tag) && int64 < 0)
goto outofrange;
switch (tag) {
case NC_UBYTE:
if(int64 <= NC_MAX_UBYTE) {
nct = NC_UBYTE;
ubyte_val = (unsigned char)int64;
}; break;
case 'S': case 's':
if((int64 >= 0) && (int64 <= NC_MAX_USHORT)) {
} else
goto outofrange;
break;
case NC_USHORT:
if(int64 <= NC_MAX_USHORT) {
nct = NC_USHORT;
uint16_val = (unsigned short)int64;
} break;
case 'L': case 'l':
if((int64 >= 0) && (int64 <= NC_MAX_UINT64)) {
} else
goto outofrange;
break;
case NC_UINT:
if(int64 <= NC_MAX_UINT) {
nct = NC_UINT;
uint32_val = (unsigned int)int64;
} else
goto outofrange;
break;
case NC_UINT64:
if(int64 <= NC_MAX_UINT64) {
nct = NC_UINT64;
uint64_val = uint64;
} break;
default:
return NC_NAT;
}
} else { /* !hasU */
switch (tag) {
case 'B': case 'b':
if((int64 >= NC_MIN_BYTE) && (int64 <= NC_MAX_BYTE)) {
nct = NC_BYTE;
byte_val = (signed char)int64;
} else {/* force to unsigned value */
uint64_val = uint64 & 0xff;
nct = NC_UBYTE;
}
} else
goto outofrange;
break;
case 'S': case 's':
if((int64 >= NC_MIN_SHORT) && (int64 <= NC_MAX_SHORT)) {
nct = NC_SHORT;
int16_val = (signed short)int64;
} else {/* force to unsigned value */
uint64_val = uint64 & 0xffff;
nct = NC_USHORT;
}
case NC_INT64:
nct = NC_INT64;
int64_val = int64;
break;
case 'L': case 'l':
if((uint64 <= NC_MAX_INT64)) {
nct = NC_INT64;
int64_val = int64;
} else {/* force to unsigned value */
uint64_val = uint64;
nct = NC_UINT64;
}
case NC_BYTE:
nct = NC_BYTE;
byte_val = (signed char)int64;
break;
default:
return NC_NAT;
}
case NC_SHORT:
nct = NC_SHORT;
int16_val = (signed short)int64;
break;
case NC_INT:
nct = NC_INT;
int32_val = (signed int)int64;
break;
default:
goto outofrange;
}
done:
*tagp = tag;
return nct;
outofrange:
yyerror("Value out of range");
return NC_NAT;
}
static int
@ -789,23 +802,62 @@ nct2lexeme(nc_type nct)
return 0;
}
static int
tagmatch(nc_type nct, int tag, int hasU)
tagmatch(nc_type nct, int tag)
{
if(hasU) switch(nct) {
case NC_UBYTE: return (tag == 0 || tag == 'B' || tag == 'b');
case NC_USHORT: return (tag == 0 || tag == 'S' || tag == 's');
case NC_UINT: return (tag == 0);
case NC_UINT64: return (tag == 0 || tag == 'L' || tag == 'l');
default: return 0;
} else switch(nct) {
case NC_BYTE: return (tag == 0 || tag == 'B' || tag == 'b');
case NC_SHORT: return (tag == 0 || tag == 'S' || tag == 's');
case NC_INT: return (tag == 0);
case NC_INT64: return (tag == 0 || tag == 'L' || tag == 'l');
default: return 0;
}
return 0;
if(tag == NC_NAT || tag == NC_NOTAG)
return 1;
return nct == tag;
}
/* capture the tag string */
static int
collecttag(char* text, char** stagp)
{
char* stag0;
#define MAXTAGLEN 3
char stag[MAXTAGLEN+1];
int slen = strlen(text);
int staglen;
int tag = NC_NAT;
int hasU = 0;
for(stag0 = text+(slen-1);stag0 > 0;stag0--) {
if(strchr(TAGCHARS,*stag0) == NULL) {stag0++; break;}
}
if(stagp) *stagp = stag0;
staglen = strlen(stag0);
if(staglen == 0)
return NC_NOTAG;
if(staglen > MAXTAGLEN)
return tag;
strncpy(stag,stag0,sizeof(stag));
stag[MAXTAGLEN] = '\0';
if(stag[0] == 'U' || stag[0] == 'u') {
hasU = 1;
memmove(stag,stag+1,MAXTAGLEN);
staglen--;
} else if(stag[staglen-1] == 'U' || stag[staglen-1] == 'u') {
hasU = 1;
staglen--;
stag[staglen] = '\0';
}
if(strlen(stag) == 0 && hasU) {
tag = NC_UINT64;
} else if(strlen(stag) == 1) {
switch (stag[0]) {
case 'B': case 'b': tag = (hasU ? NC_UBYTE : NC_BYTE); break;
case 'S': case 's': tag = (hasU ? NC_USHORT : NC_SHORT); break;
case 'L': case 'l': tag = (hasU ? NC_UINT : NC_INT); break;
default: break;
}
} else if(strcasecmp(stag,"ll") == 0) {
tag = (hasU ? NC_UINT64 : NC_INT64);
}
if(tag == NC_NAT) {
if(strlen(stag) > 0)
return tag;
tag = NC_NAT;
}
return tag;
}

View File

@ -903,7 +903,7 @@ ncgwrap(void) /* returns 1 on EOF if no more input */
}
/* get lexical input routine generated by lex */
#include "ncgenyy.c"
#include "ncgenl.c"
/* Really should init our data within this file */
void

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,21 +1,24 @@
/* A Bison parser, made by GNU Bison 2.5. */
/* A Bison parser, made by GNU Bison 2.3. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
/* Skeleton interface for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
@ -26,11 +29,10 @@
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
@ -87,33 +89,77 @@
DATASETID = 305
};
#endif
/* Tokens. */
#define NC_UNLIMITED_K 258
#define CHAR_K 259
#define BYTE_K 260
#define SHORT_K 261
#define INT_K 262
#define FLOAT_K 263
#define DOUBLE_K 264
#define UBYTE_K 265
#define USHORT_K 266
#define UINT_K 267
#define INT64_K 268
#define UINT64_K 269
#define IDENT 270
#define TERMSTRING 271
#define CHAR_CONST 272
#define BYTE_CONST 273
#define SHORT_CONST 274
#define INT_CONST 275
#define INT64_CONST 276
#define UBYTE_CONST 277
#define USHORT_CONST 278
#define UINT_CONST 279
#define UINT64_CONST 280
#define FLOAT_CONST 281
#define DOUBLE_CONST 282
#define DIMENSIONS 283
#define VARIABLES 284
#define NETCDF 285
#define DATA 286
#define TYPES 287
#define COMPOUND 288
#define ENUM 289
#define OPAQUE 290
#define OPAQUESTRING 291
#define GROUP 292
#define PATH 293
#define FILLMARKER 294
#define NIL 295
#define _FILLVALUE 296
#define _FORMAT 297
#define _STORAGE 298
#define _CHUNKSIZES 299
#define _DEFLATELEVEL 300
#define _SHUFFLE 301
#define _ENDIANNESS 302
#define _NOFILL 303
#define _FLETCHER32 304
#define DATASETID 305
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
/* Line 2068 of yacc.c */
#line 131 "ncgen.y"
{
Symbol* sym;
unsigned long size; /* allow for zero size to indicate e.g. UNLIMITED*/
long mark; /* track indices into the sequence*/
int nctype; /* for tracking attribute list type*/
Datalist* datalist;
NCConstant constant;
/* Line 2068 of yacc.c */
#line 111 "ncgentab.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
}
/* Line 1529 of yacc.c. */
#line 158 "ncgen.tab.h"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
extern YYSTYPE ncglval;

View File

@ -2,12 +2,17 @@
# This shell script runs the ncdump tests.
# $Id: run_nc4_tests.sh,v 1.4 2010/05/18 20:05:23 dmh Exp $
if test "x$srcdir" = x ; then srcdir="."; fi
echo "*** Testing ncgen for netCDF-4."
set -e
echo "*** creating netCDF-4 file c0_4.nc from c0_4.cdl..."
./ncgen -k nc4 -b -o c0_4.nc $srcdir/c0_4.cdl
echo "*** creating netCDF-4 classic model file c0_4c.nc from c0.cdl..."
./ncgen -k nc7 -b -o c0_4c.nc $srcdir/c0.cdl
echo "*** creating C code for CAM file ref_camrun.cdl..."
./ncgen -lc $srcdir/ref_camrun.cdl >ref_camrun.c

View File

@ -8,6 +8,7 @@ fi
echo "*** Testing ncgen."
set -e
echo "*** creating classic file c0.nc from c0.cdl..."
./ncgen -b -o c0.nc $srcdir/c0.cdl
if [ ! -f c0.nc ]; then
@ -29,6 +30,12 @@ if [ ! -f c5.nc ]; then
exit 1
fi
echo "**** creating file to test ncf-345..."
./ncgen -b -o ncf345.nc $srcdir/ncf345.cdl
if [ ! -f ncf345.nc ]; then
echo "Failure."
exit 1
fi
echo "*** Test successful!"
exit 0

View File

@ -774,29 +774,111 @@ processattributes(void)
}
/*
Look at the first primitive value of the
attribute's datalist to infer the type of the attribute.
There is a potential ambiguity when that value is a string.
Is the attribute type NC_CHAR or NC_STRING?
The answer is we always assume it is NC_CHAR in order to
be back compatible with ncgen.
Given two types, attempt to upgrade to the "bigger type"
Rules:
- type size has precedence over signed/unsigned:
e.g. NC_INT over NC_UBYTE
*/
static nc_type
infertype(nc_type prior, nc_type next, int hasneg)
{
nc_type sp, sn;
/* assert isinttype(prior) && isinttype(next) */
if(prior == NC_NAT) return next;
if(prior == next) return next;
sp = signedtype(prior);
sn = signedtype(next);
if(sp <= sn)
return next;
if(sn < sp)
return prior;
return NC_NAT; /* all other cases illegal */
}
/*
Collect info by repeated walking of the attribute value list.
*/
static nc_type
inferattributetype1(Datasrc* src)
{
nc_type result = NC_NAT;
/* Recurse down any enclosing compound markers to find first non-fill "primitive"*/
while(result == NC_NAT && srcmore(src)) {
if(issublist(src)) {
srcpush(src);
result = inferattributetype1(src);
srcpop(src);
} else {
NCConstant* con = srcnext(src);
if(isprimplus(con->nctype)) result = con->nctype;
/* else keep looking*/
int hasneg = 0;
int stringcount = 0;
int charcount = 0;
int forcefloat = 0;
int forcedouble = 0;
int forceuint64 = 0;
/* Walk the top level set of attribute values to ensure non-nesting */
while(srcmore(src)) {
NCConstant* con = srcnext(src);
if(con == NULL) return NC_NAT;
if(con->nctype > NC_MAX_ATOMIC_TYPE) { /* illegal */
return NC_NAT;
}
srcnext(src);
}
/* Walk repeatedly to get info for inference (loops could be combined) */
/* Compute: all strings or chars? */
srcreset(src);
stringcount = 0;
charcount = 0;
while(srcmore(src)) {
NCConstant* con = srcnext(src);
if(con->nctype == NC_STRING) stringcount++;
else if(con->nctype == NC_CHAR) charcount++;
}
if((stringcount+charcount) > 0) {
if((stringcount+charcount) < srclen(src))
return NC_NAT; /* not all textual */
return NC_CHAR;
}
/* Compute: any floats/doubles? */
srcreset(src);
forcefloat = 0;
forcedouble = 0;
while(srcmore(src)) {
NCConstant* con = srcnext(src);
if(con->nctype == NC_FLOAT) forcefloat = 1;
else if(con->nctype == NC_DOUBLE) {forcedouble=1; break;}
}
if(forcedouble) return NC_DOUBLE;
if(forcefloat) return NC_FLOAT;
/* At this point all the constants should be integers */
/* Compute: are there any uint64 values > NC_MAX_INT64? */
srcreset(src);
forceuint64 = 0;
while(srcmore(src)) {
NCConstant* con = srcnext(src);
if(con->nctype != NC_UINT64) continue;
if(con->value.uint64v > NC_MAX_INT64) {forceuint64=1; break;}
}
if(forceuint64)
return NC_UINT64;
/* Compute: are there any negative constants? */
srcreset(src);
hasneg = 0;
while(srcmore(src)) {
NCConstant* con = srcnext(src);
switch (con->nctype) {
case NC_BYTE : if(con->value.int8v < 0) {hasneg = 1;} break;
case NC_SHORT: if(con->value.int16v < 0) {hasneg = 1;} break;
case NC_INT: if(con->value.int32v < 0) {hasneg = 1;} break;
}
}
/* Compute: inferred integer type */
srcreset(src);
result = NC_NAT;
while(srcmore(src)) {
NCConstant* con = srcnext(src);
result = infertype(result,con->nctype,hasneg);
if(result == NC_NAT) break; /* something wrong */
}
return result;
}
@ -817,6 +899,10 @@ inferattributetype(Symbol* asym)
src = datalist2src(datalist);
nctype = inferattributetype1(src);
freedatasrc(src);
if(nctype == NC_NAT) { /* Illegal attribute value list */
semerror(asym->lineno,"Non-simple list of values for untyped attribute: %s",fullname(asym));
return;
}
/* get the corresponding primitive type built-in symbol*/
/* special case for string*/
if(nctype == NC_STRING)

View File

@ -254,6 +254,65 @@ isbounded(Dimset* dimset)
return 1;
}
int
signedtype(nc_type nctype)
{
switch (nctype) {
case NC_BYTE:
case NC_SHORT:
case NC_INT:
case NC_INT64:
return nctype;
case NC_UBYTE: return NC_BYTE;
case NC_USHORT: return NC_SHORT;
case NC_UINT: return NC_INT;
case NC_UINT64: return NC_INT64;
default: break;
}
return nctype;
}
int
unsignedtype(nc_type nctype)
{
switch (nctype) {
case NC_UBYTE:
case NC_USHORT:
case NC_UINT:
case NC_UINT64:
return nctype;
case NC_BYTE: return NC_UBYTE;
case NC_SHORT: return NC_USHORT;
case NC_INT: return NC_UINT;
case NC_INT64: return NC_UINT64;
default: break;
}
return nctype;
}
int
isinttype(nc_type nctype)
{
return (nctype != NC_CHAR)
&& ((nctype >= NC_BYTE && nctype <= NC_INT)
|| (nctype >= NC_UBYTE && nctype <= NC_UINT64));
}
int
isuinttype(nc_type t)
{
return isinttype(t)
&& t >= NC_UBYTE
&& t <= NC_UINT64
&& t != NC_INT64;
}
int
isfloattype(nc_type nctype)
{
return (nctype == NC_FLOAT || nctype <= NC_DOUBLE);
}
int
isclassicprim(nc_type nctype)
{

View File

@ -8,7 +8,6 @@
#define MAX(x,y) ((x)>(y)?(x):(y))
extern void expe2d(char*);
extern int pow2(int);
extern void tztrim(char*);
@ -27,7 +26,13 @@ extern char* nctypename(nc_type);
extern char* ncclassname(nc_class);
extern int ncsize(nc_type);
extern nc_type signedtype(nc_type nctype);
extern nc_type unsignedtype(nc_type nctype);
/* We have several versions of primitive testing*/
extern int isinttype(nc_type nctype); /* some kind of integer*/
extern int isuinttype(nc_type nctype); /* some kind of integer*/
extern int isfloattype(nc_type nctype); /* some kind of float*/
extern int isclassicprim(nc_type); /* a classic primitive type*/
extern int isclassicprimplus(nc_type); /* classic + String*/
extern int isprim(nc_type); /* a netcdf4 primitive type*/

8
run_travis.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
###
# Travis script, so that we can more easily
# create a test matrix using travis-ci and docker.
###
docker run --rm -it -e USEDASH=OFF -e RUNF=OFF -e RUNCXX=OFF -e RUNP=OFF -e RUNNCO=OFF -e USEAC=OFF -v $(pwd):/netcdf-c $DOCKIMG