NEP 4.3.0
NetCDF Expansion Pack
Loading...
Searching...
No Matches
remote_refs.c File Reference

Store references to remote datasets and follow them. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <netcdf.h>
#include "nep.h"
#include "nxcdf/nxcdf.h"
#include "nep_meta.h"

Macros

#define FILE_NAME   "remote_refs.nc"
#define ATT_URL   "remote_url"
#define ATT_PATH   "remote_path"
#define CHECK(expr)

Functions

int main (int argc, char **argv)

Detailed Description

Store references to remote datasets and follow them.

This program demonstrates nxCDF remote references. Unlike file references (see external_refs.c), a remote reference is not an HDF5 token: it is a stored convention of two strings — a URL and an object path — kept here as NC_STRING attribute values. The program writes a (URL, path) pair to a nxCDF file, reads it back after reopening, then calls nc_ref_open_remote() to open the remote dataset through nc_open() — DAP2, DAP4 or NCZarr dispatch, whatever the installed NetCDF-C resolves — and resolve the path to a real NetCDF variable, group or attribute in one call.

Usage:

NCRCENV_RC=<build>/.ncrc NETCDF_RC=<build> ./remote_refs <url> [path]

With no arguments the program only exercises the storage convention and reports that no remote URL was given. Pass a resolvable URL (for example a public DAP server dataset) and an object path like /sst or /grp/var#units to resolve a real remote object.

Learning Objectives:

  • Store a (URL, object path) remote reference as NC_STRING data
  • Resolve a remote reference with nc_ref_open_remote()
  • Resolve further paths on the same session with nc_ref_resolve()
Author
Edward Hartnett, Intelligent Data Design, Inc.

Macro Definition Documentation

◆ ATT_PATH

#define ATT_PATH   "remote_path"

◆ ATT_URL

#define ATT_URL   "remote_url"

◆ CHECK

#define CHECK ( expr)
Value:
do { \
int _ret = (expr); \
if (_ret != NC_NOERR) { \
fprintf(stderr, "%s:%d: %s failed: %s\n", __FILE__, __LINE__, #expr, nc_strerror(_ret)); \
return 1; \
} \
} while (0)

◆ FILE_NAME

#define FILE_NAME   "remote_refs.nc"

Function Documentation

◆ main()

int main ( int argc,
char ** argv )