ncfunc.c 2.3 KB

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