netcdf-c/libsrc4/ncfunc.c

122 lines
2.9 KiB
C
Raw Normal View History

2017-12-04 06:37:56 +08:00
/**
* @internal
*
* Copyright 2003, University Corporation for Atmospheric
* Research. See netcdf-4/docs/COPYRIGHT file for copying and
* redistribution conditions.
*
* This file is part of netcdf-4, a netCDF-like interface for HDF5, or a
* HDF5 backend for netCDF, depending on your point of view.
*
* This file handles the (useless) *_base_pe() functions, and the
* inq_format functions.
*
* @author Ed Hartnett, Dennis Heimbigner
2010-06-03 21:24:43 +08:00
*/
#include "nc4internal.h"
Primary change: add dap4 support Specific changes: 1. Add dap4 code: libdap4 and dap4_test. Note that until the d4ts server problem is solved, dap4 is turned off. 2. Modify various files to support dap4 flags: configure.ac, Makefile.am, CMakeLists.txt, etc. 3. Add nc_test/test_common.sh. This centralizes the handling of the locations of various things in the build tree: e.g. where is ncgen.exe located. See nc_test/test_common.sh for details. 4. Modify .sh files to use test_common.sh 5. Obsolete separate oc2 by moving it to be part of netcdf-c. This means replacing code with netcdf-c equivalents. 5. Add --with-testserver to configure.ac to allow override of the servers to be used for --enable-dap-remote-tests. 6. There were multiple versions of nctypealignment code. Try to centralize in libdispatch/doffset.c and include/ncoffsets.h 7. Add a unit test for the ncuri code because of its complexity. 8. Move the findserver code out of libdispatch and into a separate, self contained program in ncdap_test and dap4_test. 9. Move the dispatch header files (nc{3,4}dispatch.h) to .../include because they are now shared by modules. 10. Revamp the handling of TOPSRCDIR and TOPBUILDDIR for shell scripts. 11. Make use of MREMAP if available 12. Misc. minor changes e.g. - #include <config.h> -> #include "config.h" - Add some no-install headers to /include - extern -> EXTERNL and vice versa as needed - misc header cleanup - clean up checking for misc. unix vs microsoft functions 13. Change copyright decls in some files to point to LICENSE file. 14. Add notes to RELEASENOTES.md
2017-03-09 08:01:10 +08:00
#include "nc4dispatch.h"
2010-06-03 21:24:43 +08:00
2017-11-22 22:46:03 +08:00
/**
2017-12-04 06:37:56 +08:00
* @internal This function only does anything for netcdf-3 files.
2017-11-22 23:21:24 +08:00
*
2017-12-04 06:37:56 +08:00
* @param ncid File ID (ignored).
* @param pe Processor element (ignored).
2017-11-22 22:46:03 +08:00
*
2017-12-04 06:37:56 +08:00
* @return ::NC_ENOTNC3 Not a netCDF classic format file.
* @author Ed Hartnett
2017-11-22 23:21:24 +08:00
*/
2010-06-03 21:24:43 +08:00
int
NC4_set_base_pe(int ncid, int pe)
{
2017-11-22 23:21:24 +08:00
return NC_ENOTNC3;
2010-06-03 21:24:43 +08:00
}
2017-11-22 23:21:24 +08:00
/**
2017-12-04 06:37:56 +08:00
* @internal This function only does anything for netcdf-3 files.
2017-11-22 23:21:24 +08:00
*
2017-12-04 06:37:56 +08:00
* @param ncid File ID (ignored).
* @param pe Pointer to processor element. Ignored if NULL. Gets a 0
2017-11-22 23:21:24 +08:00
* if present.
*
2017-12-04 06:37:56 +08:00
* @return ::NC_ENOTNC3 Not a netCDF classic format file.
* @author Ed Hartnett
2017-11-22 23:21:24 +08:00
*/
2010-06-03 21:24:43 +08:00
int
NC4_inq_base_pe(int ncid, int *pe)
{
return NC_ENOTNC3;
2010-06-03 21:24:43 +08:00
}
2017-11-22 23:21:24 +08:00
/**
2017-12-04 06:37:56 +08:00
* @internal Get the format (i.e. NC_FORMAT_NETCDF4 pr
2017-11-22 23:21:24 +08:00
* NC_FORMAT_NETCDF4_CLASSIC) of an open netCDF-4 file.
*
2017-12-04 06:37:56 +08:00
* @param ncid File ID (ignored).
* @param formatp Pointer that gets the constant indicating format.
2017-11-22 23:21:24 +08:00
2017-12-04 06:37:56 +08:00
* @return ::NC_NOERR No error.
* @return ::NC_EBADID Bad ncid.
* @author Ed Hartnett
2017-11-22 23:21:24 +08:00
*/
2010-06-03 21:24:43 +08:00
int
NC4_inq_format(int ncid, int *formatp)
{
NC *nc;
NC_HDF5_FILE_INFO_T* nc4_info;
2010-06-03 21:24:43 +08:00
LOG((2, "nc_inq_format: ncid 0x%x", ncid));
if (!formatp)
return NC_NOERR;
/* Find the file metadata. */
if (!(nc = nc4_find_nc_file(ncid,&nc4_info)))
2010-06-03 21:24:43 +08:00
return NC_EBADID;
/* Otherwise, this is a netcdf-4 file. Check if classic NC3 rules
* are in effect for this file. */
if (nc4_info->cmode & NC_CLASSIC_MODEL)
2010-06-03 21:24:43 +08:00
*formatp = NC_FORMAT_NETCDF4_CLASSIC;
else
*formatp = NC_FORMAT_NETCDF4;
return NC_NOERR;
}
2017-11-22 23:21:24 +08:00
/**
2017-12-04 06:37:56 +08:00
* @internal Return the extended format (i.e. the dispatch model),
* plus the mode associated with an open file.
2017-11-22 23:21:24 +08:00
*
2017-12-04 06:37:56 +08:00
* @param ncid File ID (ignored).
* @param formatp a pointer that gets the extended format. Note that
2017-11-22 23:21:24 +08:00
* this is not the same as the format provided by nc_inq_format(). The
* extended foramt indicates the dispatch layer model. NetCDF-4 files
2018-02-08 21:20:58 +08:00
* will always get NC_FORMATX_NC4.
2017-12-04 06:37:56 +08:00
* @param modep a pointer that gets the open/create mode associated with
2017-11-22 23:21:24 +08:00
* this file. Ignored if NULL.
2017-12-04 06:37:56 +08:00
* @return ::NC_NOERR No error.
* @return ::NC_EBADID Bad ncid.
* @author Dennis Heimbigner
2017-11-22 23:21:24 +08:00
*/
int
NC4_inq_format_extended(int ncid, int *formatp, int *modep)
{
NC *nc;
NC_HDF5_FILE_INFO_T* h5;
2018-02-08 21:20:58 +08:00
LOG((2, "%s: ncid 0x%x", __func__, ncid));
/* Find the file metadata. */
if (!(nc = nc4_find_nc_file(ncid,&h5)))
return NC_EBADID;
if(modep) *modep = (nc->mode|NC_NETCDF4);
2018-02-08 21:20:58 +08:00
if (formatp)
2017-11-22 23:21:24 +08:00
*formatp = NC_FORMATX_NC_HDF5;
2018-02-08 21:20:58 +08:00
return NC_NOERR;
}