|
NEP 1.5.1
NetCDF Extension Pack: compression extensions for NetCDF
|
Demonstrates multi-dimensional arrays (2D, 3D, 4D) with dimension reuse. More...
#include <stdio.h>#include <stdlib.h>#include <netcdf.h>Macros | |
| #define | FILE_NAME "var4d.nc" |
| #define | NTIME 3 |
| #define | NLEVEL 2 |
| #define | NLAT 4 |
| #define | NLON 5 |
| #define | ERRCODE 2 |
| #define | ERR(e) {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);} |
Functions | |
| int | main () |
Demonstrates multi-dimensional arrays (2D, 3D, 4D) with dimension reuse.
This example shows how to work with multi-dimensional scientific data by creating variables of different dimensionalities (2D, 3D, 4D) that share common dimensions. This pattern is typical in atmospheric and oceanographic data where variables have different spatial and temporal coverage.
The program creates a file with 4 dimensions (time, level, lat, lon) and three temperature variables: surface temperature (2D), temperature profile (3D), and full 3D atmospheric temperature (4D). This demonstrates dimension reuse and efficient file organization.
Learning Objectives:
Key Concepts:
Dimension Ordering Convention:
Prerequisites:
Related Examples:
Compilation:
Usage:
Expected Output: Creates var4d.nc containing:
| #define ERR | ( | e | ) | {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);} |
| #define ERRCODE 2 |
| #define FILE_NAME "var4d.nc" |
| #define NLAT 4 |
| #define NLEVEL 2 |
| #define NLON 5 |
| #define NTIME 3 |
| int main | ( | ) |