|
NEP 1.7.0
NetCDF Extension Pack: compression extensions for NetCDF
|
Demonstrates 3D surface temperature with time, lat, lon coordinate variables. More...
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <netcdf.h>Macros | |
| #define | FILE_NAME "coord.nc" |
| #define | NTIME 3 |
| #define | NLAT 4 |
| #define | NLON 5 |
| #define | NDIMS 3 |
| #define | ERRCODE 2 |
| #define | ERR(e) {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);} |
Functions | |
| int | main () |
Demonstrates 3D surface temperature with time, lat, lon coordinate variables.
This example builds on coord_vars.c by adding a time dimension, creating a 3D surface temperature field with latitude, longitude, and time coordinate variables. It demonstrates how to work with three-dimensional data and follows Climate and Forecast (CF) conventions for all coordinate metadata, including the time axis.
The program creates a surface temperature dataset on a 4x5 lat/lon grid with 3 time steps, writes it to a classic NetCDF file, then reopens and validates all contents.
Learning Objectives:
calendar attribute for time coordinatescoordinates attribute to data variables (CF best practice)Key Concepts:
coordinates Attribute**: Explicitly links data variables to their coordinate variables, a CF convention best practiceCF Convention Attributes Used:
units: Physical units (degrees_north, degrees_east, hours since ..., K)standard_name: CF standard name vocabularylong_name: Human-readable descriptive nameaxis: Coordinate axis identifier (X, Y, T)calendar: Calendar type for time coordinates (standard)_FillValue: Value representing missing datacoordinates: Lists coordinate variables for a data variablePrerequisites:
Related Examples:
Compilation:
Usage:
Expected Output: Creates coord.nc containing:
| #define ERR | ( | e | ) | {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);} |
| #define ERRCODE 2 |
| #define FILE_NAME "coord.nc" |
| #define NDIMS 3 |
| #define NLAT 4 |
| #define NLON 5 |
| #define NTIME 3 |
| int main | ( | ) |