NetCDF  4.4.0-rc3
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_NCP: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 
124  /* Unused, throws a 'value never read' in static analysis. */
125  //int persist = ((flags & NC_WRITE) == NC_WRITE);
126 
127  int use_parallel = ((flags & NC_MPIIO) == NC_MPIIO);
128  int inmemory = (diskless && ((flags & NC_INMEMORY) == NC_INMEMORY));
129 
130  *model = 0;
131 
132  if(inmemory) {
133  NC_MEM_INFO* meminfo = (NC_MEM_INFO*)parameters;
134  if(meminfo == NULL || meminfo->size < MAGIC_NUMBER_LEN)
135  {status = NC_EDISKLESS; goto done;}
136  memcpy(magic,meminfo->memory,MAGIC_NUMBER_LEN);
137  } else {/* presumably a real file */
138  /* Get the 4-byte magic from the beginning of the file. Don't use posix
139  * for parallel, use the MPI functions instead. */
140 #ifdef USE_PARALLEL
141  if (use_parallel) {
142  MPI_File fh;
143  MPI_Status mstatus;
144  int retval;
145  MPI_Comm comm = MPI_COMM_WORLD;
146  MPI_Info info = MPI_INFO_NULL;
147 
148  if(parameters != NULL) {
149  comm = ((NC_MPI_INFO*)parameters)->comm;
150  info = ((NC_MPI_INFO*)parameters)->info;
151  }
152  if((retval = MPI_File_open(comm,(char*)path,MPI_MODE_RDONLY,info,
153  &fh)) != MPI_SUCCESS)
154  {status = NC_EPARINIT; goto done;}
155  if((retval = MPI_File_read(fh, magic, MAGIC_NUMBER_LEN, MPI_CHAR,
156  &mstatus)) != MPI_SUCCESS)
157  {status = NC_EPARINIT; goto done;}
158  if((retval = MPI_File_close(&fh)) != MPI_SUCCESS)
159  {status = NC_EPARINIT; goto done;}
160  } else
161 #endif /* USE_PARALLEL */
162  {
163  FILE *fp;
164  size_t i;
165 #ifdef HAVE_SYS_STAT_H
166  struct stat st;
167 #endif
168  if(path == NULL || strlen(path)==0)
169  {status = NC_EINVAL; goto done;}
170 
171  if (!(fp = fopen(path, "r")))
172  {status = errno; goto done;}
173 
174 #ifdef HAVE_SYS_STAT_H
175  /* The file must be at least MAGIC_NUMBER_LEN in size,
176  or otherwise the following fread will exhibit unexpected
177  behavior. */
178  if(!(fstat(fileno(fp),&st) == 0)) {
179  fclose(fp);
180  status = errno;
181  goto done;
182  }
183 
184  if(st.st_size < MAGIC_NUMBER_LEN) {
185  fclose(fp);
186  status = NC_ENOTNC;
187  goto done;
188  }
189 #endif
190 
191  i = fread(magic, MAGIC_NUMBER_LEN, 1, fp);
192  fclose(fp);
193  if(i == 0)
194  {status = NC_ENOTNC; goto done;}
195  if(i != 1)
196  {status = errno; goto done;}
197  }
198  } /* !inmemory */
199 
200  /* Look at the magic number */
201  status = NC_interpret_magic_number(magic,model,version,use_parallel);
202 
203 done:
204  return status;
205 }
206 
403 int
404 nc_create(const char *path, int cmode, int *ncidp)
405 {
406  return nc__create(path,cmode,NC_SIZEHINT_DEFAULT,NULL,ncidp);
407 }
408 
470 int
471 nc__create(const char *path, int cmode, size_t initialsz,
472  size_t *chunksizehintp, int *ncidp)
473 {
474  return NC_create(path, cmode, initialsz, 0,
475  chunksizehintp, 0, NULL, ncidp);
476 
477 }
486 int
487 nc__create_mp(const char *path, int cmode, size_t initialsz,
488  int basepe, size_t *chunksizehintp, int *ncidp)
489 {
490  return NC_create(path, cmode, initialsz, basepe,
491  chunksizehintp, 0, NULL, ncidp);
492 }
493 
608 int
609 nc_open(const char *path, int mode, int *ncidp)
610 {
611  return NC_open(path, mode, 0, NULL, 0, NULL, ncidp);
612 }
613 
665 int
666 nc__open(const char *path, int mode,
667  size_t *chunksizehintp, int *ncidp)
668 {
669  return NC_open(path, mode, 0, chunksizehintp, 0,
670  NULL, ncidp);
671 }
672 
718 int
719 nc_open_mem(const char* path, int mode, size_t size, void* memory, int* ncidp)
720 {
721 #ifdef USE_DISKLESS
722  NC_MEM_INFO meminfo;
723 
724  /* Sanity checks */
725  if(memory == NULL || size < MAGIC_NUMBER_LEN || path == NULL)
726  return NC_EINVAL;
727  if(mode & (NC_WRITE|NC_MPIIO|NC_MPIPOSIX|NC_MMAP))
728  return NC_EINVAL;
729  mode |= (NC_INMEMORY|NC_DISKLESS);
730  meminfo.size = size;
731  meminfo.memory = memory;
732  return NC_open(path, mode, 0, NULL, 0, &meminfo, ncidp);
733 #else
734  return NC_EDISKLESS;
735 #endif
736 }
737 
746 int
747 nc__open_mp(const char *path, int mode, int basepe,
748  size_t *chunksizehintp, int *ncidp)
749 {
750  return NC_open(path, mode, basepe, chunksizehintp,
751  0, NULL, ncidp);
752 }
753 
771 int
772 nc_inq_path(int ncid, size_t *pathlen, char *path)
773 {
774  NC* ncp;
775  int stat = NC_NOERR;
776  if ((stat = NC_check_id(ncid, &ncp)))
777  return stat;
778  if(ncp->path == NULL) {
779  if(pathlen) *pathlen = 0;
780  if(path) path[0] = '\0';
781  } else {
782  if (pathlen) *pathlen = strlen(ncp->path);
783  if (path) strcpy(path, ncp->path);
784  }
785  return stat;
786 }
787 
836 int
837 nc_redef(int ncid)
838 {
839  NC* ncp;
840  int stat = NC_check_id(ncid, &ncp);
841  if(stat != NC_NOERR) return stat;
842  return ncp->dispatch->redef(ncid);
843 }
844 
900 int
901 nc_enddef(int ncid)
902 {
903  int status = NC_NOERR;
904  NC *ncp;
905  status = NC_check_id(ncid, &ncp);
906  if(status != NC_NOERR) return status;
907  return ncp->dispatch->_enddef(ncid,0,1,0,1);
908 }
909 
991 int
992 nc__enddef(int ncid, size_t h_minfree, size_t v_align, size_t v_minfree,
993  size_t r_align)
994 {
995  NC* ncp;
996  int stat = NC_check_id(ncid, &ncp);
997  if(stat != NC_NOERR) return stat;
998  return ncp->dispatch->_enddef(ncid,h_minfree,v_align,v_minfree,r_align);
999 }
1000 
1068 int
1069 nc_sync(int ncid)
1070 {
1071  NC* ncp;
1072  int stat = NC_check_id(ncid, &ncp);
1073  if(stat != NC_NOERR) return stat;
1074  return ncp->dispatch->sync(ncid);
1075 }
1076 
1119 int
1120 nc_abort(int ncid)
1121 {
1122  NC* ncp;
1123  int stat = NC_check_id(ncid, &ncp);
1124  if(stat != NC_NOERR) return stat;
1125 
1126 #ifdef USE_REFCOUNT
1127  /* What to do if refcount > 0? */
1128  /* currently, forcibly abort */
1129  ncp->refcount = 0;
1130 #endif
1131 
1132  stat = ncp->dispatch->abort(ncid);
1133  del_from_NCList(ncp);
1134  free_NC(ncp);
1135  return stat;
1136 }
1137 
1178 int
1179 nc_close(int ncid)
1180 {
1181  NC* ncp;
1182  int stat = NC_check_id(ncid, &ncp);
1183  if(stat != NC_NOERR) return stat;
1184 
1185 #ifdef USE_REFCOUNT
1186  ncp->refcount--;
1187  if(ncp->refcount <= 0)
1188 #endif
1189  {
1190  stat = ncp->dispatch->close(ncid);
1191  /* Remove from the nc list */
1192  del_from_NCList(ncp);
1193  free_NC(ncp);
1194  }
1195  return stat;
1196 }
1197 
1296 int
1297 nc_set_fill(int ncid, int fillmode, int *old_modep)
1298 {
1299  NC* ncp;
1300  int stat = NC_check_id(ncid, &ncp);
1301  if(stat != NC_NOERR) return stat;
1302  return ncp->dispatch->set_fill(ncid,fillmode,old_modep);
1303 }
1304 
1316 int
1317 nc_inq_base_pe(int ncid, int *pe)
1318 {
1319  NC* ncp;
1320  int stat = NC_check_id(ncid, &ncp);
1321  if(stat != NC_NOERR) return stat;
1322  return ncp->dispatch->inq_base_pe(ncid,pe);
1323 }
1324 
1336 int
1337 nc_set_base_pe(int ncid, int pe)
1338 {
1339  NC* ncp;
1340  int stat = NC_check_id(ncid, &ncp);
1341  if(stat != NC_NOERR) return stat;
1342  return ncp->dispatch->set_base_pe(ncid,pe);
1343 }
1344 
1363 int
1364 nc_inq_format(int ncid, int *formatp)
1365 {
1366  NC* ncp;
1367  int stat = NC_check_id(ncid, &ncp);
1368  if(stat != NC_NOERR) return stat;
1369  return ncp->dispatch->inq_format(ncid,formatp);
1370 }
1371 
1397 int
1398 nc_inq_format_extended(int ncid, int *formatp, int *modep)
1399 {
1400  NC* ncp;
1401  int stat = NC_check_id(ncid, &ncp);
1402  if(stat != NC_NOERR) return stat;
1403  return ncp->dispatch->inq_format_extended(ncid,formatp,modep);
1404 }
1405 
1450 int
1451 nc_inq(int ncid, int *ndimsp, int *nvarsp, int *nattsp, int *unlimdimidp)
1452 {
1453  NC* ncp;
1454  int stat = NC_check_id(ncid, &ncp);
1455  if(stat != NC_NOERR) return stat;
1456  return ncp->dispatch->inq(ncid,ndimsp,nvarsp,nattsp,unlimdimidp);
1457 }
1458 
1459 int
1460 nc_inq_nvars(int ncid, int *nvarsp)
1461 {
1462  NC* ncp;
1463  int stat = NC_check_id(ncid, &ncp);
1464  if(stat != NC_NOERR) return stat;
1465  return ncp->dispatch->inq(ncid, NULL, nvarsp, NULL, NULL);
1466 }
1467 
1533 int
1534 nc_inq_type(int ncid, nc_type xtype, char *name, size_t *size)
1535 {
1536  NC* ncp;
1537  /* For compatibility, we need to allow inq about
1538  atomic types, even if ncid is ill-defined */
1539  if(xtype <= ATOMICTYPEMAX) {
1540  if(xtype <= NC_NAT) return NC_EBADTYPE;
1541  if(name) strncpy(name,NC_atomictypename(xtype),NC_MAX_NAME);
1542  if(size) *size = NC_atomictypelen(xtype);
1543  return NC_NOERR;
1544  } else {
1545  int stat = NC_check_id(ncid, &ncp);
1546  if(stat != NC_NOERR) return NC_EBADTYPE; /* compatibility */
1547  return ncp->dispatch->inq_type(ncid,xtype,name,size);
1548  }
1549 }
1586 int
1587 NC_create(const char *path, int cmode, size_t initialsz,
1588  int basepe, size_t *chunksizehintp, int useparallel,
1589  void* parameters, int *ncidp)
1590 {
1591  int stat = NC_NOERR;
1592  NC* ncp = NULL;
1593  NC_Dispatch* dispatcher = NULL;
1594  /* Need three pieces of information for now */
1595  int model = 0; /* one of the NC_DISPATCH_XXX values */
1596  int isurl = 0; /* dap or cdmremote or neither */
1597  int xcmode = 0; /* for implied cmode flags */
1598 
1599  /* Initialize the dispatch table. The function pointers in the
1600  * dispatch table will depend on how netCDF was built
1601  * (with/without netCDF-4, DAP, CDMREMOTE). */
1602  if(!nc_initialized)
1603  {
1604  if ((stat = NC_initialize()))
1605  return stat;
1606  /* Do local initialization */
1607  nc_local_initialize();
1608  nc_initialized = 1;
1609  }
1610 
1611 #ifdef USE_REFCOUNT
1612  /* If this path is already open, then fail */
1613  ncp = find_in_NCList_by_name(path);
1614  if(ncp != NULL)
1615  return NC_ENFILE;
1616 #endif
1617 
1618  if((isurl = NC_testurl(path)))
1619  model = NC_urlmodel(path);
1620 
1621  /* Look to the incoming cmode for hints */
1622  if(model == 0) {
1623 #ifdef USE_NETCDF4
1624  if(cmode & NC_NETCDF4)
1625  model = NC_DISPATCH_NC4;
1626  else
1627 #endif
1628 #ifdef USE_PNETCDF
1629  if(cmode & NC_PNETCDF)
1630  model = NC_DISPATCH_NCP;
1631  else
1632 #endif
1633  if(cmode & NC_CLASSIC_MODEL)
1634  model = NC_DISPATCH_NC3;
1635  }
1636 
1637  if(model == 0) {
1638  /* Check default format */
1639  int format = nc_get_default_format();
1640  switch (format) {
1641 #ifdef USE_NETCDF4
1642  case NC_FORMAT_NETCDF4:
1643  xcmode |= NC_NETCDF4;
1644  model = NC_DISPATCH_NC4;
1645  break;
1647  xcmode |= NC_CLASSIC_MODEL;
1648  model = NC_DISPATCH_NC4;
1649  break;
1650 #endif
1651  case NC_FORMAT_64BIT:
1652  xcmode |= NC_64BIT_OFFSET;
1653  /* fall thru */
1654  case NC_FORMAT_CLASSIC:
1655  default:
1656  model = NC_DISPATCH_NC3;
1657  break;
1658  }
1659  }
1660 
1661  /* Add inferred flags */
1662  cmode |= xcmode;
1663 
1664 #ifdef USE_NETCDF4
1665  if((cmode & NC_MPIIO && cmode & NC_MPIPOSIX))
1666  return NC_EINVAL;
1667 #endif
1668 
1669  if (!(dispatcher = NC_get_dispatch_override()))
1670  {
1671 
1672  /* Figure out what dispatcher to use */
1673 #ifdef USE_NETCDF4
1674 #ifdef USE_CDMREMOTE
1675  if(model == (NC_DISPATCH_NC4 | NC_DISPATCH_NCR))
1676  dispatcher = NCCR_dispatch_table;
1677  else
1678 #endif
1679  if(model == (NC_DISPATCH_NC4))
1680  dispatcher = NC4_dispatch_table;
1681  else
1682 #endif /*USE_NETCDF4*/
1683 #ifdef USE_DAP
1684  if(model == (NC_DISPATCH_NC3 | NC_DISPATCH_NCD))
1685  dispatcher = NCD2_dispatch_table;
1686  else
1687 #endif
1688 #ifdef USE_PNETCDF
1689  if(model == (NC_DISPATCH_NCP))
1690  dispatcher = NCP_dispatch_table;
1691  else
1692 #endif
1693  if(model == (NC_DISPATCH_NC3))
1694  dispatcher = NC3_dispatch_table;
1695  else
1696  return NC_ENOTNC;
1697  }
1698 
1699  /* Create the NC* instance and insert its dispatcher */
1700  stat = new_NC(dispatcher,path,cmode,&ncp);
1701  if(stat) return stat;
1702 
1703  /* Add to list of known open files and define ext_ncid */
1704  add_to_NCList(ncp);
1705 
1706 #ifdef USE_REFCOUNT
1707  /* bump the refcount */
1708  ncp->refcount++;
1709 #endif
1710 
1711  /* Assume create will fill in remaining ncp fields */
1712  if ((stat = dispatcher->create(path, cmode, initialsz, basepe, chunksizehintp,
1713  useparallel, parameters, dispatcher, ncp))) {
1714  del_from_NCList(ncp); /* oh well */
1715  free_NC(ncp);
1716  } else {
1717  if(ncidp)*ncidp = ncp->ext_ncid;
1718  }
1719  return stat;
1720 }
1721 
1737 int
1738 NC_open(const char *path, int cmode,
1739  int basepe, size_t *chunksizehintp,
1740  int useparallel, void* parameters,
1741  int *ncidp)
1742 {
1743  int stat = NC_NOERR;
1744  NC* ncp = NULL;
1745  NC_Dispatch* dispatcher = NULL;
1746  int inmemory = ((cmode & NC_INMEMORY) == NC_INMEMORY);
1747  /* Need pieces of information for now to decide model*/
1748  int model = 0;
1749  int isurl = 0;
1750  int version = 0;
1751  int flags = 0;
1752 
1753  if(!nc_initialized) {
1754  stat = NC_initialize();
1755  if(stat) return stat;
1756  /* Do local initialization */
1757  nc_local_initialize();
1758  nc_initialized = 1;
1759  }
1760 
1761 #ifdef USE_REFCOUNT
1762  /* If this path is already open, then bump the refcount and return it */
1763  ncp = find_in_NCList_by_name(path);
1764  if(ncp != NULL) {
1765  ncp->refcount++;
1766  if(ncidp) *ncidp = ncp->ext_ncid;
1767  return NC_NOERR;
1768  }
1769 #endif
1770 
1771  if(!inmemory) {
1772  isurl = NC_testurl(path);
1773  if(isurl)
1774  model = NC_urlmodel(path);
1775  }
1776  if(model == 0) {
1777  version = 0;
1778  /* Try to find dataset type */
1779  if(useparallel) flags |= NC_MPIIO;
1780  if(inmemory) flags |= NC_INMEMORY;
1781  stat = NC_check_file_type(path,flags,parameters,&model,&version);
1782  if(stat == NC_NOERR) {
1783  if(model == 0)
1784  return NC_ENOTNC;
1785  } else /* presumably not a netcdf file */
1786  return stat;
1787  }
1788 
1789  if(model == 0) {
1790  fprintf(stderr,"Model == 0\n");
1791  return NC_ENOTNC;
1792  }
1793 
1794  /* Force flag consistentcy */
1795  if(model & NC_DISPATCH_NC4)
1796  cmode |= NC_NETCDF4;
1797  else if(model & NC_DISPATCH_NC3) {
1798  cmode &= ~NC_NETCDF4; /* must be netcdf-3 */
1799  if(version == 2) cmode |= NC_64BIT_OFFSET;
1800  } else if(model & NC_DISPATCH_NCP) {
1801 #if 0
1802 It appears that pnetcdf can read NC_64_BIT_OFFSET
1803  cmode &= ~(NC_NETCDF4 | NC_64BIT_OFFSET); /* must be pnetcdf */
1804 #else
1805  cmode &= ~(NC_NETCDF4);
1806 #endif
1807  cmode |= NC_PNETCDF;
1808  }
1809 
1810  if((cmode & NC_MPIIO && cmode & NC_MPIPOSIX))
1811  return NC_EINVAL;
1812 
1813  /* override overrides any other table choice */
1814  dispatcher = NC_get_dispatch_override();
1815  if(dispatcher != NULL) goto havetable;
1816 
1817  /* Figure out what dispatcher to use */
1818 #if defined(USE_CDMREMOTE)
1819  if(model == (NC_DISPATCH_NC4 | NC_DISPATCH_NCR))
1820  dispatcher = NCCR_dispatch_table;
1821  else
1822 #endif
1823 #if defined(USE_DAP)
1824  if(model == (NC_DISPATCH_NC3 | NC_DISPATCH_NCD))
1825  dispatcher = NCD2_dispatch_table;
1826  else
1827 #endif
1828 #if defined(USE_PNETCDF)
1829  if(model == (NC_DISPATCH_NCP))
1830  dispatcher = NCP_dispatch_table;
1831  else
1832 #endif
1833 #if defined(USE_NETCDF4)
1834  if(model == (NC_DISPATCH_NC4))
1835  dispatcher = NC4_dispatch_table;
1836  else
1837 #endif
1838  if(model == (NC_DISPATCH_NC3))
1839  dispatcher = NC3_dispatch_table;
1840  else
1841  return NC_ENOTNC;
1842 
1843 havetable:
1844 
1845  /* Create the NC* instance and insert its dispatcher */
1846  stat = new_NC(dispatcher,path,cmode,&ncp);
1847  if(stat) return stat;
1848 
1849  /* Add to list of known open files */
1850  add_to_NCList(ncp);
1851 
1852 #ifdef USE_REFCOUNT
1853  /* bump the refcount */
1854  ncp->refcount++;
1855 #endif
1856 
1857  /* Assume open will fill in remaining ncp fields */
1858  stat = dispatcher->open(path, cmode, basepe, chunksizehintp,
1859  useparallel, parameters, dispatcher, ncp);
1860  if(stat == NC_NOERR) {
1861  if(ncidp) *ncidp = ncp->ext_ncid;
1862  } else {
1863  del_from_NCList(ncp);
1864  free_NC(ncp);
1865  }
1866  return stat;
1867 }
1868 
1869 /*Provide an internal function for generating pseudo file descriptors
1870  for systems that are not file based (e.g. dap, memio).
1871 */
1872 
1873 /* Static counter for pseudo file descriptors (incremented) */
1874 static int pseudofd = 0;
1875 
1876 /* Create a pseudo file descriptor that does not
1877  overlap real file descriptors
1878 */
1879 int
1880 nc__pseudofd(void)
1881 {
1882  if(pseudofd == 0) {
1883  int maxfd = 32767; /* default */
1884 #ifdef HAVE_GETRLIMIT
1885  struct rlimit rl;
1886  if(getrlimit(RLIMIT_NOFILE,&rl) == 0) {
1887  if(rl.rlim_max != RLIM_INFINITY)
1888  maxfd = (int)rl.rlim_max;
1889  if(rl.rlim_cur != RLIM_INFINITY)
1890  maxfd = (int)rl.rlim_cur;
1891  }
1892  pseudofd = maxfd+1;
1893 #endif
1894  }
1895  return pseudofd++;
1896 }
#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:666
#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:837
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:992
#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:1364
int nc_inq(int ncid, int *ndimsp, int *nvarsp, int *nattsp, int *unlimdimidp)
Inquire about a file or group.
Definition: dfile.c:1451
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:1398
#define NC_ENOTNC
Not a netcdf file.
Definition: netcdf.h:333
int nc_close(int ncid)
Close an open netCDF dataset.
Definition: dfile.c:1179
#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:1297
#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:1534
#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:471
#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:772
#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:609
int nc_enddef(int ncid)
Leave define mode.
Definition: dfile.c:901
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:719
#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:1069
int nc_create(const char *path, int cmode, int *ncidp)
Create a new netCDF file.
Definition: dfile.c:404
#define NC_MPIPOSIX
Turn on MPI POSIX I/O.
Definition: netcdf.h:159

Return to the Main Unidata NetCDF page.
Generated on Sun Nov 1 2015 19:54:55 for NetCDF. NetCDF is a Unidata library.