NEP 2.7.0
NetCDF Extension Pack
Loading...
Searching...
No Matches
Macros | Functions
opendap_simple.c File Reference

Simple OPeNDAP example - open, read, and close a remote dataset. More...

#include <netcdf.h>
#include <stdio.h>
#include <stdlib.h>

Macros

#define ERR(e)
 

Functions

int main (void)
 

Detailed Description

Simple OPeNDAP example - open, read, and close a remote dataset.

This is the most basic OPeNDAP example, demonstrating the core concept: remote datasets are accessed using the same NetCDF API calls as local files.

What this example does:

  1. Opens a remote sea surface temperature dataset from the public OPeNDAP test server at test.opendap.org
  2. Queries dataset metadata (dimensions, variables, attributes)
  3. Reads information about the 'sst' variable and its dimensions
  4. Reads a small 5x5 spatial subset from the first time step
  5. Closes the remote connection

Key OPeNDAP concepts demonstrated:

The dataset accessed is sst.mnmean.nc.gz, a classic netCDF-3 file containing NOAA Extended Reconstructed Sea Surface Temperature data. The server transparently decompresses and serves the data via OPeNDAP.

Learning Objectives:

Key Concepts:

Prerequisites:

Related Examples:

Compilation:

gcc -o opendap_simple opendap_simple.c -lnetcdf

Usage:

./opendap_simple

Expected Output:

Note
Companion code for "The NetCDF Developer's Handbook: The Authoritative Guide to Writing High-Performance Programs for Scientific Data Management, Second Edition" (https://www.amazon.com/dp/B0H7Q1Z75L)
Author
Edward Hartnett
Date
6/15/26

Macro Definition Documentation

◆ ERR

#define ERR (   e)
Value:
do { \
if (e) { \
fprintf(stderr, "Error: %s at line %d\n", nc_strerror(e), __LINE__); \
return 1; \
} \
} while (0)

Function Documentation

◆ main()

int main ( void  )