1 | /* |
---|
2 | |
---|
3 | This file is part of netcdf-4, a netCDF-like interface for HDF5, or a |
---|
4 | HDF5 backend for netCDF, depending on your point of view. |
---|
5 | |
---|
6 | This file handles the nc_ calls, calling the appropriate nc3 or nc4 |
---|
7 | function, depending on ncid. |
---|
8 | |
---|
9 | Copyright 2003, University Corporation for Atmospheric Research. See |
---|
10 | netcdf-4/docs/COPYRIGHT file for copying and redistribution |
---|
11 | conditions. |
---|
12 | */ |
---|
13 | |
---|
14 | #include "nc4internal.h" |
---|
15 | #include "nc3dispatch.h" |
---|
16 | |
---|
17 | #ifdef IGNORE |
---|
18 | /* Keep a linked list of file info objects. */ |
---|
19 | extern NC_FILE_INFO_T *nc_file; |
---|
20 | #endif |
---|
21 | |
---|
22 | #ifdef IGNORE |
---|
23 | /* This function deletes a member of parliment. Be careful! Last time |
---|
24 | * this function was used, Labor got in! This function only does |
---|
25 | * anything for netcdf-3 files. */ |
---|
26 | |
---|
27 | int |
---|
28 | nc_delete(const char *path) |
---|
29 | { |
---|
30 | return NC3_delete_mp(path, 0); |
---|
31 | } |
---|
32 | |
---|
33 | int |
---|
34 | nc_delete_mp(const char *path, int basepe) |
---|
35 | { |
---|
36 | return NC3_delete_mp(path, basepe); |
---|
37 | } |
---|
38 | #endif |
---|
39 | |
---|
40 | /* This will return the length of a netcdf data type in bytes. Since |
---|
41 | we haven't added any new types, I just call the v3 function. |
---|
42 | Ed Hartnett 10/43/03 |
---|
43 | */ |
---|
44 | |
---|
45 | /* This function only does anything for netcdf-3 files. */ |
---|
46 | int |
---|
47 | NC4_set_base_pe(int ncid, int pe) |
---|
48 | { |
---|
49 | NC_FILE_INFO_T *nc; |
---|
50 | if (!(nc = nc4_find_nc_file(ncid))) |
---|
51 | return NC_EBADID; |
---|
52 | if (nc->nc4_info) |
---|
53 | return NC_ENOTNC3; |
---|
54 | return NC3_set_base_pe(nc->int_ncid, pe); |
---|
55 | } |
---|
56 | |
---|
57 | /* This function only does anything for netcdf-3 files. */ |
---|
58 | int |
---|
59 | NC4_inq_base_pe(int ncid, int *pe) |
---|
60 | { |
---|
61 | NC_FILE_INFO_T *nc; |
---|
62 | if (!(nc = nc4_find_nc_file(ncid))) |
---|
63 | return NC_EBADID; |
---|
64 | if (nc->nc4_info) |
---|
65 | return NC_ENOTNC3; |
---|
66 | return NC3_inq_base_pe(nc->int_ncid, pe); |
---|
67 | } |
---|
68 | |
---|
69 | /* Get the format (i.e. classic, 64-bit-offset, or netcdf-4) of an |
---|
70 | * open file. */ |
---|
71 | int |
---|
72 | NC4_inq_format(int ncid, int *formatp) |
---|
73 | { |
---|
74 | NC_FILE_INFO_T *nc; |
---|
75 | |
---|
76 | LOG((2, "nc_inq_format: ncid 0x%x", ncid)); |
---|
77 | |
---|
78 | if (!formatp) |
---|
79 | return NC_NOERR; |
---|
80 | |
---|
81 | /* Find the file metadata. */ |
---|
82 | if (!(nc = nc4_find_nc_file(ncid))) |
---|
83 | return NC_EBADID; |
---|
84 | |
---|
85 | /* If this isn't a netcdf-4 file, pass this call on to the netcdf-3 |
---|
86 | * library. */ |
---|
87 | if (!nc->nc4_info) |
---|
88 | return NC3_inq_format(nc->int_ncid, formatp); |
---|
89 | |
---|
90 | /* Otherwise, this is a netcdf-4 file. Check if classic NC3 rules |
---|
91 | * are in effect for this file. */ |
---|
92 | if (nc->nc4_info->cmode & NC_CLASSIC_MODEL) |
---|
93 | *formatp = NC_FORMAT_NETCDF4_CLASSIC; |
---|
94 | else |
---|
95 | *formatp = NC_FORMAT_NETCDF4; |
---|
96 | |
---|
97 | return NC_NOERR; |
---|
98 | } |
---|
99 | |
---|
100 | |
---|