|
NEP 1.5.1
NetCDF Extension Pack: compression extensions for NetCDF
|
Demonstrates NetCDF-4 user-defined types (compound, enum, vlen, opaque) More...
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>#include <netcdf.h>Data Structures | |
| struct | WeatherObs |
Macros | |
| #define | FILE_NAME "user_types.nc" |
| #define | NOBS 5 |
| #define | NDAYS 3 |
| #define | CALIB_SIZE 16 |
| #define | ERRCODE 2 |
| #define | ERR(e) {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);} |
Enumerations | |
| enum | CloudCover { CLEAR = 0 , PARTLY_CLOUDY = 1 , CLOUDY = 2 , OVERCAST = 3 } |
Functions | |
| int | main () |
Demonstrates NetCDF-4 user-defined types (compound, enum, vlen, opaque)
This example showcases NetCDF-4's powerful type system, which extends beyond the basic atomic types (int, float, etc.) to include user-defined types similar to C structures and enumerations. User-defined types enable more expressive and efficient data models for complex scientific data.
The program demonstrates four types of user-defined types:
Learning Objectives:
Key Concepts:
User-Defined Type Details:
Compound Types:
Enum Types:
Variable-Length Types:
Opaque Types:
Prerequisites:
Related Examples:
Compilation:
Usage:
Expected Output: Creates user_types.nc containing:
| #define CALIB_SIZE 16 |
| #define ERR | ( | e | ) | {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);} |
| #define ERRCODE 2 |
| #define FILE_NAME "user_types.nc" |
| #define NDAYS 3 |
| #define NOBS 5 |
| enum CloudCover |
| int main | ( | ) |