NetCDF  4.4.0-rc2
dfile.c
Go to the documentation of this file.
1 
11 #include "config.h"
12 #include <stdlib.h>
13 #ifdef HAVE_SYS_RESOURCE_H
14 #include <sys/resource.h>
15 #endif
16 #ifdef HAVE_SYS_TYPES_H
17 #include <sys/types.h>
18 #endif
19 #ifdef HAVE_SYS_STAT_H
20 #include <sys/stat.h>
21 #endif
22 #ifdef HAVE_FCNTL_H
23 #include <fcntl.h>
24 #endif
25 #include "ncdispatch.h"
26 
27 static int nc_initialized = 0;
28 
66 size_t NC_coord_zero[NC_MAX_VAR_DIMS];
67 size_t NC_coord_one[NC_MAX_VAR_DIMS];
68 
69 static void
70 nc_local_initialize(void)
71 {
72  int i;
73 
74  for(i=0;i<NC_MAX_VAR_DIMS;i++) {
75  NC_coord_one[i] = 1;
76  NC_coord_zero[i] = 0;
77  }
78 }
79 
80 static int
81 NC_interpret_magic_number(char* magic, int* model, int* version, int use_parallel)
82 {
83  int status = NC_NOERR;
84  /* Look at the magic number */
85  /* Ignore the first byte for HDF */
86 #ifdef USE_NETCDF4
87  if(magic[1] == 'H' && magic[2] == 'D' && magic[3] == 'F') {
88  *model = NC_DISPATCH_NC4;
89  *version = 5;
90 #ifdef USE_HDF4
91  } else if(magic[0] == '\016' && magic[1] == '\003'
92  && magic[2] == '\023' && magic[3] == '\001') {
93  *model = NC_DISPATCH_NC4;
94  *version = 4;
95 #endif
96  } else
97 #endif
98  if(magic[0] == 'C' && magic[1] == 'D' && magic[2] == 'F') {
99  if(magic[3] == '\001')
100  *version = 1; /* netcdf classic version 1 */
101  else if(magic[3] == '\002')
102  *version = 2; /* netcdf classic version 2 */
103 #ifdef USE_PNETCDF
104  else if(magic[3] == '\005')
105  *version = 5; /* pnetcdf file */
106 #endif
107  else
108  {status = NC_ENOTNC; goto done;}
109  *model = (use_parallel || *version == 5)?NC_DISPATCH_NC5:NC_DISPATCH_NC3;
110  } else
111  {status = NC_ENOTNC; goto done;}
112 done:
113  return status;
114 }
115 
116 static int
117 NC_check_file_type(const char *path, int flags, void *parameters,
118  int* model, int* version)
119 {
120  char magic[MAGIC_NUMBER_LEN];
121  int status = NC_NOERR;
122  int diskless = ((flags & NC_DISKLESS) == NC_DISKLESS);
123  int persist = ((flags & NC_WRITE) == NC_WRITE);
124  int use_parallel = ((flags & NC_MPIIO) == NC_MPIIO);
125  int inmemory = (diskless && ((flags & NC_INMEMORY) == NC_INMEMORY));
126 
127  *model = 0;
128 
129  if(inmemory) {
130  NC_MEM_INFO* meminfo = (NC_MEM_INFO*)parameters;
131  if(meminfo == NULL || meminfo->size < MAGIC_NUMBER_LEN)
132  {status = NC_EDISKLESS; goto done;}
133  memcpy(magic,meminfo->memory,MAGIC_NUMBER_LEN);
134  } else {/* presumably a real file */
135  /* Get the 4-byte magic from the beginning of the file. Don't use posix
136  * for parallel, use the MPI functions instead. */
137 #ifdef USE_PARALLEL
138  if (use_parallel) {
139  MPI_File fh;
140  MPI_Status mstatus;
141  int retval;
142  MPI_Comm comm = MPI_COMM_WORLD;
143  MPI_Info info = MPI_INFO_NULL;
144 
145  if(parameters != NULL) {
146  comm = ((NC_MPI_INFO*)parameters)->comm;
147  info = ((NC_MPI_INFO*)parameters)->info;
148  }
149  if((retval = MPI_File_open(comm,(char*)path,MPI_MODE_RDONLY,info,
150  &fh)) != MPI_SUCCESS)
151  {status = NC_EPARINIT; goto done;}
152  if((retval = MPI_File_read(fh, magic, MAGIC_NUMBER_LEN, MPI_CHAR,
153  &mstatus)) != MPI_SUCCESS)
154  {status = NC_EPARINIT; goto done;}
155  if((retval = MPI_File_close(&fh)) != MPI_SUCCESS)
156  {status = NC_EPARINIT; goto done;}
157  } else
158 #endif /* USE_PARALLEL */
159  {
160  FILE *fp;
161  size_t i;
162 #ifdef HAVE_SYS_STAT_H
163  struct stat st;
164 #endif
165  if(path == NULL || strlen(path)==0)
166  {status = NC_EINVAL; goto done;}
167 
168  if (!(fp = fopen(path, "r")))
169  {status = errno; goto done;}
170 
171 #ifdef HAVE_SYS_STAT_H
172  /* The file must be at least MAGIC_NUMBER_LEN in size,
173  or otherwise the following fread will exhibit unexpected
174  behavior. */
175  if(!(fstat(fileno(fp),&st) == 0)) {
176  fclose(fp);
177  status = errno;
178  goto done;
179  }
180 
181  if(st.st_size < MAGIC_NUMBER_LEN) {
182  fclose(fp);
183  status = NC_ENOTNC;
184  goto done;
185  }
186 #endif
187 
188  i = fread(magic, MAGIC_NUMBER_LEN, 1, fp);
189  fclose(fp);
190  if(i == 0)
191  {status = NC_ENOTNC; goto done;}
192  if(i != 1)
193  {status = errno; goto done;}
194  }
195  } /* !inmemory */
196 
197  /* Look at the magic number */
198  status = NC_interpret_magic_number(magic,model,version,use_parallel);
199 
200 done:
201  return status;
202 }
203 
400 int
401 nc_create(const char *path, int cmode, int *ncidp)
402 {
403  return nc__create(path,cmode,NC_SIZEHINT_DEFAULT,NULL,ncidp);
404 }
405 
467 int
468 nc__create(const char *path, int cmode, size_t initialsz,
469  size_t *chunksizehintp, int *ncidp)
470 {
471  return NC_create(path, cmode, initialsz, 0,
472  chunksizehintp, 0, NULL, ncidp);
473 
474 }
483 int
484 nc__create_mp(const char *path, int cmode, size_t initialsz,
485  int basepe, size_t *chunksizehintp, int *ncidp)
486 {
487  return NC_create(path, cmode, initialsz, basepe,
488  chunksizehintp, 0, NULL, ncidp);
489 }
490 
605 int
606 nc_open(const char *path, int mode, int *ncidp)
607 {
608  return NC_open(path, mode, 0, NULL, 0, NULL, ncidp);
609 }
610 
662 int
663 nc__open(const char *path, int mode,
664  size_t *chunksizehintp, int *ncidp)
665 {
666  return NC_open(path, mode, 0, chunksizehintp, 0,
667  NULL, ncidp);
668 }
669 
715 int
716 nc_open_mem(const char* path, int mode, size_t size, void* memory, int* ncidp)
717 {
718 #ifdef USE_DISKLESS
719  NC_MEM_INFO meminfo;
720 
721  /* Sanity checks */
722  if(memory == NULL || size < MAGIC_NUMBER_LEN || path == NULL)
723  return NC_EINVAL;
724  if(mode & (NC_WRITE|NC_MPIIO|NC_MPIPOSIX|NC_MMAP))
725  return NC_EINVAL;
726  mode |= (NC_INMEMORY|NC_DISKLESS);
727  meminfo.size = size;
728  meminfo.memory = memory;
729  return NC_open(path, mode, 0, NULL, 0, &meminfo, ncidp);
730 #else
731  return NC_EDISKLESS;
732 #endif
733 }
734 
743 int
744 nc__open_mp(const char *path, int mode, int basepe,
745  size_t *chunksizehintp, int *ncidp)
746 {
747  return NC_open(path, mode, basepe, chunksizehintp,
748  0, NULL, ncidp);
749 }
750 
768 int
769 nc_inq_path(int ncid, size_t *pathlen, char *path)
770 {
771  NC* ncp;
772  int stat = NC_NOERR;
773  if ((stat = NC_check_id(ncid, &ncp)))
774  return stat;
775  if(ncp->path == NULL) {
776  if(pathlen) *pathlen = 0;
777  if(path) path[0] = '\0';
778  } else {
779  if (pathlen) *pathlen = strlen(ncp->path);
780  if (path) strcpy(path, ncp->path);
781  }
782  return stat;
783 }
784 
833 int
834 nc_redef(int ncid)
835 {
836  NC* ncp;
837  int stat = NC_check_id(ncid, &ncp);
838  if(stat != NC_NOERR) return stat;
839  return ncp->dispatch->redef(ncid);
840 }
841 
897 int
898 nc_enddef(int ncid)
899 {
900  int status = NC_NOERR;
901  NC *ncp;
902  status = NC_check_id(ncid, &ncp);
903  if(status != NC_NOERR) return status;
904  return ncp->dispatch->_enddef(ncid,0,1,0,1);
905 }
906 
988 int
989 nc__enddef(int ncid, size_t h_minfree, size_t v_align, size_t v_minfree,
990  size_t r_align)
991 {
992  NC* ncp;
993  int stat = NC_check_id(ncid, &ncp);
994  if(stat != NC_NOERR) return stat;
995  return ncp->dispatch->_enddef(ncid,h_minfree,v_align,v_minfree,r_align);
996 }
997 
1065 int
1066 nc_sync(int ncid)
1067 {
1068  NC* ncp;
1069  int stat = NC_check_id(ncid, &ncp);
1070  if(stat != NC_NOERR) return stat;
1071  return ncp->dispatch->sync(ncid);
1072 }
1073 
1116 int
1117 nc_abort(int ncid)
1118 {
1119  NC* ncp;
1120  int stat = NC_check_id(ncid, &ncp);
1121  if(stat != NC_NOERR) return stat;
1122 
1123 #ifdef USE_REFCOUNT
1124  /* What to do if refcount > 0? */
1125  /* currently, forcibly abort */
1126  ncp->refcount = 0;
1127 #endif
1128 
1129  stat = ncp->dispatch->abort(ncid);
1130  del_from_NCList(ncp);
1131  free_NC(ncp);
1132  return stat;
1133 }
1134 
1175 int
1176 nc_close(int ncid)
1177 {
1178  NC* ncp;
1179  int stat = NC_check_id(ncid, &ncp);
1180  if(stat != NC_NOERR) return stat;
1181 
1182 #ifdef USE_REFCOUNT
1183  ncp->refcount--;
1184  if(ncp->refcount <= 0)
1185 #endif
1186  {
1187  stat = ncp->dispatch->close(ncid);
1188  /* Remove from the nc list */
1189  del_from_NCList(ncp);
1190  free_NC(ncp);
1191  }
1192  return stat;
1193 }
1194 
1293 int
1294 nc_set_fill(int ncid, int fillmode, int *old_modep)
1295 {
1296  NC* ncp;
1297  int stat = NC_check_id(ncid, &ncp);
1298  if(stat != NC_NOERR) return stat;
1299  return ncp->dispatch->set_fill(ncid,fillmode,old_modep);
1300 }
1301 
1313 int
1314 nc_inq_base_pe(int ncid, int *pe)
1315 {
1316  NC* ncp;
1317  int stat = NC_check_id(ncid, &ncp);
1318  if(stat != NC_NOERR) return stat;
1319  return ncp->dispatch->inq_base_pe(ncid,pe);
1320 }
1321 
1333 int
1334 nc_set_base_pe(int ncid, int pe)
1335 {
1336  NC* ncp;
1337  int stat = NC_check_id(ncid, &ncp);
1338  if(stat != NC_NOERR) return stat;
1339  return ncp->dispatch->set_base_pe(ncid,pe);
1340 }
1341 
1360 int
1361 nc_inq_format(int ncid, int *formatp)
1362 {
1363  NC* ncp;
1364  int stat = NC_check_id(ncid, &ncp);
1365  if(stat != NC_NOERR) return stat;
1366  return ncp->dispatch->inq_format(ncid,formatp);
1367 }
1368 
1394 int
1395 nc_inq_format_extended(int ncid, int *formatp, int *modep)
1396 {
1397  NC* ncp;
1398  int stat = NC_check_id(ncid, &ncp);
1399  if(stat != NC_NOERR) return stat;
1400  return ncp->dispatch->inq_format_extended(ncid,formatp,modep);
1401 }
1402 
1447 int
1448 nc_inq(int ncid, int *ndimsp, int *nvarsp, int *nattsp, int *unlimdimidp)
1449 {
1450  NC* ncp;
1451  int stat = NC_check_id(ncid, &ncp);
1452  if(stat != NC_NOERR) return stat;
1453  return ncp->dispatch->inq(ncid,ndimsp,nvarsp,nattsp,unlimdimidp);
1454 }
1455 
1456 int
1457 nc_inq_nvars(int ncid, int *nvarsp)
1458 {
1459  NC* ncp;
1460  int stat = NC_check_id(ncid, &ncp);
1461  if(stat != NC_NOERR) return stat;
1462  return ncp->dispatch->inq(ncid, NULL, nvarsp, NULL, NULL);
1463 }
1464 
1530 int
1531 nc_inq_type(int ncid, nc_type xtype, char *name, size_t *size)
1532 {
1533  NC* ncp;
1534  /* For compatibility, we need to allow inq about
1535  atomic types, even if ncid is ill-defined */
1536  if(xtype <= ATOMICTYPEMAX) {
1537  if(xtype <= NC_NAT) return NC_EBADTYPE;
1538  if(name) strncpy(name,NC_atomictypename(xtype),NC_MAX_NAME);
1539  if(size) *size = NC_atomictypelen(xtype);
1540  return NC_NOERR;
1541  } else {
1542  int stat = NC_check_id(ncid, &ncp);
1543  if(stat != NC_NOERR) return NC_EBADTYPE; /* compatibility */
1544  return ncp->dispatch->inq_type(ncid,xtype,name,size);
1545  }
1546 }
1583 int
1584 NC_create(const char *path, int cmode, size_t initialsz,
1585  int basepe, size_t *chunksizehintp, int useparallel,
1586  void* parameters, int *ncidp)
1587 {
1588  int stat = NC_NOERR;
1589  NC* ncp = NULL;
1590  NC_Dispatch* dispatcher = NULL;
1591  /* Need three pieces of information for now */
1592  int model = 0; /* one of the NC_DISPATCH_XXX values */
1593  int isurl = 0; /* dap or cdmremote or neither */
1594  int xcmode = 0; /* for implied cmode flags */
1595 
1596  /* Initialize the dispatch table. The function pointers in the
1597  * dispatch table will depend on how netCDF was built
1598  * (with/without netCDF-4, DAP, CDMREMOTE). */
1599  if(!nc_initialized)
1600  {
1601  if ((stat = NC_initialize()))
1602  return stat;
1603  /* Do local initialization */
1604  nc_local_initialize();
1605  nc_initialized = 1;
1606  }
1607 
1608 #ifdef USE_REFCOUNT
1609  /* If this path is already open, then fail */
1610  ncp = find_in_NCList_by_name(path);
1611  if(ncp != NULL)
1612  return NC_ENFILE;
1613 #endif
1614 
1615  if((isurl = NC_testurl(path)))
1616  model = NC_urlmodel(path);
1617 
1618  /* Look to the incoming cmode for hints */
1619  if(model == 0) {
1620 #ifdef USE_NETCDF4
1621  if(cmode & NC_NETCDF4)
1622  model = NC_DISPATCH_NC4;
1623  else
1624 #endif
1625 #ifdef USE_PNETCDF
1626  if(cmode & NC_PNETCDF)
1627  model = NC_DISPATCH_NC5;
1628  else
1629 #endif
1630  if(cmode & NC_CLASSIC_MODEL)
1631  model = NC_DISPATCH_NC3;
1632  }
1633 
1634  if(model == 0) {
1635  /* Check default format */
1636  int format = nc_get_default_format();
1637  switch (format) {
1638 #ifdef USE_NETCDF4
1639  case NC_FORMAT_NETCDF4:
1640  xcmode |= NC_NETCDF4;
1641  model = NC_DISPATCH_NC4;
1642  break;
1644  xcmode |= NC_CLASSIC_MODEL;
1645  model = NC_DISPATCH_NC4;
1646  break;
1647 #endif
1648  case NC_FORMAT_64BIT:
1649  xcmode |= NC_64BIT_OFFSET;
1650  /* fall thru */
1651  case NC_FORMAT_CLASSIC:
1652  default:
1653  model = NC_DISPATCH_NC3;
1654  break;
1655  }
1656  }
1657 
1658  /* Add inferred flags */
1659  cmode |= xcmode;
1660 
1661 #ifdef USE_NETCDF4
1662  if((cmode & NC_MPIIO && cmode & NC_MPIPOSIX))
1663  return NC_EINVAL;
1664 #endif
1665 
1666  if (!(dispatcher = NC_get_dispatch_override()))
1667  {
1668 
1669  /* Figure out what dispatcher to use */
1670 #ifdef USE_NETCDF4
1671 #ifdef USE_CDMREMOTE
1672  if(model == (NC_DISPATCH_NC4 | NC_DISPATCH_NCR))
1673  dispatcher = NCCR_dispatch_table;
1674  else
1675 #endif
1676  if(model == (NC_DISPATCH_NC4))
1677  dispatcher = NC4_dispatch_table;
1678  else
1679 #endif /*USE_NETCDF4*/
1680 #ifdef USE_DAP
1681  if(model == (NC_DISPATCH_NC3 | NC_DISPATCH_NCD))
1682  dispatcher = NCD2_dispatch_table;
1683  else
1684 #endif
1685 #ifdef USE_PNETCDF
1686  if(model == (NC_DISPATCH_NC5))
1687  dispatcher = NC5_dispatch_table;
1688  else
1689 #endif
1690  if(model == (NC_DISPATCH_NC3))
1691  dispatcher = NC3_dispatch_table;
1692  else
1693  return NC_ENOTNC;
1694  }
1695 
1696  /* Create the NC* instance and insert its dispatcher */
1697  stat = new_NC(dispatcher,path,cmode,&ncp);
1698  if(stat) return stat;
1699 
1700  /* Add to list of known open files and define ext_ncid */
1701  add_to_NCList(ncp);
1702 
1703 #ifdef USE_REFCOUNT
1704  /* bump the refcount */
1705  ncp->refcount++;
1706 #endif
1707 
1708  /* Assume create will fill in remaining ncp fields */
1709  if ((stat = dispatcher->create(path, cmode, initialsz, basepe, chunksizehintp,
1710  useparallel, parameters, dispatcher, ncp))) {
1711  del_from_NCList(ncp); /* oh well */
1712  free_NC(ncp);
1713  } else {
1714  if(ncidp)*ncidp = ncp->ext_ncid;
1715  }
1716  return stat;
1717 }
1718 
1734 int
1735 NC_open(const char *path, int cmode,
1736  int basepe, size_t *chunksizehintp,
1737  int useparallel, void* parameters,
1738  int *ncidp)
1739 {
1740  int stat = NC_NOERR;
1741  NC* ncp = NULL;
1742  NC_Dispatch* dispatcher = NULL;
1743  int inmemory = ((cmode & NC_INMEMORY) == NC_INMEMORY);
1744  /* Need pieces of information for now to decide model*/
1745  int model = 0;
1746  int isurl = 0;
1747  int version = 0;
1748  int flags = 0;
1749 
1750  if(!nc_initialized) {
1751  stat = NC_initialize();
1752  if(stat) return stat;
1753  /* Do local initialization */
1754  nc_local_initialize();
1755  nc_initialized = 1;
1756  }
1757 
1758 #ifdef USE_REFCOUNT
1759  /* If this path is already open, then bump the refcount and return it */
1760  ncp = find_in_NCList_by_name(path);
1761  if(ncp != NULL) {
1762  ncp->refcount++;
1763  if(ncidp) *ncidp = ncp->ext_ncid;
1764  return NC_NOERR;
1765  }
1766 #endif
1767 
1768  if(!inmemory) {
1769  isurl = NC_testurl(path);
1770  if(isurl)
1771  model = NC_urlmodel(path);
1772  }
1773  if(model == 0) {
1774  version = 0;
1775  /* Try to find dataset type */
1776  if(useparallel) flags |= NC_MPIIO;
1777  if(inmemory) flags |= NC_INMEMORY;
1778  stat = NC_check_file_type(path,flags,parameters,&model,&version);
1779  if(stat == NC_NOERR) {
1780  if(model == 0)
1781  return NC_ENOTNC;
1782  } else /* presumably not a netcdf file */
1783  return stat;
1784  }
1785 
1786  if(model == 0) {
1787  fprintf(stderr,"Model == 0\n");
1788  return NC_ENOTNC;
1789  }
1790 
1791  /* Force flag consistentcy */
1792  if(model & NC_DISPATCH_NC4)
1793  cmode |= NC_NETCDF4;
1794  else if(model & NC_DISPATCH_NC3) {
1795  cmode &= ~NC_NETCDF4; /* must be netcdf-3 */
1796  if(version == 2) cmode |= NC_64BIT_OFFSET;
1797  } else if(model & NC_DISPATCH_NC5) {
1798 #if 0
1799 It appears that pnetcdf can read NC_64_BIT_OFFSET
1800  cmode &= ~(NC_NETCDF4 | NC_64BIT_OFFSET); /* must be pnetcdf */
1801 #else
1802  cmode &= ~(NC_NETCDF4);
1803 #endif
1804  cmode |= NC_PNETCDF;
1805  }
1806 
1807  if((cmode & NC_MPIIO && cmode & NC_MPIPOSIX))
1808  return NC_EINVAL;
1809 
1810  /* override overrides any other table choice */
1811  dispatcher = NC_get_dispatch_override();
1812  if(dispatcher != NULL) goto havetable;
1813 
1814  /* Figure out what dispatcher to use */
1815 #if defined(USE_CDMREMOTE)
1816  if(model == (NC_DISPATCH_NC4 | NC_DISPATCH_NCR))
1817  dispatcher = NCCR_dispatch_table;
1818  else
1819 #endif
1820 #if defined(USE_DAP)
1821  if(model == (NC_DISPATCH_NC3 | NC_DISPATCH_NCD))
1822  dispatcher = NCD2_dispatch_table;
1823  else
1824 #endif
1825 #if defined(USE_PNETCDF)
1826  if(model == (NC_DISPATCH_NC5))
1827  dispatcher = NC5_dispatch_table;
1828  else
1829 #endif
1830 #if defined(USE_NETCDF4)
1831  if(model == (NC_DISPATCH_NC4))
1832  dispatcher = NC4_dispatch_table;
1833  else
1834 #endif
1835  if(model == (NC_DISPATCH_NC3))
1836  dispatcher = NC3_dispatch_table;
1837  else
1838  return NC_ENOTNC;
1839 
1840 havetable:
1841 
1842  /* Create the NC* instance and insert its dispatcher */
1843  stat = new_NC(dispatcher,path,cmode,&ncp);
1844  if(stat) return stat;
1845 
1846  /* Add to list of known open files */
1847  add_to_NCList(ncp);
1848 
1849 #ifdef USE_REFCOUNT
1850  /* bump the refcount */
1851  ncp->refcount++;
1852 #endif
1853 
1854  /* Assume open will fill in remaining ncp fields */
1855  stat = dispatcher->open(path, cmode, basepe, chunksizehintp,
1856  useparallel, parameters, dispatcher, ncp);
1857  if(stat == NC_NOERR) {
1858  if(ncidp) *ncidp = ncp->ext_ncid;
1859  } else {
1860  del_from_NCList(ncp);
1861  free_NC(ncp);
1862  }
1863  return stat;
1864 }
1865 
1866 /*Provide an internal function for generating pseudo file descriptors
1867  for systems that are not file based (e.g. dap, memio).
1868 */
1869 
1870 /* Static counter for pseudo file descriptors (incremented) */
1871 static int pseudofd = 0;
1872 
1873 /* Create a pseudo file descriptor that does not
1874  overlap real file descriptors
1875 */
1876 int
1877 nc__pseudofd(void)
1878 {
1879  if(pseudofd == 0) {
1880  int maxfd = 32767; /* default */
1881 #ifdef HAVE_GETRLIMIT
1882  struct rlimit rl;
1883  if(getrlimit(RLIMIT_NOFILE,&rl) == 0) {
1884  if(rl.rlim_max != RLIM_INFINITY)
1885  maxfd = (int)rl.rlim_max;
1886  if(rl.rlim_cur != RLIM_INFINITY)
1887  maxfd = (int)rl.rlim_cur;
1888  }
1889  pseudofd = maxfd+1;
1890 #endif
1891  }
1892  return pseudofd++;
1893 }
1894 
1895 
#define NC_PNETCDF
Use parallel-netcdf library.
Definition: netcdf.h:160
int nc__open(const char *path, int mode, size_t *chunksizehintp, int *ncidp)
Open a netCDF file with extra performance parameters for the classic library.
Definition: dfile.c:663
#define NC_ENFILE
Too many netcdfs open.
Definition: netcdf.h:290
#define NC_CLASSIC_MODEL
Enforce classic model.
Definition: netcdf.h:139
#define NC_MAX_VAR_DIMS
max per variable dimensions
Definition: netcdf.h:236
int nc_redef(int ncid)
Put open netcdf dataset into define mode.
Definition: dfile.c:834
int nc__enddef(int ncid, size_t h_minfree, size_t v_align, size_t v_minfree, size_t r_align)
Leave define mode with performance tuning.
Definition: dfile.c:989
#define NC_INMEMORY
Read from memory.
Definition: netcdf.h:137
#define NC_MPIIO
Turn on MPI I/O.
Definition: netcdf.h:156
int nc_inq_format(int ncid, int *formatp)
Inquire about the binary format of a netCDF file as presented by the API.
Definition: dfile.c:1361
int nc_inq(int ncid, int *ndimsp, int *nvarsp, int *nattsp, int *unlimdimidp)
Inquire about a file or group.
Definition: dfile.c:1448
int nc_type
The nc_type type is just an int.
Definition: netcdf.h:28
#define NC_64BIT_OFFSET
Use large (64-bit) file offsets.
Definition: netcdf.h:140
int nc_inq_format_extended(int ncid, int *formatp, int *modep)
Obtain more detailed (vis-a-vis nc_inq_format) format information about an open dataset.
Definition: dfile.c:1395
#define NC_ENOTNC
Not a netcdf file.
Definition: netcdf.h:333
int nc_close(int ncid)
Close an open netCDF dataset.
Definition: dfile.c:1176
#define NC_EDISKLESS
Error in using diskless access.
Definition: netcdf.h:418
#define NC_FORMAT_64BIT
Format specifier for nc_set_default_format() and returned by nc_inq_format.
Definition: netcdf.h:170
#define NC_EBADTYPE
Not a netcdf data type.
Definition: netcdf.h:319
#define NC_SIZEHINT_DEFAULT
Let nc__create() or nc__open() figure out a suitable buffer size.
Definition: netcdf.h:202
#define NC_EINVAL
Invalid Argument.
Definition: netcdf.h:292
int nc_set_fill(int ncid, int fillmode, int *old_modep)
Change the fill-value mode to improve write performance.
Definition: dfile.c:1294
#define NC_MAX_NAME
Maximum for classic library.
Definition: netcdf.h:235
#define NC_NAT
Not A Type.
Definition: netcdf.h:37
int nc_inq_type(int ncid, nc_type xtype, char *name, size_t *size)
Inquire about a type.
Definition: dfile.c:1531
#define NC_EPARINIT
Error initializing for parallel access.
Definition: netcdf.h:404
#define NC_NETCDF4
Use netCDF-4/HDF5 format.
Definition: netcdf.h:152
int nc__create(const char *path, int cmode, size_t initialsz, size_t *chunksizehintp, int *ncidp)
Create a netCDF file with some extra parameters controlling classic file cacheing.
Definition: dfile.c:468
#define NC_FORMAT_NETCDF4_CLASSIC
Format specifier for nc_set_default_format() and returned by nc_inq_format.
Definition: netcdf.h:172
#define NC_FORMAT_NETCDF4
Format specifier for nc_set_default_format() and returned by nc_inq_format.
Definition: netcdf.h:171
#define NC_WRITE
Set read-write access for nc_open().
Definition: netcdf.h:131
int nc_inq_path(int ncid, size_t *pathlen, char *path)
Get the file pathname (or the opendap URL) which was used to open/create the ncid's file...
Definition: dfile.c:769
#define NC_NOERR
No Error.
Definition: netcdf.h:282
#define NC_DISKLESS
Use diskless file.
Definition: netcdf.h:135
int nc_open(const char *path, int mode, int *ncidp)
Open an existing netCDF file.
Definition: dfile.c:606
int nc_enddef(int ncid)
Leave define mode.
Definition: dfile.c:898
int nc_open_mem(const char *path, int mode, size_t size, void *memory, int *ncidp)
Open a netCDF file with the contents taken from a block of memory.
Definition: dfile.c:716
#define NC_MMAP
Use diskless file with mmap.
Definition: netcdf.h:136
#define NC_FORMAT_CLASSIC
Format specifier for nc_set_default_format() and returned by nc_inq_format.
Definition: netcdf.h:169
int nc_sync(int ncid)
Synchronize an open netcdf dataset to disk.
Definition: dfile.c:1066
int nc_create(const char *path, int cmode, int *ncidp)
Create a new netCDF file.
Definition: dfile.c:401
#define NC_MPIPOSIX
Turn on MPI POSIX I/O.
Definition: netcdf.h:159

Return to the Main Unidata NetCDF page.
Generated on Tue Oct 6 2015 12:31:48 for NetCDF. NetCDF is a Unidata library.