Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Update external libminc to write backward-compatible HDF5 1.8.x files #53

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Modules/ThirdParty/MINC/src/libminc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PROJECT(LIBMINC)

SET(LIBMINC_PACKAGE_VERSION_MAJOR 2)
SET(LIBMINC_PACKAGE_VERSION_MINOR 4)
SET(LIBMINC_PACKAGE_VERSION_PATCH 02)
SET(LIBMINC_PACKAGE_VERSION_PATCH 03)

SET(LIBMINC_SOVERSION "5.2.0")

Expand Down
3 changes: 1 addition & 2 deletions Modules/ThirdParty/MINC/src/libminc/README
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ MINC_MAX_FILE_BUFFER_KB = <N>
#
MINC_MAX_MEMORY_KB = <N>

# FILE cache, used in some minc programs
# Memory cache for MINC2 files, per open file
#
MINC_FILE_CACHE_MB = <N>

Expand All @@ -107,4 +107,3 @@ DOCUMENTATION
-------------

http://en.wikibooks.org/wiki/MINC

17 changes: 9 additions & 8 deletions Modules/ThirdParty/MINC/src/libminc/libsrc/hdf_convenience.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
#define MI2_LENGTH "length"
#define MI2_CLASS "class"

/* So we build with 1.8.4 */
#ifndef H5F_LIBVER_18
#define H5F_LIBVER_18 H5F_LIBVER_LATEST
/* Make 1.8.x compatible files if building with 1.10.x */
#if (H5_VERS_MAJOR==1)&&(H5_VERS_MINOR<10)
#define H5F_LIBVER_V18 H5F_LIBVER_LATEST
#endif

/************************************************************************
Expand Down Expand Up @@ -2218,6 +2218,8 @@ hdf_open(const char *path, int mode)

/*Set cachine parameters*/
fpid=H5Pcreate( H5P_FILE_ACCESS );
/* Limit file compatability to 1.8.x */
H5Pset_libver_bounds (fpid, H5F_LIBVER_V18, H5F_LIBVER_V18);

/*setup a bigger cache to work with typical chunking ( MI_MAX_VAR_BUFFER_SIZE )*/
H5Pset_cache(fpid, 0, 2503, miget_cfg_present(MICFG_MINC_FILE_CACHE)?miget_cfg_int(MICFG_MINC_FILE_CACHE)*100000:MI_MAX_VAR_BUFFER_SIZE*10, 1.0);
Expand All @@ -2228,6 +2230,7 @@ hdf_open(const char *path, int mode)
hid_t prp_id;

prp_id = H5Pcreate(H5P_FILE_ACCESS);
H5Pset_libver_bounds (prp_id, H5F_LIBVER_V18, H5F_LIBVER_V18);
H5Pset_fapl_mmap(prp_id, 8192, 1);
file_id = H5Fopen(path, mode & 0x7FFF, prp_id);
H5Pclose(prp_id);
Expand Down Expand Up @@ -2326,10 +2329,11 @@ hdf_create(const char *path, int cmode, struct mi2opts *opts_ptr)

/*Set cachine parameters*/
fpid = H5Pcreate (H5P_FILE_ACCESS);
/* Limit file compatability to 1.8.x */
H5Pset_libver_bounds (fpid, H5F_LIBVER_V18, H5F_LIBVER_V18);

/*setup a bigger cache to work with typical chunking ( MI_MAX_VAR_BUFFER_SIZE )*/
H5Pset_cache(fpid, 0, 2503, miget_cfg_present(MICFG_MINC_FILE_CACHE)?miget_cfg_int(MICFG_MINC_FILE_CACHE)*100000:MI_MAX_VAR_BUFFER_SIZE*10, 1.0);

H5Pset_cache(fpid, 0, 2503, miget_cfg_present(MICFG_MINC_FILE_CACHE)?miget_cfg_int(MICFG_MINC_FILE_CACHE)*100000:MI_MAX_VAR_BUFFER_SIZE*10, 1.0);

