NEP 1.7.0
NetCDF Extension Pack: compression extensions for NetCDF
Loading...
Searching...
No Matches
Macros | Functions
coord.c File Reference

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 ()
 

Detailed Description

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:

Key Concepts:

CF Convention Attributes Used:

Prerequisites:

Related Examples:

Compilation:

gcc -o coord coord.c -lnetcdf

Usage:

./coord
ncdump coord.nc

Expected Output: Creates coord.nc containing:

Author
Edward Hartnett, Intelligent Data Design, Inc.
Date
2026

Macro Definition Documentation

◆ ERR

#define ERR (   e)    {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);}

◆ ERRCODE

#define ERRCODE   2

◆ FILE_NAME

#define FILE_NAME   "coord.nc"

◆ NDIMS

#define NDIMS   3

◆ NLAT

#define NLAT   4

◆ NLON

#define NLON   5

◆ NTIME

#define NTIME   3

Function Documentation

◆ main()

int main ( )