# MI - Fimex: include/fimex/c_fimex.h File Reference

# include/fimex/c_fimex.h File Reference

`#include <stddef.h>`

Go to the source code of this file.

## Typedefs

typedef struct mifi_cdm_reader | mifi_cdm_reader
typedef int(* | doubleDatasliceCallbackPtr )(mifi_cdm_reader *reader, const char *varName, size_t unLimDimPos, double *scaledData, size_t dataSize)

## Functions

void | mifi_free_cdm_reader (mifi_cdm_reader *reader)
mifi_cdm_reader * | mifi_new_felt_reader (const char *filename, const char *configFile)
mifi_cdm_reader * | mifi_new_netcdf_reader (const char *filename)
mifi_cdm_reader * | mifi_new_grib_reader (const char *filename, const char *configFile)
mifi_cdm_reader * | mifi_new_ncml_reader (const char *ncmlFile)
mifi_cdm_reader * | mifi_new_ncml_modifier (mifi_cdm_reader *reader, const char *ncmlFile)
int | mifi_netcdf_writer (mifi_cdm_reader *reader, const char *filename, const char *configFile, int version)
int | mifi_grib_writer (mifi_cdm_reader *reader, const char *filename, const char *configFile, int version)
int | mifi_nullcdm_writer (mifi_cdm_reader *reader)
mifi_cdm_reader * | mifi_new_cdminterpolator (mifi_cdm_reader *reader, int method, const char *proj_input, const char *out_x_axis, const char *out_y_axis, const char *out_x_axis_unit, const char *out_y_axis_unit)
| change the projection of the reader to this new projection
mifi_cdm_reader * | mifi_new_c_reader (mifi_cdm_reader *reader)
int | mifi_set_callback_double (mifi_cdm_reader *c_reader, const char *varName, doubleDatasliceCallbackPtr callback)
size_t | mifi_get_variable_number (mifi_cdm_reader *reader)
const char * | mifi_get_variable_name (mifi_cdm_reader *reader, size_t pos)
int | mifi_get_double_dataslize (mifi_cdm_reader *reader, const char *varName, size_t unLimDimPos, double **data, size_t *size)
int | mifi_get_double_data (mifi_cdm_reader *reader, const char *varName, double **data, size_t *size)

## Typedef Documentation

typedef int(* doubleDatasliceCallbackPtr)(mifi_cdm_reader *reader, const char *varName, size_t unLimDimPos, double *scaledData, size_t dataSize)

Function pointer as used for the get_double_dataslice callback function

Returns:
  0 on success, error otherwise

typedef struct mifi_cdm_reader mifi_cdm_reader

This is the public C-Api for fimex. It is a wrapper api for the underlying C++ api.

## Function Documentation

void mifi_free_cdm_reader | ( | mifi_cdm_reader * | reader | ) |

Free the reader. This won't free the resources immediately, but reduce the reference counter. It is therefore possible to free a reader, while it still is used within another part of the fimex-chain.

int mifi_get_double_data | ( | mifi_cdm_reader * | reader,
|  | const char * | varName,
|  | double ** | data,
|  | size_t * | size |
| ) |  |  |

get all the data from the dataReader

Parameters:

  | reader | dataReader to read the data from
  | varName | variable name associated with the data
  | data,: | the returned data. It will be allocated automatically, it is the task of the user to free it. Undefined values will be NaN.
  | size,: | the size of the returned data.

Returns:
  0 on success

int mifi_get_double_dataslize | ( | mifi_cdm_reader * | reader,
|  | const char * | varName,
|  | size_t | unLimDimPos,
|  | double ** | data,
|  | size_t * | size |
| ) |  |  |

get a slice of data from the dataReader

Parameters:

  | reader | dataReader to read the data from
  | varName | variable name associated with the data
  | unLimDimPos | unlimited dimension of the slice
  | data,: | the returned data. It will be allocated automatically, it is the task of the user to free it. Undefined values will be NaN.
  | size,: | the size of the returned data.

Returns:
  0 on success

const char* mifi_get_variable_name | ( | mifi_cdm_reader * | reader,
|  | size_t | pos |
| ) |  |  |

Get the name of a variable from the reader.

Parameters:

  | reader | the data source
  | pos | the position number of the variable, should be between 0 and size-1

Returns:
  the variable name, or NULL on failure

size_t mifi_get_variable_number | ( | mifi_cdm_reader * | reader | ) |

Get the number of the variables from the reader.

Parameters:

  | reader | the data source

Returns:
  the number of variables

int mifi_grib_writer | ( | mifi_cdm_reader * | reader,
|  | const char * | filename,
|  | const char * | configFile,
|  | int | version |
| ) |  |  |

