├── .gitignore ├── COPYING ├── LICENSE ├── Makefile ├── README.md ├── data ├── Attributes.h5 ├── REF_REG.h5 ├── SDS.h5 ├── SDScompound.h5 ├── SDSextendible.h5 ├── Select.h5 ├── blue │ └── prefix_target.h5 ├── dtransform.h5 ├── extlink_prefix_source.h5 ├── extlink_source.h5 ├── extlink_target.h5 ├── group.h5 ├── h5ex_d_alloc.h5 ├── h5ex_d_checksum.h5 ├── h5ex_d_chunk.h5 ├── h5ex_d_unlimadd.h5 ├── h5ex_t_bit.h5 ├── h5ex_t_string.h5 ├── h5ex_t_stringatt.h5 ├── hard_link.h5 ├── red │ └── prefix_target.h5 ├── refere.h5 ├── soft_link.h5 ├── test.hdf5 └── test_aud.hdf5 ├── dub.json ├── examples ├── .gitignore ├── README ├── allocationtime │ ├── .gitignore │ ├── dub.json │ └── source │ │ └── h5ex_d_alloc.d ├── attribute │ ├── .gitignore │ ├── Attributes.h5 │ ├── attribute │ ├── dub.json │ └── source │ │ └── attribute.d ├── bitfields │ ├── .gitignore │ ├── dub.json │ └── source │ │ └── h5ex_t_bit.d ├── builddubexamples.d ├── checksum │ ├── .gitignore │ ├── dub.json │ ├── h5ex_d_checksum.h5 │ └── source │ │ └── h5ex_d_checksum.d ├── chunk │ ├── .gitignore │ ├── dub.json │ └── source │ │ └── h5ex_d_chunk.d ├── chunkread │ ├── .gitignore │ ├── dub.json │ └── source │ │ └── chunk_read.d ├── complexdatatype │ ├── .gitignore │ ├── dub.json │ ├── dub.sdl │ └── source │ │ └── h5_compound.d ├── complextypereadwrite │ ├── .gitignore │ ├── dub.json │ ├── dub.sdl │ └── source │ │ └── h5ex_t_cpxcmpd.d ├── creategroupdataset │ ├── .gitignore │ ├── dub.json │ └── source │ │ └── h5_group.d ├── datasetrefs │ ├── .gitignore │ ├── dub.json │ └── source │ │ └── h5_ref2reg.d ├── drivers │ ├── .gitignore │ ├── dub.json │ └── source │ │ └── h5_drivers.d ├── dtransform │ ├── .gitignore │ ├── dtransform.h5 │ ├── dub.json │ └── source │ │ └── h5_dtransform.d ├── dub.json ├── extendwrite │ ├── .gitignore │ ├── dub.json │ └── source │ │ └── h5_extend_write.d ├── externallinks │ ├── .gitignore │ ├── dub.json │ └── source │ │ └── h5_extlink.d ├── iterategroup │ ├── .gitignore │ ├── dub.json │ └── source │ │ └── h5ex_g_iterate.d ├── messageshare │ ├── .gitignore │ ├── dub.json │ └── source │ │ └── h5_shared_mesg.d ├── myiterator │ ├── .gitignore │ ├── dub.json │ └── source │ │ └── myiterator.d ├── objrefs │ ├── .gitignore │ ├── dub.json │ └── source │ │ └── h5_reference.d ├── read │ ├── .gitignore │ ├── dub.json │ └── source │ │ └── h5_read.d ├── readwrite │ ├── .gitignore │ ├── dub.json │ └── source │ │ └── h5_rdwt.d ├── runexamples.d ├── select │ ├── .gitignore │ ├── dub.json │ └── source │ │ └── h5_select.d ├── source │ └── app.d ├── stringattributes │ ├── .gitignore │ ├── dub.json │ └── source │ │ └── h5ex_t_stringatt.d ├── strings │ ├── .gitignore │ ├── dub.json │ └── source │ │ └── h5ex_t_string.d ├── subset │ ├── .gitignore │ ├── dub.json │ └── source │ │ └── h5_subset.d ├── szip │ ├── .gitignore │ ├── dub.json │ └── source │ │ └── h5ex_d_szip.d ├── traits │ ├── .gitignore │ ├── dub.json │ └── source │ │ └── traits.d ├── traversefile │ ├── .gitignore │ ├── dub.json │ └── source │ │ └── h5ex_g_traverse.d ├── traverseobjects │ ├── .gitignore │ ├── dub.json │ └── source │ │ └── h5_ex_g_visit.d ├── unlimiteddataset │ ├── .gitignore │ ├── dub.json │ ├── h5ex_d_unlimadd.h5 │ └── source │ │ └── h5ex_d_unlimadd.d └── write │ ├── .gitignore │ ├── dub.json │ └── source │ └── h5_write.d ├── hdf5 ├── bindings │ ├── api.d │ ├── enums.d │ └── hlapi.d ├── hdf5.d ├── wrap.d └── wraphl.d ├── old ├── examples │ ├── h5_attribute.d │ ├── h5_compound.d │ ├── h5_drivers.d │ ├── h5_dtransform.d │ ├── h5_ex_g_visit.c │ ├── h5_ex_g_visit.d │ ├── h5_extend_write.d │ ├── h5_extlink.d │ ├── h5_group.d │ ├── h5_rdwt.d │ ├── h5_read.d │ ├── h5_ref2reg.d │ ├── h5_reference.d │ ├── h5_select.d │ ├── h5_shared_mesg.d │ ├── h5_subset.d │ ├── h5_write.d │ ├── h5ex_d_alloc.d │ ├── h5ex_d_checksum.d │ ├── h5ex_d_chunk.d │ ├── h5ex_d_szip.d │ ├── h5ex_d_unlimadd.d │ ├── h5ex_g_iterate.d │ ├── h5ex_g_traverse.d │ ├── h5ex_t_bit.d │ ├── h5ex_t_cpxcmpd.d │ ├── h5ex_t_string.d │ ├── h5ex_t_stringatt.d │ ├── myiterator.d │ ├── notyetported │ │ ├── frijters_examples.d │ │ ├── h5_cmprss.c │ │ ├── h5_crtatt.c │ │ ├── h5_crtdat.c │ │ ├── h5_crtgrp (1).c │ │ ├── h5_crtgrp.c │ │ ├── h5_crtgrpar (1).c │ │ ├── h5_crtgrpar.c │ │ ├── h5_crtgrpd.c │ │ ├── h5_elink_unix2win.c │ │ ├── h5_extend.c │ │ ├── h5_extlink.c │ │ ├── h5_interm_group.c │ │ ├── h5_mount.c │ │ ├── h5_rdwt.c │ │ ├── h5_ref2reg.c │ │ ├── h5_reference.c │ │ ├── h5_select.c │ │ ├── h5_shared_mesg.c │ │ ├── h5_subset.c │ │ ├── h5ex_d_alloc.c │ │ ├── h5ex_d_checksum.c │ │ ├── h5ex_d_chunk.c │ │ ├── h5ex_d_compact.c │ │ ├── h5ex_d_extern.c │ │ ├── h5ex_d_fillval.c │ │ ├── h5ex_d_gzip.c │ │ ├── h5ex_d_hyper.c │ │ ├── h5ex_d_rdwr.c │ │ ├── h5ex_d_shuffle.c │ │ ├── h5ex_d_szip.c │ │ ├── h5ex_d_unlimadd.c │ │ ├── h5ex_d_unlimgzip.c │ │ ├── h5ex_d_unlimmod.c │ │ ├── h5ex_g_create.c │ │ ├── h5ex_g_iterate.c │ │ ├── h5ex_g_traverse.c │ │ ├── h5ex_t_array.c │ │ ├── h5ex_t_arrayatt.c │ │ ├── h5ex_t_bit.c │ │ ├── h5ex_t_bitatt.c │ │ ├── h5ex_t_cmpd.c │ │ ├── h5ex_t_cmpdatt.c │ │ ├── h5ex_t_commit.c │ │ ├── h5ex_t_convert.c │ │ ├── h5ex_t_cpxcmpd.c │ │ ├── h5ex_t_cpxcmpdatt.c │ │ ├── h5ex_t_enum.c │ │ ├── h5ex_t_enumatt.c │ │ ├── h5ex_t_float.c │ │ ├── h5ex_t_floatatt.c │ │ ├── h5ex_t_int.c │ │ ├── h5ex_t_intatt.c │ │ ├── h5ex_t_objref.c │ │ ├── h5ex_t_objrefatt.c │ │ ├── h5ex_t_opaque.c │ │ ├── h5ex_t_opaqueatt.c │ │ ├── h5ex_t_regref.c │ │ ├── h5ex_t_regrefatt.c │ │ ├── h5ex_t_string.c │ │ ├── h5ex_t_stringatt.c │ │ ├── h5ex_t_vlen.c │ │ ├── h5ex_t_vlenatt.c │ │ ├── h5ex_t_vlstring.c │ │ ├── h5ex_t_vlstringatt.c │ │ ├── ph5example.c │ │ └── simpletest.d │ └── traits.d ├── oldheaders │ ├── bindings.d │ ├── hdf5.d │ ├── hdfanother.d │ └── traits.d └── run_examples.sh ├── reflection ├── .gitignore ├── dub.sdl └── source │ └── app.d ├── runexamples.d ├── tools ├── README ├── binread.d ├── h5diff.d ├── h5dump.d ├── h5import.d ├── h5importtest.d ├── h5jam.d ├── h5jamtest.d ├── h5ls.d └── h5stat.d └── util ├── fixdubexamplesjson.d ├── fixdubjson.d └── makebuilddubexamples.d /.gitignore: -------------------------------------------------------------------------------- 1 | build/* 2 | *.o 3 | *.a 4 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | 2 | Copyright Notice and License Terms for 3 | HDF5 (Hierarchical Data Format 5) Software Library and Utilities 4 | ----------------------------------------------------------------------------- 5 | 6 | HDF5 (Hierarchical Data Format 5) Software Library and Utilities 7 | Copyright 2006-2014 by The HDF Group. 8 | 9 | NCSA HDF5 (Hierarchical Data Format 5) Software Library and Utilities 10 | Copyright 1998-2006 by the Board of Trustees of the University of Illinois. 11 | 12 | All rights reserved. 13 | 14 | Redistribution and use in source and binary forms, with or without 15 | modification, are permitted for any purpose (including commercial purposes) 16 | provided that the following conditions are met: 17 | 18 | 1. Redistributions of source code must retain the above copyright notice, 19 | this list of conditions, and the following disclaimer. 20 | 21 | 2. Redistributions in binary form must reproduce the above copyright notice, 22 | this list of conditions, and the following disclaimer in the documentation 23 | and/or materials provided with the distribution. 24 | 25 | 3. In addition, redistributions of modified forms of the source or binary 26 | code must carry prominent notices stating that the original code was 27 | changed and the date of the change. 28 | 29 | 4. All publications or advertising materials mentioning features or use of 30 | this software are asked, but not required, to acknowledge that it was 31 | developed by The HDF Group and by the National Center for Supercomputing 32 | Applications at the University of Illinois at Urbana-Champaign and 33 | credit the contributors. 34 | 35 | 5. Neither the name of The HDF Group, the name of the University, nor the 36 | name of any Contributor may be used to endorse or promote products derived 37 | from this software without specific prior written permission from 38 | The HDF Group, the University, or the Contributor, respectively. 39 | 40 | DISCLAIMER: 41 | THIS SOFTWARE IS PROVIDED BY THE HDF GROUP AND THE CONTRIBUTORS 42 | "AS IS" WITH NO WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED. In no 43 | event shall The HDF Group or the Contributors be liable for any damages 44 | suffered by the users arising out of the use of this software, even if 45 | advised of the possibility of such damage. 46 | 47 | ----------------------------------------------------------------------------- 48 | ----------------------------------------------------------------------------- 49 | 50 | Contributors: National Center for Supercomputing Applications (NCSA) at 51 | the University of Illinois, Fortner Software, Unidata Program Center (netCDF), 52 | The Independent JPEG Group (JPEG), Jean-loup Gailly and Mark Adler (gzip), 53 | and Digital Equipment Corporation (DEC). 54 | 55 | ----------------------------------------------------------------------------- 56 | 57 | Portions of HDF5 were developed with support from the Lawrence Berkeley 58 | National Laboratory (LBNL) and the United States Department of Energy 59 | under Prime Contract No. DE-AC02-05CH11231. 60 | 61 | ----------------------------------------------------------------------------- 62 | 63 | Portions of HDF5 were developed with support from the University of 64 | California, Lawrence Livermore National Laboratory (UC LLNL). 65 | The following statement applies to those portions of the product and must 66 | be retained in any redistribution of source code, binaries, documentation, 67 | and/or accompanying materials: 68 | 69 | This work was partially produced at the University of California, 70 | Lawrence Livermore National Laboratory (UC LLNL) under contract 71 | no. W-7405-ENG-48 (Contract 48) between the U.S. Department of Energy 72 | (DOE) and The Regents of the University of California (University) 73 | for the operation of UC LLNL. 74 | 75 | DISCLAIMER: 76 | This work was prepared as an account of work sponsored by an agency of 77 | the United States Government. Neither the United States Government nor 78 | the University of California nor any of their employees, makes any 79 | warranty, express or implied, or assumes any liability or responsibility 80 | for the accuracy, completeness, or usefulness of any information, 81 | apparatus, product, or process disclosed, or represents that its use 82 | would not infringe privately- owned rights. Reference herein to any 83 | specific commercial products, process, or service by trade name, 84 | trademark, manufacturer, or otherwise, does not necessarily constitute 85 | or imply its endorsement, recommendation, or favoring by the United 86 | States Government or the University of California. The views and 87 | opinions of authors expressed herein do not necessarily state or reflect 88 | those of the United States Government or the University of California, 89 | and shall not be used for advertising or product endorsement purposes. 90 | ----------------------------------------------------------------------------- 91 | 92 | 93 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright by The HDF Group. * 2 | Copyright by the Board of Trustees of the University of Illinois. * 3 | All rights reserved. * 4 | * 5 | This file is part of HDF5. The full HDF5 copyright notice, including * 6 | terms governing use, modification, and redistribution, is contained in * 7 | the files COPYING and Copyright.html. COPYING can be found at the root * 8 | of the source code distribution tree; Copyright.html can be found at the * 9 | root level of an installed copy of the electronic HDF5 document set and * 10 | is linked from the top-level documents page. It can also be found at * 11 | http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * 12 | access to either file, you may request a copy from help@hdfgroup.org. * 13 | 14 | Ported to D by Laeeth Isharc 2014 15 | Borrowed heavily in terms of C API declarations from https://github.com/SFrijters/hdf5-d 16 | Stefan Frijters bindings for D 17 | 18 | License applying for Frijters's work is: 19 | These bindings are made available under the [Boost Software License 1.0](http://www.boost.org/LICENSE_1_0.txt). 20 | HDF5 is subject to [its own license](COPYING). 21 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Makefile to build HDF D examples - ported from C to D by Laeeth Isharc 2 | # 3 | # uses bindings and wrappers in hdf5 directory 4 | # 5 | # make => makes release build of the library 6 | # 7 | # make clean => removes all targets built by the makefile 8 | # 9 | # make BUILD=debug => makes debug build of the library 10 | # 11 | # build file inspired by Phobos make 12 | ################################################################################ 13 | # Configurable stuff, usually from the command line 14 | # 15 | # OS can be linux, win32, win32wine, osx, or freebsd. The system will be 16 | # determined by using uname 17 | # 18 | # Default to a release built, override with BUILD=debug 19 | ifeq (,$(BUILD)) 20 | BUILD_WAS_SPECIFIED=0 21 | BUILD=release 22 | else 23 | BUILD_WAS_SPECIFIED=1 24 | endif 25 | 26 | ifneq ($(BUILD),release) 27 | ifneq ($(BUILD),debug) 28 | $(error Unrecognized BUILD=$(BUILD), must be 'debug' or 'release') 29 | endif 30 | endif 31 | BUILD_DIR=build 32 | 33 | LIBS = -L-lhdf5 -L-lhdf5_hl 34 | DMD = dmd 35 | BUILDTYPE = -release 36 | # Set DFLAGS 37 | ifeq ($(BUILD),debug) 38 | DFLAGS += -g -debug 39 | else 40 | DFLAGS += -O -release 41 | endif 42 | 43 | DFLAGS=$($LIBS) $(BUILDTYPE) 44 | DEPS=hdf5/wrap hdf5/bindings/enums hdf5/bindings/api hdf5/hdf5 45 | 46 | # not currently compiling: 47 | # h5_extlink h5ex_d_unlimadd h5_rdwt h5_select h5ex_g_iterate h5_subset h5_reference h5_ref2reg 48 | # h5ex_g_traverse h5ex_t_cpxcmpd.d 49 | 50 | EXAMPLES = $(addprefix examples/h5ex_d_, alloc chunk szip) \ 51 | $(addprefix examples/h5_, write read attribute extend_write chunk_read compound group) \ 52 | $(addprefix examples/, traits myiterator) \ 53 | $(addprefix examples/h5ex_t_, bit stringatt string) 54 | 55 | all: $(EXAMPLES) $(DEPS) 56 | 57 | # line below is gnu make specific. change to the following if it fails 58 | # $(DMD) $(DFLAGS) $(LIBS) $@ $(DEPS) -of$@ 59 | $(EXAMPLES): % : %.d $(DEPS) 60 | $(DMD) $(DFLAGS) $(LIBS) $@ $(DEPS) -of$(BUILD_DIR)/$(notdir $@) 61 | 62 | $(DEPS): 63 | $(DMD) -c $@ $(BUILDTYPE) -of$@ 64 | 65 | clean: 66 | rm -f build/*.o 67 | rm -f build/h5_* 68 | rm -f build/h5ex_* 69 | rm -f build/traits 70 | rm -f build/myiterator 71 | 72 | #realclean purge: clean 73 | # rm -f $(PROGRAMS) 74 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | d_hdf5 2 | ======= 3 | 4 | [![Join the chat at https://gitter.im/Laeeth/d_hdf5](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Laeeth/d_hdf5?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 5 | 6 | D bindings and wrappers for the HDF5 scientific data format. These differ from another project in being more C oriented and not exposing the Byzantine HDF5 class structure. I think aldacron's version may be more object-oriented, although I have not looked at it. Link (here)[https://github.com/aldanor/h5d] 7 | 8 | Relatively raw stage - there may be some bugs still, although it does work for my own projects. 9 | 10 | Ported to D by Laeeth Isharc 2014, 2015. Linux only I am afraid, although it should not be much work to port to Windows. 11 | 12 | * Borrowed heavily from C API declarations in [https://github.com/SFrijters/hdf5-d](Stefan Frijters bindings for D) 13 | * Three parts: 14 | 1. Low-level C bindings: hdf5/bindings/api.d and hdf5/bindings/enum.d 15 | 2. High-level D wrappers: hdf5/wrap.d 16 | - currently these provide simple sugar such as accepting and returning D strings rather than char*. 17 | - over time I will work on developing these, but you can see code for dumping and retrieving an array of structs to/from an hdf5 18 | dataset in the file examples/traits.d. Compile-time reflection is used to infer the format of the data set. The mapping from D types 19 | to HDF5 dataset types is pretty basic, but usable. 20 | 3. Ports of the example code from C to D. Only some these have been finished, but they are enough to demonstrate the basic functionality. See examples/*.d for the examples that work. (To build run make or dub in the root directory). Example C code that has not yet been ported is in the old/examples/notyetported/ directory 21 | 22 | * To Do 23 | 1. Better exception handling that calls HDF5 to get error message and returns appropriate subclass of Exception 24 | 2. Unit tests (use example to build them) 25 | 3. Refinement of use of CTFE - better checking of types, allow tables of higher dimensions, allow reading tables where the record type is not known beforehand. 26 | 4. Integration with D dataframe library 27 | 5. I have started wrapping the high-level library. The bindings are more or less done. The wrappings I have only made a start on and for now the code is commented out. 28 | 29 | Sample Use Code (Ported from the C example) 30 | =========================================== 31 | 32 | ```D 33 | import hdf5.hdf5; 34 | import std.stdio; 35 | import std.exception; 36 | 37 | enum filename="dset.h5"; 38 | 39 | int main(string[] args) 40 | { 41 | 42 | int[600][1000] dset_data; 43 | 44 | H5open(); 45 | // Initialize the dataset. 46 | foreach(i;0..dset_data.length) 47 | foreach(j;0..dset_data[0].length) 48 | dset_data[i][j] = cast(int)i * cast(int)dset_data.length + cast(int)j + 1; 49 | 50 | writefln("* opening %s",filename); 51 | // Open an existing file. 52 | auto file_id = H5F.open(filename, H5F_ACC_RDWR, H5P_DEFAULT); 53 | 54 | writefln("* opening /dset"); 55 | // Open an existing dataset. 56 | auto dataset_id = H5D.open2(file_id, "/dset", H5P_DEFAULT); 57 | 58 | // Write the dataset. 59 | writefln("* writing dataset"); 60 | H5D.write(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, cast(ubyte*)dset_data.ptr); 61 | writefln("* reading dataset"); 62 | 63 | H5D.read(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, cast(ubyte*)&dset_data).ptr; 64 | 65 | writefln("* closing dataset"); 66 | /* Close the dataset. */ 67 | H5D.close(dataset_id); 68 | writefln("* closing file"); 69 | /* Close the file. */ 70 | H5F.close(file_id); 71 | H5close(); 72 | return 0; 73 | } 74 | ``` 75 | Getting Started 76 | =============== 77 | 78 | 1. Make sure you have the hdf5-1.8.15-patch1 version of the HDF5 C library - you should have libhdf5 and libhdf5_hl and check that /etd.dmd.conf knows where to find them. The interface changes for HDF5 even with minor releases, and I do not have the manpower to maintain different versions of the bindings for different releases 79 | 2. Build the examples 80 | cd examples 81 | dub build --force 82 | cd .. 83 | 4. Type rdmd runexamples.d in the base directory to run the examples one by one. Not all examples are finished or working 84 | 85 | 86 | Pull requests welcomed, and I need to find a co-maintainer as I don't have time to do this consistently. 87 | -------------------------------------------------------------------------------- /data/Attributes.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Laeeth/d_hdf5/b688f39549bc074e646992920431ae8765bf6ea4/data/Attributes.h5 -------------------------------------------------------------------------------- /data/REF_REG.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Laeeth/d_hdf5/b688f39549bc074e646992920431ae8765bf6ea4/data/REF_REG.h5 -------------------------------------------------------------------------------- /data/SDS.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Laeeth/d_hdf5/b688f39549bc074e646992920431ae8765bf6ea4/data/SDS.h5 -------------------------------------------------------------------------------- /data/SDScompound.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Laeeth/d_hdf5/b688f39549bc074e646992920431ae8765bf6ea4/data/SDScompound.h5 -------------------------------------------------------------------------------- /data/SDSextendible.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Laeeth/d_hdf5/b688f39549bc074e646992920431ae8765bf6ea4/data/SDSextendible.h5 -------------------------------------------------------------------------------- /data/Select.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Laeeth/d_hdf5/b688f39549bc074e646992920431ae8765bf6ea4/data/Select.h5 -------------------------------------------------------------------------------- /data/blue/prefix_target.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Laeeth/d_hdf5/b688f39549bc074e646992920431ae8765bf6ea4/data/blue/prefix_target.h5 -------------------------------------------------------------------------------- /data/dtransform.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Laeeth/d_hdf5/b688f39549bc074e646992920431ae8765bf6ea4/data/dtransform.h5 -------------------------------------------------------------------------------- /data/extlink_prefix_source.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Laeeth/d_hdf5/b688f39549bc074e646992920431ae8765bf6ea4/data/extlink_prefix_source.h5 -------------------------------------------------------------------------------- /data/extlink_source.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Laeeth/d_hdf5/b688f39549bc074e646992920431ae8765bf6ea4/data/extlink_source.h5 -------------------------------------------------------------------------------- /data/extlink_target.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Laeeth/d_hdf5/b688f39549bc074e646992920431ae8765bf6ea4/data/extlink_target.h5 -------------------------------------------------------------------------------- /data/group.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Laeeth/d_hdf5/b688f39549bc074e646992920431ae8765bf6ea4/data/group.h5 -------------------------------------------------------------------------------- /data/h5ex_d_alloc.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Laeeth/d_hdf5/b688f39549bc074e646992920431ae8765bf6ea4/data/h5ex_d_alloc.h5 -------------------------------------------------------------------------------- /data/h5ex_d_checksum.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Laeeth/d_hdf5/b688f39549bc074e646992920431ae8765bf6ea4/data/h5ex_d_checksum.h5 -------------------------------------------------------------------------------- /data/h5ex_d_chunk.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Laeeth/d_hdf5/b688f39549bc074e646992920431ae8765bf6ea4/data/h5ex_d_chunk.h5 -------------------------------------------------------------------------------- /data/h5ex_d_unlimadd.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Laeeth/d_hdf5/b688f39549bc074e646992920431ae8765bf6ea4/data/h5ex_d_unlimadd.h5 -------------------------------------------------------------------------------- /data/h5ex_t_bit.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Laeeth/d_hdf5/b688f39549bc074e646992920431ae8765bf6ea4/data/h5ex_t_bit.h5 -------------------------------------------------------------------------------- /data/h5ex_t_string.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Laeeth/d_hdf5/b688f39549bc074e646992920431ae8765bf6ea4/data/h5ex_t_string.h5 -------------------------------------------------------------------------------- /data/h5ex_t_stringatt.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Laeeth/d_hdf5/b688f39549bc074e646992920431ae8765bf6ea4/data/h5ex_t_stringatt.h5 -------------------------------------------------------------------------------- /data/hard_link.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Laeeth/d_hdf5/b688f39549bc074e646992920431ae8765bf6ea4/data/hard_link.h5 -------------------------------------------------------------------------------- /data/red/prefix_target.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Laeeth/d_hdf5/b688f39549bc074e646992920431ae8765bf6ea4/data/red/prefix_target.h5 -------------------------------------------------------------------------------- /data/refere.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Laeeth/d_hdf5/b688f39549bc074e646992920431ae8765bf6ea4/data/refere.h5 -------------------------------------------------------------------------------- /data/soft_link.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Laeeth/d_hdf5/b688f39549bc074e646992920431ae8765bf6ea4/data/soft_link.h5 -------------------------------------------------------------------------------- /data/test.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Laeeth/d_hdf5/b688f39549bc074e646992920431ae8765bf6ea4/data/test.hdf5 -------------------------------------------------------------------------------- /data/test_aud.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Laeeth/d_hdf5/b688f39549bc074e646992920431ae8765bf6ea4/data/test_aud.hdf5 -------------------------------------------------------------------------------- /dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "d_hdf5", 3 | "description": "HDF5 bindings and wrappers for the D Programming Language.", 4 | "authors": ["Laeeth Isharc"], 5 | "homepage": "https://github.com/Laeeth/d_hdf5", 6 | "license": "Boost-1.0", 7 | "libs":["hdf5","hdf5_hl"], 8 | "targetType":"sourceLibrary", 9 | "systemDependencies": "requires HDF5 1.8.15.patch-1 versions of libhdf5 and libhdf5_hl", 10 | "sourcePaths": [ "hdf5" ], 11 | "importPaths": [ "hdf5" ], 12 | } 13 | -------------------------------------------------------------------------------- /examples/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | -------------------------------------------------------------------------------- /examples/README: -------------------------------------------------------------------------------- 1 | Some of the examples have dummies in for now as they require further 2 | updates to the C bindings. 3 | 4 | 5 | -------------------------------------------------------------------------------- /examples/allocationtime/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | -------------------------------------------------------------------------------- /examples/allocationtime/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "allocationtime", 3 | "description": " 4 | Based on h5ex_d_alloc.c 5 | This example shows how to set the space allocation time 6 | for a dataset. The program first creates two datasets, 7 | one with the default allocation time (late) and one with 8 | early allocation time, and displays whether each has been 9 | allocated and their allocation size. Next, it writes data 10 | to the datasets, and again displays whether each has been 11 | allocated and their allocation size.", 12 | "authors": ["Laeeth Isharc,HDF5 Group"], 13 | "homepage": "https://github.com/Laeeth/d_hdf5", 14 | "license": "Boost-1.0", 15 | "libs":["hdf5","hdf5_hl"], 16 | "targetType":"executable", 17 | "targetPath": "../../build", 18 | "dependencies": { 19 | "d_hdf5": { "path": "../../" } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /examples/allocationtime/source/h5ex_d_alloc.d: -------------------------------------------------------------------------------- 1 | /** 2 | Ported by Laeeth Isharc 2014 to the D Programming Language 3 | Use at your own risk! 4 | 5 | This example shows how to set the space allocation time 6 | for a dataset. The program first creates two datasets, 7 | one with the default allocation time (late) and one with 8 | early allocation time, and displays whether each has been 9 | allocated and their allocation size. Next, it writes data 10 | to the datasets, and again displays whether each has been 11 | allocated and their allocation size. 12 | 13 | This file is intended for use with HDF5 Library version 1.6 14 | 15 | */ 16 | 17 | import hdf5.hdf5; 18 | 19 | 20 | import std.stdio; 21 | 22 | string f_name="h5ex_d_alloc.h5"; 23 | string DATASET1= "DS1"; 24 | string DATASET2="DS2"; 25 | enum DIM0=4; 26 | enum DIM1=7; 27 | enum FILLVAL=99; 28 | 29 | int main (string[] args) 30 | { 31 | hsize_t[2] dims = [DIM0, DIM1]; 32 | int[DIM1][DIM0] wdata; // write buffer 33 | 34 | // Initialize data. 35 | foreach(i;0.. DIM0) 36 | foreach(j;0..DIM1) 37 | wdata[i][j] = i * j - j; 38 | 39 | // Create a new file using the default properties. 40 | hid_t file; 41 | file = H5F.create(f_name, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); 42 | 43 | // Create dataspace. Leaving out maximum size sets the maximum size to be the current size. 44 | // passed as NULL to c API 45 | auto space = H5S.create_simple(dims); 46 | 47 | // Create the dataset creation property list, and set the chunk size 48 | auto dcpl = H5P.create (H5P_DATASET_CREATE); 49 | 50 | // Set the allocation time to "early". This way we can be sure that reading from the dataset immediately 51 | // after creation will return the fill value. 52 | H5P.set_alloc_time (dcpl, H5DAllocTime.Early); 53 | 54 | writefln("Creating datasets..."); 55 | writefln("%s has allocation time H5D_ALLOC_TIME_LATE", DATASET1); 56 | writefln("%s has allocation time H5D_ALLOC_TIME_EARLY", DATASET2); 57 | 58 | //Create the dataset using the dataset creation property list. 59 | auto dset1 = H5D.create2 (file, DATASET1, H5T_STD_I32LE, space, H5TCset.ASCII, dcpl ,H5P_DEFAULT); 60 | auto dset2 = H5D.create2(file, DATASET2, H5T_STD_I32LE, space, H5TCset.ASCII, dcpl,H5P_DEFAULT); 61 | 62 | // Retrieve and print space status and storage size for dset1. 63 | auto space_status = H5D.get_space_status (dset1); 64 | auto storage_size = H5D.get_storage_size (dset1); 65 | writefln("Space for %s has%sbeen allocated.", DATASET1,space_status == H5DSpaceStatus.Allocated ? " " : " not "); 66 | writefln("Storage size for %s is: %s bytes.", DATASET1,storage_size); 67 | 68 | // Retrieve and print space status and storage size for dset2. 69 | auto status = H5D.get_space_status (dset2); 70 | storage_size = H5D.get_storage_size (dset2); 71 | writefln("Space for %s has%sbeen allocated.", DATASET2, space_status == H5DSpaceStatus.Allocated ? " " : " not "); 72 | writefln("Storage size for %s is: %s bytes.", DATASET2, storage_size); 73 | writefln("\nWriting data...\n"); 74 | 75 | // Write the data to the datasets. 76 | H5D.write(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, cast(ubyte*)&wdata); 77 | H5D.write(dset2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, cast(ubyte*)&wdata); 78 | 79 | // Retrieve and print space status and storage size for dset1. 80 | status = H5D.get_space_status(dset1); 81 | storage_size = H5D.get_storage_size (dset1); 82 | writefln("Space for %s has%sbeen allocated.", DATASET1, space_status == H5DSpaceStatus.Allocated ? " " : " not "); 83 | writefln("Storage size for %s is: %s bytes.", DATASET1, storage_size); 84 | 85 | // Retrieve and print space status and storage size for dset2. 86 | status = H5D.get_space_status(dset2); 87 | storage_size = H5D.get_storage_size (dset2); 88 | writefln("Space for %s has%sbeen allocated.", DATASET2, space_status == H5DSpaceStatus.Allocated ? " " : " not "); 89 | writefln("Storage size for %s is: %s bytes.", DATASET2, storage_size); 90 | 91 | // Close and release resources. 92 | H5P.close(dcpl); 93 | H5D.close(dset1); 94 | H5D.close(dset2); 95 | H5S.close(space); 96 | H5F.close(file); 97 | return 0; 98 | } 99 | -------------------------------------------------------------------------------- /examples/attribute/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | -------------------------------------------------------------------------------- /examples/attribute/Attributes.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Laeeth/d_hdf5/b688f39549bc074e646992920431ae8765bf6ea4/examples/attribute/Attributes.h5 -------------------------------------------------------------------------------- /examples/attribute/attribute: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Laeeth/d_hdf5/b688f39549bc074e646992920431ae8765bf6ea4/examples/attribute/attribute -------------------------------------------------------------------------------- /examples/attribute/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "attribute", 3 | "description": "illustrates the usage of the H5A Interface functions: based on h5_attribute.c 4 | 5 | This program illustrates the usage of the H5A Interface functions. 6 | It creates and writes a dataset, and then creates and writes array, 7 | scalar, and string attributes of the dataset. 8 | Program reopens the file, attaches to the scalar attribute using 9 | attribute name and reads and displays its value. Then index of the 10 | third attribute is used to read and display attribute values. 11 | The H5Aiterate function is used to iterate through the dataset attributes, 12 | and display their names. The function is also reads and displays the values 13 | of the array attribute. 14 | ", 15 | "authors": ["Laeeth Isharc,HDF5 Group"], 16 | "homepage": "https://github.com/Laeeth/d_hdf5", 17 | "license": "Boost-1.0", 18 | "libs":["hdf5","hdf5_hl"], 19 | "targetType":"executable", 20 | "targetPath": "../../build", 21 | "dependencies": { 22 | "d_hdf5": { "path": "../../" } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /examples/bitfields/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | -------------------------------------------------------------------------------- /examples/bitfields/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bitfields", 3 | "description": " 4 | Based on h5ex_t_bit.c 5 | This example shows how to read and write bitfield 6 | datatypes to a dataset. The program first writes bit 7 | fields to a dataset with a dataspace of DIM0xDIM1, then 8 | closes the file. Next, it reopens the file, reads back 9 | the data, and outputs it to the screen. 10 | ", 11 | "authors": ["Laeeth Isharc,HDF5 Group"], 12 | "homepage": "https://github.com/Laeeth/d_hdf5", 13 | "license": "Boost-1.0", 14 | "libs":["hdf5","hdf5_hl"], 15 | "targetType":"executable", 16 | "targetPath": "../../build", 17 | "dependencies": { 18 | "d_hdf5": { "path": "../../" } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples/builddubexamples.d: -------------------------------------------------------------------------------- 1 | import std.file; 2 | import std.path; 3 | import std.stdio; 4 | import std.string; 5 | import std.exception; 6 | import std.process; 7 | 8 | void main(string[] args) 9 | { 10 | string[] work; 11 | string[] desc; 12 | string[] file; 13 | writefln("*** building list of projects to build"); 14 | foreach(entry;dirEntries(".",SpanMode.breadth)) 15 | { 16 | if (!entry.isDir) 17 | continue; 18 | if (!exists(entry.name~"/"~"source")) 19 | continue; 20 | foreach(sourceFile;dirEntries(entry.name~"/"~"source",SpanMode.depth)) 21 | { 22 | if ((sourceFile.isDir)||(!sourceFile.name.endsWith(".d"))) 23 | continue; 24 | work~=sourceFile.name; 25 | } 26 | } 27 | foreach(string f;work) 28 | { 29 | auto i=f.lastIndexOf("/source/"); 30 | f=f[0..i]; 31 | writefln("*** building %s",f); 32 | chdir(f); 33 | auto ls=executeShell("dub build"); 34 | if (ls.status!=0) 35 | { 36 | writefln("**** %s failed to build",f); 37 | } 38 | chdir(".."); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /examples/checksum/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | -------------------------------------------------------------------------------- /examples/checksum/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "checksum", 3 | "description": " 4 | Based on h5ex_d_checksum.c 5 | This example shows how to read and write data to a dataset 6 | using the Fletcher32 checksum filter. The program first 7 | checks if the Fletcher32 filter is available, then if it 8 | is it writes integers to a dataset using Fletcher32, then 9 | closes the file. Next, it reopens the file, reads back 10 | the data, checks if the filter detected an error and 11 | outputs the type of filter and the maximum value in the 12 | dataset to the screen. 13 | ", 14 | "authors": ["Laeeth Isharc,HDF5 Group"], 15 | "homepage": "https://github.com/Laeeth/d_hdf5", 16 | "license": "Boost-1.0", 17 | "libs":["hdf5","hdf5_hl"], 18 | "targetType":"executable", 19 | "targetPath": "../../build", 20 | "dependencies": { 21 | "d_hdf5": { "path": "../../" } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /examples/checksum/h5ex_d_checksum.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Laeeth/d_hdf5/b688f39549bc074e646992920431ae8765bf6ea4/examples/checksum/h5ex_d_checksum.h5 -------------------------------------------------------------------------------- /examples/chunk/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | -------------------------------------------------------------------------------- /examples/chunk/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "chunk", 3 | "description": " 4 | Based on h5ex_d_chunk.c 5 | This example shows how to create a chunked dataset. The 6 | program first writes integers in a hyperslab selection to 7 | a chunked dataset with dataspace dimensions of DIM0xDIM1 8 | and chunk size of CHUNK0xCHUNK1, then closes the file. 9 | Next, it reopens the file, reads back the data, and 10 | outputs it to the screen. Finally it reads the data again 11 | using a different hyperslab selection, and outputs 12 | the result to the screen. 13 | ", 14 | "authors": ["Laeeth Isharc,HDF5 Group"], 15 | "homepage": "https://github.com/Laeeth/d_hdf5", 16 | "license": "Boost-1.0", 17 | "libs":["hdf5","hdf5_hl"], 18 | "targetType":"executable", 19 | "targetPath": "../../build", 20 | "dependencies": { 21 | "d_hdf5": { "path": "../../" } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /examples/chunkread/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | -------------------------------------------------------------------------------- /examples/chunkread/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "chunkread", 3 | "description": " 4 | This example shows how to read data from a chunked dataset. 5 | We will read from the file created by h5_extend_write.d 6 | ", 7 | "authors": ["Laeeth Isharc,HDF5 Group"], 8 | "homepage": "https://github.com/Laeeth/d_hdf5", 9 | "license": "Boost-1.0", 10 | "libs":["hdf5","hdf5_hl"], 11 | "targetType":"executable", 12 | "targetPath": "../../build", 13 | "dependencies": { 14 | "d_hdf5": { "path": "../../" } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /examples/complexdatatype/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | -------------------------------------------------------------------------------- /examples/complexdatatype/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "complexdatatype", 3 | "description": " 4 | This example shows how to create a compound data type, 5 | write an array which has the compound data type to the file, 6 | and read back fields' subsets. 7 | ", 8 | "authors": ["Laeeth Isharc,HDF5 Group"], 9 | "homepage": "https://github.com/Laeeth/d_hdf5", 10 | "license": "Boost-1.0", 11 | "libs":["hdf5","hdf5_hl"], 12 | "targetType":"executable", 13 | "targetPath": "../../build", 14 | "dependencies": { 15 | "d_hdf5": { "path": "../../" } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /examples/complexdatatype/dub.sdl: -------------------------------------------------------------------------------- 1 | name "compound" 2 | description "A minimal D application." 3 | copyright "Copyright © 2015, laeeth" 4 | authors "laeeth" 5 | -------------------------------------------------------------------------------- /examples/complextypereadwrite/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | -------------------------------------------------------------------------------- /examples/complextypereadwrite/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "complexdatatypereadwrite", 3 | "description": "illustrates the usage of the H5A Interface functions: based on h5_attribute.c 4 | 5 | This example shows how to read and write a complex 6 | compound datatype to a dataset. The program first writes 7 | complex compound structures to a dataset with a dataspace 8 | of DIM0, then closes the file. Next, it reopens the file, 9 | reads back selected fields in the structure, and outputs 10 | them to the screen. 11 | 12 | Unlike the other datatype examples, in this example we 13 | save to the file using native datatypes to simplify the 14 | type definitions here. To save using standard types you 15 | must manually calculate the sizes and offsets of compound 16 | types as shown in h5ex_t_cmpd.c, and convert enumerated 17 | values as shown in h5ex_t_enum.c. 18 | 19 | The datatype defined here consists of a compound 20 | containing a variable-length list of compound types, as 21 | well as a variable-length string, enumeration, double 22 | array, object reference and region reference. The nested 23 | compound type contains an int, variable-length string and 24 | two doubles. 25 | */ ", 26 | "authors": ["Laeeth Isharc,HDF5 Group"], 27 | "homepage": "https://github.com/Laeeth/d_hdf5", 28 | "license": "Boost-1.0", 29 | "libs":["hdf5","hdf5_hl"], 30 | "targetType":"executable", 31 | "targetPath": "../../build", 32 | "dependencies": { 33 | "d_hdf5": { "path": "../../" } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /examples/complextypereadwrite/dub.sdl: -------------------------------------------------------------------------------- 1 | name "complextypereadwrite" 2 | description "A minimal D application." 3 | copyright "Copyright © 2015, laeeth" 4 | authors "laeeth" 5 | -------------------------------------------------------------------------------- /examples/creategroupdataset/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | -------------------------------------------------------------------------------- /examples/creategroupdataset/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "creategroupdataset", 3 | "description": " 4 | This program creates a group in the file and two datasets in the group. 5 | Hard link to the group object is created and one of the datasets is accessed 6 | under new name. 7 | Iterator functions are used to find information about the objects 8 | in the root group and in the created group.", 9 | "authors": ["Laeeth Isharc,HDF5 Group"], 10 | "homepage": "https://github.com/Laeeth/d_hdf5", 11 | "license": "Boost-1.0", 12 | "libs":["hdf5","hdf5_hl"], 13 | "targetType":"executable", 14 | "targetPath": "../../build", 15 | "dependencies": { 16 | "d_hdf5": { "path": "../../" } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /examples/datasetrefs/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | -------------------------------------------------------------------------------- /examples/datasetrefs/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "datasetrefs", 3 | "description": " 4 | This program shows how to create, store and dereference references 5 | to the dataset regions. 6 | 7 | It creates a file and writes a two dimensional integer dataset 8 | to it. Then it creates a dataset to store region references in. It 9 | stores references to a hyperslab and 3 points selected (for the 10 | integer dataset previously created). 11 | 12 | It then reopens the references dataset, reads and dereferences the 13 | region references, and then reads and displays the selected hyperslab 14 | and selected elements data from the integer dataset. 15 | ", 16 | "authors": ["Laeeth Isharc,HDF5 Group"], 17 | "homepage": "https://github.com/Laeeth/d_hdf5", 18 | "license": "Boost-1.0", 19 | "libs":["hdf5","hdf5_hl"], 20 | "targetType":"executable", 21 | "targetPath": "../../build", 22 | "dependencies": { 23 | "d_hdf5": { "path": "../../" } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /examples/drivers/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | -------------------------------------------------------------------------------- /examples/drivers/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "drivers", 3 | "description": " 4 | This shows how to use the hdf5 virtual file drivers. 5 | The example codes here do not check return values for the 6 | sake of simplicity. As in all proper programs, return codes 7 | should be checked. 8 | ", 9 | "authors": ["Laeeth Isharc,HDF5 Group"], 10 | "homepage": "https://github.com/Laeeth/d_hdf5", 11 | "license": "Boost-1.0", 12 | "libs":["hdf5","hdf5_hl"], 13 | "targetType":"executable", 14 | "targetPath": "../../build", 15 | "dependencies": { 16 | "d_hdf5": { "path": "../../" } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /examples/drivers/source/h5_drivers.d: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright by The HDF Group. * 3 | Copyright by the Board of Trustees of the University of Illinois. * 4 | All rights reserved. * 5 | * 6 | This file is part of HDF5. The full HDF5 copyright notice, including * 7 | terms governing use, modification, and redistribution, is contained in * 8 | the files COPYING and Copyright.html. COPYING can be found at the root * 9 | of the source code distribution tree; Copyright.html can be found at the * 10 | root level of an installed copy of the electronic HDF5 document set and * 11 | is linked from the top-level documents page. It can also be found at * 12 | http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * 13 | access to either file, you may request a copy from help@hdfgroup.org. * 14 | 15 | Ported by Laeeth Isharc 2014 to the D Programming Language 16 | Use at your own risk! 17 | 18 | This shows how to use the hdf5 virtual file drivers. 19 | The example codes here do not check return values for the 20 | sake of simplicity. As in all proper programs, return codes 21 | should be checked. 22 | */ 23 | 24 | 25 | import hdf5.hdf5; 26 | import std.file; 27 | import std.stdio; 28 | import std.exception; 29 | import std.string; 30 | import std.conv; 31 | import std.process; 32 | 33 | 34 | /+ 35 | H5Pset_fapl missing from bindings so this will not compile 36 | There may be some other problems too; 37 | +/ 38 | 39 | void main(string[] args) 40 | { 41 | writefln("drivers not yet implemented:H5P:set_fapl_split not yet ported"); 42 | } 43 | 44 | 45 | /+ 46 | 47 | /* global variables */ 48 | int cleanup_g = -1; /* whether to clean. Init to not set. */ 49 | 50 | 51 | // Cleanup a file unless $HDF5_NOCLEANUP is set. 52 | void cleanup(string filename) 53 | { 54 | if (cleanup_g == -1) 55 | cleanup_g = environment.get("HDF5_NOCLEANUP") ? 0 : 1; 56 | if (cleanup_g) 57 | remove(filename); 58 | } 59 | 60 | 61 | /// This shows how to use the split file driver. 62 | 63 | void split_file() 64 | { 65 | hid_t fapl, fid; 66 | 67 | /* Example 1: Both metadata and rawdata files are in the same */ 68 | /* directory. Use Station1-m.h5 and Station1-r.h5 as */ 69 | /* the metadata and rawdata files. */ 70 | fapl = H5P.create(H5P_FILE_ACCESS); 71 | H5P.set_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT); 72 | fid=H5F.create("Station1",H5F_ACC_TRUNC,H5P_DEFAULT,fapl); 73 | /* using the file ... */ 74 | H5F.close(fid); 75 | H5P.close(fapl); 76 | /* Remove files created */ 77 | cleanup("Station1-m.h5"); 78 | cleanup("Station1-r.h5"); 79 | 80 | /* Example 2: metadata and rawdata files are in different */ 81 | /* directories. Use PointA-m.h5 and /tmp/PointA-r.h5 as */ 82 | /* the metadata and rawdata files. */ 83 | fapl = H5P.create(H5P_FILE_ACCESS); 84 | H5P.set_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "/tmp/%s-r.h5", H5P_DEFAULT); 85 | fid=H5F.create("PointA",H5F_ACC_TRUNC,H5P_DEFAULT,fapl); 86 | /* using the file ... */ 87 | H5F.close(fid); 88 | H5P.close(fapl); 89 | /* Remove files created */ 90 | cleanup("PointA-m.h5"); 91 | cleanup("/tmp/PointA-r.h5"); 92 | 93 | /* Example 3: Using default extension names for the metadata */ 94 | /* and rawdata files. Use Measure.meta and Measure.raw as */ 95 | /* the metadata and rawdata files. */ 96 | fapl = H5P.create(H5P_FILE_ACCESS); 97 | H5P.set_fapl_split(fapl, NULL, H5P_DEFAULT, NULL, H5P_DEFAULT); 98 | fid=H5F.create("Measure",H5F_ACC_TRUNC,H5P_DEFAULT,fapl); 99 | /* using the file ... */ 100 | H5F.close(fid); 101 | H5P.close(fapl); 102 | /* Remove files created */ 103 | cleanup("Measure.meta"); 104 | cleanup("Measure.raw"); 105 | } 106 | 107 | // Main Body 108 | int main(string[] args) 109 | { 110 | split_file(); 111 | return(0); 112 | } 113 | +/ -------------------------------------------------------------------------------- /examples/dtransform/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | -------------------------------------------------------------------------------- /examples/dtransform/dtransform.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Laeeth/d_hdf5/b688f39549bc074e646992920431ae8765bf6ea4/examples/dtransform/dtransform.h5 -------------------------------------------------------------------------------- /examples/dtransform/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dtransform", 3 | "description": " 4 | This example demonstrates how the data transform features of 5 | HDF5 works. 6 | 7 | (1) 8 | The test first writes out data, with no data transform set. 9 | Then, the test reads back this data with a data transform applied. 10 | 11 | (2) 12 | Then, the test writes a new set of data, with a data transform set. 13 | Then, the test reads this new set of data, without a data set. 14 | 15 | (3) 16 | Lastly, the test reads the previous set of data (that was written out 17 | with a data transform) with a data transform set for the read. 18 | 19 | (4) 20 | Get the transform from the property using H5Pget_data_transform. 21 | ", 22 | "authors": ["Laeeth Isharc,HDF5 Group"], 23 | "homepage": "https://github.com/Laeeth/d_hdf5", 24 | "license": "Boost-1.0", 25 | "libs":["hdf5","hdf5_hl"], 26 | "targetType":"executable", 27 | "targetPath": "../../build", 28 | "dependencies": { 29 | "d_hdf5": { "path": "../../" } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /examples/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dub_examples", 3 | "description": "build examples for HDF5 bindings and wrappers for the D Programming Language.", 4 | "authors": ["Laeeth Isharc"], 5 | "homepage": "https://github.com/Laeeth/d_hdf5", 6 | "license": "Boost-1.0", 7 | "libs":["hdf5","hdf5_hl"], 8 | "targetType":"library", 9 | "dependencies": { 10 | }, 11 | "systemDependencies": "requires HDF5 1.8.15.patch-1 versions of libhdf5 and libhdf5_hl", 12 | "preBuildCommands": ["rdmd builddubexamples.d"], 13 | "postBuildCommands": ["rm libdub_examples.a"] 14 | } 15 | -------------------------------------------------------------------------------- /examples/extendwrite/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | -------------------------------------------------------------------------------- /examples/extendwrite/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "attribute", 3 | "description": "illustrates the usage of the H5A Interface functions: based on h5_attribute.c", 4 | "authors": ["Laeeth Isharc,HDF5 Group"], 5 | "homepage": "https://github.com/Laeeth/d_hdf5", 6 | "license": "Boost-1.0", 7 | "libs":["hdf5","hdf5_hl"], 8 | "targetType":"executable", 9 | "targetPath": "../../build", 10 | "dependencies": { 11 | "d_hdf5": { "path": "../../" } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /examples/externallinks/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | -------------------------------------------------------------------------------- /examples/externallinks/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "externallinks", 3 | "description": " 4 | This program demonstrates how to create and use external links in HDF5. 5 | External links point from one HDF5 file to an object (Group, Dataset, or 6 | committed Datatype) in another file. 7 | ", 8 | "authors": ["Laeeth Isharc,HDF5 Group"], 9 | "homepage": "https://github.com/Laeeth/d_hdf5", 10 | "license": "Boost-1.0", 11 | "libs":["hdf5","hdf5_hl"], 12 | "targetType":"executable", 13 | "targetPath": "../../build", 14 | "dependencies": { 15 | "d_hdf5": { "path": "../../" } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /examples/iterategroup/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | -------------------------------------------------------------------------------- /examples/iterategroup/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "attribute", 3 | "description": "illustrates the usage of the H5A Interface functions: based on h5_attribute.c", 4 | "authors": ["Laeeth Isharc,HDF5 Group"], 5 | "homepage": "https://github.com/Laeeth/d_hdf5", 6 | "license": "Boost-1.0", 7 | "libs":["hdf5","hdf5_hl"], 8 | "targetType":"executable", 9 | "targetPath": "../../build", 10 | "dependencies": { 11 | "d_hdf5": { "path": "../../" } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /examples/iterategroup/source/h5ex_g_iterate.d: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright by The HDF Group. * 3 | Copyright by the Board of Trustees of the University of Illinois. * 4 | All rights reserved. * 5 | * 6 | This file is part of HDF5. The full HDF5 copyright notice, including * 7 | terms governing use, modification, and redistribution, is contained in * 8 | the files COPYING and Copyright.html. COPYING can be found at the root * 9 | of the source code distribution tree; Copyright.html can be found at the * 10 | root level of an installed copy of the electronic HDF5 document set and * 11 | is linked from the top-level documents page. It can also be found at * 12 | http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * 13 | access to either file, you may request a copy from help@hdfgroup.org. * 14 | 15 | Ported by Laeeth Isharc 2014 to the D Programming Language 16 | Use at your own risk! 17 | 18 | This example shows how to iterate over group members using 19 | H5Giterate. 20 | */ 21 | 22 | 23 | import hdf5.hdf5; 24 | import std.stdio; 25 | import std.exception; 26 | 27 | void main(string[] args) 28 | { 29 | writefln("sorry but group iterate is not yet ported - bindings"); 30 | } 31 | /+ 32 | 33 | enum filename ="d_examples/h5ex_g_iterate.h5"; 34 | 35 | /* 36 | * Operator function to be called by H5Giterate. 37 | */ 38 | herr_t op_func (hid_t loc_id, const char *name, void *operator_data); 39 | 40 | int main(string[] args) 41 | { 42 | hid_t file; /* Handle */ 43 | herr_t status; 44 | 45 | /* 46 | * Open file. 47 | */ 48 | file = H5F.open (filename, H5F_ACC_RDONLY, H5P_DEFAULT); 49 | 50 | /* 51 | * Begin iteration. 52 | */ 53 | writefln("Objects in root group:"); 54 | status = H5G.iterate (file, "/", NULL, op_func, NULL); 55 | 56 | /* 57 | * Close and release resources. 58 | */ 59 | status = H5F.close (file); 60 | return 0; 61 | } 62 | 63 | 64 | /************************************************************ 65 | 66 | Operator function. Prints the name and type of the object 67 | being examined. 68 | 69 | ************************************************************/ 70 | extern(C) herr_t op_func (hid_t loc_id, const char *name, void *operator_data) 71 | { 72 | herr_t status; 73 | H5G_stat_t statbuf; 74 | 75 | /* 76 | * Get type of the object and display its name and type. 77 | * The name of the object is passed to this function by 78 | * the Library. 79 | */ 80 | status = H5Gget_objinfo (loc_id, name, 0, &statbuf); 81 | switch (statbuf.type) { 82 | case H5G_GROUP: 83 | writef (" Group: %s\n", name); 84 | break; 85 | case H5G_DATASET: 86 | writef (" Dataset: %s\n", name); 87 | break; 88 | case H5G_TYPE: 89 | writef (" Datatype: %s\n", name); 90 | break; 91 | default: 92 | writef ( " Unknown: %s\n", name); 93 | } 94 | 95 | return 0; 96 | } 97 | +/ -------------------------------------------------------------------------------- /examples/messageshare/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | -------------------------------------------------------------------------------- /examples/messageshare/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "attribute", 3 | "description": "illustrates the usage of the H5A Interface functions: based on h5_attribute.c", 4 | "authors": ["Laeeth Isharc,HDF5 Group"], 5 | "homepage": "https://github.com/Laeeth/d_hdf5", 6 | "license": "Boost-1.0", 7 | "libs":["hdf5","hdf5_hl"], 8 | "targetType":"executable", 9 | "targetPath": "../../build", 10 | "dependencies": { 11 | "d_hdf5": { "path": "../../" } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /examples/myiterator/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | -------------------------------------------------------------------------------- /examples/myiterator/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "attribute", 3 | "description": "illustrates the usage of the H5A Interface functions: based on h5_attribute.c", 4 | "authors": ["Laeeth Isharc,HDF5 Group"], 5 | "homepage": "https://github.com/Laeeth/d_hdf5", 6 | "license": "Boost-1.0", 7 | "libs":["hdf5","hdf5_hl"], 8 | "targetType":"executable", 9 | "targetPath": "../../build", 10 | "dependencies": { 11 | "d_hdf5": { "path": "../../" } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /examples/objrefs/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | -------------------------------------------------------------------------------- /examples/objrefs/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "objrefs", 3 | "description": " 4 | This program illustrates how references to objects can be used. 5 | Program creates a dataset and a group in a file. It also creates 6 | second dataset, and references to the first dataset and the group 7 | are stored in it. 8 | Program reopens the file and reads dataset with the references. 9 | References are used to open the objects. Information about the 10 | objects is displayed.", 11 | "authors": ["Laeeth Isharc,HDF5 Group"], 12 | "homepage": "https://github.com/Laeeth/d_hdf5", 13 | "license": "Boost-1.0", 14 | "libs":["hdf5","hdf5_hl"], 15 | "targetType":"executable", 16 | "targetPath": "../../build", 17 | "dependencies": { 18 | "d_hdf5": { "path": "../../" } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples/objrefs/source/h5_reference.d: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | Copyright by The HDF Group. * 4 | Copyright by the Board of Trustees of the University of Illinois. * 5 | All rights reserved. * 6 | * 7 | This file is part of HDF5. The full HDF5 copyright notice, including * 8 | terms governing use, modification, and redistribution, is contained in * 9 | the files COPYING and Copyright.html. COPYING can be found at the root * 10 | of the source code distribution tree; Copyright.html can be found at the * 11 | root level of an installed copy of the electronic HDF5 document set and * 12 | is linked from the top-level documents page. It can also be found at * 13 | http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * 14 | access to either file, you may request a copy from help@hdfgroup.org. * 15 | 16 | Ported by Laeeth Isharc 2014 to the D Programming Language 17 | Use at your own risk! 18 | 19 | * This program illustrates how references to objects can be used. 20 | * Program creates a dataset and a group in a file. It also creates 21 | * second dataset, and references to the first dataset and the group 22 | * are stored in it. 23 | * Program reopens the file and reads dataset with the references. 24 | * References are used to open the objects. Information about the 25 | * objects is displayed. 26 | */ 27 | 28 | import hdf5.hdf5; 29 | import std.stdio; 30 | import std.exception; 31 | import std.string; 32 | 33 | 34 | enum H5FILE_NAME="refere.h5"; 35 | 36 | int main(string[] args) 37 | { 38 | hid_t fid; /* File, group, datasets, datatypes */ 39 | hid_t gid_a; /* and dataspaces identifiers */ 40 | hid_t did_b, sid_b, tid_b; 41 | hid_t did_r, tid_r, sid_r; 42 | H5OType obj_type; 43 | herr_t status; 44 | 45 | H5OType[2] wbuf; /* buffer to write to disk */ 46 | H5OType[2] rbuf; /* buffer to read from disk */ 47 | 48 | 49 | hsize_t[1] dim_r; 50 | hsize_t[2] dim_b; 51 | 52 | /* 53 | * Create a file using default properties. 54 | */ 55 | fid = H5F.create(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); 56 | 57 | /* 58 | * Create group "A" in the file. 59 | */ 60 | gid_a = H5G.create2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); 61 | 62 | /* 63 | * Create dataset "B" in the file. 64 | */ 65 | dim_b[0] = 2; 66 | dim_b[1] = 6; 67 | sid_b = H5S.create_simple(dim_b); 68 | did_b = H5D.create2(fid, "B", H5T_NATIVE_FLOAT, sid_b, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); 69 | 70 | /* 71 | * Create dataset "R" to store references to the objects "A" and "B". 72 | */ 73 | dim_r[0] = 2; 74 | sid_r = H5S.create_simple(dim_r); 75 | tid_r = H5T.copy(H5T_STD_REF_OBJ); 76 | did_r = H5D.create2(fid, "R", tid_r, sid_r, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); 77 | 78 | /* 79 | * Create references to the group "A" and dataset "B" 80 | * and store them in the wbuf. 81 | */ 82 | H5R.create(&wbuf[0], fid, "A", H5RType.ObjectRef, cast(hid_t)-1); 83 | H5R.create(&wbuf[1], fid, "B", H5RType.ObjectRef, cast(hid_t)-1); 84 | 85 | /* 86 | * Write dataset R using default transfer properties. 87 | */ 88 | H5D.write(did_r, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, cast(ubyte*)wbuf.ptr); 89 | 90 | /* 91 | * Close all objects. 92 | */ 93 | H5G.close(gid_a); 94 | H5S.close(sid_b); 95 | H5D.close(did_b); 96 | H5T.close(tid_r); 97 | H5S.close(sid_r); 98 | H5D.close(did_r); 99 | H5F.close(fid); 100 | 101 | /* 102 | * Reopen the file. 103 | */ 104 | fid = H5F.open(H5FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); 105 | 106 | did_r = H5D.open2(fid, "R", H5P_DEFAULT); 107 | H5D.read(did_r, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, cast(ubyte*)rbuf.ptr); 108 | 109 | /* 110 | * Find the type of referenced objects. 111 | */ 112 | writefln("now trying to figure out obj type 1"); 113 | obj_type=H5R.get_obj_type2(did_r, H5RType.ObjectRef, &rbuf[0]); 114 | if(obj_type == H5OType.Group) 115 | writefln("First dereferenced object is a group."); 116 | 117 | writefln("now trying to figure out obj type 2"); 118 | obj_type=H5R.get_obj_type2(did_r, H5RType.ObjectRef, &rbuf[1]); 119 | if(obj_type == H5OType.Dataset) 120 | writefln("Second dereferenced object is a dataset."); 121 | 122 | /* 123 | * Get datatype of the dataset "B" 124 | */ 125 | did_b = H5R.dereference(did_r, H5RType.ObjectRef, &rbuf[1]); 126 | tid_b = H5D.get_type(did_b); 127 | if(H5Tequal(tid_b, H5T_NATIVE_FLOAT)) 128 | writefln("Datatype of the dataset is H5T_NATIVE_FLOAT."); 129 | writefln(""); 130 | H5D.close(did_r); 131 | H5D.close(did_b); 132 | H5T.close(tid_b); 133 | H5F.close(fid); 134 | return 0; 135 | } 136 | 137 | -------------------------------------------------------------------------------- /examples/read/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | -------------------------------------------------------------------------------- /examples/read/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "attribute", 3 | "description": "illustrates the usage of the H5A Interface functions: based on h5_attribute.c", 4 | "authors": ["Laeeth Isharc,HDF5 Group"], 5 | "homepage": "https://github.com/Laeeth/d_hdf5", 6 | "license": "Boost-1.0", 7 | "libs":["hdf5","hdf5_hl"], 8 | "targetType":"executable", 9 | "targetPath": "../../build", 10 | "dependencies": { 11 | "d_hdf5": { "path": "../../" } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /examples/readwrite/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | -------------------------------------------------------------------------------- /examples/readwrite/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "attribute", 3 | "description": "illustrates the usage of the H5A Interface functions: based on h5_attribute.c", 4 | "authors": ["Laeeth Isharc,HDF5 Group"], 5 | "homepage": "https://github.com/Laeeth/d_hdf5", 6 | "license": "Boost-1.0", 7 | "libs":["hdf5","hdf5_hl"], 8 | "targetType":"executable", 9 | "targetPath": "../../build", 10 | "dependencies": { 11 | "d_hdf5": { "path": "../../" } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /examples/readwrite/source/h5_rdwt.d: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright by The HDF Group. * 3 | Copyright by the Board of Trustees of the University of Illinois. * 4 | All rights reserved. * 5 | * 6 | This file is part of HDF5. The full HDF5 copyright notice, including * 7 | terms governing use, modification, and redistribution, is contained in * 8 | the files COPYING and Copyright.html. COPYING can be found at the root * 9 | of the source code distribution tree; Copyright.html can be found at the * 10 | root level of an installed copy of the electronic HDF5 document set and * 11 | is linked from the top-level documents page. It can also be found at * 12 | http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * 13 | access to either file, you may request a copy from help@hdfgroup.org. * 14 | 15 | Ported by Laeeth Isharc 2014 to the D Programming Language 16 | Use at your own risk! 17 | 18 | This example illustrates how to write and read data in an existing 19 | dataset. It is used in the HDF5 Tutorial. 20 | */ 21 | 22 | 23 | import hdf5.hdf5; 24 | import std.stdio; 25 | import std.exception; 26 | 27 | enum filename="dset.h5"; 28 | 29 | int main(string[] args) 30 | { 31 | 32 | int[600][1000] dset_data; 33 | 34 | H5open(); 35 | /* Initialize the dataset. */ 36 | foreach(i;0..dset_data.length) 37 | foreach(j;0..dset_data[0].length) 38 | dset_data[i][j] = cast(int)i * cast(int)dset_data.length + cast(int)j + 1; 39 | 40 | writefln("* opening %s",filename); 41 | /* Open an existing file. */ 42 | auto file_id = H5F.open(filename, H5F_ACC_RDWR, H5P_DEFAULT); 43 | 44 | writefln("* opening /dset"); 45 | /* Open an existing dataset. */ 46 | auto dataset_id = H5D.open2(file_id, "/dset", H5P_DEFAULT); 47 | 48 | /* Write the dataset. */ 49 | writefln("* writing dataset"); 50 | H5D.write(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, cast(ubyte*)dset_data.ptr); 51 | writefln("* reading dataset"); 52 | 53 | H5D.read(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, cast(ubyte*)&dset_data).ptr; 54 | 55 | writefln("* closing dataset"); 56 | /* Close the dataset. */ 57 | H5D.close(dataset_id); 58 | writefln("* closing file"); 59 | /* Close the file. */ 60 | H5F.close(file_id); 61 | H5close(); 62 | return 0; 63 | } 64 | -------------------------------------------------------------------------------- /examples/runexamples.d: -------------------------------------------------------------------------------- 1 | import std.file; 2 | import std.path; 3 | import std.stdio; 4 | import std.string; 5 | import std.exception; 6 | import std.process; 7 | 8 | void main(string[] args) 9 | { 10 | string[] work; 11 | string[] desc; 12 | string[] file; 13 | writefln("*** building list of projects to build"); 14 | foreach(entry;dirEntries(".",SpanMode.breadth)) 15 | { 16 | if (!entry.isDir) 17 | continue; 18 | if (!exists(entry.name~"/"~"source")) 19 | continue; 20 | foreach(sourceFile;dirEntries(entry.name~"/"~"source",SpanMode.depth)) 21 | { 22 | if ((sourceFile.isDir)||(!sourceFile.name.endsWith(".d"))) 23 | continue; 24 | work~=sourceFile.name; 25 | } 26 | } 27 | foreach(string f;work) 28 | { 29 | auto i=f.lastIndexOf("/source/"); 30 | f=f[0..i]; 31 | writefln("*** building %s",f); 32 | chdir(f); 33 | auto ls=executeShell("dub build"); 34 | if (ls.status!=0) 35 | { 36 | writefln("**** %s failed to build",f); 37 | } 38 | chdir(".."); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /examples/select/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | -------------------------------------------------------------------------------- /examples/select/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "select", 3 | "description": " 4 | * This program shows how the H5Sselect_hyperslab and H5Sselect_elements 5 | * functions are used to write selected data from memory to the file. 6 | * Program takes 48 elements from the linear buffer and writes them into 7 | * the matrix using 3x2 blocks, (4,3) stride and (2,4) count. 8 | * Then four elements of the matrix are overwritten with the new values and 9 | * file is closed. Program reopens the file and selects the union of two 10 | * hyperslabs in the dataset in the file. Then it reads the selection into the 11 | * memory dataset preserving the shape of the selection. 12 | *", 13 | "authors": ["Laeeth Isharc,HDF5 Group"], 14 | "homepage": "https://github.com/Laeeth/d_hdf5", 15 | "license": "Boost-1.0", 16 | "libs":["hdf5","hdf5_hl"], 17 | "targetType":"executable", 18 | "targetPath": "../../build", 19 | "dependencies": { 20 | "d_hdf5": { "path": "../../" } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /examples/source/app.d: -------------------------------------------------------------------------------- 1 | 2 | version(none) 3 | { 4 | void dummy() 5 | { 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /examples/stringattributes/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | -------------------------------------------------------------------------------- /examples/stringattributes/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "attribute", 3 | "description": "illustrates the usage of the H5A Interface functions: based on h5_attribute.c", 4 | "authors": ["Laeeth Isharc,HDF5 Group"], 5 | "homepage": "https://github.com/Laeeth/d_hdf5", 6 | "license": "Boost-1.0", 7 | "libs":["hdf5","hdf5_hl"], 8 | "targetType":"executable", 9 | "targetPath": "../../build", 10 | "dependencies": { 11 | "d_hdf5": { "path": "../../" } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /examples/strings/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | -------------------------------------------------------------------------------- /examples/strings/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "attribute", 3 | "description": "illustrates the usage of the H5A Interface functions: based on h5_attribute.c", 4 | "authors": ["Laeeth Isharc,HDF5 Group"], 5 | "homepage": "https://github.com/Laeeth/d_hdf5", 6 | "license": "Boost-1.0", 7 | "libs":["hdf5","hdf5_hl"], 8 | "targetType":"executable", 9 | "targetPath": "../../build", 10 | "dependencies": { 11 | "d_hdf5": { "path": "../../" } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /examples/subset/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | -------------------------------------------------------------------------------- /examples/subset/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "attribute", 3 | "description": "illustrates the usage of the H5A Interface functions: based on h5_attribute.c", 4 | "authors": ["Laeeth Isharc,HDF5 Group"], 5 | "homepage": "https://github.com/Laeeth/d_hdf5", 6 | "license": "Boost-1.0", 7 | "libs":["hdf5","hdf5_hl"], 8 | "targetType":"executable", 9 | "targetPath": "../../build", 10 | "dependencies": { 11 | "d_hdf5": { "path": "../../" } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /examples/szip/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | -------------------------------------------------------------------------------- /examples/szip/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "attribute", 3 | "description": "illustrates the usage of the H5A Interface functions: based on h5_attribute.c", 4 | "authors": ["Laeeth Isharc,HDF5 Group"], 5 | "homepage": "https://github.com/Laeeth/d_hdf5", 6 | "license": "Boost-1.0", 7 | "libs":["hdf5","hdf5_hl"], 8 | "targetType":"executable", 9 | "targetPath": "../../build", 10 | "dependencies": { 11 | "d_hdf5": { "path": "../../" } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /examples/traits/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | -------------------------------------------------------------------------------- /examples/traits/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "traits", 3 | "description": " 4 | Basic conversion of HDF5 types to D types and back 5 | Not recursive so D structs must be built of native D types 6 | 7 | To load HDF5 series into an array of D type T: 8 | auto results=slurpDataspaceVector!T(string filename, string dataset name); 9 | 10 | To save an array of D type T to an HDF5 data series: 11 | dumpDataSpaceVector!T(string filename,string datasetName, T[] data,bool append) 12 | append=true means append; otherwise overwrite 13 | ", 14 | "authors": ["Laeeth Isharc,HDF5 Group"], 15 | "homepage": "https://github.com/Laeeth/d_hdf5", 16 | "license": "Boost-1.0", 17 | "libs":["hdf5","hdf5_hl"], 18 | "targetType":"executable", 19 | "targetPath": "../../build", 20 | "dependencies": { 21 | "d_hdf5": { "path": "../../" } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /examples/traversefile/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | -------------------------------------------------------------------------------- /examples/traversefile/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "attribute", 3 | "description": "illustrates the usage of the H5A Interface functions: based on h5_attribute.c", 4 | "authors": ["Laeeth Isharc,HDF5 Group"], 5 | "homepage": "https://github.com/Laeeth/d_hdf5", 6 | "license": "Boost-1.0", 7 | "libs":["hdf5","hdf5_hl"], 8 | "targetType":"executable", 9 | "targetPath": "../../build", 10 | "dependencies": { 11 | "d_hdf5": { "path": "../../" } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /examples/traverseobjects/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | -------------------------------------------------------------------------------- /examples/traverseobjects/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "traverseobjects", 3 | "description": " 4 | 5 | This example shows how to recursively traverse a file 6 | using H5Ovisit and H5Lvisit. The program prints all of 7 | the objects in the file specified in FILE, then prints all 8 | of the links in that file. 9 | 10 | ", 11 | "authors": ["Laeeth Isharc,HDF5 Group"], 12 | "homepage": "https://github.com/Laeeth/d_hdf5", 13 | "license": "Boost-1.0", 14 | "libs":["hdf5","hdf5_hl"], 15 | "targetType":"executable", 16 | "targetPath": "../../build", 17 | "dependencies": { 18 | "d_hdf5": { "path": "../../" } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples/traverseobjects/source/h5_ex_g_visit.d: -------------------------------------------------------------------------------- 1 | /************************************************************ 2 | 3 | This example shows how to recursively traverse a file 4 | using H5Ovisit and H5Lvisit. The program prints all of 5 | the objects in the file specified in FILE, then prints all 6 | of the links in that file. 7 | 8 | This file is intended for use with HDF5 Library version 1.8 9 | 10 | ************************************************************/ 11 | 12 | 13 | import hdf5.hdf5; 14 | import std.stdio; 15 | import std.string; 16 | 17 | //enum fname="h5ex_g_visit.h5"; 18 | enum fname="group.h5"; 19 | int main(string[] args) 20 | { 21 | H5open(); 22 | //open file 23 | //auto file = H5F.open(fname, H5F_ACC_RDONLY, H5P_DEFAULT); 24 | auto file = H5F.open(fname, H5F_ACC_RDONLY, H5P_DEFAULT); 25 | 26 | // Begin iteration using H5Ovisit 27 | writefln ("Objects in the file:"); 28 | //H5O.visit (file, H5Index.Name, H5IterOrder.Native, &op_func, cast(void*)0); 29 | H5Ovisit (file, H5Index.Name, H5IterOrder.Native, &op_func, cast(void*)0); 30 | 31 | // Repeat the same process using H5Lvisit 32 | writefln ("\nLinks in the file:"); 33 | //H5L.visit(file, H5Index.Name, H5IterOrder.Native, &op_func_L, cast(void*)0); 34 | H5Lvisit(file, H5Index.Name, H5IterOrder.Native, &op_func_L, cast(void*)0); 35 | writefln("About to close"); 36 | // Close and release resources. 37 | //H5F.close (file); 38 | H5Fclose (file); 39 | H5close(); 40 | return 0; 41 | } 42 | 43 | 44 | // Operator function for H5Ovisit. This function prints the name and type of the object passed to it. 45 | extern(C) herr_t op_func (hid_t loc_id, const (char *)name, const H5OInfo *info, void *operator_data) 46 | { 47 | writef("/"); /* Print root group in object path */ 48 | 49 | /* 50 | * Check if the current object is the root group, and if not print 51 | * the full path name and type. 52 | */ 53 | if (name[0] == '.') /* Root group, do not print '.' */ 54 | writefln (" (Group)"); 55 | else 56 | { 57 | auto namestring=ZtoString(name); 58 | switch (info.type) { 59 | case H5OType.Group: 60 | writefln ("%s (Group)", namestring); 61 | break; 62 | case H5OType.Dataset: 63 | writefln ("%s (Dataset)", namestring); 64 | break; 65 | case H5OType.NamedDataType: 66 | writefln ("%s (Datatype)", namestring); 67 | break; 68 | default: 69 | writefln ("%s (Unknown)", namestring); 70 | } 71 | } 72 | return 0; 73 | } 74 | 75 | 76 | /************************************************************ 77 | 78 | Operator function for H5Lvisit. This function simply 79 | retrieves the info for the object the current link points 80 | to, and calls the operator function for H5Ovisit. 81 | 82 | ************************************************************/ 83 | extern(C) herr_t op_func_L (hid_t loc_id, const (char *)name, const (H5LInfo*)info, void *operator_data) 84 | { 85 | H5OInfo infobuf; 86 | /* 87 | * Get type of the object and display its name and type. 88 | * The name of the object is passed to this function by 89 | * the Library. 90 | */ 91 | //H5O.get_info_by_name (loc_id, ZtoString(name), &infobuf, H5P_DEFAULT); 92 | H5Oget_info_by_name(loc_id,name, &infobuf, H5P_DEFAULT); 93 | //writefln("H5O: returning: name=%s",ZtoString(name)); 94 | //writefln("H5O: returning: loc_id=%s, name=%s, infobuf=%s, operator_data=%s",loc_id,ZtoString(name),infobuf,operator_data); 95 | return 0; // op_func (loc_id, name, &infobuf, operator_data); 96 | } 97 | -------------------------------------------------------------------------------- /examples/unlimiteddataset/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | -------------------------------------------------------------------------------- /examples/unlimiteddataset/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "unlimiteddataset", 3 | "description": " 4 | This example shows how to create and extend an unlimited 5 | dataset. The program first writes integers to a dataset 6 | with dataspace dimensions of DIM0xDIM1, then closes the 7 | file. Next, it reopens the file, reads back the data, 8 | outputs it to the screen, extends the dataset, and writes 9 | new data to the extended portions of the dataset. Finally 10 | it reopens the file again, reads back the data, and 11 | outputs it to the screen. 12 | ", 13 | "authors": ["Laeeth Isharc,HDF5 Group"], 14 | "homepage": "https://github.com/Laeeth/d_hdf5", 15 | "license": "Boost-1.0", 16 | "libs":["hdf5","hdf5_hl"], 17 | "targetType":"executable", 18 | "targetPath": "../../build", 19 | "dependencies": { 20 | "d_hdf5": { "path": "../../" } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /examples/unlimiteddataset/h5ex_d_unlimadd.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Laeeth/d_hdf5/b688f39549bc074e646992920431ae8765bf6ea4/examples/unlimiteddataset/h5ex_d_unlimadd.h5 -------------------------------------------------------------------------------- /examples/write/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | -------------------------------------------------------------------------------- /examples/write/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "attribute", 3 | "description": "illustrates the usage of the H5A Interface functions: based on h5_attribute.c", 4 | "authors": ["Laeeth Isharc,HDF5 Group"], 5 | "homepage": "https://github.com/Laeeth/d_hdf5", 6 | "license": "Boost-1.0", 7 | "libs":["hdf5","hdf5_hl"], 8 | "targetType":"executable", 9 | "targetPath": "../../build", 10 | "dependencies": { 11 | "d_hdf5": { "path": "../../" } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /examples/write/source/h5_write.d: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright by The HDF Group. * 3 | Copyright by the Board of Trustees of the University of Illinois. * 4 | All rights reserved. * 5 | * 6 | This file is part of HDF5. The full HDF5 copyright notice, including * 7 | terms governing use, modification, and redistribution, is contained in * 8 | the files COPYING and Copyright.html. COPYING can be found at the root * 9 | of the source code distribution tree; Copyright.html can be found at the * 10 | root level of an installed copy of the electronic HDF5 document set and * 11 | is linked from the top-level documents page. It can also be found at * 12 | http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * 13 | access to either file, you may request a copy from help@hdfgroup.org. * 14 | 15 | Ported by Laeeth Ishaac 2014 to the D Programming Language 16 | Use at your own risk! 17 | 18 | This example writes data to the HDF5 file. 19 | Data conversion is performed during write operation. 20 | */ 21 | 22 | 23 | import hdf5.hdf5; 24 | 25 | import std.stdio; 26 | import std.exception; 27 | 28 | string H5FILE_NAME="SDS.h5"; 29 | string DATASETNAME="IntArray"; 30 | enum NX=5; /* dataset dimensions */ 31 | enum NY=6; 32 | enum RANK=2; 33 | 34 | int main(string[] args) 35 | { 36 | hid_t file, dataset; /* file and dataset handles */ 37 | hid_t datatype, dataspace; /* handles */ 38 | hsize_t[2] dimsf; /* dataset dimensions */ 39 | herr_t status; 40 | int[NY][NX] data; /* data to write */ 41 | int i, j; 42 | 43 | writefln("* initializing buffer"); 44 | // Data and output buffer initialization. 45 | for(j = 0; j < NX; j++) 46 | for(i = 0; i < NY; i++) 47 | data[j][i] = i + j; 48 | /* 49 | * 0 1 2 3 4 5 50 | * 1 2 3 4 5 6 51 | * 2 3 4 5 6 7 52 | * 3 4 5 6 7 8 53 | * 4 5 6 7 8 9 54 | */ 55 | 56 | 57 | // Create a new file using H5F_ACC_TRUNC access, default file creation properties, and default file 58 | // access properties. 59 | writefln("* creating file %s",H5FILE_NAME); 60 | file = H5F.create(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); 61 | 62 | // Describe the size of the array and create the data space for fixed size dataset. 63 | dimsf[0] = NX; 64 | dimsf[1] = NY; 65 | writefln("* creating dataspace with dims [%s,%s]",dimsf[0],dimsf[1]); 66 | dataspace = H5S.create_simple(dimsf); 67 | 68 | // Define datatype for the data in the file. We will store little endian INT numbers. 69 | writefln("* copying dataset"); 70 | datatype = H5T.copy(H5T_NATIVE_INT); 71 | writefln("* byteorder = little-endian"); 72 | H5T.set_order(datatype, H5TByteOrder.LE); 73 | 74 | // Create a new dataset within the file using defined dataspace and datatype and default dataset creation properties. 75 | writefln("* new dataset within file called %s",DATASETNAME); 76 | dataset = H5D.create2(file, DATASETNAME, datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); 77 | 78 | // Write the data to the dataset using default transfer properties. 79 | writefln("* writing"); 80 | H5D.write(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, cast(ubyte*)&data); 81 | 82 | /* 83 | * Close/release resources. 84 | */ 85 | writefln("* closing up shop"); 86 | H5S.close(dataspace); 87 | H5T.close(datatype); 88 | H5D.close(dataset); 89 | H5F.close(file); 90 | 91 | return 0; 92 | } 93 | -------------------------------------------------------------------------------- /hdf5/hdf5.d: -------------------------------------------------------------------------------- 1 | module hdf5.hdf5; 2 | public import hdf5.wrap; 3 | public import hdf5.bindings.enums; 4 | public import hdf5.bindings.api; 5 | -------------------------------------------------------------------------------- /old/examples/h5_drivers.d: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright by The HDF Group. * 3 | Copyright by the Board of Trustees of the University of Illinois. * 4 | All rights reserved. * 5 | * 6 | This file is part of HDF5. The full HDF5 copyright notice, including * 7 | terms governing use, modification, and redistribution, is contained in * 8 | the files COPYING and Copyright.html. COPYING can be found at the root * 9 | of the source code distribution tree; Copyright.html can be found at the * 10 | root level of an installed copy of the electronic HDF5 document set and * 11 | is linked from the top-level documents page. It can also be found at * 12 | http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * 13 | access to either file, you may request a copy from help@hdfgroup.org. * 14 | 15 | Ported by Laeeth Isharc 2014 to the D Programming Language 16 | Use at your own risk! 17 | 18 | This shows how to use the hdf5 virtual file drivers. 19 | The example codes here do not check return values for the 20 | sake of simplicity. As in all proper programs, return codes 21 | should be checked. 22 | */ 23 | 24 | import hdf5.wrap; 25 | import hdf5.bindings.enums; 26 | import std.file; 27 | import std.stdio; 28 | import std.exception; 29 | import std.string; 30 | import std.conv; 31 | import std.process; 32 | 33 | /* global variables */ 34 | int cleanup_g = -1; /* whether to clean. Init to not set. */ 35 | 36 | 37 | // Cleanup a file unless $HDF5_NOCLEANUP is set. 38 | void cleanup(string filename) 39 | { 40 | if (cleanup_g == -1) 41 | cleanup_g = environment.get("HDF5_NOCLEANUP") ? 0 : 1; 42 | if (cleanup_g) 43 | remove(filename); 44 | } 45 | 46 | 47 | /// This shows how to use the split file driver. 48 | 49 | void split_file() 50 | { 51 | hid_t fapl, fid; 52 | 53 | /* Example 1: Both metadata and rawdata files are in the same */ 54 | /* directory. Use Station1-m.h5 and Station1-r.h5 as */ 55 | /* the metadata and rawdata files. */ 56 | fapl = H5P.create(H5P_FILE_ACCESS); 57 | H5P.set_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT); 58 | fid=H5F.create("Station1",H5F_ACC_TRUNC,H5P_DEFAULT,fapl); 59 | /* using the file ... */ 60 | H5F.close(fid); 61 | H5P.close(fapl); 62 | /* Remove files created */ 63 | cleanup("Station1-m.h5"); 64 | cleanup("Station1-r.h5"); 65 | 66 | /* Example 2: metadata and rawdata files are in different */ 67 | /* directories. Use PointA-m.h5 and /tmp/PointA-r.h5 as */ 68 | /* the metadata and rawdata files. */ 69 | fapl = H5P.create(H5P_FILE_ACCESS); 70 | H5P.set_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "/tmp/%s-r.h5", H5P_DEFAULT); 71 | fid=H5F.create("PointA",H5F_ACC_TRUNC,H5P_DEFAULT,fapl); 72 | /* using the file ... */ 73 | H5F.close(fid); 74 | H5P.close(fapl); 75 | /* Remove files created */ 76 | cleanup("PointA-m.h5"); 77 | cleanup("/tmp/PointA-r.h5"); 78 | 79 | /* Example 3: Using default extension names for the metadata */ 80 | /* and rawdata files. Use Measure.meta and Measure.raw as */ 81 | /* the metadata and rawdata files. */ 82 | fapl = H5P.create(H5P_FILE_ACCESS); 83 | H5P.set_fapl_split(fapl, NULL, H5P_DEFAULT, NULL, H5P_DEFAULT); 84 | fid=H5F.create("Measure",H5F_ACC_TRUNC,H5P_DEFAULT,fapl); 85 | /* using the file ... */ 86 | H5F.close(fid); 87 | H5P.close(fapl); 88 | /* Remove files created */ 89 | cleanup("Measure.meta"); 90 | cleanup("Measure.raw"); 91 | } 92 | 93 | // Main Body 94 | int main(string[] args) 95 | { 96 | split_file(); 97 | return(0); 98 | } -------------------------------------------------------------------------------- /old/examples/h5_ex_g_visit.c: -------------------------------------------------------------------------------- 1 | /************************************************************ 2 | 3 | This example shows how to recursively traverse a file 4 | using H5Ovisit and H5Lvisit. The program prints all of 5 | the objects in the file specified in FILE, then prints all 6 | of the links in that file. 7 | 8 | This file is intended for use with HDF5 Library version 1.8 9 | 10 | ************************************************************/ 11 | 12 | #include "hdf5.h" 13 | #include 14 | 15 | #define FILE "h5ex_g_visit.h5" 16 | 17 | /* 18 | * Operator function to be called by H5Ovisit. 19 | */ 20 | herr_t op_func (hid_t loc_id, const char *name, const H5O_info_t *info, 21 | void *operator_data); 22 | 23 | /* 24 | * Operator function to be called by H5Lvisit. 25 | */ 26 | herr_t op_func_L (hid_t loc_id, const char *name, const H5L_info_t *info, 27 | void *operator_data); 28 | 29 | int 30 | main (void) 31 | { 32 | hid_t file; /* Handle */ 33 | herr_t status; 34 | 35 | /* 36 | * Open file 37 | */ 38 | file = H5Fopen (FILE, H5F_ACC_RDONLY, H5P_DEFAULT); 39 | 40 | /* 41 | * Begin iteration using H5Ovisit 42 | */ 43 | printf ("Objects in the file:\n"); 44 | status = H5Ovisit (file, H5_INDEX_NAME, H5_ITER_NATIVE, op_func, NULL); 45 | 46 | /* 47 | * Repeat the same process using H5Lvisit 48 | */ 49 | printf ("\nLinks in the file:\n"); 50 | status = H5Lvisit (file, H5_INDEX_NAME, H5_ITER_NATIVE, op_func_L, NULL); 51 | 52 | /* 53 | * Close and release resources. 54 | */ 55 | status = H5Fclose (file); 56 | 57 | return 0; 58 | } 59 | 60 | 61 | /************************************************************ 62 | 63 | Operator function for H5Ovisit. This function prints the 64 | name and type of the object passed to it. 65 | 66 | ************************************************************/ 67 | herr_t op_func (hid_t loc_id, const char *name, const H5O_info_t *info, 68 | void *operator_data) 69 | { 70 | printf ("/"); /* Print root group in object path */ 71 | 72 | /* 73 | * Check if the current object is the root group, and if not print 74 | * the full path name and type. 75 | */ 76 | if (name[0] == '.') /* Root group, do not print '.' */ 77 | printf (" (Group)\n"); 78 | else 79 | switch (info->type) { 80 | case H5O_TYPE_GROUP: 81 | printf ("%s (Group)\n", name); 82 | break; 83 | case H5O_TYPE_DATASET: 84 | printf ("%s (Dataset)\n", name); 85 | break; 86 | case H5O_TYPE_NAMED_DATATYPE: 87 | printf ("%s (Datatype)\n", name); 88 | break; 89 | default: 90 | printf ("%s (Unknown)\n", name); 91 | } 92 | 93 | return 0; 94 | } 95 | 96 | 97 | /************************************************************ 98 | 99 | Operator function for H5Lvisit. This function simply 100 | retrieves the info for the object the current link points 101 | to, and calls the operator function for H5Ovisit. 102 | 103 | ************************************************************/ 104 | herr_t op_func_L (hid_t loc_id, const char *name, const H5L_info_t *info, 105 | void *operator_data) 106 | { 107 | herr_t status; 108 | H5O_info_t infobuf; 109 | 110 | /* 111 | * Get type of the object and display its name and type. 112 | * The name of the object is passed to this function by 113 | * the Library. 114 | */ 115 | status = H5Oget_info_by_name (loc_id, name, &infobuf, H5P_DEFAULT); 116 | return op_func (loc_id, name, &infobuf, operator_data); 117 | } 118 | -------------------------------------------------------------------------------- /old/examples/h5_ex_g_visit.d: -------------------------------------------------------------------------------- 1 | /************************************************************ 2 | 3 | This example shows how to recursively traverse a file 4 | using H5Ovisit and H5Lvisit. The program prints all of 5 | the objects in the file specified in FILE, then prints all 6 | of the links in that file. 7 | 8 | This file is intended for use with HDF5 Library version 1.8 9 | 10 | ************************************************************/ 11 | 12 | import hdf5.wrap; 13 | import hdf5.bindings.enums; 14 | import std.stdio; 15 | import std.string; 16 | 17 | //enum fname="h5ex_g_visit.h5"; 18 | enum fname="group.h5"; 19 | int main(string[] args) 20 | { 21 | H5open(); 22 | //open file 23 | //auto file = H5F.open(fname, H5F_ACC_RDONLY, H5P_DEFAULT); 24 | auto file = H5F.open(toStringz(fname), H5F_ACC_RDONLY, H5P_DEFAULT); 25 | 26 | // Begin iteration using H5Ovisit 27 | writefln ("Objects in the file:"); 28 | //H5O.visit (file, H5Index.Name, H5IterOrder.Native, &op_func, cast(void*)0); 29 | H5Ovisit (file, H5I.ndex.Name, H5IterOrder.Native, &op_func, cast(void*)0); 30 | 31 | // Repeat the same process using H5Lvisit 32 | writefln ("\nLinks in the file:"); 33 | //H5L.visit(file, H5Index.Name, H5IterOrder.Native, &op_func_L, cast(void*)0); 34 | H5Lvisit(file, H5Index.Name, H5IterOrder.Native, &op_func_L, cast(void*)0); 35 | writefln("About to close"); 36 | // Close and release resources. 37 | //H5F.close (file); 38 | H5Fclose (file); 39 | H5close(); 40 | return 0; 41 | } 42 | 43 | 44 | // Operator function for H5Ovisit. This function prints the name and type of the object passed to it. 45 | extern(C) herr_t op_func (hid_t loc_id, const (char *)name, const H5O_info_t *info, void *operator_data) 46 | { 47 | writef("/"); /* Print root group in object path */ 48 | 49 | /* 50 | * Check if the current object is the root group, and if not print 51 | * the full path name and type. 52 | */ 53 | if (name[0] == '.') /* Root group, do not print '.' */ 54 | writefln (" (Group)"); 55 | else 56 | { 57 | auto namestring=ZtoString(name); 58 | switch (info.type) { 59 | case H5OType.Group: 60 | writefln ("%s (Group)", namestring); 61 | break; 62 | case H5OType.Dataset: 63 | writefln ("%s (Dataset)", namestring); 64 | break; 65 | case H5OType.NamedDataType: 66 | writefln ("%s (Datatype)", namestring); 67 | break; 68 | default: 69 | writefln ("%s (Unknown)", namestring); 70 | } 71 | } 72 | return 0; 73 | } 74 | 75 | 76 | /************************************************************ 77 | 78 | Operator function for H5Lvisit. This function simply 79 | retrieves the info for the object the current link points 80 | to, and calls the operator function for H5Ovisit. 81 | 82 | ************************************************************/ 83 | extern(C) herr_t op_func_L (hid_t loc_id, const (char *)name, const (H5LInfo*)info, void *operator_data) 84 | { 85 | H5O_info_t infobuf; 86 | /* 87 | * Get type of the object and display its name and type. 88 | * The name of the object is passed to this function by 89 | * the Library. 90 | */ 91 | //H5O.get_info_by_name (loc_id, ZtoString(name), &infobuf, H5P_DEFAULT); 92 | H5Oget_info_by_name(loc_id,name, &infobuf, H5P_DEFAULT); 93 | //writefln("H5O: returning: name=%s",ZtoString(name)); 94 | //writefln("H5O: returning: loc_id=%s, name=%s, infobuf=%s, operator_data=%s",loc_id,ZtoString(name),infobuf,operator_data); 95 | return 0; // op_func (loc_id, name, &infobuf, operator_data); 96 | } 97 | -------------------------------------------------------------------------------- /old/examples/h5_rdwt.d: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright by The HDF Group. * 3 | Copyright by the Board of Trustees of the University of Illinois. * 4 | All rights reserved. * 5 | * 6 | This file is part of HDF5. The full HDF5 copyright notice, including * 7 | terms governing use, modification, and redistribution, is contained in * 8 | the files COPYING and Copyright.html. COPYING can be found at the root * 9 | of the source code distribution tree; Copyright.html can be found at the * 10 | root level of an installed copy of the electronic HDF5 document set and * 11 | is linked from the top-level documents page. It can also be found at * 12 | http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * 13 | access to either file, you may request a copy from help@hdfgroup.org. * 14 | 15 | Ported by Laeeth Isharc 2014 to the D Programming Language 16 | Use at your own risk! 17 | 18 | This example illustrates how to write and read data in an existing 19 | dataset. It is used in the HDF5 Tutorial. 20 | */ 21 | 22 | import hdf5; 23 | import std.stdio; 24 | import std.exception; 25 | 26 | enum filename="dset.h5"; 27 | 28 | int main(string[] args) 29 | { 30 | 31 | int[600][1000] dset_data; 32 | 33 | H5open(); 34 | /* Initialize the dataset. */ 35 | foreach(i;0..dset_data.length) 36 | foreach(j;0..dset_data[0].length) 37 | dset_data[i][j] = cast(int)i * cast(int)dset_data.length + cast(int)j + 1; 38 | 39 | writefln("* opening %s",filename); 40 | /* Open an existing file. */ 41 | auto file_id = H5F.open(filename, H5F_ACC_RDWR, H5P_DEFAULT); 42 | 43 | writefln("* opening /dset"); 44 | /* Open an existing dataset. */ 45 | auto dataset_id = H5D.open2(file_id, "/dset", H5P_DEFAULT); 46 | 47 | /* Write the dataset. */ 48 | writefln("* writing dataset"); 49 | H5D.write(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, cast(ubyte*)dset_data); 50 | writefln("* reading dataset"); 51 | 52 | H5D.read(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, cast(ubyte*)&dset_data); 53 | 54 | writefln("* closing dataset"); 55 | /* Close the dataset. */ 56 | H5D.close(dataset_id); 57 | writefln("* closing file"); 58 | /* Close the file. */ 59 | H5F.close(file_id); 60 | H5close(); 61 | return 0; 62 | } 63 | -------------------------------------------------------------------------------- /old/examples/h5_reference.d: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | Copyright by The HDF Group. * 4 | Copyright by the Board of Trustees of the University of Illinois. * 5 | All rights reserved. * 6 | * 7 | This file is part of HDF5. The full HDF5 copyright notice, including * 8 | terms governing use, modification, and redistribution, is contained in * 9 | the files COPYING and Copyright.html. COPYING can be found at the root * 10 | of the source code distribution tree; Copyright.html can be found at the * 11 | root level of an installed copy of the electronic HDF5 document set and * 12 | is linked from the top-level documents page. It can also be found at * 13 | http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * 14 | access to either file, you may request a copy from help@hdfgroup.org. * 15 | 16 | Ported by Laeeth Isharc 2014 to the D Programming Language 17 | Use at your own risk! 18 | 19 | * This program illustrates how references to objects can be used. 20 | * Program creates a dataset and a group in a file. It also creates 21 | * second dataset, and references to the first dataset and the group 22 | * are stored in it. 23 | * Program reopens the file and reads dataset with the references. 24 | * References are used to open the objects. Information about the 25 | * objects is displayed. 26 | */ 27 | 28 | import hdf5; 29 | import std.stdio; 30 | import std.exception; 31 | import std.string; 32 | 33 | 34 | enum H5FILE_NAME="refere.h5"; 35 | 36 | int main(string[] args) 37 | { 38 | hid_t fid; /* File, group, datasets, datatypes */ 39 | hid_t gid_a; /* and dataspaces identifiers */ 40 | hid_t did_b, sid_b, tid_b; 41 | hid_t did_r, tid_r, sid_r; 42 | H5OType obj_type; 43 | herr_t status; 44 | 45 | H5OType[2] wbuf; /* buffer to write to disk */ 46 | H5OType[2] rbuf; /* buffer to read from disk */ 47 | 48 | 49 | hsize_t[1] dim_r; 50 | hsize_t[2] dim_b; 51 | 52 | /* 53 | * Create a file using default properties. 54 | */ 55 | fid = H5F.create(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); 56 | 57 | /* 58 | * Create group "A" in the file. 59 | */ 60 | gid_a = H5G.create2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); 61 | 62 | /* 63 | * Create dataset "B" in the file. 64 | */ 65 | dim_b[0] = 2; 66 | dim_b[1] = 6; 67 | sid_b = H5S.create_simple(dim_b); 68 | did_b = H5D.create2(fid, "B", H5T_NATIVE_FLOAT, sid_b, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); 69 | 70 | /* 71 | * Create dataset "R" to store references to the objects "A" and "B". 72 | */ 73 | dim_r[0] = 2; 74 | sid_r = H5S.create_simple(dim_r); 75 | tid_r = H5T.copy(H5T_STD_REF_OBJ); 76 | did_r = H5D.create2(fid, "R", tid_r, sid_r, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); 77 | 78 | /* 79 | * Create references to the group "A" and dataset "B" 80 | * and store them in the wbuf. 81 | */ 82 | H5R.create(&wbuf[0], fid, "A", H5RType.ObjectRef, cast(hid_t)-1); 83 | H5R.create(&wbuf[1], fid, "B", H5RType.ObjectRef, cast(hid_t)-1); 84 | 85 | /* 86 | * Write dataset R using default transfer properties. 87 | */ 88 | H5D.write(did_r, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, cast(ubyte*)wbuf); 89 | 90 | /* 91 | * Close all objects. 92 | */ 93 | H5G.close(gid_a); 94 | H5S.close(sid_b); 95 | H5D.close(did_b); 96 | H5T.close(tid_r); 97 | H5S.close(sid_r); 98 | H5D.close(did_r); 99 | H5F.close(fid); 100 | 101 | /* 102 | * Reopen the file. 103 | */ 104 | fid = H5F.open(H5FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); 105 | 106 | did_r = H5D.open2(fid, "R", H5P_DEFAULT); 107 | H5D.read(did_r, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, cast(ubyte*)rbuf); 108 | 109 | /* 110 | * Find the type of referenced objects. 111 | */ 112 | writefln("now trying to figure out obj type 1"); 113 | H5R.get_obj_type2(did_r, H5RType.ObjectRef, &rbuf[0], &obj_type); 114 | if(obj_type == H5OType.Group) 115 | writefln("First dereferenced object is a group."); 116 | 117 | writefln("now trying to figure out obj type 2"); 118 | H5R.get_obj_type2(did_r, H5RType.ObjectRef, &rbuf[1], &obj_type); 119 | if(obj_type == H5OType.Dataset) 120 | writefln("Second dereferenced object is a dataset."); 121 | 122 | /* 123 | * Get datatype of the dataset "B" 124 | */ 125 | did_b = H5R.dereference(did_r, H5RType.ObjectRef, &rbuf[1]); 126 | tid_b = H5D.get_type(did_b); 127 | if(H5Tequal(tid_b, H5T_NATIVE_FLOAT)) 128 | writefln("Datatype of the dataset is H5T_NATIVE_FLOAT."); 129 | writefln(""); 130 | H5D.close(did_r); 131 | H5D.close(did_b); 132 | H5T.close(tid_b); 133 | H5F.close(fid); 134 | return 0; 135 | } 136 | 137 | -------------------------------------------------------------------------------- /old/examples/h5_write.d: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright by The HDF Group. * 3 | Copyright by the Board of Trustees of the University of Illinois. * 4 | All rights reserved. * 5 | * 6 | This file is part of HDF5. The full HDF5 copyright notice, including * 7 | terms governing use, modification, and redistribution, is contained in * 8 | the files COPYING and Copyright.html. COPYING can be found at the root * 9 | of the source code distribution tree; Copyright.html can be found at the * 10 | root level of an installed copy of the electronic HDF5 document set and * 11 | is linked from the top-level documents page. It can also be found at * 12 | http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * 13 | access to either file, you may request a copy from help@hdfgroup.org. * 14 | 15 | Ported by Laeeth Ishaac 2014 to the D Programming Language 16 | Use at your own risk! 17 | 18 | This example writes data to the HDF5 file. 19 | Data conversion is performed during write operation. 20 | */ 21 | 22 | import hdf5.wrap; 23 | import hdf5.bindings.enums; 24 | import hdf5.bindings.api; 25 | import std.stdio; 26 | import std.exception; 27 | 28 | string H5FILE_NAME="SDS.h5"; 29 | string DATASETNAME="IntArray"; 30 | enum NX=5; /* dataset dimensions */ 31 | enum NY=6; 32 | enum RANK=2; 33 | 34 | int main(string[] args) 35 | { 36 | hid_t file, dataset; /* file and dataset handles */ 37 | hid_t datatype, dataspace; /* handles */ 38 | hsize_t dimsf[2]; /* dataset dimensions */ 39 | herr_t status; 40 | int[NY][NX] data; /* data to write */ 41 | int i, j; 42 | 43 | writefln("* initializing buffer"); 44 | // Data and output buffer initialization. 45 | for(j = 0; j < NX; j++) 46 | for(i = 0; i < NY; i++) 47 | data[j][i] = i + j; 48 | /* 49 | * 0 1 2 3 4 5 50 | * 1 2 3 4 5 6 51 | * 2 3 4 5 6 7 52 | * 3 4 5 6 7 8 53 | * 4 5 6 7 8 9 54 | */ 55 | 56 | 57 | // Create a new file using H5F_ACC_TRUNC access, default file creation properties, and default file 58 | // access properties. 59 | writefln("* creating file %s",H5FILE_NAME); 60 | file = H5F.create(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); 61 | 62 | // Describe the size of the array and create the data space for fixed size dataset. 63 | dimsf[0] = NX; 64 | dimsf[1] = NY; 65 | writefln("* creating dataspace with dims [%s,%s]",dimsf[0],dimsf[1]); 66 | dataspace = H5S.create_simple(dimsf); 67 | 68 | // Define datatype for the data in the file. We will store little endian INT numbers. 69 | writefln("* copying dataset"); 70 | datatype = H5T.copy(H5T_NATIVE_INT); 71 | writefln("* byteorder = little-endian"); 72 | H5T.set_order(datatype, H5TByteOrder.LE); 73 | 74 | // Create a new dataset within the file using defined dataspace and datatype and default dataset creation properties. 75 | writefln("* new dataset within file called %s",DATASETNAME); 76 | dataset = H5D.create2(file, DATASETNAME, datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); 77 | 78 | // Write the data to the dataset using default transfer properties. 79 | writefln("* writing"); 80 | H5D.write(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, cast(ubyte*)&data); 81 | 82 | /* 83 | * Close/release resources. 84 | */ 85 | writefln("* closing up shop"); 86 | H5S.close(dataspace); 87 | H5T.close(datatype); 88 | H5D.close(dataset); 89 | H5F.close(file); 90 | 91 | return 0; 92 | } 93 | -------------------------------------------------------------------------------- /old/examples/h5ex_d_alloc.d: -------------------------------------------------------------------------------- 1 | /** 2 | Ported by Laeeth Isharc 2014 to the D Programming Language 3 | Use at your own risk! 4 | 5 | This example shows how to set the space allocation time 6 | for a dataset. The program first creates two datasets, 7 | one with the default allocation time (late) and one with 8 | early allocation time, and displays whether each has been 9 | allocated and their allocation size. Next, it writes data 10 | to the datasets, and again displays whether each has been 11 | allocated and their allocation size. 12 | 13 | This file is intended for use with HDF5 Library version 1.6 14 | 15 | */ 16 | 17 | import hdf5.bindings.enums; 18 | import hdf5.wrap; 19 | import hdf5.bindings.api; 20 | import std.stdio; 21 | 22 | string f_name="h5ex_d_alloc.h5"; 23 | string DATASET1= "DS1"; 24 | string DATASET2="DS2"; 25 | enum DIM0=4; 26 | enum DIM1=7; 27 | enum FILLVAL=99; 28 | 29 | int main (string[] args) 30 | { 31 | hsize_t[2] dims = [DIM0, DIM1]; 32 | int[DIM1][DIM0] wdata; // write buffer 33 | 34 | // Initialize data. 35 | foreach(i;0.. DIM0) 36 | foreach(j;0..DIM1) 37 | wdata[i][j] = i * j - j; 38 | 39 | // Create a new file using the default properties. 40 | hid_t file; 41 | file = H5F.create(f_name, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); 42 | 43 | // Create dataspace. Leaving out maximum size sets the maximum size to be the current size. 44 | // passed as NULL to c API 45 | auto space = H5S.create_simple(dims); 46 | 47 | // Create the dataset creation property list, and set the chunk size 48 | auto dcpl = H5P.create (H5P_DATASET_CREATE); 49 | 50 | // Set the allocation time to "early". This way we can be sure that reading from the dataset immediately 51 | // after creation will return the fill value. 52 | H5P.set_alloc_time (dcpl, H5DAllocTime.Early); 53 | 54 | writefln("Creating datasets..."); 55 | writefln("%s has allocation time H5D_ALLOC_TIME_LATE", DATASET1); 56 | writefln("%s has allocation time H5D_ALLOC_TIME_EARLY", DATASET2); 57 | 58 | //Create the dataset using the dataset creation property list. 59 | auto dset1 = H5D.create2 (file, DATASET1, H5T_STD_I32LE, space, H5TCset.ASCII, dcpl ,H5P_DEFAULT); 60 | auto dset2 = H5D.create2(file, DATASET2, H5T_STD_I32LE, space, H5TCset.ASCII, dcpl,H5P_DEFAULT); 61 | 62 | // Retrieve and print space status and storage size for dset1. 63 | auto space_status = H5D.get_space_status (dset1); 64 | auto storage_size = H5D.get_storage_size (dset1); 65 | writefln("Space for %s has%sbeen allocated.", DATASET1,space_status == H5DSpaceStatus.Allocated ? " " : " not "); 66 | writefln("Storage size for %s is: %s bytes.", DATASET1,storage_size); 67 | 68 | // Retrieve and print space status and storage size for dset2. 69 | auto status = H5D.get_space_status (dset2); 70 | storage_size = H5D.get_storage_size (dset2); 71 | writefln("Space for %s has%sbeen allocated.", DATASET2, space_status == H5DSpaceStatus.Allocated ? " " : " not "); 72 | writefln("Storage size for %s is: %s bytes.", DATASET2, storage_size); 73 | writefln("\nWriting data...\n"); 74 | 75 | // Write the data to the datasets. 76 | H5D.write(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, cast(ubyte*)&wdata); 77 | H5D.write(dset2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, cast(ubyte*)&wdata); 78 | 79 | // Retrieve and print space status and storage size for dset1. 80 | status = H5D.get_space_status(dset1); 81 | storage_size = H5D.get_storage_size (dset1); 82 | writefln("Space for %s has%sbeen allocated.", DATASET1, space_status == H5DSpaceStatus.Allocated ? " " : " not "); 83 | writefln("Storage size for %s is: %s bytes.", DATASET1, storage_size); 84 | 85 | // Retrieve and print space status and storage size for dset2. 86 | status = H5D.get_space_status(dset2); 87 | storage_size = H5D.get_storage_size (dset2); 88 | writefln("Space for %s has%sbeen allocated.", DATASET2, space_status == H5DSpaceStatus.Allocated ? " " : " not "); 89 | writefln("Storage size for %s is: %s bytes.", DATASET2, storage_size); 90 | 91 | // Close and release resources. 92 | H5P.close(dcpl); 93 | H5D.close(dset1); 94 | H5D.close(dset2); 95 | H5S.close(space); 96 | H5F.close(file); 97 | return 0; 98 | } 99 | -------------------------------------------------------------------------------- /old/examples/h5ex_g_iterate.d: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright by The HDF Group. * 3 | Copyright by the Board of Trustees of the University of Illinois. * 4 | All rights reserved. * 5 | * 6 | This file is part of HDF5. The full HDF5 copyright notice, including * 7 | terms governing use, modification, and redistribution, is contained in * 8 | the files COPYING and Copyright.html. COPYING can be found at the root * 9 | of the source code distribution tree; Copyright.html can be found at the * 10 | root level of an installed copy of the electronic HDF5 document set and * 11 | is linked from the top-level documents page. It can also be found at * 12 | http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * 13 | access to either file, you may request a copy from help@hdfgroup.org. * 14 | 15 | Ported by Laeeth Isharc 2014 to the D Programming Language 16 | Use at your own risk! 17 | 18 | This example shows how to iterate over group members using 19 | H5Giterate. 20 | */ 21 | 22 | import hdf5; 23 | import std.stdio; 24 | import std.exception; 25 | 26 | 27 | enum filename ="d_examples/h5ex_g_iterate.h5"; 28 | 29 | /* 30 | * Operator function to be called by H5Giterate. 31 | */ 32 | herr_t op_func (hid_t loc_id, const char *name, void *operator_data); 33 | 34 | int main(string[] args) 35 | { 36 | hid_t file; /* Handle */ 37 | herr_t status; 38 | 39 | /* 40 | * Open file. 41 | */ 42 | file = H5F.open (filename, H5F_ACC_RDONLY, H5P_DEFAULT); 43 | 44 | /* 45 | * Begin iteration. 46 | */ 47 | writefln("Objects in root group:"); 48 | status = H5G.iterate (file, "/", NULL, op_func, NULL); 49 | 50 | /* 51 | * Close and release resources. 52 | */ 53 | status = H5F.close (file); 54 | return 0; 55 | } 56 | 57 | 58 | /************************************************************ 59 | 60 | Operator function. Prints the name and type of the object 61 | being examined. 62 | 63 | ************************************************************/ 64 | extern(C) herr_t op_func (hid_t loc_id, const char *name, void *operator_data) 65 | { 66 | herr_t status; 67 | H5G_stat_t statbuf; 68 | 69 | /* 70 | * Get type of the object and display its name and type. 71 | * The name of the object is passed to this function by 72 | * the Library. 73 | */ 74 | status = H5Gget_objinfo (loc_id, name, 0, &statbuf); 75 | switch (statbuf.type) { 76 | case H5G_GROUP: 77 | writef (" Group: %s\n", name); 78 | break; 79 | case H5G_DATASET: 80 | writef (" Dataset: %s\n", name); 81 | break; 82 | case H5G_TYPE: 83 | writef (" Datatype: %s\n", name); 84 | break; 85 | default: 86 | writef ( " Unknown: %s\n", name); 87 | } 88 | 89 | return 0; 90 | } 91 | -------------------------------------------------------------------------------- /old/examples/notyetported/h5_cmprss.c: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright by The HDF Group. * 3 | * Copyright by the Board of Trustees of the University of Illinois. * 4 | * All rights reserved. * 5 | * * 6 | * This file is part of HDF5. The full HDF5 copyright notice, including * 7 | * terms governing use, modification, and redistribution, is contained in * 8 | * the files COPYING and Copyright.html. COPYING can be found at the root * 9 | * of the source code distribution tree; Copyright.html can be found at the * 10 | * root level of an installed copy of the electronic HDF5 document set and * 11 | * is linked from the top-level documents page. It can also be found at * 12 | * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * 13 | * access to either file, you may request a copy from help@hdfgroup.org. * 14 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 15 | 16 | /* 17 | * This example illustrates how to create a compressed dataset. 18 | * It is used in the HDF5 Tutorial. 19 | */ 20 | 21 | #include "hdf5.h" 22 | 23 | #define FILE "cmprss.h5" 24 | #define RANK 2 25 | #define DIM0 100 26 | #define DIM1 20 27 | 28 | int main () { 29 | 30 | hid_t file_id, dataset_id, dataspace_id; /* identifiers */ 31 | hid_t plist_id; 32 | 33 | size_t nelmts; 34 | unsigned flags, filter_info; 35 | H5Z_filter_t filter_type; 36 | 37 | herr_t status; 38 | hsize_t dims[2]; 39 | hsize_t cdims[2]; 40 | 41 | int idx; 42 | int i,j, numfilt; 43 | int buf[DIM0][DIM1]; 44 | int rbuf [DIM0][DIM1]; 45 | 46 | /* Uncomment these variables to use SZIP compression 47 | unsigned szip_options_mask; 48 | unsigned szip_pixels_per_block; 49 | */ 50 | 51 | /* Create a file. */ 52 | file_id = H5Fcreate (FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); 53 | 54 | 55 | /* Create dataset "Compressed Data" in the group using absolute name. */ 56 | dims[0] = DIM0; 57 | dims[1] = DIM1; 58 | dataspace_id = H5Screate_simple (RANK, dims, NULL); 59 | 60 | plist_id = H5Pcreate (H5P_DATASET_CREATE); 61 | 62 | /* Dataset must be chunked for compression */ 63 | cdims[0] = 20; 64 | cdims[1] = 20; 65 | status = H5Pset_chunk (plist_id, 2, cdims); 66 | 67 | /* Set ZLIB / DEFLATE Compression using compression level 6. 68 | * To use SZIP Compression comment out these lines. 69 | */ 70 | status = H5Pset_deflate (plist_id, 6); 71 | 72 | /* Uncomment these lines to set SZIP Compression 73 | szip_options_mask = H5_SZIP_NN_OPTION_MASK; 74 | szip_pixels_per_block = 16; 75 | status = H5Pset_szip (plist_id, szip_options_mask, szip_pixels_per_block); 76 | */ 77 | 78 | dataset_id = H5Dcreate2 (file_id, "Compressed_Data", H5T_STD_I32BE, 79 | dataspace_id, H5P_DEFAULT, plist_id, H5P_DEFAULT); 80 | 81 | for (i = 0; i< DIM0; i++) 82 | for (j=0; j 15 | #include 16 | 17 | #define FILE "h5ex_d_compact.h5" 18 | #define DATASET "DS1" 19 | #define DIM0 4 20 | #define DIM1 7 21 | 22 | int 23 | main (void) 24 | { 25 | hid_t file, space, dset, dcpl; /* Handles */ 26 | herr_t status; 27 | H5D_layout_t layout; 28 | hsize_t dims[2] = {DIM0, DIM1}; 29 | int wdata[DIM0][DIM1], /* Write buffer */ 30 | rdata[DIM0][DIM1], /* Read buffer */ 31 | i, j; 32 | 33 | /* 34 | * Initialize data. 35 | */ 36 | for (i=0; i 16 | #include 17 | 18 | #define FILE "h5ex_d_extern.h5" 19 | #define EXTERNAL "h5ex_d_extern.data" 20 | #define DATASET "DS1" 21 | #define DIM0 4 22 | #define DIM1 7 23 | #define NAME_BUF_SIZE 32 24 | 25 | int 26 | main (void) 27 | { 28 | hid_t file, space, dset, dcpl; /* Handles */ 29 | herr_t status; 30 | hsize_t dims[2] = {DIM0, DIM1}; 31 | char name[NAME_BUF_SIZE]; 32 | int wdata[DIM0][DIM1], /* Write buffer */ 33 | rdata[DIM0][DIM1], /* Read buffer */ 34 | i, j; 35 | 36 | /* 37 | * Initialize data. 38 | */ 39 | for (i=0; i 15 | #include 16 | 17 | #define FILE "h5ex_d_rdwr.h5" 18 | #define DATASET "DS1" 19 | #define DIM0 4 20 | #define DIM1 7 21 | 22 | int 23 | main (void) 24 | { 25 | hid_t file, space, dset; /* Handles */ 26 | herr_t status; 27 | hsize_t dims[2] = {DIM0, DIM1}; 28 | int wdata[DIM0][DIM1], /* Write buffer */ 29 | rdata[DIM0][DIM1], /* Read buffer */ 30 | i, j; 31 | 32 | /* 33 | * Initialize data. 34 | */ 35 | for (i=0; i 12 | 13 | #define FILE "h5ex_g_iterate.h5" 14 | 15 | /* 16 | * Operator function to be called by H5Giterate. 17 | */ 18 | herr_t op_func (hid_t loc_id, const char *name, void *operator_data); 19 | 20 | int 21 | main (void) 22 | { 23 | hid_t file; /* Handle */ 24 | herr_t status; 25 | 26 | /* 27 | * Open file. 28 | */ 29 | file = H5Fopen (FILE, H5F_ACC_RDONLY, H5P_DEFAULT); 30 | 31 | /* 32 | * Begin iteration. 33 | */ 34 | printf ("Objects in root group:\n"); 35 | status = H5Giterate (file, "/", NULL, op_func, NULL); 36 | 37 | /* 38 | * Close and release resources. 39 | */ 40 | status = H5Fclose (file); 41 | 42 | return 0; 43 | } 44 | 45 | 46 | /************************************************************ 47 | 48 | Operator function. Prints the name and type of the object 49 | being examined. 50 | 51 | ************************************************************/ 52 | herr_t op_func (hid_t loc_id, const char *name, void *operator_data) 53 | { 54 | herr_t status; 55 | H5G_stat_t statbuf; 56 | 57 | /* 58 | * Get type of the object and display its name and type. 59 | * The name of the object is passed to this function by 60 | * the Library. 61 | */ 62 | status = H5Gget_objinfo (loc_id, name, 0, &statbuf); 63 | switch (statbuf.type) { 64 | case H5G_GROUP: 65 | printf (" Group: %s\n", name); 66 | break; 67 | case H5G_DATASET: 68 | printf (" Dataset: %s\n", name); 69 | break; 70 | case H5G_TYPE: 71 | printf (" Datatype: %s\n", name); 72 | break; 73 | default: 74 | printf ( " Unknown: %s\n", name); 75 | } 76 | 77 | return 0; 78 | } 79 | -------------------------------------------------------------------------------- /old/examples/notyetported/h5ex_t_bit.c: -------------------------------------------------------------------------------- 1 | /************************************************************ 2 | 3 | This example shows how to read and write bitfield 4 | datatypes to a dataset. The program first writes bit 5 | fields to a dataset with a dataspace of DIM0xDIM1, then 6 | closes the file. Next, it reopens the file, reads back 7 | the data, and outputs it to the screen. 8 | 9 | This file is intended for use with HDF5 Library version 1.6 10 | 11 | ************************************************************/ 12 | 13 | #include "hdf5.h" 14 | #include 15 | #include 16 | 17 | #define FILE "h5ex_t_bit.h5" 18 | #define DATASET "DS1" 19 | #define DIM0 4 20 | #define DIM1 7 21 | 22 | int 23 | main (void) 24 | { 25 | hid_t file, space, dset; /* Handles */ 26 | herr_t status; 27 | hsize_t dims[2] = {DIM0, DIM1}; 28 | unsigned char wdata[DIM0][DIM1], /* Write buffer */ 29 | **rdata; /* Read buffer */ 30 | int ndims, A, B, C, D, 31 | i, j; 32 | 33 | /* 34 | * Initialize data. We will manually pack 4 2-bit integers into 35 | * each unsigned char data element. 36 | */ 37 | for (i=0; i> 2) & 0x03; /* Retrieve field "B" */ 125 | C = (rdata[i][j] >> 4) & 0x03; /* Retrieve field "C" */ 126 | D = (rdata[i][j] >> 6) & 0x03; /* Retrieve field "D" */ 127 | printf (" {%d, %d, %d, %d}", A, B, C, D); 128 | } 129 | printf (" ]\n"); 130 | } 131 | 132 | /* 133 | * Close and release resources. 134 | */ 135 | free (rdata[0]); 136 | free (rdata); 137 | status = H5Dclose (dset); 138 | status = H5Sclose (space); 139 | status = H5Fclose (file); 140 | 141 | return 0; 142 | } 143 | -------------------------------------------------------------------------------- /old/examples/notyetported/h5ex_t_commit.c: -------------------------------------------------------------------------------- 1 | /************************************************************ 2 | 3 | This example shows how to commit a named datatype to a 4 | file, and read back that datatype. The program first 5 | defines a compound datatype, commits it to a file, then 6 | closes the file. Next, it reopens the file, opens the 7 | datatype, and outputs the names of its fields to the 8 | screen. 9 | 10 | This file is intended for use with HDF5 Library version 1.6 11 | 12 | ************************************************************/ 13 | 14 | #include "hdf5.h" 15 | #include 16 | #include 17 | 18 | #define FILE "h5ex_t_commit.h5" 19 | #define DATATYPE "Sensor_Type" 20 | 21 | int 22 | main (void) 23 | { 24 | hid_t file, filetype, strtype; 25 | /* Handles */ 26 | herr_t status; 27 | H5T_class_t typeclass; 28 | char *name; 29 | int nmembs, 30 | i; 31 | 32 | /* 33 | * Create a new file using the default properties. 34 | */ 35 | file = H5Fcreate (FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); 36 | 37 | /* 38 | * Create variable-length string datatype. 39 | */ 40 | strtype = H5Tcopy (H5T_C_S1); 41 | status = H5Tset_size (strtype, H5T_VARIABLE); 42 | 43 | /* 44 | * Create the compound datatype. Because the standard types we are 45 | * using may have different sizes than the corresponding native 46 | * types, we must manually calculate the offset of each member. 47 | */ 48 | filetype = H5Tcreate (H5T_COMPOUND, 8 + sizeof (char *) + 8 + 8); 49 | status = H5Tinsert (filetype, "Serial number", 0, H5T_STD_I64BE); 50 | status = H5Tinsert (filetype, "Location", 8, strtype); 51 | status = H5Tinsert (filetype, "Temperature (F)", 8 + sizeof (char *), 52 | H5T_IEEE_F64BE); 53 | status = H5Tinsert (filetype, "Pressure (inHg)", 8 + sizeof (char *) + 8, 54 | H5T_IEEE_F64BE); 55 | 56 | /* 57 | * Commit the compound datatype to the file, creating a named 58 | * datatype. 59 | */ 60 | status = H5Tcommit (file, DATATYPE, filetype); 61 | 62 | /* 63 | * Close and release resources. 64 | */ 65 | status = H5Tclose (filetype); 66 | status = H5Tclose (strtype); 67 | status = H5Fclose (file); 68 | 69 | 70 | /* 71 | * Now we begin the read section of this example. 72 | */ 73 | 74 | /* 75 | * Open file. 76 | */ 77 | file = H5Fopen (FILE, H5F_ACC_RDONLY, H5P_DEFAULT); 78 | 79 | /* 80 | * Open the named datatype. 81 | */ 82 | filetype = H5Topen (file, DATATYPE); 83 | 84 | /* 85 | * Output the data to the screen. 86 | */ 87 | printf ("Named datatype: %s:\n", DATATYPE); 88 | /* 89 | * Get datatype class. If it isn't compound, we won't print 90 | * anything. 91 | */ 92 | typeclass = H5Tget_class (filetype); 93 | if (typeclass == H5T_COMPOUND) { 94 | printf (" Class: H5T_COMPOUND\n"); 95 | nmembs = H5Tget_nmembers (filetype); 96 | /* 97 | * Iterate over compound datatype members. 98 | */ 99 | for (i=0; i 15 | #include 16 | 17 | #define FILE "h5ex_t_float.h5" 18 | #define DATASET "DS1" 19 | #define DIM0 4 20 | #define DIM1 7 21 | 22 | int 23 | main (void) 24 | { 25 | hid_t file, space, dset; /* Handles */ 26 | herr_t status; 27 | hsize_t dims[2] = {DIM0, DIM1}; 28 | double wdata[DIM0][DIM1], /* Write buffer */ 29 | **rdata; /* Read buffer */ 30 | int ndims, 31 | i, j; 32 | 33 | /* 34 | * Initialize data. 35 | */ 36 | for (i=0; i 15 | #include 16 | 17 | #define FILE "h5ex_t_floatatt.h5" 18 | #define DATASET "DS1" 19 | #define ATTRIBUTE "A1" 20 | #define DIM0 4 21 | #define DIM1 7 22 | 23 | int 24 | main (void) 25 | { 26 | hid_t file, space, dset, attr; /* Handles */ 27 | herr_t status; 28 | hsize_t dims[2] = {DIM0, DIM1}; 29 | double wdata[DIM0][DIM1], /* Write buffer */ 30 | **rdata; /* Read buffer */ 31 | int ndims, 32 | i, j; 33 | 34 | /* 35 | * Initialize data. 36 | */ 37 | for (i=0; i 15 | #include 16 | 17 | #define FILE "h5ex_t_int.h5" 18 | #define DATASET "DS1" 19 | #define DIM0 4 20 | #define DIM1 7 21 | 22 | int 23 | main (void) 24 | { 25 | hid_t file, space, dset; /* Handles */ 26 | herr_t status; 27 | hsize_t dims[2] = {DIM0, DIM1}; 28 | int wdata[DIM0][DIM1], /* Write buffer */ 29 | **rdata, /* Read buffer */ 30 | ndims, 31 | i, j; 32 | 33 | /* 34 | * Initialize data. 35 | */ 36 | for (i=0; i 15 | #include 16 | 17 | #define FILE "h5ex_t_intatt.h5" 18 | #define DATASET "DS1" 19 | #define ATTRIBUTE "A1" 20 | #define DIM0 4 21 | #define DIM1 7 22 | 23 | int 24 | main (void) 25 | { 26 | hid_t file, space, dset, attr; /* Handles */ 27 | herr_t status; 28 | hsize_t dims[2] = {DIM0, DIM1}; 29 | int wdata[DIM0][DIM1], /* Write buffer */ 30 | **rdata, /* Read buffer */ 31 | ndims, 32 | i, j; 33 | 34 | /* 35 | * Initialize data. 36 | */ 37 | for (i=0; i 15 | #include 16 | 17 | #define FILE "h5ex_t_opaque.h5" 18 | #define DATASET "DS1" 19 | #define DIM0 4 20 | #define LEN 7 21 | 22 | int 23 | main (void) 24 | { 25 | hid_t file, space, dtype, dset; /* Handles */ 26 | herr_t status; 27 | hsize_t dims[1] = {DIM0}; 28 | size_t len; 29 | char wdata[DIM0*LEN], /* Write buffer */ 30 | *rdata, /* Read buffer */ 31 | str[LEN] = "OPAQUE", 32 | *tag; 33 | int ndims, 34 | i, j; 35 | 36 | /* 37 | * Initialize data. 38 | */ 39 | for (i=0; i 15 | #include 16 | 17 | #define FILE "h5ex_t_opaqueatt.h5" 18 | #define DATASET "DS1" 19 | #define ATTRIBUTE "A1" 20 | #define DIM0 4 21 | #define LEN 7 22 | 23 | int 24 | main (void) 25 | { 26 | hid_t file, space, dtype, dset, attr; /* Handles */ 27 | herr_t status; 28 | hsize_t dims[1] = {DIM0}; 29 | size_t len; 30 | char wdata[DIM0*LEN], /* Write buffer */ 31 | *rdata, /* Read buffer */ 32 | str[LEN] = "OPAQUE", 33 | *tag; 34 | int ndims, 35 | i, j; 36 | 37 | /* 38 | * Initialize data. 39 | */ 40 | for (i=0; i 15 | #include 16 | 17 | #define FILE "h5ex_t_string.h5" 18 | #define DATASET "DS1" 19 | #define DIM0 4 20 | #define SDIM 8 21 | 22 | int 23 | main (void) 24 | { 25 | hid_t file, filetype, memtype, space, dset; 26 | /* Handles */ 27 | herr_t status; 28 | hsize_t dims[1] = {DIM0}; 29 | size_t sdim; 30 | char wdata[DIM0][SDIM] = {"Parting", "is such", "sweet", "sorrow."}, 31 | /* Write buffer */ 32 | **rdata; /* Read buffer */ 33 | int ndims, 34 | i; 35 | 36 | /* 37 | * Create a new file using the default properties. 38 | */ 39 | file = H5Fcreate (FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); 40 | 41 | /* 42 | * Create file and memory datatypes. For this example we will save 43 | * the strings as FORTRAN strings, therefore they do not need space 44 | * for the null terminator in the file. 45 | */ 46 | filetype = H5Tcopy (H5T_FORTRAN_S1); 47 | status = H5Tset_size (filetype, SDIM - 1); 48 | memtype = H5Tcopy (H5T_C_S1); 49 | status = H5Tset_size (memtype, SDIM); 50 | 51 | /* 52 | * Create dataspace. Setting maximum size to NULL sets the maximum 53 | * size to be the current size. 54 | */ 55 | space = H5Screate_simple (1, dims, NULL); 56 | 57 | /* 58 | * Create the dataset and write the string data to it. 59 | */ 60 | dset = H5Dcreate (file, DATASET, filetype, space, H5P_DEFAULT); 61 | status = H5Dwrite (dset, memtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata[0]); 62 | 63 | /* 64 | * Close and release resources. 65 | */ 66 | status = H5Dclose (dset); 67 | status = H5Sclose (space); 68 | status = H5Tclose (filetype); 69 | status = H5Tclose (memtype); 70 | status = H5Fclose (file); 71 | 72 | 73 | /* 74 | * Now we begin the read section of this example. Here we assume 75 | * the dataset and string have the same name and rank, but can have 76 | * any size. Therefore we must allocate a new array to read in 77 | * data using malloc(). 78 | */ 79 | 80 | /* 81 | * Open file and dataset. 82 | */ 83 | file = H5Fopen (FILE, H5F_ACC_RDONLY, H5P_DEFAULT); 84 | dset = H5Dopen (file, DATASET); 85 | 86 | /* 87 | * Get the datatype and its size. 88 | */ 89 | filetype = H5Dget_type (dset); 90 | sdim = H5Tget_size (filetype); 91 | sdim++; /* Make room for null terminator */ 92 | 93 | /* 94 | * Get dataspace and allocate memory for read buffer. This is a 95 | * two dimensional dataset so the dynamic allocation must be done 96 | * in steps. 97 | */ 98 | space = H5Dget_space (dset); 99 | ndims = H5Sget_simple_extent_dims (space, dims, NULL); 100 | 101 | /* 102 | * Allocate array of pointers to rows. 103 | */ 104 | rdata = (char **) malloc (dims[0] * sizeof (char *)); 105 | 106 | /* 107 | * Allocate space for integer data. 108 | */ 109 | rdata[0] = (char *) malloc (dims[0] * sdim * sizeof (char)); 110 | 111 | /* 112 | * Set the rest of the pointers to rows to the correct addresses. 113 | */ 114 | for (i=1; i 15 | #include 16 | 17 | #define FILE "h5ex_t_vlstring.h5" 18 | #define DATASET "DS1" 19 | #define DIM0 4 20 | 21 | int 22 | main (void) 23 | { 24 | hid_t file, filetype, memtype, space, dset; 25 | /* Handles */ 26 | herr_t status; 27 | hsize_t dims[1] = {DIM0}; 28 | char *wdata[DIM0] = {"Parting", "is such", "sweet", "sorrow."}, 29 | /* Write buffer */ 30 | **rdata; /* Read buffer */ 31 | int ndims, 32 | i; 33 | 34 | /* 35 | * Create a new file using the default properties. 36 | */ 37 | file = H5Fcreate (FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); 38 | 39 | /* 40 | * Create file and memory datatypes. For this example we will save 41 | * the strings as FORTRAN strings. 42 | */ 43 | filetype = H5Tcopy (H5T_FORTRAN_S1); 44 | status = H5Tset_size (filetype, H5T_VARIABLE); 45 | memtype = H5Tcopy (H5T_C_S1); 46 | status = H5Tset_size (memtype, H5T_VARIABLE); 47 | 48 | /* 49 | * Create dataspace. Setting maximum size to NULL sets the maximum 50 | * size to be the current size. 51 | */ 52 | space = H5Screate_simple (1, dims, NULL); 53 | 54 | /* 55 | * Create the dataset and write the variable-length string data to 56 | * it. 57 | */ 58 | dset = H5Dcreate (file, DATASET, filetype, space, H5P_DEFAULT); 59 | status = H5Dwrite (dset, memtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); 60 | 61 | /* 62 | * Close and release resources. 63 | */ 64 | status = H5Dclose (dset); 65 | status = H5Sclose (space); 66 | status = H5Tclose (filetype); 67 | status = H5Tclose (memtype); 68 | status = H5Fclose (file); 69 | 70 | 71 | /* 72 | * Now we begin the read section of this example. Here we assume 73 | * the dataset has the same name and rank, but can have any size. 74 | * Therefore we must allocate a new array to read in data using 75 | * malloc(). 76 | */ 77 | 78 | /* 79 | * Open file and dataset. 80 | */ 81 | file = H5Fopen (FILE, H5F_ACC_RDONLY, H5P_DEFAULT); 82 | dset = H5Dopen (file, DATASET); 83 | 84 | /* 85 | * Get the datatype. 86 | */ 87 | filetype = H5Dget_type (dset); 88 | 89 | /* 90 | * Get dataspace and allocate memory for read buffer. 91 | */ 92 | space = H5Dget_space (dset); 93 | ndims = H5Sget_simple_extent_dims (space, dims, NULL); 94 | rdata = (char **) malloc (dims[0] * sizeof (char *)); 95 | 96 | /* 97 | * Create the memory datatype. 98 | */ 99 | memtype = H5Tcopy (H5T_C_S1); 100 | status = H5Tset_size (memtype, H5T_VARIABLE); 101 | 102 | /* 103 | * Read the data. 104 | */ 105 | status = H5Dread (dset, memtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata); 106 | 107 | /* 108 | * Output the data to the screen. 109 | */ 110 | for (i=0; i 16 | #include 17 | 18 | #define FILE "h5ex_t_vlstringatt.h5" 19 | #define DATASET "DS1" 20 | #define ATTRIBUTE "A1" 21 | #define DIM0 4 22 | 23 | int 24 | main (void) 25 | { 26 | hid_t file, filetype, memtype, space, dset, attr; 27 | /* Handles */ 28 | herr_t status; 29 | hsize_t dims[1] = {DIM0}; 30 | char *wdata[DIM0] = {"Parting", "is such", "sweet", "sorrow."}, 31 | /* Write buffer */ 32 | **rdata; /* Read buffer */ 33 | int ndims, 34 | i; 35 | 36 | /* 37 | * Create a new file using the default properties. 38 | */ 39 | file = H5Fcreate (FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); 40 | 41 | /* 42 | * Create file and memory datatypes. For this example we will save 43 | * the strings as FORTRAN strings. 44 | */ 45 | filetype = H5Tcopy (H5T_FORTRAN_S1); 46 | status = H5Tset_size (filetype, H5T_VARIABLE); 47 | memtype = H5Tcopy (H5T_C_S1); 48 | status = H5Tset_size (memtype, H5T_VARIABLE); 49 | 50 | /* 51 | * Create dataset with a scalar dataspace. 52 | */ 53 | space = H5Screate (H5S_SCALAR); 54 | dset = H5Dcreate (file, DATASET, H5T_STD_I32LE, space, H5P_DEFAULT); 55 | status = H5Sclose (space); 56 | 57 | /* 58 | * Create dataspace. Setting maximum size to NULL sets the maximum 59 | * size to be the current size. 60 | */ 61 | space = H5Screate_simple (1, dims, NULL); 62 | 63 | /* 64 | * Create the attribute and write the variable-length string data 65 | * to it. 66 | */ 67 | attr = H5Acreate (dset, ATTRIBUTE, filetype, space, H5P_DEFAULT); 68 | status = H5Awrite (attr, memtype, wdata); 69 | 70 | /* 71 | * Close and release resources. 72 | */ 73 | status = H5Aclose (attr); 74 | status = H5Dclose (dset); 75 | status = H5Sclose (space); 76 | status = H5Tclose (filetype); 77 | status = H5Tclose (memtype); 78 | status = H5Fclose (file); 79 | 80 | 81 | /* 82 | * Now we begin the read section of this example. Here we assume 83 | * the attribute has the same name and rank, but can have any size. 84 | * Therefore we must allocate a new array to read in data using 85 | * malloc(). 86 | */ 87 | 88 | /* 89 | * Open file, dataset, and attribute. 90 | */ 91 | file = H5Fopen (FILE, H5F_ACC_RDONLY, H5P_DEFAULT); 92 | dset = H5Dopen (file, DATASET); 93 | attr = H5Aopen_name (dset, ATTRIBUTE); 94 | 95 | /* 96 | * Get the datatype. 97 | */ 98 | filetype = H5Aget_type (attr); 99 | 100 | /* 101 | * Get dataspace and allocate memory for read buffer. 102 | */ 103 | space = H5Aget_space (attr); 104 | ndims = H5Sget_simple_extent_dims (space, dims, NULL); 105 | rdata = (char **) malloc (dims[0] * sizeof (char *)); 106 | 107 | /* 108 | * Create the memory datatype. 109 | */ 110 | memtype = H5Tcopy (H5T_C_S1); 111 | status = H5Tset_size (memtype, H5T_VARIABLE); 112 | 113 | /* 114 | * Read the data. 115 | */ 116 | status = H5Aread (attr, memtype, rdata); 117 | 118 | /* 119 | * Output the data to the screen. 120 | */ 121 | for (i=0; i 20 | #include 21 | #include 22 | 23 | /* 24 | This program reads binary output from h5dump (-b option). 25 | To use change the following 3 symbols accordingly. 26 | For example, to read 2 elements of a float type , define 27 | 28 | #define NELMTS 2 29 | #define TYPE float 30 | #define FORMAT "%f " 31 | 32 | */ 33 | 34 | #define NELMTS 6 35 | #define TYPE int 36 | #define FORMAT "%d " 37 | 38 | /*------------------------------------------------------------------------- 39 | * Function: usage 40 | * 41 | * Purpose: Prints a usage message on stderr and then returns. 42 | * 43 | * Return: void 44 | * 45 | * Programmer: Pedro Vicente Nunes 46 | * 47 | * Modifications: 48 | * 49 | *------------------------------------------------------------------------- 50 | */ 51 | static void 52 | usage (void) 53 | { 54 | fprintf(stderr, "\ 55 | usage: binread FILE_NAME\n"); 56 | } 57 | 58 | /*------------------------------------------------------------------------- 59 | * Function: main 60 | * 61 | * Purpose: main program. 62 | * 63 | *------------------------------------------------------------------------- 64 | */ 65 | 66 | int 67 | main (int argc, const char *argv[]) 68 | { 69 | FILE *stream; 70 | int numread; 71 | TYPE buf[NELMTS]; 72 | size_t i, nelmts = NELMTS; 73 | char *fname=NULL; 74 | 75 | if (argc != 2) 76 | { 77 | usage(); 78 | exit(1); 79 | } 80 | 81 | fname = strdup(argv[1]); 82 | 83 | if( (stream = fopen(fname, "rb" )) != NULL ) 84 | { 85 | numread = fread( buf, sizeof( TYPE ), nelmts, stream ); 86 | printf( "Number of items read = %d\n", numread ); 87 | 88 | for (i = 0; i < nelmts; i++) 89 | { 90 | printf(FORMAT,buf[i]); 91 | } 92 | printf("\n"); 93 | 94 | fclose( stream ); 95 | } 96 | else 97 | printf( "File %s could not be opened\n",fname ); 98 | 99 | free(fname); 100 | 101 | return 0; 102 | } 103 | 104 | -------------------------------------------------------------------------------- /util/fixdubexamplesjson.d: -------------------------------------------------------------------------------- 1 | import std.file; 2 | import std.path; 3 | import std.stdio; 4 | import std.string; 5 | import std.exception; 6 | 7 | void main(string[] args) 8 | { 9 | string[] work; 10 | string[] desc; 11 | string[] file; 12 | foreach(entry;dirEntries(".",SpanMode.breadth)) 13 | { 14 | if (!entry.isDir) 15 | continue; 16 | if (!exists(entry.name~"/"~"source")) 17 | continue; 18 | foreach(sourceFile;dirEntries(entry.name~"/"~"source",SpanMode.depth)) 19 | { 20 | if ((sourceFile.isDir)||(!sourceFile.name.endsWith(".d"))) 21 | continue; 22 | work~=sourceFile.name; 23 | } 24 | } 25 | foreach(name;work) 26 | writefln("%s",name); 27 | foreach(string f;work) 28 | { 29 | auto text=cast(string)read(f); 30 | text=text.replace("import hdf5;",""); 31 | text=text.replace("import hdf5.wrap;",""); 32 | text=text.replace("import hdf5.bindings.enums;","import hdf5.hdf5;"); 33 | text=text.replace("import hdf5.bindings.api;",""); 34 | //writefln("%s",text); 35 | std.file.write(f,text); 36 | } 37 | } 38 | 39 | string extractPackageName(string s) 40 | { 41 | auto i=s.indexOf("/source/"); 42 | s=s[0..i]; 43 | i=s.lastIndexOf("/"); 44 | return s[i+1..$]; 45 | } 46 | string makePackageRootPath(string s) 47 | { 48 | auto i=s.indexOf("/source/"); 49 | return s[0..i]~"/"; 50 | } 51 | 52 | string makeJsonPath(string s) 53 | { 54 | auto i=s.indexOf("/source/"); 55 | return s[0..i]~"/dub.json"; 56 | } 57 | 58 | string replaceField(string json, string field, string newValue) 59 | { 60 | field ="\"" ~field~"\":"; 61 | auto i=json.indexOf(field); 62 | auto oldValueBegin=json[i+field.length..$].indexOf("\""); 63 | enforce(oldValueBegin!=-1); 64 | oldValueBegin+=i+field.length; 65 | auto oldValueEnd=json[oldValueBegin+1..$].indexOf("\""); 66 | enforce(oldValueEnd!=-1); 67 | oldValueEnd+=oldValueBegin+1; 68 | return json[0..oldValueBegin]~"\""~newValue~"\""~json[oldValueEnd+1..$]; 69 | } -------------------------------------------------------------------------------- /util/fixdubjson.d: -------------------------------------------------------------------------------- 1 | import std.file; 2 | import std.path; 3 | import std.stdio; 4 | import std.string; 5 | import std.exception; 6 | 7 | void main(string[] args) 8 | { 9 | string[] work; 10 | string[] desc; 11 | string[] file; 12 | foreach(entry;dirEntries(".",SpanMode.breadth)) 13 | { 14 | if (!entry.isDir) 15 | continue; 16 | if (!exists(entry.name~"/"~"source")) 17 | continue; 18 | foreach(sourceFile;dirEntries(entry.name~"/"~"source",SpanMode.depth)) 19 | { 20 | if ((sourceFile.isDir)||(!sourceFile.name.endsWith(".d"))) 21 | continue; 22 | work~=sourceFile.name; 23 | } 24 | } 25 | foreach(name;work) 26 | writefln("%s",name); 27 | foreach(string f;work) 28 | { 29 | auto text=cast(string)read(f); 30 | auto i=text.indexOf("This example"); 31 | if(i==-1) 32 | { 33 | writefln("skipping %s",f); 34 | continue; 35 | } 36 | auto j=text[i+20..$].indexOf("*/"); 37 | if(j==-1) 38 | { 39 | writefln("skipping %s",f); 40 | continue; 41 | } 42 | desc~=text[i..i+j+20]; 43 | } 44 | foreach(i,item;desc) 45 | { 46 | auto sdlPath=work[i].makePackageRootPath~"dub.sdl"; 47 | if (sdlPath.exists) 48 | sdlPath.remove; 49 | auto jsonPath=work[i].makeJsonPath; 50 | auto json=cast(string)read(jsonPath); 51 | auto newJson=json.replaceField("name",work[i].extractPackageName) 52 | .replaceField("description","\n"~item~"\n"); 53 | std.file.write(jsonPath,json); 54 | } 55 | } 56 | 57 | string extractPackageName(string s) 58 | { 59 | auto i=s.indexOf("/source/"); 60 | s=s[0..i]; 61 | i=s.lastIndexOf("/"); 62 | return s[i+1..$]; 63 | } 64 | string makePackageRootPath(string s) 65 | { 66 | auto i=s.indexOf("/source/"); 67 | return s[0..i]~"/"; 68 | } 69 | 70 | string makeJsonPath(string s) 71 | { 72 | auto i=s.indexOf("/source/"); 73 | return s[0..i]~"/dub.json"; 74 | } 75 | 76 | string replaceField(string json, string field, string newValue) 77 | { 78 | field ="\"" ~field~"\":"; 79 | auto i=json.indexOf(field); 80 | auto oldValueBegin=json[i+field.length..$].indexOf("\""); 81 | enforce(oldValueBegin!=-1); 82 | oldValueBegin+=i+field.length; 83 | auto oldValueEnd=json[oldValueBegin+1..$].indexOf("\""); 84 | enforce(oldValueEnd!=-1); 85 | oldValueEnd+=oldValueBegin+1; 86 | return json[0..oldValueBegin]~"\""~newValue~"\""~json[oldValueEnd+1..$]; 87 | } -------------------------------------------------------------------------------- /util/makebuilddubexamples.d: -------------------------------------------------------------------------------- 1 | import std.file; 2 | import std.path; 3 | import std.stdio; 4 | import std.string; 5 | import std.exception; 6 | import std.process; 7 | 8 | void main(string[] args) 9 | { 10 | string[] work; 11 | string[] desc; 12 | string[] file; 13 | writefln("*** building list of projects to build"); 14 | foreach(entry;dirEntries(".",SpanMode.breadth)) 15 | { 16 | if (!entry.isDir) 17 | continue; 18 | if (!exists(entry.name~"/"~"source")) 19 | continue; 20 | foreach(sourceFile;dirEntries(entry.name~"/"~"source",SpanMode.depth)) 21 | { 22 | if ((sourceFile.isDir)||(!sourceFile.name.endsWith(".d"))) 23 | continue; 24 | work~=sourceFile.name; 25 | } 26 | } 27 | foreach(string f;work) 28 | { 29 | auto i=f.lastIndexOf("/source/"); 30 | f=f[0..i]; 31 | writefln("*** building %s",f); 32 | chdir(f); 33 | auto ls=executeShell(("dub build"); 34 | if (ls.status!=0) 35 | { 36 | writefln("**** %s failed to build",f); 37 | } 38 | chdir(".."); 39 | } 40 | } 41 | --------------------------------------------------------------------------------