HNBody Version 1.0.10

- Main Page
- Related Pages
- Data Structures
- Files

- File List
- Globals

Data Structures | Macros | Typedefs | Functions
output.h File Reference

Facilities to manipulate HNBody output files. More...

`#include "hnbody/opts.h"`
Include dependency graph for output.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures
struct | hnb_header_struct
| Output file header data structure. More...

## Macros
#define | HNB_MAGIC 462639
| Magic number identifying HNBody output files (think 1-800-HNBODY).

## Typedefs
typedef struct hnb_header_struct | hnb_header_t
| Output file header data structure.

## Functions
DLLSPEC void | hnb_fill_header (hnb_header_t *h, hnb_class_t fclass, hnb_format_t format, hnb_coord_t coord, double epoch, double G, double c, double M, double E0, const double L0[], double tinit, double stepsize, double rate, int id, int digits, const double offset[], const hnb_option_tag order[], int ncol)
| Fills a header structure with specific values. More...
DLLSPEC size_t | hnb_read_file (double *ddata[], float *fdata[], size_t *nalloc, size_t nkeep, size_t nrec, size_t nresv, int raw, const hnb_header_t *h, FILE *f)
DLLSPEC size_t | hnb_write_file (double *const ddata[], float *const fdata[], size_t nrec, int header, int raw, const hnb_header_t *h, FILE *f)
| Writes data arrays to an HNBody output file. More...
DLLSPEC int | hnb_read_dataline (double data[], hnb_format_t format, int ncol, int size, const double offset[], FILE *f)
DLLSPEC int | hnb_read_header (hnb_header_t *h, FILE *f)
DLLSPEC int | hnb_seek_file (size_t rec, FILE *f)
DLLSPEC int | hnb_tag2ctype (hnb_option_tag tag)
DLLSPEC int | hnb_trim_file (const char *datafile, size_t nrec)
DLLSPEC int | hnb_write_binary (const double data[], int nelem, int dprec, FILE *f)
DLLSPEC int | hnb_write_dataline (const double data[], hnb_class_t fclass, hnb_format_t format, int ncol, int digits, const double offset[], FILE *f)
DLLSPEC int | hnb_write_header (const hnb_header_t *h, FILE *f)
DLLSPEC int | hnb_write_text (const double data[], int nelem, int digits, FILE *f)
DLLSPEC hnb_option_tag | hnb_ctype2tag (int ctype)
DLLSPEC FILE * | hnb_fopen (const char *file, const char *mode)
| Opens an HNBody output file in a standardized manner. More...

## Detailed Description

Id
  output.h,v 1.8 2004/02/04 23:19:15 rauch Exp

Author
  Kevin P. Rauch

## Function Documentation

DLLSPEC void hnb_fill_header | ( | hnb_header_t * | h,
|  | hnb_class_t | fclass,
|  | hnb_format_t | format,
|  | hnb_coord_t | coord,
|  | double | epoch,
|  | double | G,
|  | double | c,
|  | double | M,
|  | double | E0,
|  | const double | L0[],
|  | double | tinit,
|  | double | dz,
|  | double | rate,
|  | int | id,
|  | int | digits,
|  | const double | offset[],
|  | const hnb_option_tag | order[],
|  | int | ntags
| ) |  |

This method fills an HNBody file header structure with the supplied values.

Note
  Not all arguments are used by every output file type.

See also
  hnb_header_struct

References hnb_header_struct::c, hnb_header_struct::coord, hnb_header_struct::ctype, hnb_header_struct::epoch, hnb_header_struct::fclass, hnb_header_struct::format, hnb_header_struct::G, HNB_BARY, HNB_ENERGY, HNB_MAGIC, HNB_TEXT, hnb_header_struct::id, hnb_header_struct::M, hnb_header_struct::magic, hnb_header_struct::ncol, hnb_header_struct::offset, hnb_header_struct::rate, hnb_header_struct::size, hnb_header_struct::stepsize, and hnb_header_struct::tinit.

DLLSPEC FILE* hnb_fopen | ( | const char * | file,
|  | const char * | mode
| ) |  |

This method is similar to `fopen()` except that error handling is built in. In addition, binary mode is always enabled on the stream, and the special file name "-" is interpreted as stdin or stdout as appropriate. The returned stream is generic and should be closed with `fclose()` as usual.

Note
  The call will not return if the open fails.

Parameters

  file | is the name of the file to open
  mode | is the read/write mode setting

Returns
  A valid file stream.

DLLSPEC size_t hnb_write_file | ( | double *const | ddata[],
|  | float *const | fdata[],
|  | size_t | nrec,
|  | int | header,
|  | int | raw,
|  | const hnb_header_t * | h,
|  | FILE * | f
| ) |  |

This method writes a specified number of records to an open stream, optionally preceded by a standard HNBody output header. Either single or double precision data columns can be supplied and will be converted to the appropriate output format (double precision takes precedence).

Parameters

  ddata | is the array of data columns to output (double precision format; set to `NULL` if unavailable).
  fdata | is the array of data columns to output (single precision format; set to `NULL` if unavailable).
  nrec | is the number of data records to output.
  header | is non-zero if and only if an HNBody file header should be written.
  raw | is non-zero if and only if SMARTFLOAT offsets have already been subtracted from the input data columns (meaningful only for SMARTFLOAT output format).
  h | is the header corresponding the file f.
  f | is a stream pointing to HNBody output file records.

Returns
  The number of records successfully written.

References hnb_header_struct::fclass, hnb_header_struct::format, HNB_ORDER_MAX, hnb_header_struct::ncol, hnb_header_struct::offset, and hnb_header_struct::size.