<?xml version="1.0" encoding="UTF-8"?>
<!--
* Scilab ( https://www.scilab.org/ ) - This file is part of Scilab
* Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
*
 * Copyright (C) 2012 - 2016 - Scilab Enterprises
 *
 * This file is hereby licensed under the terms of the GNU GPL v2.0,
 * pursuant to article 5.3.4 of the CeCILL v.2.1.
 * This file was originally licensed under the terms of the CeCILL v2.1,
 * and continues to be available under such terms.
 * For more information, see the COPYING file which you should have received
 * along with this program.
*
-->
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="h5open" xml:lang="en">
    <refnamediv>
        <refname>h5open</refname>
        <refpurpose>Open an HDF5 file</refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Syntax</title>
        <synopsis>
            obj = h5open(filename [, access])
            obj = h5open(filename, access, driver [, driver_options...])
        </synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>Arguments</title>
        <variablelist>
            <varlistentry>
                <term>filename</term>
                <listitem>
                    <para>a string giving the filename</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>access</term>
                <listitem>
                    <para>A string giving the access mode to use</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>driver</term>
                <listitem>
                    <para>A string giving the driver name</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>driver_options</term>
                <listitem>
                    <para>A boolean or a double depending of the driver value</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>obj</term>
                <listitem>
                    <para>A H5Object corresponding to the open file</para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Description</title>
        <para>Open an HDF5 file in using the access mode (by default "a").</para>
        <para>The access mode is one of the five values:</para>
        <simplelist type="inline">
            <member>
                "r": read only, the file must exist.
            </member>
            <member>
                "r+": read/write, the file must exist.
            </member>
            <member>
                "w": create file, truncate if exists.
            </member>
            <member>
                "w-": create file, fail if exists.
            </member>
            <member>
                "a": read/write if exists, create otherwise (default).
            </member>
        </simplelist>
        <para>Several drivers can be used:</para>
        <simplelist type="inline">
            <member>
                "sec2": Unbuffered, using standard POSIX functions.
            </member>
            <member>
                "stdio": Uses functions from the standard C stdio.h to perform I/O.
            </member>
            <member>
                "core": Uses a file in memory (improves read/write). This driver has two options:
                <simplelist type="inline">
                    <member>
                        backingStore: a boolean, if %T (default), the changes are saved in the real file.
                    </member>
                    <member>
                        blockSize: a double: increment (in bytes) to use to increase buffer size (default 64K).
                    </member>
                </simplelist>
            </member>
            <member>
                "family": Allow to split the file when its size is greater than the option memberSize (a double, by default 2^31 -1). The filename must contain a %d which will be used to generate the family filenames.
            </member>
        </simplelist>
    </refsection>
    <refsection>
        <title>Examples</title>
        <programlisting role="example"><![CDATA[
x = 1:10;
save(TMPDIR + "/x.sod", "x"); // SOD files are HDF5 ones

// Open the created file
a = h5open(TMPDIR + "/x.sod");

// Dump the file content
h5dump(a);

// list the contents of the root element.
h5ls(a)

// Get the SOD version
a.root.SCILAB_sod_version.data

// or if the name contains 'invalid' chars
a.root("SCILAB_sod_version").data

// Get the content of the dataset x
a.root.x.data

// it is possible to open the dataset directly with its path
// Subgroups or datasets are separated with '/'
a("/x")

// Free the resources
h5close(a);
    ]]></programlisting>
    </refsection>
    <refsection role="see also">
        <title>See also</title>
        <simplelist type="inline">
            <member>
                <link linkend="h5close">h5close</link>
            </member>
        </simplelist>
    </refsection>
    <refsection>
        <title>History</title>
        <revhistory>
            <revision>
                <revnumber>5.5.0</revnumber>
                <revremark>HDF5 module introduced.</revremark>
            </revision>
        </revhistory>
    </refsection>
</refentry>
