Simple OPeNDAP example in Fortran.
This is the Fortran equivalent of opendap_simple.c, demonstrating that OPeNDAP remote access works identically in Fortran through the NetCDF-Fortran library.
What this example does:
- Opens a remote sea surface temperature dataset from test.opendap.org
- Queries dataset metadata using nf90_inquire
- Reads information about the 'sst' variable dimensions
- Reads a small 5x5 spatial subset from the first time step
- Closes the remote connection
CRITICAL: Indexing differences to understand:
- OPeNDAP constraint expressions in URLs use 0-based indexing [0:2]
- NetCDF-Fortran API uses 1-based indexing: start=(/1, 1, 1/)
- This is automatically handled by the Fortran interface
The example uses the same public test dataset as the C version: sst.mnmean.nc.gz - NOAA Extended Reconstructed Sea Surface Temperature
Learning Objectives:
- Open a remote OPeNDAP dataset from Fortran using nf90_open() with an HTTP URL
- Query dataset metadata (dimensions, variables, attributes) via nf90_inquire()
- Read a spatial subset using start/count arrays with 1-based Fortran indexing
- Understand that OPeNDAP access is transparent — same API as local files
Key Concepts:
- Transparent Remote Access: nf90_open() accepts HTTP URLs just like local paths
- 1-Based Indexing: Fortran start arrays begin at 1, not 0 as in C
- Constraint vs Client Subsetting: This example uses no URL constraints; subsetting is done client-side via start/count in nf90_get_var()
- OPeNDAP Indexing: URL constraint expressions use 0-based indexing, but Fortran API calls use 1-based — the library handles the translation
Prerequisites:
Related Examples:
Compilation:
program f_opendap_simple
Definition f_opendap_simple.f90:77
Usage:
Expected Output:
- Opens remote SST dataset and prints dimension/variable counts
- Reads and displays a 5x5 spatial subset from the first time step
- 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