Write the content of the reader to the filename as gribfile.

Parameters:

  | reader | the data source
  | filename | the name of the grib-file to write
  | configFile | an optional configFile, use "" or 0 if not needed
  | version,the | version of the grib-edition. Implemented are 1 or 2.

Returns:
  0 on success.

int mifi_netcdf_writer | ( | mifi_cdm_reader * | reader,
|  | const char * | filename,
|  | const char * | configFile,
|  | int | version |
| ) |  |  |

Write the content of the reader to the filename.

Parameters:

  | reader | the data source
  | filename | the name of the netcdf-file to write
  | configFile | an optional configFile, use "" or 0 if not needed
  | version,the | version of the netcdf-file. Implemented are 3 or 4.

Returns:
  0 on success.

mifi_cdm_reader* mifi_new_c_reader | ( | mifi_cdm_reader * | reader | ) |

Get a new reader which allows setting c-callback functions.

Parameters:

  | the | original data-source

Returns:
  the reader object-pointer, use mifi_freeCDMReader to free, or NULL on error.

mifi_cdm_reader* mifi_new_cdminterpolator | ( | mifi_cdm_reader * | reader,
|  | int | method,
|  | const char * | proj_input,
|  | const char * | out_x_axis,
|  | const char * | out_y_axis,
|  | const char * | out_x_axis_unit,
|  | const char * | out_y_axis_unit |
| ) |  |  |

change the projection of the reader to this new projection

Parameters:

  | method | Interpolation method
  | proj_input | input-string for proj4, used as output projection
  | out_x_axis | config-string for x_axis, either '1,2,...,5' or 'auto' or 'auto,distance=3.5'
  | out_y_axis | config-string for y_axis, either '1,2,...,5' or 'auto' or 'auto,distance=3.5'
  | out_x_axis_unit | unit of the output x-axis
  | out_y_axis_unit | unit of the output y-axis

Returns:
  the reader object-pointer, use mifi_freeCDMReader to free, or NULL on error.

mifi_cdm_reader* mifi_new_felt_reader | ( | const char * | filename,
|  | const char * | configFile |
| ) |  |  |

Get a new reader from a felt file.

Parameters:

  | filename | name of the felt-file
  | configFile | configuration file for the felt-file

Returns:
  the reader object-pointer, use mifi_freeCDMReader to free, or NULL on error.

mifi_cdm_reader* mifi_new_grib_reader | ( | const char * | filename,
|  | const char * | configFile |
| ) |  |  |

Get a new reader from a grib1/2 file.

Parameters:

  | filename | name of the grib-file
  | configFile | configuration file for the grib-file

Returns:
  the reader object-pointer, use mifi_freeCDMReader to free, or NULL on error.

mifi_cdm_reader* mifi_new_ncml_modifier | ( | mifi_cdm_reader * | reader,
|  | const char * | ncmlFile |
| ) |  |  |

Modify a reader using a ncml file.

Parameters:

  | reader | the data/cdm source
  | ncmlFile | name of the ncml config file

Returns:
  the reader object-pointer, use mifi_freeCDMReader to free, or NULL on error.

mifi_cdm_reader* mifi_new_ncml_reader | ( | const char * | ncmlFile | ) |

Get a new reader from a ncml file.

Parameters:

  | ncmlFile | name of the ncml config file

Returns:
  the reader object-pointer, use mifi_freeCDMReader to free, or NULL on error.

mifi_cdm_reader* mifi_new_netcdf_reader | ( | const char * | filename | ) |

Get a new reader from a netcdf file.

Parameters:

  | filename | name of the felt-file
  | configFile | configuration file for the felt-file

Returns:
  the reader object-pointer, use mifi_freeCDMReader to free, or NULL on error.

int mifi_nullcdm_writer | ( | mifi_cdm_reader * | reader | ) |

Fetch the whole data belonging to the cdm, but don't write it anywhere.

Parameters:

  | reader | the data source

Returns:
  0 on success.

int mifi_set_callback_double | ( | mifi_cdm_reader * | c_reader,
|  | const char * | varName,
|  | doubleDatasliceCallbackPtr | callback |
| ) |  |  |

Add a callback for a variable. The variable will be converted to datatype double.

Parameters:

  | c_reader | the reader as created by mifi_new_c_reader
  | varName | the name of the variable
  | callback | a function-ptr to the callback function

Returns:
  0 on success, else error

Warning:
  the callback function will only be able to modify data which is available in the reader. It cannot change any information the writer request, but the reader doesn't now about. This data will continue to be undefined!