HDF5

De Wiki de Calcul Québec
Aller à : Navigation, rechercher
Cette page est une traduction de la page HDF5 et la traduction est complétée à 100 % et à jour.

Autres langues :anglais 100% • ‎français 100%

Description

HDF5 (Hierarchical Data Format) is a library for managing the formatting of scientific data. It allows you to store, read, visualize, manipulate and analyze the data in an efficient manner.

Advantages and Disadvantages

Here is a short list of the advantages and disadvantages of HDF5:

  • The data are independent of the processor architecture (endianness).
  • The data are structured in such a way as to keep all the pertinent information (e.g. physical units).
  • It can be used in parallel (MPI-IO).
  • It is possible to compress the data when upon writing (zlib or szip).
  • It has interfaces for C, C++, Fortran 90, Java and Python.
  • It can manage any sort of data (more options than NetCDF).
  • It is able to read and write the .mat format used by Matlab.
  • It is free software for most platforms.
  • Documentation, tutorials and examples are available online at the website.
  • The interface is more complicated than that of NetCDF.

Example

Here's an example of the creation of a data set in a file:


File : ex_hdf5.c
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Copyright by The HDF Group.                                               *
 * Copyright by the Board of Trustees of the University of Illinois.         *
 * All rights reserved.                                                      *
 *                                                                           *
 * This file is part of HDF5.  The full HDF5 copyright notice, including     *
 * terms governing use, modification, and redistribution, is contained in    *
 * the files COPYING and Copyright.html.  COPYING can be found at the root   *
 * of the source code distribution tree; Copyright.html can be found at the  *
 * root level of an installed copy of the electronic HDF5 document set and   *
 * is linked from the top-level documents page.  It can also be found at     *
 * http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have          *
 * access to either file, you may request a copy from help@hdfgroup.org.     *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 
/*
 * The example illustrates how to create a data set from a 
* 4x6 matrix and comes from an HDF5 tutorial.
 */
 
#include "hdf5.h"
#define FILE "dset.h5"
 
int main() {
 
   hid_t       file_id, dataset_id, dataspace_id;
   hsize_t     dims[2];
   herr_t      status;
 
   /* Create a new file using the default properties */
   file_id = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
 
   /* Create the domain for the data set */
   dims[0] = 4; 
   dims[1] = 6; 
   dataspace_id = H5Screate_simple(2, dims, NULL);
 
   /* Create the data set */
   dataset_id = H5Dcreate2(file_id, "/dset", H5T_STD_I32BE, dataspace_id, 
                          H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
 
   /* Release the resources used by the data set */
   status = H5Dclose(dataset_id);
 
   /* Close the access to the domain */
   status = H5Sclose(dataspace_id);
 
   /* Close the file */
   status = H5Fclose(file_id);
}


The compilation of the example is very simple:

[nom@serveur $] icc ex_hdf5.c -lhdf5


Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Ressources de Calcul Québec
Outils
Partager