-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from texadactyl/master
FBH5 - satisfy enhancement request in issue #19
- Loading branch information
Showing
11 changed files
with
951 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | ||
* fbh5_close.c * | ||
* ---------- * | ||
* Close an FBH5 writing session: . * | ||
* Dataspace, Dataset, and File (in that order). * | ||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
|
||
|
||
#include "fbh5_defs.h" | ||
#define MILLION 1000000.0 | ||
|
||
|
||
/*** | ||
Main entry point. | ||
***/ | ||
void fbh5_close(fbh5_context_t * p_fbh5_ctx, int debug_callback) { | ||
herr_t status; // Status from HDF5 function call | ||
hsize_t sz_store; // Storage size | ||
double MiBstore; // sz_store converted to MiB | ||
double MiBlogical; // sz_store converted to MiB | ||
|
||
sz_store = H5Dget_storage_size(p_fbh5_ctx->dataset_id); | ||
MiBlogical = (double) p_fbh5_ctx->tint_size * (double) p_fbh5_ctx->offset_dims[0] / MILLION; | ||
|
||
/* | ||
* Attach "dimension scale" labels. | ||
*/ | ||
fbh5_set_ds_label(p_fbh5_ctx, "time", 0, debug_callback); | ||
fbh5_set_ds_label(p_fbh5_ctx, "feed_id", 1, debug_callback); | ||
fbh5_set_ds_label(p_fbh5_ctx, "frequency", 2, debug_callback); | ||
|
||
/* | ||
* Close dataspace. | ||
*/ | ||
status = H5Sclose(p_fbh5_ctx->dataspace_id); | ||
if(status != 0) | ||
fbh5_oops(__FILE__, __LINE__, "fbh5_close H5Sclose dataspace FAILED\n"); | ||
|
||
/* | ||
* Close dataset. | ||
*/ | ||
status = H5Dclose(p_fbh5_ctx->dataset_id); | ||
if(status != 0) | ||
fbh5_oops(__FILE__, __LINE__, "fbh5_close H5Dclose dataset 'data' FAILED\n"); | ||
|
||
/* | ||
* Close file. | ||
*/ | ||
status = H5Fclose(p_fbh5_ctx->file_id); | ||
if(status != 0) | ||
fbh5_oops(__FILE__, __LINE__, "fbh5_close H5Fclose FAILED\n"); | ||
p_fbh5_ctx->active = 0; | ||
|
||
/* | ||
* Closing statistics. | ||
*/ | ||
if(debug_callback) { | ||
printf("fbh5_close: Context closed.\n"); | ||
printf("fbh5_close: %ld dumps processed.\n", p_fbh5_ctx->dump_count); | ||
printf("fbh5_close: %lld time integrations processed.\n", p_fbh5_ctx->offset_dims[0]); | ||
MiBstore = (double) sz_store / MILLION; | ||
printf("fbh5_close: Compressed %.2f MiB --> %.2f MiB\n", MiBlogical, MiBstore); | ||
} | ||
|
||
/* | ||
* Bye-bye. | ||
*/ | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | ||
* fbh5_defs.h * | ||
* ----------- * | ||
* Global Definitions . * | ||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
|
||
#ifndef FBH5_DEFS_H | ||
#define FBH5_DEFS_H | ||
|
||
#include <stdlib.h> | ||
#include <stdarg.h> | ||
#include <stdint.h> | ||
#include <sys/types.h> | ||
#include <string.h> | ||
#include <time.h> | ||
|
||
/* | ||
* HDF5 library definitions | ||
*/ | ||
#include <hdf5/serial/hdf5.h> | ||
#include <hdf5/serial/H5pubconf.h> | ||
#include <hdf5/serial/H5DSpublic.h> | ||
#ifndef H5_HAVE_THREADSAFE | ||
#error The installed HDF5 run-time is not thread-safe! | ||
#endif | ||
|
||
/* | ||
* Rawspec callback definitions | ||
*/ | ||
#include "rawspec_callback.h" | ||
|
||
/* | ||
* Global definitions | ||
*/ | ||
#define DATASETNAME "data" // FBH5 dataset name to hold the data matrix | ||
#define NDIMS 3 // # of data matrix dimensions (rank) | ||
#define FILTERBANK_CLASS "FILTERBANK" // File-level attribute "CLASS" | ||
#define FILTERBANK_VERSION "2.0" // File-level attribute "VERSION" | ||
#define ENABLER_FD_FOR_FBH5 42 // Fake fd value to enable dump_file_thread_func() | ||
|
||
/* | ||
* fbh5 API functions | ||
*/ | ||
void fbh5_open(fbh5_context_t * p_fbh5_ctx, fb_hdr_t * p_fb_hdr, char * output_path, int debug_callback); | ||
void fbh5_write(fbh5_context_t * p_fbh5_ctx, fb_hdr_t * p_fb_hdr, void * buffer, size_t bufsize, int debug_callback); | ||
void fbh5_close(fbh5_context_t * p_fbh5_ctx, int debug_callback); | ||
|
||
/* | ||
* fbh5_util.c functions | ||
*/ | ||
void fbh5_oops(char * srcfile, int linenum, char * msg); | ||
void fbh5_set_str_attr(hid_t file_or_dataset_id, char * tag, char * value, int debug_callback); | ||
void fbh5_set_dataset_double_attr(hid_t dataset_id, char * tag, double * p_value, int debug_callback); | ||
void fbh5_set_dataset_int_attr(hid_t dataset_id, char * tag, int * p_value, int debug_callback); | ||
void fbh5_write_metadata(hid_t dataset_id, fb_hdr_t * p_metadata, int debug_callback); | ||
void fbh5_set_ds_label(fbh5_context_t * p_fbh5_ctx, char * label, int dims_index, int debug_callback); | ||
void fbh5_show_context(char * caller, fbh5_context_t * p_fbh5_ctx); | ||
|
||
#endif | ||
|
Oops, something went wrong.