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

Demonstrates coordinate variables and CF convention metadata. More...

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

Macros

#define FILE_NAME   "coord_vars.nc"
 
#define NLAT   4
 
#define NLON   5
 
#define ERRCODE   2
 
#define ERR(e)   {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);}
 

Functions

int main ()
 

Detailed Description

Demonstrates coordinate variables and CF convention metadata.

This example introduces the concept of coordinate variables - special 1D variables that share the same name as their dimension and provide values along that axis. Coordinate variables are essential for geospatial data, defining latitude, longitude, time, or other dimensional coordinates.

The program creates a 2D temperature field (4x5 grid) with latitude and longitude coordinate variables following Climate and Forecast (CF) conventions. CF conventions are the standard metadata conventions for climate and forecast data.

Learning Objectives:

Key Concepts:

CF Convention Attributes Used:

Prerequisites:

Related Examples:

Compilation:

gcc -o coord_vars coord_vars.c -lnetcdf

Usage:

./coord_vars
ncdump coord_vars.nc

Expected Output: Creates coord_vars.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_vars.nc"

◆ NLAT

#define NLAT   4

◆ NLON

#define NLON   5

Function Documentation

◆ main()

int main ( )