/src/netcdf-c/libsrc4/ncfunc.c
| Line | Count | Source | 
| 1 |  | /** | 
| 2 |  |  * @internal | 
| 3 |  |  * | 
| 4 |  |  * Copyright 2018, University Corporation for Atmospheric | 
| 5 |  |  * Research. See netcdf-4/docs/COPYRIGHT file for copying and | 
| 6 |  |  * redistribution conditions. | 
| 7 |  |  * | 
| 8 |  |  * This file is part of netcdf-4, a netCDF-like interface for HDF5, or a | 
| 9 |  |  * HDF5 backend for netCDF, depending on your point of view. | 
| 10 |  |  * | 
| 11 |  |  * This file handles the inq_format functions. | 
| 12 |  |  * | 
| 13 |  |  * @author Ed Hartnett, Dennis Heimbigner | 
| 14 |  |  */ | 
| 15 |  |  | 
| 16 |  | #include "nc4internal.h" | 
| 17 |  | #include "nc4dispatch.h" | 
| 18 |  |  | 
| 19 |  | /** | 
| 20 |  |  * @internal Get the format (i.e. NC_FORMAT_NETCDF4 pr | 
| 21 |  |  * NC_FORMAT_NETCDF4_CLASSIC) of an open netCDF-4 file. | 
| 22 |  |  * | 
| 23 |  |  * @param ncid File ID (ignored). | 
| 24 |  |  * @param formatp Pointer that gets the constant indicating format. | 
| 25 |  |  | 
| 26 |  |  * @return ::NC_NOERR No error. | 
| 27 |  |  * @return ::NC_EBADID Bad ncid. | 
| 28 |  |  * @author Ed Hartnett | 
| 29 |  |  */ | 
| 30 |  | int | 
| 31 |  | NC4_inq_format(int ncid, int *formatp) | 
| 32 | 0 | { | 
| 33 | 0 |     NC_FILE_INFO_T *nc4_info; | 
| 34 | 0 |     int retval; | 
| 35 |  | 
 | 
| 36 | 0 |     LOG((2, "nc_inq_format: ncid 0x%x", ncid)); | 
| 37 |  | 
 | 
| 38 | 0 |     if (!formatp) | 
| 39 | 0 |         return NC_NOERR; | 
| 40 |  |  | 
| 41 |  |     /* Find the file metadata. */ | 
| 42 | 0 |     if ((retval = nc4_find_nc_grp_h5(ncid, NULL, NULL, &nc4_info))) | 
| 43 | 0 |         return retval; | 
| 44 |  |  | 
| 45 |  |     /* Check if classic NC3 rules are in effect for this file. */ | 
| 46 | 0 |     if (nc4_info->cmode & NC_CLASSIC_MODEL) | 
| 47 | 0 |         *formatp = NC_FORMAT_NETCDF4_CLASSIC; | 
| 48 | 0 |     else | 
| 49 | 0 |         *formatp = NC_FORMAT_NETCDF4; | 
| 50 |  | 
 | 
| 51 | 0 |     return NC_NOERR; | 
| 52 | 0 | } | 
| 53 |  |  | 
| 54 |  | /** | 
| 55 |  |  * @internal Return the extended format (i.e. the dispatch model), | 
| 56 |  |  * plus the mode associated with an open file. | 
| 57 |  |  * | 
| 58 |  |  * @param ncid File ID (ignored). | 
| 59 |  |  * @param formatp a pointer that gets the extended format. Note that | 
| 60 |  |  * this is not the same as the format provided by nc_inq_format(). The | 
| 61 |  |  * extended format indicates the dispatch layer model. NetCDF-4 files | 
| 62 |  |  * will always get NC_FORMATX_NC4. | 
| 63 |  |  * @param modep a pointer that gets the open/create mode associated with | 
| 64 |  |  * this file. Ignored if NULL. | 
| 65 |  |  | 
| 66 |  |  * @return ::NC_NOERR No error. | 
| 67 |  |  * @return ::NC_EBADID Bad ncid. | 
| 68 |  |  * @author Dennis Heimbigner | 
| 69 |  |  */ | 
| 70 |  | int | 
| 71 |  | NC4_inq_format_extended(int ncid, int *formatp, int *modep) | 
| 72 | 0 | { | 
| 73 | 0 |     NC *nc; | 
| 74 | 0 |     int retval; | 
| 75 |  | 
 | 
| 76 | 0 |     LOG((2, "%s: ncid 0x%x", __func__, ncid)); | 
| 77 |  | 
 | 
| 78 | 0 |     if ((retval = nc4_find_nc_grp_h5(ncid, &nc, NULL, NULL))) | 
| 79 | 0 |         return NC_EBADID; | 
| 80 |  |  | 
| 81 | 0 |     if(modep) | 
| 82 | 0 |         *modep = nc->mode|NC_NETCDF4; | 
| 83 |  | 
 | 
| 84 | 0 |     if (formatp) | 
| 85 | 0 |         *formatp = NC_FORMATX_NC_HDF5; | 
| 86 |  | 
 | 
| 87 | 0 |     return NC_NOERR; | 
| 88 | 0 | } |