![]() |
NetCDF
4.9.3
|
Suppose that you have the URL to a remote dataset which is a normal netcdf-3 or netcdf-4 file.
The netCDF-c library now supports read-only access to such datasets using the HTTP byte range capability [], assuming that the remote server supports byte-range access.
Two examples:
Other remote servers may also provide byte-range access in a similar form.
It is important to note that this is not intended as a true production capability because it is believed that this kind of access can be quite slow. In addition, the byte-range IO drivers do not currently do any sort of optimization or caching.
This capability is enabled using the option *–enable-byterange* option to the *./configure* command for Automake. For Cmake, the option flag is *-DNETCDF_ENABLE_BYTERANGE=true*.
This capability requires access to libcurl, and an error will occur if byterange is enabled, but libcurl could not be located. In this, it is similar to the DAP2 and DAP4 capabilities.
In order to use this capability at run-time, with ncdump for example, it is necessary to provide a URL pointing to the basic dataset to be accessed. The URL must be annotated to tell the netcdf-c library that byte-range access should be used. This is indicated by appending the phrase #mode=bytes to the end of the URL. The two examples above show how this will look.
In order to determine the kind of file being accessed, the netcdf-c library will read what is called the "magic number" from the beginning of the remote dataset. This magic number is a specific set of bytes that indicates the kind of file: classic, enhanced, cdf5, etc.
Internally, this capability is implemented with the following drivers:
Both httpio.c and H5FDhttp.c are adapters that use dhttp.c to do the work. Testing for the magic number is also carried out by using the dhttp.c code. H5FDros3 is also an adapter, but specialized for cloud storage access.
The netcdf-3 code in the directory libsrc is built using a secondary dispatch mechanism called ncio. This allows the netcdf-3 code be independent of the lowest level IO access mechanisms. This is how in-memory and mmap based access is implemented. The file httpio.c is the dispatcher used to provide byte-range IO for the netcdf-3 code. Note that httpio.c is mostly just an adapter between the ncio API and the dhttp.c code.
Similar to the netcdf-3 code, the HDF5 library provides a secondary dispatch mechanism H5FD. This allows the HDF5 code to be independent of the lowest level IO access mechanisms. The netcdf-4 code in libhdf5 is built on the HDF5 library, so it indirectly inherits the H5FD mechanism.
The file H5FDhttp.c implements the H5FD dispatcher API and provides byte-range IO for the netcdf-4 code (and for the HDF5 library as a side effect). It only works for non-cloud servers such as the Unidata Thredds server.
Note that H5FDhttp.c is mostly just an adapter between the H5FD API and the dhttp.c code.