merge pull

This commit is contained in:
Russ Rew 2015-07-14 10:07:29 -06:00
commit 792ea21a34
9 changed files with 185 additions and 307 deletions

View File

@ -678,7 +678,7 @@ ELSE()
ENDIF()
# Enable some developer-only tests
OPTION(ENABLE_EXTRA_TESTS "Enable Extra tests. Some may not work because of known issues. Developers only." OFF)
OPTION(ENABLE_EXTRA_TESTS "Enable Extra tests. Some may not work because of known issues. Developers only." ON)
IF(ENABLE_EXTRA_TESTS)
SET(EXTRA_TESTS ON)
ENDIF()

View File

@ -1,14 +1,10 @@
Unidata NetCDF
==============
# Unidata NetCDF
[![Build Status](https://travis-ci.org/Unidata/netcdf-c.svg?branch=master)](https://travis-ci.org/Unidata/netcdf-c)
[![Coverity Scan Build Status](https://scan.coverity.com/projects/157/badge.svg)](https://scan.coverity.com/projects/157)
<a href="https://scan.coverity.com/projects/157">
<img alt="Coverity Scan Build Status"
src="https://scan.coverity.com/projects/157/badge.svg"/>
</a>
The Unidata network Common Data Form (netCDF) is an interface for
### About
The Unidata network Common Data Form (**netCDF**) is an interface for
scientific data access and a freely-distributed software library that
provides an implementation of the interface. The netCDF library also
defines a machine-independent format for representing scientific data.
@ -19,6 +15,7 @@ distributions available from Unidata provide Java, Fortran, Python,
and C++ interfaces. They have been tested on various common
platforms.
#### Properties
NetCDF files are self-describing, network-transparent, directly
accessible, and extendible. `Self-describing` means that a netCDF file
includes information about the data it contains. `Network-transparent`
@ -29,6 +26,7 @@ large dataset may be accessed efficiently, without first reading through
all the preceding data. `Extendible` means that data can be appended to
a netCDF dataset without copying it or redefining its structure.
#### Use
NetCDF is useful for supporting access to diverse kinds of scientific
data in heterogeneous networking environments and for writing
application software that does not depend on application-specific
@ -38,23 +36,27 @@ netCDF form, see
* http://www.unidata.ucar.edu/netcdf/software.html
##### More informations
For more information about netCDF, see the netCDF Web page at
* http://www.unidata.ucar.edu/netcdf/
### Latest releases
You can obtain a copy of the latest released version of netCDF software
from
* http://github.com/Unidata/netcdf-c
* http://github.com/Unidata/netcdf-fortran
* http://github.com/Unidata/netcdf-cxx4
* http://github.com/Unidata/netcdf4-python
* C - http://github.com/Unidata/netcdf-c
* Fortan - http://github.com/Unidata/netcdf-fortran
* Libraries and utilities in C - http://github.com/Unidata/netcdf-cxx4
* Python - http://github.com/Unidata/netcdf4-python
### Copyright
Copyright and licensing information can be found here, as well as in
the COPYRIGHT file accompanying the software
* http://www.unidata.ucar.edu/software/netcdf/copyright.html
### Install
To install this package, please see the file INSTALL in the
distribution, or the (usually more up-to-date) document:
@ -66,6 +68,7 @@ pages at
* http://www.unidata.ucar.edu/netcdf/docs/netcdf-man-3.html
* http://www.unidata.ucar.edu/netcdf/docs/netcdf-man-3f.html
### User's Guides
User's Guides are also available in several forms from the same
location.
@ -75,6 +78,7 @@ enhancements. For information about how to subscribe, see the URL
* http://www.unidata.ucar.edu/netcdf/mailing-lists.html
### Feedback
We appreciate feedback from users of this package. Please send
comments, suggestions, and bug reports to
<support-netcdf@unidata.ucar.edu>. Please identify the version of the

View File

@ -7,7 +7,11 @@ This file contains a high-level description of this package's evolution. Release
## 4.4.0 Released TBD
### 4.4.0-RC1 Released TBD
### 4.4.0-RC2 Released 2015-07-09
* Minor bug fixes and cleanup of issues reported with first release candidate.
### 4.4.0-RC1 Released 2015-06-09
* The pre-built Windows binaries are now built using `Visual Studio 2012`, instead of `Visual Studio 2010`. Source-code compilation remains function with `Visual Studio 2010`, this is just a change in the pre-built binaries.

View File

@ -426,9 +426,9 @@ AM_CONDITIONAL(INTERNAL_OCLIB,[test "x" = "x"])
# Does the user want to do some extra tests?
AC_MSG_CHECKING([whether netCDF extra tests should be run (developers only)])
AC_ARG_ENABLE([extra-tests],
[AS_HELP_STRING([--enable-extra-tests],
[run some extra tests that may not pass because of known issues])])
test "x$enable_extra_tests" = xyes || enable_extra_tests=no
[AS_HELP_STRING([--disable-extra-tests],
[disable some extra tests that may not pass because of known issues])])
test "x$enable_extra_tests" = xno || enable_extra_tests=yes
AC_MSG_RESULT($enable_extra_tests)
if test "x$enable_extra_tests" = xyes; then
AC_DEFINE([EXTRA_TESTS], [1], [if true, run extra tests which may not work yet])

View File

@ -1,137 +1,14 @@
Software for Manipulating or Displaying NetCDF Data {#software}
===================================================
[TOC]
This document provides references to software packages that may be used for manipulating or displaying [netCDF](/software/netcdf/) data. We include information about both freely-available and licensed (commercial) software that can be used with netCDF data. We rely on developers to help keep this list up-to-date. If you know of corrections or additions, please [send them to us (mailto:support@unidata.ucar.edu). Where practical, we would like to include WWW links to information about these packages in the HTML version of this document.
Other useful guides to utilities that can handle netCDF data include ARM's list of [ARM-tested netCDF data tools](http://science.arm.gov/%7ecflynn/ARM_Tested_Tools/), which includes some downloadable binaries and the NOAA Geophysical Fluid Dynamics Laboratory [guide to netCDF utilities](http://nomads.gfdl.noaa.gov/sandbox/products/vis/data/netcdf/GFDL_VG_NetCDF_Utils.html).
------------------------------------------------------------------------
[Freely Available Software](#freely)
------------------------------------
- [ANDX (ARM NetCDF Data eXtract) and ANAX (ARM NetCDF ASCII
eXtract)](#ANDX)
- [ANTS (ARM NetCDF Tool Suite)](#ANTS)
- [ARGOS (interActive thRee-dimensional Graphics ObServatory)](#ARGOS)
- [CDAT (Climate Data Analysis Tool)](#CDAT)
- [CDFconvert (Convert netCDF to RPN and GEMPAK Grids)](#CDFconvert)
- [cdfsync (network synchronization of netCDF files)](#cdfsync)
- [CDO (Climate Data Operators)](#CDO)
- [CIDS Tools](#CIDS_Tools)
- [CSIRO MATLAB/netCDF interface](#CSIRO-MATLAB)
- [EPIC](#EPIC)
- [Excel Use](#ExcelUse)
- [EzGet](#EzGet)
- [FAN (File Array Notation)](#FAN)
- [FERRET](#FERRET)
- [FIMEX (File Interpolation, Manipulation, and EXtraction)](#fimex)
- [FWTools (GIS Binary Kit for Windows and Linux)](#fwtools)
- [GDAL (Geospatial Data Abstraction Library)](#GDAL)
- [GDL (GNU Data Language)](#GDL)
- [Gfdnavi (Geophysical fluid data navigator)](#Gfdnavi)
- [GMT (Generic Mapping Tools)](#GMT)
- [Grace](#Grace)
- [GrADS (Grid Analysis and Display System)](#GrADS)
- [Gri](#Gri)
- [GXSM - Gnome X Scanning Microscopy project](#GXSM)
- [HDF (Hierarchical Data Format) interface](#HDF_interface)
- [HDF-EOS to netCDF converter](#HDF-EOS)
- [HIPHOP (Handy IDL-Program for HDF-Output Plotting)](#HIPHOP)
- [HOPS (Hyperslab OPerator
Suite)](#HOPS))
- [iCDF (imports chromatographic netCDF data into MATLAB)](#iCDF)
- [IDV (Integrated Data Viewer)](#IDV)
- [Ingrid](#Ingrid)
- [Intel Array Visualizer](#IntelArrayVisualizer)
- [IVE (Interactive Visualization Environment)](#IVE)
- [JSON format with the ncdump-json utility](#JSON)
- [Java interface](#Java_interface)
- [Kst (2D plotting tool)](#KST)
- [Labview interface](#Labview-API)
- [MBDyn (MultiBody Dynamics)](#MBDyn)
- [Max_diff_nc](#Maxdiffnc)
- [MeteoExplorer](#MeteoExplorer)
- [MeteoInfo](#MeteoInfo)
- [MexEPS (MATLAB interface)](#MexEPS)
- [MEXNC and SNCTOOLS (a MATLAB interface)](#MEXNC)
- [Mirone (Windows MATLAB-based display)](#Mirone)
- [ncBrowse (netCDF File Browser)](#ncBrowse)
- [nccmp (netCDF compare)](#nccmp)
- [ncdx (netCDF for OpenDX)](#ncdx)
- [ncensemble (command line utility to do ensemble
statistics)](#ncensemble)
- [NCL (NCAR Command Language)](#NCL)
- [NCO (NetCDF Operators)](#NCO)
- [ncregrid](#ncregrid)
- [nctoolbox (a MATLAB common data model interface)](#nctoolbox)
- [ncview](#ncview)
- [NetCDF Toolbox for MATLAB-5](#matlab5)
- [ncvtk](#ncvtk)
- [netcdf tools](#netcdf_tools)
- [netcdf4excel (add-in for MS Excel)](#netcdf4excel)
- [NetCDF95 alternative Fortran API](#netcdf95)
- [Objective-C interface](#Objective-C)
- [Octave interface](#NCMEX)
- [Octave interface (Barth)](#Octave)
- [OPeNDAP (formerly DODS)](#OPeNDAP)
- [OpenDX (formerly IBM Data Explorer)](#OpenDX)
- [Panoply](#Panoply)
- [Parallel-NetCDF](#Parallel-NetCDF)
- [Paraview and vtkCSCSNetCDF](#Paraview)
- [Perl interfaces](#Perl)
- [PolyPaint+](#PolyPaint)
- [Pomegranate](#pomegranate)
- [Pupynere (PUre PYthon NEtcdf REader)](#pupynere)
- [PyNGL and PyNIO](#PyNGL)
- [Python interfaces](#Python)
- [QGIS (Quantum GIS)](#QGIS)
- [R interface](#R)
- [Ruby interface](#Ruby)
- [Scientific DataSet (SDS) Library](#SDS)
- [Apache Spatial Information System (SIS)](#SIS)
- [Tcl/Tk interfaces](#TclTk)
- [Tcl-nap (N-dimensional array processor)](#Tcl-nap)
- [Visual Basic and VB.net](#VB)
- [VisAD](#VisAD)
- [WebWinds](#WebWinds)
- [xray (Python N-D labelled arrays)](#xray)
- [Zebra](#Zebra)
- [User-contributed software](#user)
------------------------------------------------------------------------
[Commercial or Licensed Packages](#commercial)
----------------------------------------------
- [ASA ViewNcDap](#ViewNcDap)
- [Avizo](#Avizo)
- [AVS](#AVS)
- [Barrodale UFI](#BCS-UFI)
- [DioVISTA/Storm](#DioVISTAStorm)
- [EnSight](#EnSight)
- [Environmental WorkBench](#Environmental_WorkBench)
- [ESRI](#ESRI)
- [FME](#FME)
- [HDF Explorer](#HDF-Explorer)
- [IDL Interface](#IDL)
- [InterFormat](#InterFormat)
- [IRIS Explorer Module](#IRIS_Explorer_Module)
- [LeoNetCDF](#LeoNetCDF)
- [Mathematica](#Mathematica)
- [MATLAB](#MATLAB)
- [Noesys](#Noesys)
- [Origin](#Origin)
- [PPLUS](#PPLUS)
- [PV-Wave](#PV-Wave)
- [Slicer Dicer](#SlicerDicer)
- [Surfer](#Surfer)
- [vGeo](#vGeo)
- [VISAGE and Decimate](#VISAGE_and_Decimate)
- [Voyager](#Voyager)
Freely Available Software {#freely}
=========================

View File

@ -3,7 +3,7 @@
This file has the var and att copy functions.
"$Id: copy.c,v 1.1 2010/06/01 15:46:49 ed Exp $"
"$Id: copy.c,v 1.1 2010/06/01 15:46:49 ed Exp $"
*/
#include "ncdispatch.h"
@ -13,13 +13,13 @@
/* Compare two netcdf types for equality. Must have the ncids as well,
to find user-defined types. */
static int
NC_compare_nc_types(int ncid1, int typeid1, int ncid2, int typeid2,
NC_compare_nc_types(int ncid1, int typeid1, int ncid2, int typeid2,
int *equalp)
{
int ret = NC_NOERR;
/* If you don't care about the answer, neither do I! */
if(equalp == NULL)
if(equalp == NULL)
return NC_NOERR;
/* Assume the types are not equal. If we find any inequality, then
@ -27,13 +27,13 @@ NC_compare_nc_types(int ncid1, int typeid1, int ncid2, int typeid2,
*equalp = 0;
/* Atomic types are so easy! */
if (typeid1 <= NC_MAX_ATOMIC_TYPE)
if (typeid1 <= NC_MAX_ATOMIC_TYPE)
{
if (typeid2 != typeid1)
if (typeid2 != typeid1)
return NC_NOERR;
*equalp = 1;
}
else
else
{
int i, ret, equal1;
char name1[NC_MAX_NAME];
@ -53,23 +53,23 @@ NC_compare_nc_types(int ncid1, int typeid1, int ncid2, int typeid2,
/* Find out about the two types. */
if ((ret = nc_inq_user_type(ncid1, typeid1, name1, &size1,
&base1, &nelems1, &class1)))
return ret;
return ret;
if ((ret = nc_inq_user_type(ncid2, typeid2, name2, &size2,
&base2, &nelems2, &class2)))
return ret;
return ret;
/* Check the obvious. */
if(size1 != size2 || class1 != class2 || strcmp(name1,name2))
return NC_NOERR;
/* Check user-defined types in detail. */
switch(class1)
switch(class1)
{
case NC_VLEN:
if((ret = NC_compare_nc_types(ncid1, base1, ncid2,
base1, &equal1)))
return ret;
if(!equal1)
if(!equal1)
return NC_NOERR;
break;
case NC_OPAQUE:
@ -80,10 +80,12 @@ NC_compare_nc_types(int ncid1, int typeid1, int ncid2, int typeid2,
if (!(value1 = malloc(size1)))
return NC_ENOMEM;
if (!(value2 = malloc(size2)))
return NC_ENOMEM;
if (!(value2 = malloc(size2))) {
free(value1);
return NC_ENOMEM;
}
for(i = 0; i < nelems1; i++)
for(i = 0; i < nelems1; i++)
{
if ((ret = nc_inq_enum_member(ncid1, typeid1, i, name1,
value1)) ||
@ -91,39 +93,39 @@ NC_compare_nc_types(int ncid1, int typeid1, int ncid2, int typeid2,
value2)) ||
strcmp(name1, name2) || memcmp(value1, value2, size1))
{
free(value1);
free(value1);
free(value2);
return ret;
}
}
free(value1);
free(value1);
free(value2);
break;
case NC_COMPOUND:
if(nelems1 != nelems2)
if(nelems1 != nelems2)
return NC_NOERR;
/* Compare each field. Each must be equal! */
for(i = 0; i < nelems1; i++)
for(i = 0; i < nelems1; i++)
{
int j;
if ((ret = nc_inq_compound_field(ncid1, typeid1, i, name1, &offset1,
if ((ret = nc_inq_compound_field(ncid1, typeid1, i, name1, &offset1,
&ftype1, &ndims1, dimsizes1)))
return ret;
if ((ret = nc_inq_compound_field(ncid2, typeid2, i, name2, &offset2,
&ftype2, &ndims2, dimsizes2)))
return ret;
if(ndims1 != ndims2)
if(ndims1 != ndims2)
return NC_NOERR;
for(j = 0; j < ndims1;j++)
if(dimsizes1[j] != dimsizes2[j])
for(j = 0; j < ndims1;j++)
if(dimsizes1[j] != dimsizes2[j])
return NC_NOERR;
/* Compare user-defined field types. */
if((ret = NC_compare_nc_types(ncid1, ftype1, ncid2, ftype2,
&equal1)))
return ret;
if(!equal1)
if(!equal1)
return NC_NOERR;
}
break;
@ -145,7 +147,7 @@ NC_rec_find_nc_type(int ncid1, nc_type tid1, int ncid2, nc_type* tid2)
int* ids = NULL;
/* Get all types in grp ncid2 */
if(tid2)
if(tid2)
*tid2 = 0;
if ((ret = nc_inq_typeids(ncid2, &nids, NULL)))
return ret;
@ -155,22 +157,22 @@ NC_rec_find_nc_type(int ncid1, nc_type tid1, int ncid2, nc_type* tid2)
return NC_ENOMEM;
if ((ret = nc_inq_typeids(ncid2, &nids, ids)))
return ret;
for(i = 0; i < nids; i++)
for(i = 0; i < nids; i++)
{
int equal = 0;
if ((ret = NC_compare_nc_types(ncid1, tid1, ncid2, ids[i], &equal)))
return ret;
if(equal)
if(equal)
{
if(tid2)
*tid2 = ids[i];
if(tid2)
*tid2 = ids[i];
free(ids);
return NC_NOERR;
}
}
free(ids);
}
/* recurse */
if ((ret = nc_inq_grps(ncid1, &nids, NULL)))
return ret;
@ -183,10 +185,10 @@ NC_rec_find_nc_type(int ncid1, nc_type tid1, int ncid2, nc_type* tid2)
free(ids);
return ret;
}
for (i = 0; i < nids; i++)
for (i = 0; i < nids; i++)
{
ret = NC_rec_find_nc_type(ncid1, tid1, ids[i], tid2);
if (ret && ret != NC_EBADTYPE)
if (ret && ret != NC_EBADTYPE)
break;
if (tid2 && *tid2 != 0) /* found */
{
@ -207,13 +209,13 @@ NC_find_equal_type(int ncid1, nc_type xtype1, int ncid2, nc_type *xtype2)
int ret = NC_NOERR;
/* Check input */
if(xtype1 <= NC_NAT)
if(xtype1 <= NC_NAT)
return NC_EINVAL;
/* Handle atomic types. */
if (xtype1 <= NC_MAX_ATOMIC_TYPE)
if (xtype1 <= NC_MAX_ATOMIC_TYPE)
{
if(xtype2)
if(xtype2)
*xtype2 = xtype1;
return NC_NOERR;
}
@ -268,10 +270,10 @@ nc_copy_var(int ncid_in, int varid_in, int ncid_out)
int i;
/* Learn about this var. */
if ((retval = nc_inq_var(ncid_in, varid_in, name, &xtype,
if ((retval = nc_inq_var(ncid_in, varid_in, name, &xtype,
&ndims, dimids_in, &natts)))
return retval;
/* find corresponding dimids in the output file */
/* find corresponding dimids in the output file */
for(i = 0; i < ndims; i++) {
dimids_out[i] = dimids_in[i];
if ((retval = nc_inq_dimname(ncid_in, dimids_in[i], dimname_in)))
@ -281,7 +283,7 @@ nc_copy_var(int ncid_in, int varid_in, int ncid_out)
}
#ifdef USE_NETCDF4
LOG((2, "nc_copy_var: ncid_in 0x%x varid_in %d ncid_out 0x%x",
LOG((2, "nc_copy_var: ncid_in 0x%x varid_in %d ncid_out 0x%x",
ncid_in, varid_in, ncid_out));
#endif
@ -315,7 +317,7 @@ nc_copy_var(int ncid_in, int varid_in, int ncid_out)
{
if ((retval = nc_inq_attname(ncid_in, varid_in, a, att_name)))
BAIL(retval);
if ((retval = nc_copy_att(ncid_in, varid_in, att_name,
if ((retval = nc_copy_att(ncid_in, varid_in, att_name,
ncid_out, varid_out)))
BAIL(retval);
}
@ -376,7 +378,7 @@ nc_copy_var(int ncid_in, int varid_in, int ncid_out)
if(dimlen) free(dimlen);
if(start) free(start);
return NC_ENOMEM;
}
}
/* Copy the var data one record at a time. */
for (start[0]=0; !retval && start[0]<(size_t)dimlen[0]; start[0]++)
@ -387,14 +389,14 @@ nc_copy_var(int ncid_in, int varid_in, int ncid_out)
retval = nc_get_vara_schar(ncid_in, varid_in, start, count,
(signed char *)data);
if (!retval)
retval = nc_put_vara_schar(ncid_out, varid_out, start, count,
retval = nc_put_vara_schar(ncid_out, varid_out, start, count,
(const signed char *)data);
break;
case NC_CHAR:
retval = nc_get_vara_text(ncid_in, varid_in, start, count,
(char *)data);
if (!retval)
retval = nc_put_vara_text(ncid_out, varid_out, start, count,
retval = nc_put_vara_text(ncid_out, varid_out, start, count,
(char *)data);
break;
case NC_SHORT:
@ -422,49 +424,49 @@ nc_copy_var(int ncid_in, int varid_in, int ncid_out)
retval = nc_get_vara_double(ncid_in, varid_in, start, count,
(double *)data);
if (!retval)
retval = nc_put_vara_double(ncid_out, varid_out, start, count,
retval = nc_put_vara_double(ncid_out, varid_out, start, count,
(double *)data);
break;
case NC_UBYTE:
retval = nc_get_vara_uchar(ncid_in, varid_in, start, count,
(unsigned char *)data);
if (!retval)
retval = nc_put_vara_uchar(ncid_out, varid_out, start, count,
retval = nc_put_vara_uchar(ncid_out, varid_out, start, count,
(unsigned char *)data);
break;
case NC_USHORT:
retval = nc_get_vara_ushort(ncid_in, varid_in, start, count,
(unsigned short *)data);
if (!retval)
retval = nc_put_vara_ushort(ncid_out, varid_out, start, count,
retval = nc_put_vara_ushort(ncid_out, varid_out, start, count,
(unsigned short *)data);
break;
case NC_UINT:
retval = nc_get_vara_uint(ncid_in, varid_in, start, count,
(unsigned int *)data);
if (!retval)
retval = nc_put_vara_uint(ncid_out, varid_out, start, count,
retval = nc_put_vara_uint(ncid_out, varid_out, start, count,
(unsigned int *)data);
break;
case NC_INT64:
retval = nc_get_vara_longlong(ncid_in, varid_in, start, count,
(long long *)data);
if (!retval)
retval = nc_put_vara_longlong(ncid_out, varid_out, start, count,
retval = nc_put_vara_longlong(ncid_out, varid_out, start, count,
(long long *)data);
break;
case NC_UINT64:
retval = nc_get_vara_ulonglong(ncid_in, varid_in, start, count,
(unsigned long long *)data);
if (!retval)
retval = nc_put_vara_ulonglong(ncid_out, varid_out, start, count,
retval = nc_put_vara_ulonglong(ncid_out, varid_out, start, count,
(unsigned long long *)data);
break;
default:
retval = NC_EBADTYPE;
}
}
exit:
if (data) free(data);
if (dimlen) free(dimlen);
@ -474,25 +476,25 @@ nc_copy_var(int ncid_in, int varid_in, int ncid_out)
}
static int
NC_copy_att(int ncid_in, int varid_in, const char *name,
NC_copy_att(int ncid_in, int varid_in, const char *name,
int ncid_out, int varid_out)
{
nc_type xtype;
size_t len;
void *data=NULL;
int res;
LOG((2, "nc_copy_att: ncid_in 0x%x varid_in %d name %s",
LOG((2, "nc_copy_att: ncid_in 0x%x varid_in %d name %s",
ncid_in, varid_in, name));
/* Find out about the attribute to be copied. */
if ((res = nc_inq_att(ncid_in, varid_in, name, &xtype, &len)))
return res;
if (xtype < NC_STRING)
if (xtype < NC_STRING)
{
/* Handle non-string atomic types. */
if (len)
if (len)
{
size_t size = NC_atomictypelen(xtype);
@ -503,13 +505,13 @@ NC_copy_att(int ncid_in, int varid_in, const char *name,
res = nc_get_att(ncid_in, varid_in, name, data);
if (!res)
res = nc_put_att(ncid_out, varid_out, name, xtype,
res = nc_put_att(ncid_out, varid_out, name, xtype,
len, data);
if (len)
free(data);
}
#ifdef USE_NETCDF4
else if (xtype == NC_STRING)
else if (xtype == NC_STRING)
{
/* Copy string attributes. */
char **str_data;
@ -517,12 +519,12 @@ NC_copy_att(int ncid_in, int varid_in, const char *name,
return NC_ENOMEM;
res = nc_get_att_string(ncid_in, varid_in, name, str_data);
if (!res)
res = nc_put_att_string(ncid_out, varid_out, name, len,
res = nc_put_att_string(ncid_out, varid_out, name, len,
(const char **)str_data);
nc_free_string(len, str_data);
free(str_data);
}
else
}
else
{
/* Copy user-defined type attributes. */
int class;
@ -535,28 +537,28 @@ NC_copy_att(int ncid_in, int varid_in, const char *name,
which we had to "duplicate" here */
if ((res = NC_find_equal_type(ncid_in, xtype, ncid_out, &xtype_out)))
return res;
if (xtype_out)
if (xtype_out)
{
/* We found an equal type! */
if ((res = nc_inq_user_type(ncid_in, xtype, NULL, &size,
if ((res = nc_inq_user_type(ncid_in, xtype, NULL, &size,
NULL, NULL, &class)))
return res;
if (class == NC_VLEN) /* VLENs are different... */
{
{
nc_vlen_t *vldata;
int i;
if (!(vldata = malloc(sizeof(nc_vlen_t) * len)))
return NC_ENOMEM;
if ((res = nc_get_att(ncid_in, varid_in, name, vldata)))
return res;
if ((res = nc_put_att(ncid_out, varid_out, name, xtype_out,
if ((res = nc_put_att(ncid_out, varid_out, name, xtype_out,
len, vldata)))
return res;
for (i = 0; i < len; i++)
if((res = nc_free_vlen(&vldata[i])))
for (i = 0; i < len; i++)
if((res = nc_free_vlen(&vldata[i])))
return res;
free(vldata);
}
}
else /* not VLEN */
{
if (!(data = malloc(size * len)))
@ -576,7 +578,7 @@ NC_copy_att(int ncid_in, int varid_in, const char *name,
Special programming challenge: this function must work even if one
of the other of the files is a netcdf version 1.0 file (i.e. not
HDF5). So only use top level netcdf api functions.
HDF5). So only use top level netcdf api functions.
From the netcdf-3 docs: The output netCDF dataset should be in
define mode if the attribute to be copied does not already exist
@ -584,7 +586,7 @@ NC_copy_att(int ncid_in, int varid_in, const char *name,
attribute to grow.
*/
int
nc_copy_att(int ncid_in, int varid_in, const char *name,
nc_copy_att(int ncid_in, int varid_in, const char *name,
int ncid_out, int varid_out)
{
int format, target_natts, target_attid;
@ -594,11 +596,11 @@ nc_copy_att(int ncid_in, int varid_in, const char *name,
/* What is the destination format? */
if ((retval = nc_inq_format(ncid_out, &format)))
return retval;
/* Can't copy to same var in same file. */
if (ncid_in == ncid_out && varid_in == varid_out)
return NC_NOERR;
/* For classic model netCDF-4 files, order of attributes must be
* maintained during copies. We MUST MAINTAIN ORDER! */
if (format == NC_FORMAT_NETCDF4_CLASSIC)
@ -620,7 +622,7 @@ nc_copy_att(int ncid_in, int varid_in, const char *name,
* off the hook. */
if (target_attid == target_natts - 1)
return NC_copy_att(ncid_in, varid_in, name, ncid_out, varid_out);
/* Order MUST BE MAINTAINED! Copy all existing atts in the target
* file, stopping at our target att. */
for (a = 0; a < target_natts; a++)
@ -629,12 +631,12 @@ nc_copy_att(int ncid_in, int varid_in, const char *name,
{
if ((retval = NC_copy_att(ncid_in, varid_in, name, ncid_out, varid_out)))
return retval;
}
}
else
{
if ((retval = nc_inq_attname(ncid_out, varid_out, a, att_name)))
return retval;
if ((retval = NC_copy_att(ncid_out, varid_out, att_name,
if ((retval = NC_copy_att(ncid_out, varid_out, att_name,
ncid_out, varid_out)))
return retval;
}
@ -648,5 +650,3 @@ nc_copy_att(int ncid_in, int varid_in, const char *name,
return NC_NOERR;
}

View File

@ -1,11 +1,11 @@
/** \file
/** \file
File create and open functions
These functions end up calling functions in one of the dispatch layers
(netCDF-4, dap server, etc).
Copyright 2010 University Corporation for Atmospheric
Research/Unidata. See COPYRIGHT file for more info.
Research/Unidata. See COPYRIGHT file for more info.
*/
#include "config.h"
@ -44,7 +44,7 @@ associated with a netCDF dataset.
Functions that deal with the netCDF library include:
- Get version of library.
- Get error message corresponding to a returned error code.
- Get error message corresponding to a returned error code.
The operations supported on a netCDF dataset as a single object are:
- Create, given dataset name and whether to overwrite or not.
@ -120,10 +120,13 @@ NC_check_file_type(const char *path, int flags, void *parameters,
char magic[MAGIC_NUMBER_LEN];
int status = NC_NOERR;
int diskless = ((flags & NC_DISKLESS) == NC_DISKLESS);
int persist = ((flags & NC_WRITE) == NC_WRITE);
/* Unused, throws a 'value never read' in static analysis. */
//int persist = ((flags & NC_WRITE) == NC_WRITE);
int use_parallel = ((flags & NC_MPIIO) == NC_MPIIO);
int inmemory = (diskless && ((flags & NC_INMEMORY) == NC_INMEMORY));
*model = 0;
if(inmemory) {
@ -141,7 +144,7 @@ NC_check_file_type(const char *path, int flags, void *parameters,
int retval;
MPI_Comm comm = MPI_COMM_WORLD;
MPI_Info info = MPI_INFO_NULL;
if(parameters != NULL) {
comm = ((NC_MPI_INFO*)parameters)->comm;
info = ((NC_MPI_INFO*)parameters)->info;
@ -164,7 +167,7 @@ NC_check_file_type(const char *path, int flags, void *parameters,
#endif
if(path == NULL || strlen(path)==0)
{status = NC_EINVAL; goto done;}
if (!(fp = fopen(path, "r")))
{status = errno; goto done;}
@ -177,7 +180,7 @@ NC_check_file_type(const char *path, int flags, void *parameters,
status = errno;
goto done;
}
if(st.st_size < MAGIC_NUMBER_LEN) {
fclose(fp);
status = NC_ENOTNC;
@ -187,13 +190,13 @@ NC_check_file_type(const char *path, int flags, void *parameters,
i = fread(magic, MAGIC_NUMBER_LEN, 1, fp);
fclose(fp);
if(i == 0)
if(i == 0)
{status = NC_ENOTNC; goto done;}
if(i != 1)
if(i != 1)
{status = errno; goto done;}
}
} /* !inmemory */
/* Look at the magic number */
status = NC_interpret_magic_number(magic,model,version,use_parallel);
@ -227,7 +230,7 @@ stored.
<h2>The cmode Flag</h2>
The cmode flag is used to control the type of file created, and some
aspects of how it may be used.
aspects of how it may be used.
Setting NC_NOCLOBBER means you do not want to clobber (overwrite) an
existing dataset; an error (NC_EEXIST) is returned if the specified
@ -239,7 +242,7 @@ concurrently; it means that dataset accesses are not buffered and
caching is limited. Since the buffering scheme is optimized for
sequential access, programs that do not access data sequentially may
see some performance improvement by setting the NC_SHARE flag. This
flag is ignored for netCDF-4 files.
flag is ignored for netCDF-4 files.
Setting NC_64BIT_OFFSET causes netCDF to create a 64-bit offset format
file, instead of a netCDF classic format file. The 64-bit offset
@ -407,7 +410,7 @@ nc_create(const char *path, int cmode, int *ncidp)
Create a netCDF file with some extra parameters controlling classic
file cacheing.
Like nc_create(), this function creates a netCDF file.
Like nc_create(), this function creates a netCDF file.
\param path The file name of the new netCDF dataset.
@ -468,7 +471,7 @@ int
nc__create(const char *path, int cmode, size_t initialsz,
size_t *chunksizehintp, int *ncidp)
{
return NC_create(path, cmode, initialsz, 0,
return NC_create(path, cmode, initialsz, 0,
chunksizehintp, 0, NULL, ncidp);
}
@ -481,16 +484,16 @@ backward compatibility.
*/
int
nc__create_mp(const char *path, int cmode, size_t initialsz,
nc__create_mp(const char *path, int cmode, size_t initialsz,
int basepe, size_t *chunksizehintp, int *ncidp)
{
return NC_create(path, cmode, initialsz, basepe,
return NC_create(path, cmode, initialsz, basepe,
chunksizehintp, 0, NULL, ncidp);
}
/**
/**
Open an existing netCDF file.
This function opens an existing netCDF dataset for access. It
determines the underlying file format automatically. Use the same call
to open a netCDF classic, 64-bit offset, or netCDF-4 file.
@ -498,7 +501,7 @@ to open a netCDF classic, 64-bit offset, or netCDF-4 file.
\param path File name for netCDF dataset to be opened. When DAP
support is enabled, then the path may be an OPeNDAP URL rather than a
file path.
\param mode The mode flag may include NC_WRITE (for read/write
access) and NC_SHARE (see below) and NC_DISKLESS (see below).
@ -561,7 +564,7 @@ improvement in this case.
It is not necessary to pass any information about the format of the
file being opened. The file type will be detected automatically by the
netCDF library.
If a the path is a DAP URL, then the open mode is read-only.
Setting NC_WRITE will be ignored.
@ -594,10 +597,10 @@ named foo.nc for read-only, non-shared access:
@code
#include <netcdf.h>
...
...
int status = NC_NOERR;
int ncid;
...
...
status = nc_open("foo.nc", 0, &ncid);
if (status != NC_NOERR) handle_error(status);
@endcode
@ -608,14 +611,14 @@ nc_open(const char *path, int mode, int *ncidp)
return NC_open(path, mode, 0, NULL, 0, NULL, ncidp);
}
/**
/**
Open a netCDF file with extra performance parameters for the classic
library.
\param path File name for netCDF dataset to be opened. When DAP
support is enabled, then the path may be an OPeNDAP URL rather than a
file path.
\param mode The mode flag may include NC_WRITE (for read/write
access) and NC_SHARE as in nc_open().
@ -636,7 +639,7 @@ Because of internal requirements, the value may not be set to exactly
the value requested. The actual value chosen is returned by reference.
Using a NULL pointer or having the pointer point to the value
NC_SIZEHINT_DEFAULT causes the library to choose a default.
NC_SIZEHINT_DEFAULT causes the library to choose a default.
How the system chooses the default depends on the system. On
many systems, the "preferred I/O block size" is available from the
stat() system call, struct stat member st_blksize. If this is
@ -663,11 +666,11 @@ int
nc__open(const char *path, int mode,
size_t *chunksizehintp, int *ncidp)
{
return NC_open(path, mode, 0, chunksizehintp, 0,
return NC_open(path, mode, 0, chunksizehintp, 0,
NULL, ncidp);
}
/**
/**
Open a netCDF file with the contents taken from a block of memory.
\param path Must be non-null, but otherwise only used to set the dataset name.
@ -675,7 +678,7 @@ Open a netCDF file with the contents taken from a block of memory.
\param mode the mode flags; Note that this procedure uses a limited set of flags because it forcibly sets NC_NOWRITE|NC_DISKLESS|NC_INMEMORY.
\param size The length of the block of memory being passed.
\param memory Pointer to the block of memory containing the contents
of a netcdf file.
@ -699,15 +702,15 @@ example in that it assumes the contents of foo.nc have been read into memory.
@code
#include <netcdf.h>
#include <netcdf_mem.h>
...
...
int status = NC_NOERR;
int ncid;
size_t size;
void* memory;
...
...
size = <compute file size of foo.nc in bytes>;
memory = malloc(size);
...
...
status = nc_open_mem("foo.nc", 0, size, memory, &ncid);
if (status != NC_NOERR) handle_error(status);
@endcode
@ -728,7 +731,7 @@ nc_open_mem(const char* path, int mode, size_t size, void* memory, int* ncidp)
meminfo.memory = memory;
return NC_open(path, mode, 0, NULL, 0, &meminfo, ncidp);
#else
return NC_EDISKLESS;
return NC_EDISKLESS;
#endif
}
@ -741,14 +744,14 @@ backward compatibility.
*/
int
nc__open_mp(const char *path, int mode, int basepe,
nc__open_mp(const char *path, int mode, int basepe,
size_t *chunksizehintp, int *ncidp)
{
return NC_open(path, mode, basepe, chunksizehintp,
0, NULL, ncidp);
}
/**
/**
Get the file pathname (or the opendap URL) which was used to
open/create the ncid's file.
@ -759,13 +762,13 @@ nc_create().
if NULL.
\param path Pointer where path name will be copied. Space must already
be allocated. Ignored if NULL.
be allocated. Ignored if NULL.
\returns ::NC_NOERR No error.
\returns ::NC_EBADID Invalid ncid passed.
*/
int
int
nc_inq_path(int ncid, size_t *pathlen, char *path)
{
NC* ncp;
@ -819,14 +822,14 @@ named foo.nc and put it into define mode:
\code
#include <netcdf.h>
...
...
int status = NC_NOERR;
int ncid;
...
status = nc_open("foo.nc", NC_WRITE, &ncid);
...
status = nc_open("foo.nc", NC_WRITE, &ncid);
if (status != NC_NOERR) handle_error(status);
...
status = nc_redef(ncid);
...
status = nc_redef(ncid);
if (status != NC_NOERR) handle_error(status);
\endcode
*/
@ -861,7 +864,7 @@ For netCDF-4/HDF5 format files there are some variable settings (the
compression, endianness, fletcher32 error correction, and fill value)
which must be set (if they are going to be set at all) between the
nc_def_var() and the next nc_enddef(). Once the nc_enddef() is called,
these settings can no longer be changed for a variable.
these settings can no longer be changed for a variable.
\param ncid NetCDF ID, from a previous call to nc_open() or
nc_create().
@ -887,10 +890,10 @@ netCDF dataset named foo.nc and put it into data mode:
...
status = nc_create("foo.nc", NC_NOCLOBBER, &ncid);
if (status != NC_NOERR) handle_error(status);
... create dimensions, variables, attributes
status = nc_enddef(ncid);
... create dimensions, variables, attributes
status = nc_enddef(ncid);
if (status != NC_NOERR) handle_error(status);
\endcode
*/
@ -899,7 +902,7 @@ nc_enddef(int ncid)
{
int status = NC_NOERR;
NC *ncp;
status = NC_check_id(ncid, &ncp);
status = NC_check_id(ncid, &ncp);
if(status != NC_NOERR) return status;
return ncp->dispatch->_enddef(ncid,0,1,0,1);
}
@ -963,7 +966,7 @@ calculated from the sizes of the record variables. This unfortunate
fact prevents us from providing minfree and alignment control of the
"records" in a netcdf file. If you add a variable which has an
unlimited dimension, the third section will always be copied with the
new variable added.
new variable added.
\param ncid NetCDF ID, from a previous call to nc_open() or
nc_create().
@ -986,7 +989,7 @@ variables).
*/
int
nc__enddef(int ncid, size_t h_minfree, size_t v_align, size_t v_minfree,
nc__enddef(int ncid, size_t h_minfree, size_t v_align, size_t v_minfree,
size_t r_align)
{
NC* ncp;
@ -1101,13 +1104,13 @@ dataset named foo.nc:
status = nc_open("foo.nc", NC_WRITE, &ncid);
if (status != NC_NOERR) handle_error(status);
...
status = nc_redef(ncid);
status = nc_redef(ncid);
if (status != NC_NOERR) handle_error(status);
...
status = nc_def_dim(ncid, "lat", 18L, &latid);
if (status != NC_NOERR) {
handle_error(status);
status = nc_abort(ncid);
status = nc_abort(ncid);
if (status != NC_NOERR) handle_error(status);
}
\endcode
@ -1129,7 +1132,7 @@ nc_abort(int ncid)
stat = ncp->dispatch->abort(ncid);
del_from_NCList(ncp);
free_NC(ncp);
return stat;
return stat;
}
/**
@ -1164,10 +1167,10 @@ netCDF dataset named foo.nc and release its netCDF ID:
...
status = nc_create("foo.nc", NC_NOCLOBBER, &ncid);
if (status != NC_NOERR) handle_error(status);
... create dimensions, variables, attributes
status = nc_close(ncid);
... create dimensions, variables, attributes
status = nc_close(ncid);
if (status != NC_NOERR) handle_error(status);
\endcode
@ -1249,7 +1252,7 @@ The use of this feature may not be available (or even needed) in
future releases. Programmers are cautioned against heavy reliance upon
this feature.
\param ncid NetCDF ID, from a previous call to nc_open() or
\param ncid NetCDF ID, from a previous call to nc_open() or
nc_create().
\param fillmode Desired fill mode for the dataset, either ::NC_NOFILL or
@ -1279,15 +1282,15 @@ writes of a netCDF dataset named foo.nc:
...
int ncid, status, old_fill_mode;
...
status = nc_open("foo.nc", NC_WRITE, &ncid);
status = nc_open("foo.nc", NC_WRITE, &ncid);
if (status != NC_NOERR) handle_error(status);
... write data with default prefilling behavior
status = nc_set_fill(ncid, ::NC_NOFILL, &old_fill_mode);
if (status != NC_NOERR) handle_error(status);
... write data with no prefilling
... write data with no prefilling
\endcode
*/
int
@ -1345,7 +1348,7 @@ as presented by the API.
This function returns the (rarely needed) format version.
\param ncid NetCDF ID, from a previous call to nc_open() or
\param ncid NetCDF ID, from a previous call to nc_open() or
nc_create().
\param formatp Pointer to location for returned format version, one of
@ -1376,7 +1379,7 @@ a netcdf file; it might be DAP, HDF4, or PNETCDF,
for example. This function returns that true file type.
It also returns the effective mode for the file.
\param ncid NetCDF ID, from a previous call to nc_open() or
\param ncid NetCDF ID, from a previous call to nc_open() or
nc_create().
\param formatp Pointer to location for returned true format.
@ -1404,7 +1407,7 @@ nc_inq_format_extended(int ncid, int *formatp, int *modep)
Inquire about a file or group.
\param ncid NetCDF or group ID, from a previous call to nc_open(),
nc_create(), nc_def_grp(), or associated inquiry functions such as
nc_create(), nc_def_grp(), or associated inquiry functions such as
nc_inq_ncid().
\param ndimsp Pointer to location for returned number of dimensions
@ -1419,7 +1422,7 @@ attributes defined for this netCDF dataset. Ignored if NULL.
\param unlimdimidp Pointer to location for returned ID of the
unlimited dimension, if there is one for this netCDF dataset. If no
unlimited length dimension has been defined, -1 is returned. Ignored
if NULL. If there are multiple unlimited dimensions (possible only
if NULL. If there are multiple unlimited dimensions (possible only
for netCDF-4 files), only a pointer to the first is returned, for
backward compatibility. If you want them all, use nc_inq_unlimids().
@ -1472,7 +1475,7 @@ type, whether compound, opaque, enumeration, or variable length array.
For even more information about a user defined type nc_inq_user_type().
\param ncid The ncid for the group containing the type (ignored for
atomic types).
atomic types).
\param xtype The typeid for this type, as returned by nc_def_compound,
nc_def_opaque, nc_def_enum, nc_def_vlen, or nc_inq_var, or as found in
@ -1507,7 +1510,7 @@ for which classic model has been turned on.
This example is from the test program tst_enums.c, and it uses all the
possible inquiry functions on an enum type.
\code
\code
if (nc_inq_user_type(ncid, typeids[0], name_in, &base_size_in, &base_nc_type_in,
&nfields_in, &class_in)) ERR;
if (strcmp(name_in, TYPE_NAME) || base_size_in != sizeof(int) ||
@ -1523,7 +1526,7 @@ possible inquiry functions on an enum type.
if (nc_inq_enum_ident(ncid, typeid, member_value[i], name_in)) ERR;
if (strcmp(name_in, member_name[i])) ERR;
}
if (nc_close(ncid)) ERR;
\endcode
*/
@ -1581,8 +1584,8 @@ stored.
\returns ::NC_NOERR No error.
*/
int
NC_create(const char *path, int cmode, size_t initialsz,
int basepe, size_t *chunksizehintp, int useparallel,
NC_create(const char *path, int cmode, size_t initialsz,
int basepe, size_t *chunksizehintp, int useparallel,
void* parameters, int *ncidp)
{
int stat = NC_NOERR;
@ -1599,7 +1602,7 @@ NC_create(const char *path, int cmode, size_t initialsz,
if(!nc_initialized)
{
if ((stat = NC_initialize()))
return stat;
return stat;
/* Do local initialization */
nc_local_initialize();
nc_initialized = 1;
@ -1609,7 +1612,7 @@ NC_create(const char *path, int cmode, size_t initialsz,
/* If this path is already open, then fail */
ncp = find_in_NCList_by_name(path);
if(ncp != NULL)
return NC_ENFILE;
return NC_ENFILE;
#endif
if((isurl = NC_testurl(path)))
@ -1654,7 +1657,7 @@ NC_create(const char *path, int cmode, size_t initialsz,
break;
}
}
/* Add inferred flags */
cmode |= xcmode;
@ -1743,7 +1746,7 @@ NC_open(const char *path, int cmode,
int inmemory = ((cmode & NC_INMEMORY) == NC_INMEMORY);
/* Need pieces of information for now to decide model*/
int model = 0;
int isurl = 0;
int isurl = 0;
int version = 0;
int flags = 0;
@ -1760,7 +1763,7 @@ NC_open(const char *path, int cmode,
ncp = find_in_NCList_by_name(path);
if(ncp != NULL) {
ncp->refcount++;
if(ncidp) *ncidp = ncp->ext_ncid;
if(ncidp) *ncidp = ncp->ext_ncid;
return NC_NOERR;
}
#endif
@ -1797,7 +1800,7 @@ NC_open(const char *path, int cmode,
} else if(model & NC_DISPATCH_NC5) {
#if 0
It appears that pnetcdf can read NC_64_BIT_OFFSET
cmode &= ~(NC_NETCDF4 | NC_64BIT_OFFSET); /* must be pnetcdf */
cmode &= ~(NC_NETCDF4 | NC_64BIT_OFFSET); /* must be pnetcdf */
#else
cmode &= ~(NC_NETCDF4);
#endif
@ -1891,5 +1894,3 @@ nc__pseudofd(void)
}
return pseudofd++;
}

View File

@ -564,10 +564,6 @@ NC5_get_vara(int ncid,
nc5 = NC5_DATA(nc);
assert(nc5);
/* No NC_LONG for parallel-netcdf library! */
if(memtype == NC_INT64)
return NC_EINVAL;
/* get variable's rank */
status= ncmpi_inq_varndims(nc->int_ncid, varid, &rank);
if(status) return status;
@ -645,10 +641,6 @@ NC5_put_vara(int ncid,
nc5 = NC5_DATA(nc);
assert(nc5);
/* No NC_LONG for parallel-netcdf library! */
if(memtype == NC_INT64)
return NC_EINVAL;
/* get variable's rank */
status = ncmpi_inq_varndims(nc->int_ncid, varid, &rank);
if(status) return status;

View File

@ -125,7 +125,7 @@ static void
rctrim(char* text)
{
char* p = text;
size_t len = strlen(text);
size_t len;
int i;
/* locate first non-trimchar */
for(;*p;p++) {
@ -371,7 +371,7 @@ ocrc_load(void)
2. set by DAPRCFILE env variable
3. '.'
4. $HOME
*/
*/
if(ocglobalstate.rc.rcfile != NULL) { /* always use this */
path = strdup(ocglobalstate.rc.rcfile);
} else if(getenv(OCRCFILEENV) != NULL && strlen(getenv(OCRCFILEENV)) > 0) {