/* Convert the MINC (NetCDF) mode to a HDF5 mode.
*/
Expand All @@ -2340,9 +2344,6 @@ hdf_create(const char *path, int cmode, struct mi2opts *opts_ptr)
cmode = H5F_ACC_TRUNC;
}

/*VF use all the features of new HDF5 1.8*/
H5Pset_libver_bounds (fpid, H5F_LIBVER_18, H5F_LIBVER_18);

H5E_BEGIN_TRY {
file_id = H5Fcreate(path, cmode, H5P_DEFAULT, fpid);
} H5E_END_TRY;
Expand Down
4 changes: 2 additions & 2 deletions Modules/ThirdParty/MINC/src/libminc/libsrc/voxel_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ PRIVATE void setup_variables(int inmincid, int outmincid,
}
else {
set_ncopts(0);
(void) ncattdel(outmincid, outimgid, MIvalid_range); /*VF: why is this needed?*/
(void) ncattdel(outmincid, outimgid, MIvalid_range); /*VF: needed for MINC v2 and not for MINC v1*/
set_ncopts(NC_OPTS_VAL);
}
}
Expand Down Expand Up @@ -1669,7 +1669,6 @@ PRIVATE int do_voxel_loop(Loop_Options *loop_options,
if( loop_options->is_labels )
{
/*Have to write out global valid range and global image range*/

if ((global_minimum[ofile] == DBL_MAX) &&
(global_maximum[ofile] == -DBL_MAX)) {
global_minimum[ofile] = 0.0;
Expand All @@ -1689,6 +1688,7 @@ PRIVATE int do_voxel_loop(Loop_Options *loop_options,
}
(void) mivarput1(outmincid, minid, 0, NC_DOUBLE, NULL, &valid_range[0]);
(void) mivarput1(outmincid, maxid, 0, NC_DOUBLE, NULL, &valid_range[1]);
/*VF: if MINC2 this works, if MINC1 - variables are not updated?*/
(void) miset_valid_range(outmincid, imgid, valid_range);
}
}
Expand Down
11 changes: 6 additions & 5 deletions Modules/ThirdParty/MINC/src/libminc/libsrc2/volume.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
#include "minc2.h"
#include "minc2_private.h"

/* So we build with 1.8.4 */
#ifndef H5F_LIBVER_18
#define H5F_LIBVER_18 H5F_LIBVER_LATEST
/* Build with 1.8.x support if using 1.10.x */
#if (H5_VERS_MAJOR==1)&&(H5_VERS_MINOR<10)
#define H5F_LIBVER_V18 H5F_LIBVER_LATEST
#endif

/*Used to optimize chunking size for faster MINC1 API access*/
Expand Down Expand Up @@ -117,6 +117,7 @@ static hid_t _hdf_open(const char *path, int mode)
int ndims;*/

prp_id = H5Pcreate(H5P_FILE_ACCESS);
H5Pset_libver_bounds(prp_id, H5F_LIBVER_V18, H5F_LIBVER_V18);
H5Pset_cache(prp_id, 0, 2503, miget_cfg_present(MICFG_MINC_FILE_CACHE)?miget_cfg_int(MICFG_MINC_FILE_CACHE)*100000:_MI1_MAX_VAR_BUFFER_SIZE*10, 1.0);

H5E_BEGIN_TRY {
Expand Down Expand Up @@ -218,8 +219,8 @@ static hid_t _hdf_create(const char *path, int cmode)

fpid = H5Pcreate (H5P_FILE_ACCESS);

/*VF use all the features of new HDF5 1.8*/
H5Pset_libver_bounds (fpid, H5F_LIBVER_18, H5F_LIBVER_18);
/* Limit filetype to 1.8.x */
H5Pset_libver_bounds(fpid, H5F_LIBVER_V18, H5F_LIBVER_V18);

H5Pset_cache(fpid, 0, 2503, miget_cfg_present(MICFG_MINC_FILE_CACHE)?miget_cfg_int(MICFG_MINC_FILE_CACHE)*100000:_MI1_MAX_VAR_BUFFER_SIZE*100, 1.0);

Expand Down