|
NEP 4.3.0
NetCDF Expansion Pack
|
NetCDF Expansion Pack (NEP) - Public API. More...
#include <stdio.h>#include <stdint.h>#include <netcdf.h>#include <netcdf_filter.h>Go to the source code of this file.
Typedefs | |
| typedef uint16_t | nc_bfloat16_t |
| typedef uint16_t | nc_float16_t |
Functions | |
| int | nep_set_log_level (int new_level) |
| int | nc_get_var1_bfloat16 (int ncid, int varid, const size_t *indexp, nc_bfloat16_t *ip) |
| Read one value from a variable as bfloat16. | |
| int | nc_put_var1_bfloat16 (int ncid, int varid, const size_t *indexp, const nc_bfloat16_t *op) |
| Write one value to a variable as bfloat16. | |
| int | nc_get_var_bfloat16 (int ncid, int varid, nc_bfloat16_t *ip) |
| Read a whole variable as bfloat16. | |
| int | nc_put_var_bfloat16 (int ncid, int varid, const nc_bfloat16_t *op) |
| Write a whole variable from bfloat16 values. | |
| int | nc_get_vars_bfloat16 (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, nc_bfloat16_t *ip) |
| Read a strided hyperslab of a variable as bfloat16. | |
| int | nc_put_vars_bfloat16 (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const nc_bfloat16_t *op) |
| Write a strided hyperslab of a variable from bfloat16 values. | |
| int | nc_get_vara_bfloat16 (int ncid, int varid, const size_t *startp, const size_t *countp, nc_bfloat16_t *ip) |
| Read a hyperslab of a variable as bfloat16. | |
| int | nc_put_vara_bfloat16 (int ncid, int varid, const size_t *startp, const size_t *countp, const nc_bfloat16_t *op) |
| Write a hyperslab of a variable from bfloat16 values. | |
| int | nc_get_var1_float16 (int ncid, int varid, const size_t *indexp, nc_float16_t *ip) |
| Read one value from a variable as IEEE 754 float16. | |
| int | nc_put_var1_float16 (int ncid, int varid, const size_t *indexp, const nc_float16_t *op) |
| Write one value to a variable as IEEE 754 float16. | |
| int | nc_get_var_float16 (int ncid, int varid, nc_float16_t *ip) |
| Read a whole variable as IEEE 754 float16. | |
| int | nc_put_var_float16 (int ncid, int varid, const nc_float16_t *op) |
| Write a whole variable from IEEE 754 float16 values. | |
| int | nc_get_vars_float16 (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, nc_float16_t *ip) |
| Read a strided hyperslab of a variable as IEEE 754 float16. | |
| int | nc_put_vars_float16 (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const nc_float16_t *op) |
| Write a strided hyperslab of a variable from IEEE 754 float16 values. | |
| int | nc_get_vara_float16 (int ncid, int varid, const size_t *startp, const size_t *countp, nc_float16_t *ip) |
| Read a hyperslab of a variable as IEEE 754 float16. | |
| int | nc_put_vara_float16 (int ncid, int varid, const size_t *startp, const size_t *countp, const nc_float16_t *op) |
| Write a hyperslab of a variable from IEEE 754 float16 values. | |
NetCDF Expansion Pack (NEP) - Public API.
Defines NEP logging and the centralized mapping of file formats to NetCDF User-Defined Format (UDF) slot numbers.
Current netcdf-c main provides 64 UDF slots (UDF0-UDF63). NEP occupies UDF0-UDF9:
| #define NEP_HAVE_NATIVE_BFLOAT16 0 |
1 when nc_bfloat16_t is the compiler's __bf16 type, 0 when it is uint16_t.
| #define NEP_HAVE_NATIVE_FLOAT16 0 |
1 when nc_float16_t is the compiler's _Float16 type, 0 when it is uint16_t.
| typedef uint16_t nc_bfloat16_t |
One bfloat16 value in memory: 2 bytes holding the bfloat16 bit pattern either way. With __bf16, C casts convert numerically, so code that holds raw bits in uint16_t passes them by casting the pointer ((nc_bfloat16_t *)(void *)bits), not by assigning values.
| typedef uint16_t nc_float16_t |
One IEEE 754 binary16 value in memory: 2 bytes holding the float16 bit pattern either way. With _Float16, C casts convert numerically, so code that holds raw bits in uint16_t passes them by casting the pointer ((nc_float16_t *)(void *)bits), not by assigning values.
| int nc_get_var1_bfloat16 | ( | int | ncid, |
| int | varid, | ||
| const size_t * | indexp, | ||
| nc_bfloat16_t * | ip ) |
Read one value from a variable as bfloat16.
| ncid | NetCDF file ID. |
| varid | Variable ID. |
| indexp | Element coordinates (NULL reads element 0). |
| ip | Returned bfloat16 value. |
Read one value from a variable as bfloat16. See nep.h for the variable types accepted and the conversion rules.
| int nc_get_var1_float16 | ( | int | ncid, |
| int | varid, | ||
| const size_t * | indexp, | ||
| nc_float16_t * | ip ) |
Read one value from a variable as IEEE 754 float16.
| ncid | NetCDF file ID. |
| varid | Variable ID. |
| indexp | Element coordinates (NULL reads element 0). |
| ip | Returned float16 value. |
| int nc_get_var_bfloat16 | ( | int | ncid, |
| int | varid, | ||
| nc_bfloat16_t * | ip ) |
Read a whole variable as bfloat16.
| ncid | NetCDF file ID. |
| varid | Variable ID. |
| ip | Returned bfloat16 values, one per element. |
Read a whole variable as bfloat16. See nep.h for the variable types accepted and the conversion rules.
| int nc_get_var_float16 | ( | int | ncid, |
| int | varid, | ||
| nc_float16_t * | ip ) |
Read a whole variable as IEEE 754 float16.
| ncid | NetCDF file ID. |
| varid | Variable ID. |
| ip | Returned float16 values, one per element. |
| int nc_get_vara_bfloat16 | ( | int | ncid, |
| int | varid, | ||
| const size_t * | startp, | ||
| const size_t * | countp, | ||
| nc_bfloat16_t * | ip ) |
Read a hyperslab of a variable as bfloat16.
Works on any file the netCDF API can open. An NC_BFLOAT16 variable returns its raw bit patterns with no conversion. An NC_FLOAT or NC_DOUBLE variable is read with the corresponding typed call and every value is converted to bfloat16 by NEP, rounding to nearest with ties to even (a single rounding from double); the bfloat16-to-float/double direction is exact. An NC_CHAR variable returns NC_ECHAR; every other variable type (including NC_FLOAT16) returns NC_EBADTYPE, and nothing is read.
| ncid | NetCDF file ID. |
| varid | Variable ID (NC_BFLOAT16, NC_FLOAT or NC_DOUBLE). |
| startp | Start index in each dimension. |
| countp | Edge count in each dimension. |
| ip | Returned bfloat16 values. |
Read a hyperslab of a variable as bfloat16. See nep.h for the variable types accepted and the conversion rules.
| int nc_get_vara_float16 | ( | int | ncid, |
| int | varid, | ||
| const size_t * | startp, | ||
| const size_t * | countp, | ||
| nc_float16_t * | ip ) |
Read a hyperslab of a variable as IEEE 754 float16.
Works on any file the netCDF API can open. An NC_FLOAT16 variable returns its raw bit patterns with no conversion. An NC_FLOAT or NC_DOUBLE variable is read with the corresponding typed call and every value is converted to float16 by NEP, rounding to nearest with ties to even (a single rounding from double); the float16-to-float/double direction is exact. An NC_CHAR variable returns NC_ECHAR; every other variable type (including NC_BFLOAT16) returns NC_EBADTYPE, and nothing is read.
| ncid | NetCDF file ID. |
| varid | Variable ID (NC_FLOAT16, NC_FLOAT or NC_DOUBLE). |
| startp | Start index in each dimension. |
| countp | Edge count in each dimension. |
| ip | Returned float16 values. |
| int nc_get_vars_bfloat16 | ( | int | ncid, |
| int | varid, | ||
| const size_t * | startp, | ||
| const size_t * | countp, | ||
| const ptrdiff_t * | stridep, | ||
| nc_bfloat16_t * | ip ) |
Read a strided hyperslab of a variable as bfloat16.
| ncid | NetCDF file ID. |
| varid | Variable ID. |
| startp | Start index in each dimension. |
| countp | Edge count in each dimension. |
| stridep | Stride in each dimension. |
| ip | Returned bfloat16 values. |
Read a strided hyperslab of a variable as bfloat16. See nep.h for the variable types accepted and the conversion rules.
| int nc_get_vars_float16 | ( | int | ncid, |
| int | varid, | ||
| const size_t * | startp, | ||
| const size_t * | countp, | ||
| const ptrdiff_t * | stridep, | ||
| nc_float16_t * | ip ) |
Read a strided hyperslab of a variable as IEEE 754 float16.
| ncid | NetCDF file ID. |
| varid | Variable ID. |
| startp | Start index in each dimension. |
| countp | Edge count in each dimension. |
| stridep | Stride in each dimension. |
| ip | Returned float16 values. |
| int nc_put_var1_bfloat16 | ( | int | ncid, |
| int | varid, | ||
| const size_t * | indexp, | ||
| const nc_bfloat16_t * | op ) |
Write one value to a variable as bfloat16.
| ncid | NetCDF file ID. |
| varid | Variable ID. |
| indexp | Element coordinates (NULL writes element 0). |
| op | The bfloat16 value to write. |
Write one value to a variable as bfloat16. See nep.h for the variable types accepted and the conversion rules.
| int nc_put_var1_float16 | ( | int | ncid, |
| int | varid, | ||
| const size_t * | indexp, | ||
| const nc_float16_t * | op ) |
Write one value to a variable as IEEE 754 float16.
| ncid | NetCDF file ID. |
| varid | Variable ID. |
| indexp | Element coordinates (NULL writes element 0). |
| op | The float16 value to write. |
| int nc_put_var_bfloat16 | ( | int | ncid, |
| int | varid, | ||
| const nc_bfloat16_t * | op ) |
Write a whole variable from bfloat16 values.
| ncid | NetCDF file ID. |
| varid | Variable ID. |
| op | The bfloat16 values to write, one per element. |
Write a whole variable from bfloat16 values. See nep.h for the variable types accepted and the conversion rules.
| int nc_put_var_float16 | ( | int | ncid, |
| int | varid, | ||
| const nc_float16_t * | op ) |
Write a whole variable from IEEE 754 float16 values.
| ncid | NetCDF file ID. |
| varid | Variable ID. |
| op | The float16 values to write, one per element. |
| int nc_put_vara_bfloat16 | ( | int | ncid, |
| int | varid, | ||
| const size_t * | startp, | ||
| const size_t * | countp, | ||
| const nc_bfloat16_t * | op ) |
Write a hyperslab of a variable from bfloat16 values.
Works on any file the netCDF API can open. An NC_BFLOAT16 variable stores the raw bit patterns with no conversion. An NC_FLOAT or NC_DOUBLE variable is written with the corresponding typed call after every value is widened exactly to float or double by NEP; puts never overflow. An NC_CHAR variable returns NC_ECHAR; every other variable type (including NC_FLOAT16) returns NC_EBADTYPE, and nothing is written.
| ncid | NetCDF file ID. |
| varid | Variable ID (NC_BFLOAT16, NC_FLOAT or NC_DOUBLE). |
| startp | Start index in each dimension. |
| countp | Edge count in each dimension. |
| op | The bfloat16 values to write. |
Write a hyperslab of a variable from bfloat16 values. See nep.h for the variable types accepted and the conversion rules.
| int nc_put_vara_float16 | ( | int | ncid, |
| int | varid, | ||
| const size_t * | startp, | ||
| const size_t * | countp, | ||
| const nc_float16_t * | op ) |
Write a hyperslab of a variable from IEEE 754 float16 values.
Works on any file the netCDF API can open. An NC_FLOAT16 variable stores the raw bit patterns with no conversion. An NC_FLOAT or NC_DOUBLE variable is written with the corresponding typed call after every value is widened exactly to float or double by NEP; puts never overflow. An NC_CHAR variable returns NC_ECHAR; every other variable type (including NC_BFLOAT16) returns NC_EBADTYPE, and nothing is written.
| ncid | NetCDF file ID. |
| varid | Variable ID (NC_FLOAT16, NC_FLOAT or NC_DOUBLE). |
| startp | Start index in each dimension. |
| countp | Edge count in each dimension. |
| op | The float16 values to write. |
| int nc_put_vars_bfloat16 | ( | int | ncid, |
| int | varid, | ||
| const size_t * | startp, | ||
| const size_t * | countp, | ||
| const ptrdiff_t * | stridep, | ||
| const nc_bfloat16_t * | op ) |
Write a strided hyperslab of a variable from bfloat16 values.
| ncid | NetCDF file ID. |
| varid | Variable ID. |
| startp | Start index in each dimension. |
| countp | Edge count in each dimension. |
| stridep | Stride in each dimension. |
| op | The bfloat16 values to write. |
Write a strided hyperslab of a variable from bfloat16 values. See nep.h for the variable types accepted and the conversion rules.
| int nc_put_vars_float16 | ( | int | ncid, |
| int | varid, | ||
| const size_t * | startp, | ||
| const size_t * | countp, | ||
| const ptrdiff_t * | stridep, | ||
| const nc_float16_t * | op ) |
Write a strided hyperslab of a variable from IEEE 754 float16 values.
| ncid | NetCDF file ID. |
| varid | Variable ID. |
| startp | Start index in each dimension. |
| countp | Edge count in each dimension. |
| stridep | Stride in each dimension. |
| op | The float16 values to write. |
| int nep_set_log_level | ( | int | new_level | ) |
Set the NEP logging level (0=errors, higher=more verbose, -1=off).
Set the NEP logging threshold.
| new_level | The new logging level. Use -1 to disable logging, 0 for errors only, and higher numbers for progressively more verbose output. |