NEP 2.7.0
NetCDF Extension Pack
Loading...
Searching...
No Matches
Functions/Subroutines
f_opendap_constraint.f90 File Reference

OPeNDAP constraint expression example in Fortran. More...

Functions/Subroutines

program f_opendap_constraint
 

Detailed Description

OPeNDAP constraint expression example in Fortran.

This is the Fortran equivalent of opendap_constraint.c, demonstrating server-side subsetting using OPeNDAP constraint expressions.

What this example does:

  1. Builds a constrained URL: base_url + "?sst[0:2][0:88][0:179]"
  2. Opens the constrained dataset - only 3 time steps are visible
  3. Shows that nf90_inquire_dimension returns CONSTRAINED sizes
  4. Dynamically allocates array based on constrained dimensions
  5. Reads all constrained data with nf90_get_var
  6. Reopens with stride constraint [0:2:12] to sample every 2nd step

IMPORTANT indexing note:

Server-side subsetting reduces network transfer by having the OPeNDAP server extract only requested data. The constrained dataset appears to have only the subset dimensions, not the full original dimensions.

Learning Objectives:

Key Concepts:

Prerequisites:

Related Examples:

Compilation:

gfortran -o f_opendap_constraint f_opendap_constraint.f90 -lnetcdff -lnetcdf
program f_opendap_constraint
Definition f_opendap_constraint.f90:86

Usage:

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

Function/Subroutine Documentation

◆ f_opendap_constraint()

program f_opendap_constraint