1
0
mirror of https://github.com/TREX-CoE/trexio.git synced 2024-12-24 13:23:44 +01:00

Deploying to gh-pages from @ TREX-CoE/trexio@8ca74ffef1 🚀

This commit is contained in:
q-posev 2021-12-17 16:14:30 +00:00
parent dbb8186477
commit 8e44af311b
8 changed files with 2173 additions and 1132 deletions

View File

@ -3,7 +3,7 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2021-12-15 Wed 12:52 -->
<!-- 2021-12-17 Fri 16:14 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name=google-site-verification content=jdDnuP2rYGJVy8AHSd-8LkmOmvK_dyz5buZ98wilYII />
@ -347,7 +347,7 @@ and bug reports should be submitted at
</div>
<div id="postamble" class="status">
<p class="author">Author: TREX-CoE</p>
<p class="date">Created: 2021-12-15 Wed 12:52</p>
<p class="date">Created: 2021-12-17 Fri 16:14</p>
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
</body>

View File

@ -1,285 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2021-12-15 Wed 12:52 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>&lrm;</title>
<meta name="generator" content="Org mode" />
<style type="text/css">
<!--/*--><![CDATA[/*><!--*/
.title { text-align: center;
margin-bottom: .2em; }
.subtitle { text-align: center;
font-size: medium;
font-weight: bold;
margin-top:0; }
.todo { font-family: monospace; color: red; }
.done { font-family: monospace; color: green; }
.priority { font-family: monospace; color: orange; }
.tag { background-color: #eee; font-family: monospace;
padding: 2px; font-size: 80%; font-weight: normal; }
.timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; }
.org-right { margin-left: auto; margin-right: 0px; text-align: right; }
.org-left { margin-left: 0px; margin-right: auto; text-align: left; }
.org-center { margin-left: auto; margin-right: auto; text-align: center; }
.underline { text-decoration: underline; }
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
p.verse { margin-left: 3%; }
pre {
border: 1px solid #ccc;
box-shadow: 3px 3px 3px #eee;
padding: 8pt;
font-family: monospace;
overflow: auto;
margin: 1.2em;
}
pre.src {
position: relative;
overflow: visible;
padding-top: 1.2em;
}
pre.src:before {
display: none;
position: absolute;
background-color: white;
top: -10px;
right: 10px;
padding: 3px;
border: 1px solid black;
}
pre.src:hover:before { display: inline;}
/* Languages per Org manual */
pre.src-asymptote:before { content: 'Asymptote'; }
pre.src-awk:before { content: 'Awk'; }
pre.src-C:before { content: 'C'; }
/* pre.src-C++ doesn't work in CSS */
pre.src-clojure:before { content: 'Clojure'; }
pre.src-css:before { content: 'CSS'; }
pre.src-D:before { content: 'D'; }
pre.src-ditaa:before { content: 'ditaa'; }
pre.src-dot:before { content: 'Graphviz'; }
pre.src-calc:before { content: 'Emacs Calc'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
pre.src-fortran:before { content: 'Fortran'; }
pre.src-gnuplot:before { content: 'gnuplot'; }
pre.src-haskell:before { content: 'Haskell'; }
pre.src-hledger:before { content: 'hledger'; }
pre.src-java:before { content: 'Java'; }
pre.src-js:before { content: 'Javascript'; }
pre.src-latex:before { content: 'LaTeX'; }
pre.src-ledger:before { content: 'Ledger'; }
pre.src-lisp:before { content: 'Lisp'; }
pre.src-lilypond:before { content: 'Lilypond'; }
pre.src-lua:before { content: 'Lua'; }
pre.src-matlab:before { content: 'MATLAB'; }
pre.src-mscgen:before { content: 'Mscgen'; }
pre.src-ocaml:before { content: 'Objective Caml'; }
pre.src-octave:before { content: 'Octave'; }
pre.src-org:before { content: 'Org mode'; }
pre.src-oz:before { content: 'OZ'; }
pre.src-plantuml:before { content: 'Plantuml'; }
pre.src-processing:before { content: 'Processing.js'; }
pre.src-python:before { content: 'Python'; }
pre.src-R:before { content: 'R'; }
pre.src-ruby:before { content: 'Ruby'; }
pre.src-sass:before { content: 'Sass'; }
pre.src-scheme:before { content: 'Scheme'; }
pre.src-screen:before { content: 'Gnu Screen'; }
pre.src-sed:before { content: 'Sed'; }
pre.src-sh:before { content: 'shell'; }
pre.src-sql:before { content: 'SQL'; }
pre.src-sqlite:before { content: 'SQLite'; }
/* additional languages in org.el's org-babel-load-languages alist */
pre.src-forth:before { content: 'Forth'; }
pre.src-io:before { content: 'IO'; }
pre.src-J:before { content: 'J'; }
pre.src-makefile:before { content: 'Makefile'; }
pre.src-maxima:before { content: 'Maxima'; }
pre.src-perl:before { content: 'Perl'; }
pre.src-picolisp:before { content: 'Pico Lisp'; }
pre.src-scala:before { content: 'Scala'; }
pre.src-shell:before { content: 'Shell Script'; }
pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
/* additional language identifiers per "defun org-babel-execute"
in ob-*.el */
pre.src-cpp:before { content: 'C++'; }
pre.src-abc:before { content: 'ABC'; }
pre.src-coq:before { content: 'Coq'; }
pre.src-groovy:before { content: 'Groovy'; }
/* additional language identifiers from org-babel-shell-names in
ob-shell.el: ob-shell is the only babel language using a lambda to put
the execution function name together. */
pre.src-bash:before { content: 'bash'; }
pre.src-csh:before { content: 'csh'; }
pre.src-ash:before { content: 'ash'; }
pre.src-dash:before { content: 'dash'; }
pre.src-ksh:before { content: 'ksh'; }
pre.src-mksh:before { content: 'mksh'; }
pre.src-posh:before { content: 'posh'; }
/* Additional Emacs modes also supported by the LaTeX listings package */
pre.src-ada:before { content: 'Ada'; }
pre.src-asm:before { content: 'Assembler'; }
pre.src-caml:before { content: 'Caml'; }
pre.src-delphi:before { content: 'Delphi'; }
pre.src-html:before { content: 'HTML'; }
pre.src-idl:before { content: 'IDL'; }
pre.src-mercury:before { content: 'Mercury'; }
pre.src-metapost:before { content: 'MetaPost'; }
pre.src-modula-2:before { content: 'Modula-2'; }
pre.src-pascal:before { content: 'Pascal'; }
pre.src-ps:before { content: 'PostScript'; }
pre.src-prolog:before { content: 'Prolog'; }
pre.src-simula:before { content: 'Simula'; }
pre.src-tcl:before { content: 'tcl'; }
pre.src-tex:before { content: 'TeX'; }
pre.src-plain-tex:before { content: 'Plain TeX'; }
pre.src-verilog:before { content: 'Verilog'; }
pre.src-vhdl:before { content: 'VHDL'; }
pre.src-xml:before { content: 'XML'; }
pre.src-nxml:before { content: 'XML'; }
/* add a generic configuration mode; LaTeX export needs an additional
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
pre.src-conf:before { content: 'Configuration File'; }
table { border-collapse:collapse; }
caption.t-above { caption-side: top; }
caption.t-bottom { caption-side: bottom; }
td, th { vertical-align:top; }
th.org-right { text-align: center; }
th.org-left { text-align: center; }
th.org-center { text-align: center; }
td.org-right { text-align: right; }
td.org-left { text-align: left; }
td.org-center { text-align: center; }
dt { font-weight: bold; }
.footpara { display: inline; }
.footdef { margin-bottom: 1em; }
.figure { padding: 1em; }
.figure p { text-align: center; }
.inlinetask {
padding: 10px;
border: 2px solid gray;
margin: 10px;
background: #ffffcc;
}
#org-div-home-and-up
{ text-align: right; font-size: 70%; white-space: nowrap; }
textarea { overflow-x: auto; }
.linenr { font-size: smaller }
.code-highlighted { background-color: #ffff00; }
.org-info-js_info-navigation { border-style: none; }
#org-info-js_console-label
{ font-size: 10px; font-weight: bold; white-space: nowrap; }
.org-info-js_search-highlight
{ background-color: #ffff00; color: #000000; font-weight: bold; }
.org-svg { width: 90%; }
/*]]>*/-->
</style>
<script type="text/javascript">
/*
@licstart The following is the entire license notice for the
JavaScript code in this tag.
Copyright (C) 2012-2019 Free Software Foundation, Inc.
The JavaScript code in this tag is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version. The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.
@licend The above is the entire license notice
for the JavaScript code in this tag.
*/
<!--/*--><![CDATA[/*><!--*/
function CodeHighlightOn(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.cacheClassElem = elem.className;
elem.cacheClassTarget = target.className;
target.className = "code-highlighted";
elem.className = "code-highlighted";
}
}
function CodeHighlightOff(elem, id)
{
var target = document.getElementById(id);
if(elem.cacheClassElem)
elem.className = elem.cacheClassElem;
if(elem.cacheClassTarget)
target.className = elem.cacheClassTarget;
}
/*]]>*///-->
</script>
</head>
<body>
<div id="content">
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#org4492593">1. Text back end</a></li>
<li><a href="#orgdf0b5cc">2. HDF5 Back end</a></li>
</ul>
</div>
</div>
<p>
See templator<sub>front.org</sub>
</p>
<div id="outline-container-org4492593" class="outline-2">
<h2 id="org4492593"><span class="section-number-2">1</span> Text back end</h2>
<div class="outline-text-2" id="text-1">
<p>
As the size of the dataset should be extensible, the simplest
solution is to use one file for each sparse data set, and store a
the name of this file in the group.
Each integral can be a line in the file:
i j k l x
which can be read with "%10ld %10ld %10ld %10ld %24.16e".
The offset can be used with <code>fseek(69L*offset, SEEK_SET)</code>
</p>
</div>
</div>
<div id="outline-container-orgdf0b5cc" class="outline-2">
<h2 id="orgdf0b5cc"><span class="section-number-2">2</span> HDF5 Back end</h2>
<div class="outline-text-2" id="text-2">
<p>
We need to declare the number of rows of the dataset as
<code>UNLIMITED</code>. This requires to use the <code>Chunked</code> storage, and the
chunks should absolutely not be larger than 1MB.
</p>
<p>
To extend the storage, see :
<a href="https://support.hdfgroup.org/HDF5/doc1.6/UG/10_Datasets.html">https://support.hdfgroup.org/HDF5/doc1.6/UG/10_Datasets.html</a>
(figure 17)
</p>
<p>
If the offset+num &gt; nmax, we need to extend the dataset.
</p>
</div>
</div>
</div>
<div id="postamble" class="status">
<p class="date">Created: 2021-12-15 Wed 12:52</p>
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
</body>
</html>

692
examples.html Normal file
View File

@ -0,0 +1,692 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2021-12-17 Fri 16:14 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Examples</title>
<meta name="generator" content="Org mode" />
<meta name="author" content="TREX-CoE" />
<style type="text/css">
<!--/*--><![CDATA[/*><!--*/
.title { text-align: center;
margin-bottom: .2em; }
.subtitle { text-align: center;
font-size: medium;
font-weight: bold;
margin-top:0; }
.todo { font-family: monospace; color: red; }
.done { font-family: monospace; color: green; }
.priority { font-family: monospace; color: orange; }
.tag { background-color: #eee; font-family: monospace;
padding: 2px; font-size: 80%; font-weight: normal; }
.timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; }
.org-right { margin-left: auto; margin-right: 0px; text-align: right; }
.org-left { margin-left: 0px; margin-right: auto; text-align: left; }
.org-center { margin-left: auto; margin-right: auto; text-align: center; }
.underline { text-decoration: underline; }
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
p.verse { margin-left: 3%; }
pre {
border: 1px solid #ccc;
box-shadow: 3px 3px 3px #eee;
padding: 8pt;
font-family: monospace;
overflow: auto;
margin: 1.2em;
}
pre.src {
position: relative;
overflow: visible;
padding-top: 1.2em;
}
pre.src:before {
display: none;
position: absolute;
background-color: white;
top: -10px;
right: 10px;
padding: 3px;
border: 1px solid black;
}
pre.src:hover:before { display: inline;}
/* Languages per Org manual */
pre.src-asymptote:before { content: 'Asymptote'; }
pre.src-awk:before { content: 'Awk'; }
pre.src-C:before { content: 'C'; }
/* pre.src-C++ doesn't work in CSS */
pre.src-clojure:before { content: 'Clojure'; }
pre.src-css:before { content: 'CSS'; }
pre.src-D:before { content: 'D'; }
pre.src-ditaa:before { content: 'ditaa'; }
pre.src-dot:before { content: 'Graphviz'; }
pre.src-calc:before { content: 'Emacs Calc'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
pre.src-fortran:before { content: 'Fortran'; }
pre.src-gnuplot:before { content: 'gnuplot'; }
pre.src-haskell:before { content: 'Haskell'; }
pre.src-hledger:before { content: 'hledger'; }
pre.src-java:before { content: 'Java'; }
pre.src-js:before { content: 'Javascript'; }
pre.src-latex:before { content: 'LaTeX'; }
pre.src-ledger:before { content: 'Ledger'; }
pre.src-lisp:before { content: 'Lisp'; }
pre.src-lilypond:before { content: 'Lilypond'; }
pre.src-lua:before { content: 'Lua'; }
pre.src-matlab:before { content: 'MATLAB'; }
pre.src-mscgen:before { content: 'Mscgen'; }
pre.src-ocaml:before { content: 'Objective Caml'; }
pre.src-octave:before { content: 'Octave'; }
pre.src-org:before { content: 'Org mode'; }
pre.src-oz:before { content: 'OZ'; }
pre.src-plantuml:before { content: 'Plantuml'; }
pre.src-processing:before { content: 'Processing.js'; }
pre.src-python:before { content: 'Python'; }
pre.src-R:before { content: 'R'; }
pre.src-ruby:before { content: 'Ruby'; }
pre.src-sass:before { content: 'Sass'; }
pre.src-scheme:before { content: 'Scheme'; }
pre.src-screen:before { content: 'Gnu Screen'; }
pre.src-sed:before { content: 'Sed'; }
pre.src-sh:before { content: 'shell'; }
pre.src-sql:before { content: 'SQL'; }
pre.src-sqlite:before { content: 'SQLite'; }
/* additional languages in org.el's org-babel-load-languages alist */
pre.src-forth:before { content: 'Forth'; }
pre.src-io:before { content: 'IO'; }
pre.src-J:before { content: 'J'; }
pre.src-makefile:before { content: 'Makefile'; }
pre.src-maxima:before { content: 'Maxima'; }
pre.src-perl:before { content: 'Perl'; }
pre.src-picolisp:before { content: 'Pico Lisp'; }
pre.src-scala:before { content: 'Scala'; }
pre.src-shell:before { content: 'Shell Script'; }
pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
/* additional language identifiers per "defun org-babel-execute"
in ob-*.el */
pre.src-cpp:before { content: 'C++'; }
pre.src-abc:before { content: 'ABC'; }
pre.src-coq:before { content: 'Coq'; }
pre.src-groovy:before { content: 'Groovy'; }
/* additional language identifiers from org-babel-shell-names in
ob-shell.el: ob-shell is the only babel language using a lambda to put
the execution function name together. */
pre.src-bash:before { content: 'bash'; }
pre.src-csh:before { content: 'csh'; }
pre.src-ash:before { content: 'ash'; }
pre.src-dash:before { content: 'dash'; }
pre.src-ksh:before { content: 'ksh'; }
pre.src-mksh:before { content: 'mksh'; }
pre.src-posh:before { content: 'posh'; }
/* Additional Emacs modes also supported by the LaTeX listings package */
pre.src-ada:before { content: 'Ada'; }
pre.src-asm:before { content: 'Assembler'; }
pre.src-caml:before { content: 'Caml'; }
pre.src-delphi:before { content: 'Delphi'; }
pre.src-html:before { content: 'HTML'; }
pre.src-idl:before { content: 'IDL'; }
pre.src-mercury:before { content: 'Mercury'; }
pre.src-metapost:before { content: 'MetaPost'; }
pre.src-modula-2:before { content: 'Modula-2'; }
pre.src-pascal:before { content: 'Pascal'; }
pre.src-ps:before { content: 'PostScript'; }
pre.src-prolog:before { content: 'Prolog'; }
pre.src-simula:before { content: 'Simula'; }
pre.src-tcl:before { content: 'tcl'; }
pre.src-tex:before { content: 'TeX'; }
pre.src-plain-tex:before { content: 'Plain TeX'; }
pre.src-verilog:before { content: 'Verilog'; }
pre.src-vhdl:before { content: 'VHDL'; }
pre.src-xml:before { content: 'XML'; }
pre.src-nxml:before { content: 'XML'; }
/* add a generic configuration mode; LaTeX export needs an additional
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
pre.src-conf:before { content: 'Configuration File'; }
table { border-collapse:collapse; }
caption.t-above { caption-side: top; }
caption.t-bottom { caption-side: bottom; }
td, th { vertical-align:top; }
th.org-right { text-align: center; }
th.org-left { text-align: center; }
th.org-center { text-align: center; }
td.org-right { text-align: right; }
td.org-left { text-align: left; }
td.org-center { text-align: center; }
dt { font-weight: bold; }
.footpara { display: inline; }
.footdef { margin-bottom: 1em; }
.figure { padding: 1em; }
.figure p { text-align: center; }
.inlinetask {
padding: 10px;
border: 2px solid gray;
margin: 10px;
background: #ffffcc;
}
#org-div-home-and-up
{ text-align: right; font-size: 70%; white-space: nowrap; }
textarea { overflow-x: auto; }
.linenr { font-size: smaller }
.code-highlighted { background-color: #ffff00; }
.org-info-js_info-navigation { border-style: none; }
#org-info-js_console-label
{ font-size: 10px; font-weight: bold; white-space: nowrap; }
.org-info-js_search-highlight
{ background-color: #ffff00; color: #000000; font-weight: bold; }
.org-svg { width: 90%; }
/*]]>*/-->
</style>
<link rel="stylesheet" title="Standard" href="trexio.css" type="text/css" />
<script type="text/javascript" src="org-info.js">
/**
*
* @source: org-info.js
*
* @licstart The following is the entire license notice for the
* JavaScript code in org-info.js.
*
* Copyright (C) 2012-2019 Free Software Foundation, Inc.
*
*
* The JavaScript code in this tag is free software: you can
* redistribute it and/or modify it under the terms of the GNU
* General Public License (GNU GPL) as published by the Free Software
* Foundation, either version 3 of the License, or (at your option)
* any later version. The code is distributed WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
*
* As additional permission under GNU GPL version 3 section 7, you
* may distribute non-source (e.g., minimized or compacted) forms of
* that code without the copy of the GNU GPL normally required by
* section 4, provided you include this license notice and a URL
* through which recipients can access the Corresponding Source.
*
* @licend The above is the entire license notice
* for the JavaScript code in org-info.js.
*
*/
</script>
<script type="text/javascript">
/*
@licstart The following is the entire license notice for the
JavaScript code in this tag.
Copyright (C) 2012-2019 Free Software Foundation, Inc.
The JavaScript code in this tag is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version. The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.
@licend The above is the entire license notice
for the JavaScript code in this tag.
*/
<!--/*--><![CDATA[/*><!--*/
org_html_manager.set("TOC_DEPTH", "4");
org_html_manager.set("LINK_HOME", "index.html");
org_html_manager.set("LINK_UP", "");
org_html_manager.set("LOCAL_TOC", "1");
org_html_manager.set("VIEW_BUTTONS", "0");
org_html_manager.set("MOUSE_HINT", "underline");
org_html_manager.set("FIXED_TOC", "0");
org_html_manager.set("TOC", "1");
org_html_manager.set("VIEW", "info");
org_html_manager.setup(); // activate after the parameters are set
/*]]>*///-->
</script>
<script type="text/javascript">
/*
@licstart The following is the entire license notice for the
JavaScript code in this tag.
Copyright (C) 2012-2019 Free Software Foundation, Inc.
The JavaScript code in this tag is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version. The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.
@licend The above is the entire license notice
for the JavaScript code in this tag.
*/
<!--/*--><![CDATA[/*><!--*/
function CodeHighlightOn(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.cacheClassElem = elem.className;
elem.cacheClassTarget = target.className;
target.className = "code-highlighted";
elem.className = "code-highlighted";
}
}
function CodeHighlightOff(elem, id)
{
var target = document.getElementById(id);
if(elem.cacheClassElem)
elem.className = elem.cacheClassElem;
if(elem.cacheClassTarget)
target.className = elem.cacheClassTarget;
}
/*]]>*///-->
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
displayAlign: "center",
displayIndent: "0em",
"HTML-CSS": { scale: 100,
linebreaks: { automatic: "false" },
webFont: "TeX"
},
SVG: {scale: 100,
linebreaks: { automatic: "false" },
font: "TeX"},
NativeMML: {scale: 100},
TeX: { equationNumbers: {autoNumber: "AMS"},
MultLineWidth: "85%",
TagSide: "right",
TagIndent: ".8em"
}
});
</script>
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_HTML"></script>
</head>
<body>
<div id="org-div-home-and-up">
<a accesskey="h" href=""> UP </a>
|
<a accesskey="H" href="index.html"> HOME </a>
</div><div id="content">
<h1 class="title">Examples</h1>
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#org6ac36fa">1. Accessing sparse quantities</a>
<ul>
<li><a href="#org76bf5b4">1.1. Fortran</a>
<ul>
<li><a href="#org68ffb54">1.1.1. Declare Temporary variables</a></li>
<li><a href="#org5bd37e3">1.1.2. Obtain the name of the TREXIO file from the command line, and open it for reading</a></li>
<li><a href="#org73bf891">1.1.3. Read the nuclear repulsion energy</a></li>
<li><a href="#org6a86ab9">1.1.4. Read the number of molecular orbitals</a></li>
<li><a href="#orge116fb6">1.1.5. Allocate memory</a></li>
<li><a href="#org0639c0b">1.1.6. Read one-electron quantities</a></li>
<li><a href="#orgd10fcbf">1.1.7. Read two-electron quantities</a>
<ul>
<li><a href="#orgd8374a9">1.1.7.1. Electron repulsion integrals</a></li>
<li><a href="#org82df80a">1.1.7.2. Reduced density matrix</a></li>
</ul>
</li>
<li><a href="#org6d22a63">1.1.8. Compute the energy</a></li>
<li><a href="#org3a5c3f6">1.1.9. Terminate</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div id="outline-container-org6ac36fa" class="outline-2">
<h2 id="org6ac36fa"><span class="section-number-2">1</span> Accessing sparse quantities</h2>
<div class="outline-text-2" id="text-1">
</div>
<div id="outline-container-org76bf5b4" class="outline-3">
<h3 id="org76bf5b4"><span class="section-number-3">1.1</span> Fortran</h3>
<div class="outline-text-3" id="text-1-1">
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #a020f0;">program</span> <span style="color: #0000ff;">print_energy</span>
<span style="color: #a020f0;">use</span> <span style="color: #0000ff;">trexio</span>
<span style="color: #a020f0;">implicit</span> <span style="color: #228b22;">none</span>
<span style="color: #228b22;">character</span>*(128) ::<span style="color: #a0522d;"> filename </span>! <span style="color: #b22222;">Name of the input file</span>
<span style="color: #228b22;">integer</span> ::<span style="color: #a0522d;"> rc </span>! <span style="color: #b22222;">Return code for error checking</span>
<span style="color: #228b22;">integer</span>(8) ::<span style="color: #a0522d;"> f </span>! <span style="color: #b22222;">TREXIO file handle</span>
<span style="color: #228b22;">character</span>*(128) ::<span style="color: #a0522d;"> err_msg </span>! <span style="color: #b22222;">Error message</span>
</pre>
</div>
<p>
This program computes the energy as:
</p>
<p>
\[
E = E_{\text{NN}} + \sum_{ij} D_{ij}\, \langle i | h | j \rangle\,
+\, \frac{1}{2} \sum_{ijkl} \Gamma_{ijkl}\, \langle i j | k l
\rangle\; \textrm{ with } \; 0 < i,j,k,l \le n
\]
</p>
<p>
One needs to read from the TREXIO file:
</p>
<dl class="org-dl">
<dt>\(n\)</dt><dd>The number of molecular orbitals</dd>
<dt>\(E_{\text{NN}}\)</dt><dd>The nuclear repulsion energy</dd>
<dt>\(D_{ij}\)</dt><dd>The one-body reduced density matrix</dd>
<dt>\(\langle i |h| j \rangle\)</dt><dd>The one-electron Hamiltonian integrals</dd>
<dt>\(\Gamma_{ijkl}\)</dt><dd>The two-body reduced density matrix</dd>
<dt>\(\langle i j | k l \rangle\)</dt><dd>The electron repulsion integrals</dd>
</dl>
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #228b22;">integer</span> ::<span style="color: #a0522d;"> n</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> E, E_nn</span>
<span style="color: #228b22;">double precision</span>, <span style="color: #a020f0;">allocatable</span> ::<span style="color: #a0522d;"> D(:,:), h0(:,:)</span>
<span style="color: #228b22;">double precision</span>, <span style="color: #a020f0;">allocatable</span> ::<span style="color: #a0522d;"> G(:,:,:,:), W(:,:,:,:)</span>
</pre>
</div>
</div>
<div id="outline-container-org68ffb54" class="outline-4">
<h4 id="org68ffb54"><span class="section-number-4">1.1.1</span> Declare Temporary variables</h4>
<div class="outline-text-4" id="text-1-1-1">
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #228b22;">integer</span> ::<span style="color: #a0522d;"> i, j, k, l, m</span>
<span style="color: #228b22;">integer</span>(8), <span style="color: #a020f0;">parameter</span> ::<span style="color: #a0522d;"> BUFSIZE = 100000_8</span>
<span style="color: #228b22;">integer</span>(8) ::<span style="color: #a0522d;"> offset, icount, size_max</span>
<span style="color: #228b22;">integer</span> ::<span style="color: #a0522d;"> buffer_index(4,BUFSIZE)</span>
<span style="color: #228b22;">double precision</span> ::<span style="color: #a0522d;"> buffer_values(BUFSIZE)</span>
<span style="color: #228b22;">double precision</span>, <span style="color: #a020f0;">external</span> ::<span style="color: #a0522d;"> ddot </span>! <span style="color: #b22222;">BLAS dot product</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org5bd37e3" class="outline-4">
<h4 id="org5bd37e3"><span class="section-number-4">1.1.2</span> Obtain the name of the TREXIO file from the command line, and open it for reading</h4>
<div class="outline-text-4" id="text-1-1-2">
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #a020f0;">call</span> <span style="color: #0000ff;">getarg</span>(1, filename)
f = trexio_open (filename, <span style="color: #8b2252;">'r'</span>, TREXIO_HDF5, rc)
<span style="color: #a020f0;">if</span> (rc /= TREXIO_SUCCESS) <span style="color: #a020f0;">then</span>
<span style="color: #a020f0;">call</span> <span style="color: #0000ff;">trexio_string_of_error</span>(rc, err_msg)
<span style="color: #a020f0;">print</span> *, <span style="color: #8b2252;">'Error opening TREXIO file: '</span>//<span style="color: #a020f0;">trim</span>(err_msg)
<span style="color: #a020f0;">stop</span>
<span style="color: #a020f0;">end if</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org73bf891" class="outline-4">
<h4 id="org73bf891"><span class="section-number-4">1.1.3</span> Read the nuclear repulsion energy</h4>
<div class="outline-text-4" id="text-1-1-3">
<div class="org-src-container">
<pre class="src src-f90">rc = trexio_read_nucleus_repulsion(f, E_nn)
<span style="color: #a020f0;">if</span> (rc /= TREXIO_SUCCESS) <span style="color: #a020f0;">then</span>
<span style="color: #a020f0;">call</span> <span style="color: #0000ff;">trexio_string_of_error</span>(rc, err_msg)
<span style="color: #a020f0;">print</span> *, <span style="color: #8b2252;">'Error reading nuclear repulsion: '</span>//<span style="color: #a020f0;">trim</span>(err_msg)
<span style="color: #a020f0;">stop</span>
<span style="color: #a020f0;">end if</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org6a86ab9" class="outline-4">
<h4 id="org6a86ab9"><span class="section-number-4">1.1.4</span> Read the number of molecular orbitals</h4>
<div class="outline-text-4" id="text-1-1-4">
<div class="org-src-container">
<pre class="src src-f90">rc = trexio_read_mo_num(f, n)
<span style="color: #a020f0;">if</span> (rc /= TREXIO_SUCCESS) <span style="color: #a020f0;">then</span>
<span style="color: #a020f0;">call</span> <span style="color: #0000ff;">trexio_string_of_error</span>(rc, err_msg)
<span style="color: #a020f0;">print</span> *, <span style="color: #8b2252;">'Error reading number of MOs: '</span>//<span style="color: #a020f0;">trim</span>(err_msg)
<span style="color: #a020f0;">stop</span>
<span style="color: #a020f0;">end if</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-orge116fb6" class="outline-4">
<h4 id="orge116fb6"><span class="section-number-4">1.1.5</span> Allocate memory</h4>
<div class="outline-text-4" id="text-1-1-5">
<div class="org-src-container">
<pre class="src src-f90"><span style="color: #a020f0;">allocate</span>( D(n,n), h0(n,n) )
<span style="color: #a020f0;">allocate</span>( G(n,n,n,n), W(n,n,n,n) )
G(:,:,:,:) = 0.d0
W(:,:,:,:) = 0.d0
</pre>
</div>
</div>
</div>
<div id="outline-container-org0639c0b" class="outline-4">
<h4 id="org0639c0b"><span class="section-number-4">1.1.6</span> Read one-electron quantities</h4>
<div class="outline-text-4" id="text-1-1-6">
<div class="org-src-container">
<pre class="src src-f90">rc = trexio_has_mo_1e_int_core_hamiltonian(f)
<span style="color: #a020f0;">if</span> (rc /= TREXIO_SUCCESS) <span style="color: #a020f0;">then</span>
<span style="color: #a020f0;">stop</span> <span style="color: #8b2252;">'No core hamiltonian in file'</span>
<span style="color: #a020f0;">end if</span>
rc = trexio_read_mo_1e_int_core_hamiltonian(f, h0)
<span style="color: #a020f0;">if</span> (rc /= TREXIO_SUCCESS) <span style="color: #a020f0;">then</span>
<span style="color: #a020f0;">call</span> <span style="color: #0000ff;">trexio_string_of_error</span>(rc, err_msg)
<span style="color: #a020f0;">print</span> *, <span style="color: #8b2252;">'Error reading core Hamiltonian: '</span>//<span style="color: #a020f0;">trim</span>(err_msg)
<span style="color: #a020f0;">stop</span>
<span style="color: #a020f0;">end if</span>
rc = trexio_has_rdm_1e(f)
<span style="color: #a020f0;">if</span> (rc /= TREXIO_SUCCESS) <span style="color: #a020f0;">then</span>
<span style="color: #a020f0;">stop</span> <span style="color: #8b2252;">'No 1e RDM in file'</span>
<span style="color: #a020f0;">end if</span>
rc = trexio_read_rdm_1e(f, D)
<span style="color: #a020f0;">if</span> (rc /= TREXIO_SUCCESS) <span style="color: #a020f0;">then</span>
<span style="color: #a020f0;">call</span> <span style="color: #0000ff;">trexio_string_of_error</span>(rc, err_msg)
<span style="color: #a020f0;">print</span> *, <span style="color: #8b2252;">'Error reading one-body RDM: '</span>//<span style="color: #a020f0;">trim</span>(err_msg)
<span style="color: #a020f0;">stop</span>
<span style="color: #a020f0;">end if</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-orgd10fcbf" class="outline-4">
<h4 id="orgd10fcbf"><span class="section-number-4">1.1.7</span> Read two-electron quantities</h4>
<div class="outline-text-4" id="text-1-1-7">
<p>
Reading is done with OpenMP. Each thread reads its own buffer, and
the buffers are then processed in parallel.
</p>
<p>
Reading the file requires a lock, so it is done in a critical
section. The <code>offset</code> variable is shared, and it is incremented in
the critical section. For each read, the function returns in
<code>icount</code> the number of read integrals, so this variable needs also
to be protected in the critical section when modified.
</p>
</div>
<div id="outline-container-orgd8374a9" class="outline-5">
<h5 id="orgd8374a9"><span class="section-number-5">1.1.7.1</span> Electron repulsion integrals</h5>
<div class="outline-text-5" id="text-1-1-7-1">
<div class="org-src-container">
<pre class="src src-f90">rc = trexio_has_mo_2e_int_eri(f)
<span style="color: #a020f0;">if</span> (rc /= TREXIO_SUCCESS) <span style="color: #a020f0;">then</span>
<span style="color: #a020f0;">stop</span> <span style="color: #8b2252;">'No electron repulsion integrals in file'</span>
<span style="color: #a020f0;">end if</span>
rc = trexio_read_mo_2e_int_eri_size (f, size_max)
<span style="color: #a020f0;">if</span> (rc /= TREXIO_SUCCESS) <span style="color: #a020f0;">then</span>
<span style="color: #a020f0;">call</span> <span style="color: #0000ff;">trexio_string_of_error</span>(rc, err_msg)
<span style="color: #a020f0;">print</span> *, <span style="color: #8b2252;">'Error reading number of ERIs: '</span>//<span style="color: #a020f0;">trim</span>(err_msg)
<span style="color: #a020f0;">stop</span>
<span style="color: #a020f0;">end if</span>
offset = 0_8
!<span style="color: #b22222;">$OMP PARALLEL DEFAULT(SHARED) PRIVATE(icount, i, j, k, l, &amp;</span>
!<span style="color: #b22222;">$OMP buffer_index, buffer_values, m)</span>
icount = BUFSIZE
<span style="color: #a020f0;">do while</span> (icount == BUFSIZE)
!<span style="color: #b22222;">$OMP CRITICAL</span>
<span style="color: #a020f0;">if</span> (offset &lt; size_max) <span style="color: #a020f0;">then</span>
rc = trexio_read_mo_2e_int_eri(f, offset, icount, buffer_index, buffer_values)
offset = offset + icount
<span style="color: #a020f0;">else</span>
icount = 0
<span style="color: #a020f0;">end if</span>
!<span style="color: #b22222;">$OMP END CRITICAL</span>
<span style="color: #a020f0;">do</span> m=1,icount
i = buffer_index(1,m)
j = buffer_index(2,m)
k = buffer_index(3,m)
l = buffer_index(4,m)
W(i,j,k,l) = buffer_values(m)
W(k,j,i,l) = buffer_values(m)
W(i,l,k,j) = buffer_values(m)
W(k,l,i,j) = buffer_values(m)
W(j,i,l,k) = buffer_values(m)
W(j,k,l,i) = buffer_values(m)
W(l,i,j,k) = buffer_values(m)
W(l,k,j,i) = buffer_values(m)
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
!<span style="color: #b22222;">$OMP END PARALLEL</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org82df80a" class="outline-5">
<h5 id="org82df80a"><span class="section-number-5">1.1.7.2</span> Reduced density matrix</h5>
<div class="outline-text-5" id="text-1-1-7-2">
<div class="org-src-container">
<pre class="src src-f90">rc = trexio_has_rdm_2e(f)
<span style="color: #a020f0;">if</span> (rc /= TREXIO_SUCCESS) <span style="color: #a020f0;">then</span>
<span style="color: #a020f0;">stop</span> <span style="color: #8b2252;">'No two-body density matrix in file'</span>
<span style="color: #a020f0;">end if</span>
rc = trexio_read_rdm_2e_size (f, size_max)
<span style="color: #a020f0;">if</span> (rc /= TREXIO_SUCCESS) <span style="color: #a020f0;">then</span>
<span style="color: #a020f0;">call</span> <span style="color: #0000ff;">trexio_string_of_error</span>(rc, err_msg)
<span style="color: #a020f0;">print</span> *, <span style="color: #8b2252;">'Error reading number of 2-RDM elements: '</span>//<span style="color: #a020f0;">trim</span>(err_msg)
<span style="color: #a020f0;">stop</span>
<span style="color: #a020f0;">end if</span>
offset = 0_8
!<span style="color: #b22222;">$OMP PARALLEL DEFAULT(SHARED) PRIVATE(icount, i, j, k, l, &amp;</span>
!<span style="color: #b22222;">$OMP buffer_index, buffer_values, m)</span>
icount = bufsize
<span style="color: #a020f0;">do while</span> (offset &lt; size_max)
!<span style="color: #b22222;">$OMP CRITICAL</span>
<span style="color: #a020f0;">if</span> (offset &lt; size_max) <span style="color: #a020f0;">then</span>
rc = trexio_read_rdm_2e(f, offset, icount, buffer_index, buffer_values)
offset = offset + icount
<span style="color: #a020f0;">else</span>
icount = 0
<span style="color: #a020f0;">end if</span>
!<span style="color: #b22222;">$OMP END CRITICAL</span>
<span style="color: #a020f0;">do</span> m=1,icount
i = buffer_index(1,m)
j = buffer_index(2,m)
k = buffer_index(3,m)
l = buffer_index(4,m)
G(i,j,k,l) = buffer_values(m)
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
!<span style="color: #b22222;">$OMP END PARALLEL</span>
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-org6d22a63" class="outline-4">
<h4 id="org6d22a63"><span class="section-number-4">1.1.8</span> Compute the energy</h4>
<div class="outline-text-4" id="text-1-1-8">
<p>
As \((n,m)\) 2D arrays are stored in memory as \((\n times m)\) 1D
arrays, we could pass the matrices to the <code>ddot</code> BLAS function to
perform the summations in a single call for the 1-electron quantities.
Instead, we prefer to interleave the 1-electron (negative) and
2-electron (positive) summations to have a better cancellation of
numerical errors.
</p>
<p>
Here \(n^4\) can be larger than the largest possible 32-bit integer,
so it is not safe to pass \(n^4\) to the <code>ddot</code> BLAS
function. Hence, we perform \(n^2\) loops, using vectors of size \(n^2\).
</p>
<div class="org-src-container">
<pre class="src src-f90">
E = 0.d0
<span style="color: #a020f0;">do</span> l=1,n
E = E + ddot( n, D(1,l), 1, h0(1,l), 1 )
<span style="color: #a020f0;">do</span> k=1,n
E = E + 0.5d0 * ddot( n*n, G(1,1,k,l), 1, W(1,1,k,l), 1 )
<span style="color: #a020f0;">end do</span>
<span style="color: #a020f0;">end do</span>
E = E + E_nn
<span style="color: #a020f0;">print</span> *, <span style="color: #8b2252;">'Energy: '</span>, E
</pre>
</div>
</div>
</div>
<div id="outline-container-org3a5c3f6" class="outline-4">
<h4 id="org3a5c3f6"><span class="section-number-4">1.1.9</span> Terminate</h4>
<div class="outline-text-4" id="text-1-1-9">
<div class="org-src-container">
<pre class="src src-f90"> <span style="color: #a020f0;">deallocate</span>( D, h0, G, W )
<span style="color: #a020f0;">end program</span>
</pre>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="postamble" class="status">
<p class="author">Author: TREX-CoE</p>
<p class="date">Created: 2021-12-17 Fri 16:14</p>
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
</body>
</html>

View File

@ -3,7 +3,7 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2021-12-15 Wed 12:52 -->
<!-- 2021-12-17 Fri 16:14 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name=google-site-verification content=jdDnuP2rYGJVy8AHSd-8LkmOmvK_dyz5buZ98wilYII />
@ -347,7 +347,7 @@ and bug reports should be submitted at
</div>
<div id="postamble" class="status">
<p class="author">Author: TREX-CoE</p>
<p class="date">Created: 2021-12-15 Wed 12:52</p>
<p class="date">Created: 2021-12-17 Fri 16:14</p>
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
</body>

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2021-12-15 Wed 12:52 -->
<!-- 2021-12-17 Fri 16:14 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>HDF5 back end</title>
@ -311,27 +311,29 @@ for the JavaScript code in this tag.
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#orgd6e2c3d">1. HDF5 back end</a>
<li><a href="#org49b8ff8">1. HDF5 back end</a>
<ul>
<li><a href="#orgd0d32e4">1.1. Template for HDF5 definitions</a></li>
<li><a href="#org7f9e817">1.2. Template for HDF5 structures</a></li>
<li><a href="#orgf1e10e8">1.3. Template for HDF5 init/deinit</a></li>
<li><a href="#org06f99a4">1.4. Template for HDF5 has/read/write the numerical attribute</a></li>
<li><a href="#orgcd7e6e5">1.5. Template for HDF5 has/read/write the dataset of numerical data</a></li>
<li><a href="#org6f87ffa">1.6. Template for HDF5 has/read/write the dataset of strings</a></li>
<li><a href="#org721b617">1.7. Template for HDF5 has/read/write the string attribute</a></li>
<li><a href="#org486e7be">1.1. Template for HDF5 definitions</a></li>
<li><a href="#org7936c21">1.2. Template for HDF5 structures</a></li>
<li><a href="#org0b58f3e">1.3. Template for HDF5 init/deinit</a></li>
<li><a href="#orgd21a866">1.4. Template for HDF5 has/read/write the numerical attribute</a></li>
<li><a href="#org454fa3a">1.5. Template for HDF5 has/read/write the dataset of numerical data</a></li>
<li><a href="#org3c302ca">1.6. Template for HDF5 has/read/write the dataset of sparse data</a></li>
<li><a href="#orgf84001c">1.7. Template for HDF5 has/read/write the dataset of strings</a></li>
<li><a href="#orge2b8732">1.8. Template for HDF5 has/read/write the string attribute</a></li>
<li><a href="#orga0ed807">1.9. Helper functions</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div id="outline-container-orgd6e2c3d" class="outline-2">
<h2 id="orgd6e2c3d"><span class="section-number-2">1</span> HDF5 back end</h2>
<div id="outline-container-org49b8ff8" class="outline-2">
<h2 id="org49b8ff8"><span class="section-number-2">1</span> HDF5 back end</h2>
<div class="outline-text-2" id="text-1">
</div>
<div id="outline-container-orgd0d32e4" class="outline-3">
<h3 id="orgd0d32e4"><span class="section-number-3">1.1</span> Template for HDF5 definitions</h3>
<div id="outline-container-org486e7be" class="outline-3">
<h3 id="org486e7be"><span class="section-number-3">1.1</span> Template for HDF5 definitions</h3>
<div class="outline-text-3" id="text-1-1">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #483d8b;">#define</span> $GROUP$_GROUP_NAME <span style="color: #8b2252;">"$group$"</span>
@ -343,8 +345,8 @@ for the JavaScript code in this tag.
</div>
</div>
<div id="outline-container-org7f9e817" class="outline-3">
<h3 id="org7f9e817"><span class="section-number-3">1.2</span> Template for HDF5 structures</h3>
<div id="outline-container-org7936c21" class="outline-3">
<h3 id="org7936c21"><span class="section-number-3">1.2</span> Template for HDF5 structures</h3>
<div class="outline-text-3" id="text-1-2">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #a020f0;">typedef</span> <span style="color: #a020f0;">struct</span> <span style="color: #228b22;">trexio_hdf5_s</span> {
@ -358,8 +360,8 @@ for the JavaScript code in this tag.
</div>
<div id="outline-container-orgf1e10e8" class="outline-3">
<h3 id="orgf1e10e8"><span class="section-number-3">1.3</span> Template for HDF5 init/deinit</h3>
<div id="outline-container-org0b58f3e" class="outline-3">
<h3 id="org0b58f3e"><span class="section-number-3">1.3</span> Template for HDF5 init/deinit</h3>
<div class="outline-text-3" id="text-1-3">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">trexio_exit_code</span>
@ -439,8 +441,8 @@ for the JavaScript code in this tag.
</div>
</div>
<div id="outline-container-org06f99a4" class="outline-3">
<h3 id="org06f99a4"><span class="section-number-3">1.4</span> Template for HDF5 has/read/write the numerical attribute</h3>
<div id="outline-container-orgd21a866" class="outline-3">
<h3 id="orgd21a866"><span class="section-number-3">1.4</span> Template for HDF5 has/read/write the numerical attribute</h3>
<div class="outline-text-3" id="text-1-4">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">trexio_exit_code</span>
@ -534,8 +536,8 @@ for the JavaScript code in this tag.
</div>
</div>
<div id="outline-container-orgcd7e6e5" class="outline-3">
<h3 id="orgcd7e6e5"><span class="section-number-3">1.5</span> Template for HDF5 has/read/write the dataset of numerical data</h3>
<div id="outline-container-org454fa3a" class="outline-3">
<h3 id="org454fa3a"><span class="section-number-3">1.5</span> Template for HDF5 has/read/write the dataset of numerical data</h3>
<div class="outline-text-3" id="text-1-5">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">trexio_exit_code</span>
@ -658,9 +660,211 @@ for the JavaScript code in this tag.
</div>
</div>
<div id="outline-container-org6f87ffa" class="outline-3">
<h3 id="org6f87ffa"><span class="section-number-3">1.6</span> Template for HDF5 has/read/write the dataset of strings</h3>
<div id="outline-container-org3c302ca" class="outline-3">
<h3 id="org3c302ca"><span class="section-number-3">1.6</span> Template for HDF5 has/read/write the dataset of sparse data</h3>
<div class="outline-text-3" id="text-1-6">
<p>
Sparse data is stored using extensible datasets of HDF5. Extensibility is required
due to the fact that the sparse data will be written in chunks of user-defined size.
</p>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">trexio_exit_code</span>
<span style="color: #0000ff;">trexio_hdf5_write_$group_dset$</span> (<span style="color: #228b22;">trexio_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">offset_file</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size_max</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int32_t</span>* <span style="color: #a0522d;">index_sparse</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">value_sparse</span>)
{
<span style="color: #a020f0;">if</span> (file == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_INVALID_ARG_1;
<span style="color: #228b22;">trexio_hdf5_t</span>* <span style="color: #a0522d;">f</span> = (<span style="color: #228b22;">trexio_hdf5_t</span>*) file;
<span style="color: #228b22;">hid_t</span> <span style="color: #a0522d;">index_dtype</span>;
<span style="color: #228b22;">void</span>* <span style="color: #a0522d;">index_p</span>;
<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">size_ranked</span> = (<span style="color: #228b22;">uint64_t</span>) size * $group_dset_rank$;
/* <span style="color: #b22222;">Determine the optimal type for storing indices depending on the size_max (usually mo_num or ao_num) </span>*/
<span style="color: #a020f0;">if</span> (size_max &lt; UINT8_MAX) {
<span style="color: #228b22;">uint8_t</span>* <span style="color: #a0522d;">index</span> = CALLOC(size_ranked, uint8_t);
<span style="color: #a020f0;">if</span> (index == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_ALLOCATION_FAILED;
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">i</span>=0; i&lt;size_ranked; ++i){
index[i] = (<span style="color: #228b22;">uint8_t</span>) index_sparse[i];
}
index_p = index;
index_dtype = H5T_NATIVE_UINT8;
} <span style="color: #a020f0;">else</span> <span style="color: #a020f0;">if</span> (size_max &lt; UINT16_MAX) {
<span style="color: #228b22;">uint16_t</span>* <span style="color: #a0522d;">index</span> = CALLOC(size_ranked, uint16_t);
<span style="color: #a020f0;">if</span> (index == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_ALLOCATION_FAILED;
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">i</span>=0; i&lt;size_ranked; ++i){
index[i] = (<span style="color: #228b22;">uint16_t</span>) index_sparse[i];
}
index_p = index;
index_dtype = H5T_NATIVE_UINT16;
} <span style="color: #a020f0;">else</span> {
index_p = (<span style="color: #228b22;">int32_t</span>*) index_sparse;
index_dtype = H5T_NATIVE_INT32;
}
/* <span style="color: #b22222;">Store float values in double precision </span>*/
<span style="color: #228b22;">hid_t</span> <span style="color: #a0522d;">value_dtype</span> = H5T_NATIVE_DOUBLE;
/* <span style="color: #b22222;">Arrays of chunk dims that will be used for chunking the dataset </span>*/
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">hsize_t</span> <span style="color: #a0522d;">chunk_i_dims</span>[1] = {size_ranked};
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">hsize_t</span> <span style="color: #a0522d;">chunk_v_dims</span>[1] = {size};
/* <span style="color: #b22222;">Indices and values are stored as 2 independent datasets in the HDF5 file </span>*/
<span style="color: #228b22;">char</span> <span style="color: #a0522d;">dset_index_name</span>[256] = <span style="color: #8b2252;">"\0"</span>;
<span style="color: #228b22;">char</span> <span style="color: #a0522d;">dset_value_name</span>[256] = <span style="color: #8b2252;">"\0"</span>;
/* <span style="color: #b22222;">Build the names of the datasets </span>*/
strncpy(dset_index_name, $GROUP_DSET$_NAME <span style="color: #8b2252;">"_indices"</span>, 256);
strncpy(dset_value_name, $GROUP_DSET$_NAME <span style="color: #8b2252;">"_values"</span>, 256);
<span style="color: #228b22;">trexio_exit_code</span> <span style="color: #a0522d;">rc_write</span> = TREXIO_FAILURE;
/* <span style="color: #b22222;">NOTE: chunk size is set upon creation of the HDF5 dataset and cannot be changed ! </span>*/
<span style="color: #a020f0;">if</span> ( H5LTfind_dataset(f-&gt;$group$_group, dset_index_name) != 1 ) {
/* <span style="color: #b22222;">If the file does not exist -&gt; create it and write </span>*/
/* <span style="color: #b22222;">Create chunked dataset with index_dtype datatype and write indices into it </span>*/
rc_write = trexio_hdf5_create_write_dset_sparse(f-&gt;$group$_group, dset_index_name, index_dtype, chunk_i_dims, index_p);
<span style="color: #a020f0;">if</span> (index_p != index_sparse) FREE(index_p);
<span style="color: #a020f0;">if</span> (rc_write != TREXIO_SUCCESS) <span style="color: #a020f0;">return</span> rc_write;
/* <span style="color: #b22222;">Create chunked dataset with value_dtype datatype and write values into it </span>*/
rc_write = trexio_hdf5_create_write_dset_sparse(f-&gt;$group$_group, dset_value_name, value_dtype, chunk_v_dims, value_sparse);
<span style="color: #a020f0;">if</span> (rc_write != TREXIO_SUCCESS) <span style="color: #a020f0;">return</span> rc_write;
} <span style="color: #a020f0;">else</span> {
/* <span style="color: #b22222;">If the file exists -&gt; open it and write </span>*/
<span style="color: #228b22;">hsize_t</span> <span style="color: #a0522d;">offset_i</span>[1] = {(<span style="color: #228b22;">hsize_t</span>) offset_file * $group_dset_rank$};
<span style="color: #228b22;">hsize_t</span> <span style="color: #a0522d;">offset_v</span>[1] = {(<span style="color: #228b22;">hsize_t</span>) offset_file};
/* <span style="color: #b22222;">Create chunked dataset with index_dtype datatype and write indices into it </span>*/
rc_write = trexio_hdf5_open_write_dset_sparse(f-&gt;$group$_group, dset_index_name, index_dtype, chunk_i_dims, offset_i, index_p);
<span style="color: #a020f0;">if</span> (index_p != index_sparse) FREE(index_p);
<span style="color: #a020f0;">if</span> (rc_write != TREXIO_SUCCESS) <span style="color: #a020f0;">return</span> rc_write;
/* <span style="color: #b22222;">Create chunked dataset with value_dtype datatype and write values into it </span>*/
rc_write = trexio_hdf5_open_write_dset_sparse(f-&gt;$group$_group, dset_value_name, value_dtype, chunk_v_dims, offset_v, value_sparse);
<span style="color: #a020f0;">if</span> (rc_write != TREXIO_SUCCESS) <span style="color: #a020f0;">return</span> rc_write;
}
<span style="color: #a020f0;">return</span> TREXIO_SUCCESS;
}
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">trexio_exit_code</span>
<span style="color: #0000ff;">trexio_hdf5_read_$group_dset$</span> (<span style="color: #228b22;">trexio_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">offset_file</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size_max</span>,
<span style="color: #228b22;">int64_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">eof_read_size</span>,
<span style="color: #228b22;">int32_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">index_read</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">value_read</span>)
{
<span style="color: #a020f0;">if</span> (file == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_INVALID_ARG_1;
<span style="color: #a020f0;">if</span> (eof_read_size == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_INVALID_ARG_5;
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">trexio_hdf5_t</span>* <span style="color: #a0522d;">f</span> = (<span style="color: #a020f0;">const</span> <span style="color: #228b22;">trexio_hdf5_t</span>*) file;
/* <span style="color: #b22222;">Indices and values are stored as 2 independent datasets in the HDF5 file </span>*/
<span style="color: #228b22;">char</span> <span style="color: #a0522d;">dset_index_name</span>[256] = <span style="color: #8b2252;">"\0"</span>;
<span style="color: #228b22;">char</span> <span style="color: #a0522d;">dset_value_name</span>[256] = <span style="color: #8b2252;">"\0"</span>;
/* <span style="color: #b22222;">Build the names of the datasets </span>*/
strncpy(dset_index_name, $GROUP_DSET$_NAME <span style="color: #8b2252;">"_indices"</span>, 256);
strncpy(dset_value_name, $GROUP_DSET$_NAME <span style="color: #8b2252;">"_values"</span>, 256);
<span style="color: #228b22;">hsize_t</span> <span style="color: #a0522d;">offset_i</span>[1] = {(<span style="color: #228b22;">hsize_t</span>) offset_file * $group_dset_rank$};
<span style="color: #228b22;">hsize_t</span> <span style="color: #a0522d;">count_i</span>[1] = {(<span style="color: #228b22;">hsize_t</span>) size * $group_dset_rank$};
<span style="color: #228b22;">hsize_t</span> <span style="color: #a0522d;">offset_v</span>[1] = {(<span style="color: #228b22;">hsize_t</span>) offset_file};
<span style="color: #228b22;">hsize_t</span> <span style="color: #a0522d;">count_v</span>[1] = {(<span style="color: #228b22;">hsize_t</span>) size};
<span style="color: #228b22;">int</span> <span style="color: #a0522d;">is_index</span> = 1, <span style="color: #a0522d;">is_value</span> = 0;
<span style="color: #228b22;">trexio_exit_code</span> <span style="color: #a0522d;">rc_read</span>;
// <span style="color: #b22222;">attempt to read indices</span>
rc_read = trexio_hdf5_open_read_dset_sparse(f-&gt;$group$_group, dset_index_name, offset_i, count_i, <span style="color: #008b8b;">NULL</span>, is_index, index_read);
<span style="color: #a020f0;">if</span> (rc_read != TREXIO_SUCCESS &amp;&amp; rc_read != TREXIO_END) <span style="color: #a020f0;">return</span> rc_read;
// <span style="color: #b22222;">attempt to read values</span>
// <span style="color: #b22222;">when EOF is encountered - the count_v[0] is modified and contains the number of elements being read</span>
rc_read = trexio_hdf5_open_read_dset_sparse(f-&gt;$group$_group, dset_value_name, offset_v, count_v, eof_read_size, is_value, value_read);
<span style="color: #a020f0;">if</span> (rc_read != TREXIO_SUCCESS &amp;&amp; rc_read != TREXIO_END) <span style="color: #a020f0;">return</span> rc_read;
<span style="color: #a020f0;">return</span> rc_read;
}
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">trexio_exit_code</span>
<span style="color: #0000ff;">trexio_hdf5_read_$group_dset$_size</span> (<span style="color: #228b22;">trexio_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>, <span style="color: #228b22;">int64_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">size_max</span>)
{
<span style="color: #a020f0;">if</span> (file == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_INVALID_ARG_1;
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">trexio_hdf5_t</span>* <span style="color: #a0522d;">f</span> = (<span style="color: #a020f0;">const</span> <span style="color: #228b22;">trexio_hdf5_t</span>*) file;
<span style="color: #228b22;">hid_t</span> <span style="color: #a0522d;">dset_id</span> = H5Dopen(f-&gt;$group$_group, $GROUP_DSET$_NAME <span style="color: #8b2252;">"_values"</span>, H5P_DEFAULT);
<span style="color: #a020f0;">if</span> (dset_id &lt;= 0) <span style="color: #a020f0;">return</span> TREXIO_INVALID_ID;
<span style="color: #228b22;">hid_t</span> <span style="color: #a0522d;">fspace_id</span> = H5Dget_space(dset_id);
<span style="color: #a020f0;">if</span> (fspace_id &lt; 0) {
H5Dclose(dset_id);
<span style="color: #a020f0;">return</span> TREXIO_INVALID_ID;
}
// <span style="color: #b22222;">allocate space for the dimensions to be read</span>
<span style="color: #228b22;">hsize_t</span> <span style="color: #a0522d;">ddims</span>[1] = {0};
// <span style="color: #b22222;">get the rank and dimensions of the dataset</span>
<span style="color: #228b22;">int</span> <span style="color: #a0522d;">rrank</span> = H5Sget_simple_extent_dims(fspace_id, ddims, <span style="color: #008b8b;">NULL</span>);
H5Dclose(dset_id);
H5Sclose(fspace_id);
*size_max = (<span style="color: #228b22;">int64_t</span>) ddims[0];
<span style="color: #a020f0;">return</span> TREXIO_SUCCESS;
}
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">trexio_exit_code</span>
<span style="color: #0000ff;">trexio_hdf5_has_$group_dset$</span> (<span style="color: #228b22;">trexio_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>)
{
<span style="color: #a020f0;">if</span> (file == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_INVALID_ARG_1;
<span style="color: #228b22;">trexio_hdf5_t</span>* <span style="color: #a0522d;">f</span> = (<span style="color: #228b22;">trexio_hdf5_t</span>*) file;
<span style="color: #228b22;">herr_t</span> <span style="color: #a0522d;">status</span> = H5LTfind_dataset(f-&gt;$group$_group, $GROUP_DSET$_NAME <span style="color: #8b2252;">"_values"</span>);
/* <span style="color: #b22222;">H5LTfind_dataset returns 1 if dataset exists, 0 otherwise </span>*/
<span style="color: #a020f0;">if</span> (status == 1){
<span style="color: #a020f0;">return</span> TREXIO_SUCCESS;
} <span style="color: #a020f0;">else</span> <span style="color: #a020f0;">if</span> (status == 0) {
<span style="color: #a020f0;">return</span> TREXIO_HAS_NOT;
} <span style="color: #a020f0;">else</span> {
<span style="color: #a020f0;">return</span> TREXIO_FAILURE;
}
}
</pre>
</div>
</div>
</div>
<div id="outline-container-orgf84001c" class="outline-3">
<h3 id="orgf84001c"><span class="section-number-3">1.7</span> Template for HDF5 has/read/write the dataset of strings</h3>
<div class="outline-text-3" id="text-1-7">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">trexio_exit_code</span>
<span style="color: #0000ff;">trexio_hdf5_read_$group_dset$</span> (<span style="color: #228b22;">trexio_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>, <span style="color: #228b22;">char</span>* <span style="color: #a020f0;">const</span> $group_dset$, <span style="color: #a020f0;">const</span> <span style="color: #228b22;">uint32_t</span> <span style="color: #a0522d;">rank</span>, <span style="color: #a020f0;">const</span> <span style="color: #228b22;">uint64_t</span>* <span style="color: #a0522d;">dims</span>, <span style="color: #a020f0;">const</span> <span style="color: #228b22;">uint32_t</span> <span style="color: #a0522d;">max_str_len</span>)
@ -864,9 +1068,9 @@ for the JavaScript code in this tag.
</div>
</div>
<div id="outline-container-org721b617" class="outline-3">
<h3 id="org721b617"><span class="section-number-3">1.7</span> Template for HDF5 has/read/write the string attribute</h3>
<div class="outline-text-3" id="text-1-7">
<div id="outline-container-orge2b8732" class="outline-3">
<h3 id="orge2b8732"><span class="section-number-3">1.8</span> Template for HDF5 has/read/write the string attribute</h3>
<div class="outline-text-3" id="text-1-8">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">trexio_exit_code</span>
<span style="color: #0000ff;">trexio_hdf5_read_$group_str$</span> (<span style="color: #228b22;">trexio_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>, <span style="color: #228b22;">char</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">str</span>, <span style="color: #a020f0;">const</span> <span style="color: #228b22;">uint32_t</span> <span style="color: #a0522d;">max_str_len</span>)
@ -988,11 +1192,258 @@ for the JavaScript code in this tag.
</div>
</div>
</div>
<div id="outline-container-orga0ed807" class="outline-3">
<h3 id="orga0ed807"><span class="section-number-3">1.9</span> Helper functions</h3>
<div class="outline-text-3" id="text-1-9">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">trexio_exit_code</span>
<span style="color: #0000ff;">trexio_hdf5_create_write_dset_sparse</span> (<span style="color: #a020f0;">const</span> <span style="color: #228b22;">hid_t</span> <span style="color: #a0522d;">group_id</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">char</span>* <span style="color: #a0522d;">dset_name</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">hid_t</span> <span style="color: #a0522d;">dtype_id</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">hsize_t</span>* <span style="color: #a0522d;">chunk_dims</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">void</span>* <span style="color: #a0522d;">data_sparse</span>)
{
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int</span> <span style="color: #a0522d;">h5_rank</span> = 1;
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">hsize_t</span> <span style="color: #a0522d;">maxdims</span>[1] = {H5S_UNLIMITED};
<span style="color: #228b22;">hid_t</span> <span style="color: #a0522d;">dspace</span> = H5Screate_simple(h5_rank, chunk_dims, maxdims);
<span style="color: #a020f0;">if</span> (dspace &lt; 0) <span style="color: #a020f0;">return</span> TREXIO_INVALID_ID;
<span style="color: #228b22;">hid_t</span> <span style="color: #a0522d;">prop</span> = H5Pcreate(H5P_DATASET_CREATE);
<span style="color: #a020f0;">if</span> (prop &lt; 0) {
H5Sclose(dspace);
<span style="color: #a020f0;">return</span> TREXIO_INVALID_ID;
}
<span style="color: #228b22;">herr_t</span> <span style="color: #a0522d;">status</span> = H5Pset_chunk(prop, h5_rank, chunk_dims);
<span style="color: #a020f0;">if</span> (status &lt; 0) {
H5Sclose(dspace);
H5Pclose(prop);
<span style="color: #a020f0;">return</span> TREXIO_INVALID_ID;
}
<span style="color: #228b22;">hid_t</span> <span style="color: #a0522d;">dset_id</span> = H5Dcreate(group_id,
dset_name,
dtype_id,
dspace,
H5P_DEFAULT,
prop,
H5P_DEFAULT);
<span style="color: #a020f0;">if</span> (dset_id &lt; 0) {
H5Sclose(dspace);
H5Pclose(prop);
<span style="color: #a020f0;">return</span> TREXIO_INVALID_ID;
}
status = H5Dwrite(dset_id,
dtype_id,
H5S_ALL, H5S_ALL, H5P_DEFAULT,
data_sparse);
H5Sclose(dspace);
H5Pclose(prop);
H5Dclose(dset_id);
<span style="color: #a020f0;">if</span> (status &lt; 0) <span style="color: #a020f0;">return</span> TREXIO_FAILURE;
<span style="color: #a020f0;">return</span> TREXIO_SUCCESS;
}
<span style="color: #228b22;">trexio_exit_code</span>
<span style="color: #0000ff;">trexio_hdf5_open_write_dset_sparse</span> (<span style="color: #a020f0;">const</span> <span style="color: #228b22;">hid_t</span> <span style="color: #a0522d;">group_id</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">char</span>* <span style="color: #a0522d;">dset_name</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">hid_t</span> <span style="color: #a0522d;">dtype_id</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">hsize_t</span>* <span style="color: #a0522d;">chunk_dims</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">hsize_t</span>* <span style="color: #a0522d;">offset_file</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">void</span>* <span style="color: #a0522d;">data_sparse</span>)
{
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int</span> <span style="color: #a0522d;">h5_rank</span> = 1;
<span style="color: #228b22;">hid_t</span> <span style="color: #a0522d;">dset_id</span> = H5Dopen(group_id, dset_name, H5P_DEFAULT);
<span style="color: #a020f0;">if</span> (dset_id &lt;= 0) <span style="color: #a020f0;">return</span> TREXIO_INVALID_ID;
<span style="color: #228b22;">hid_t</span> <span style="color: #a0522d;">fspace</span> = H5Dget_space(dset_id);
<span style="color: #a020f0;">if</span> (fspace &lt; 0) {
H5Dclose(dset_id);
<span style="color: #a020f0;">return</span> TREXIO_INVALID_ID;
}
// <span style="color: #b22222;">allocate space for the dimensions to be read</span>
<span style="color: #228b22;">hsize_t</span> <span style="color: #a0522d;">ddims</span>[1] = {0};
// <span style="color: #b22222;">get the rank and dimensions of the dataset</span>
<span style="color: #228b22;">int</span> <span style="color: #a0522d;">rrank</span> = H5Sget_simple_extent_dims(fspace, ddims, <span style="color: #008b8b;">NULL</span>);
ddims[0] += chunk_dims[0];
// <span style="color: #b22222;">extend the dset size</span>
<span style="color: #228b22;">herr_t</span> <span style="color: #a0522d;">status</span> = H5Dset_extent(dset_id, ddims);
<span style="color: #a020f0;">if</span> (status &lt; 0) {
H5Sclose(fspace);
H5Dclose(dset_id);
<span style="color: #a020f0;">return</span> TREXIO_INVALID_ID;
}
// <span style="color: #b22222;">close and reopen the file dataspace to take into account the extension</span>
H5Sclose(fspace);
fspace = H5Dget_space(dset_id);
<span style="color: #a020f0;">if</span> (fspace &lt; 0) {
H5Dclose(dset_id);
<span style="color: #a020f0;">return</span> TREXIO_INVALID_ID;
}
// <span style="color: #b22222;">select hyperslab to be written using chunk_dims and offset values</span>
status = H5Sselect_hyperslab(fspace, H5S_SELECT_SET, offset_file, <span style="color: #008b8b;">NULL</span>, chunk_dims, <span style="color: #008b8b;">NULL</span>);
<span style="color: #a020f0;">if</span> (status &lt; 0) {
H5Sclose(fspace);
H5Dclose(dset_id);
<span style="color: #a020f0;">return</span> TREXIO_INVALID_ID;
}
// <span style="color: #b22222;">create memory dataspace to write from</span>
<span style="color: #228b22;">hid_t</span> <span style="color: #a0522d;">dspace</span> = H5Screate_simple(h5_rank, chunk_dims, <span style="color: #008b8b;">NULL</span>);
<span style="color: #a020f0;">if</span> (dspace &lt; 0) {
H5Sclose(fspace);
H5Sclose(dspace);
H5Dclose(dset_id);
<span style="color: #a020f0;">return</span> TREXIO_INVALID_ID;
}
status = H5Dwrite(dset_id,
dtype_id,
dspace, fspace, H5P_DEFAULT,
data_sparse);
H5Dclose(dset_id);
H5Sclose(dspace);
H5Sclose(fspace);
<span style="color: #a020f0;">if</span> (status &lt; 0) <span style="color: #a020f0;">return</span> TREXIO_FAILURE;
<span style="color: #a020f0;">return</span> TREXIO_SUCCESS;
}
<span style="color: #228b22;">trexio_exit_code</span>
<span style="color: #0000ff;">trexio_hdf5_open_read_dset_sparse</span> (<span style="color: #a020f0;">const</span> <span style="color: #228b22;">hid_t</span> <span style="color: #a0522d;">group_id</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">char</span>* <span style="color: #a0522d;">dset_name</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">hsize_t</span>* <span style="color: #a0522d;">offset_file</span>,
<span style="color: #228b22;">hsize_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">size_read</span>,
<span style="color: #228b22;">int64_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">eof_read_size</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int</span> <span style="color: #a0522d;">is_index</span>,
<span style="color: #228b22;">void</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">data_sparse</span>
)
{
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int</span> <span style="color: #a0522d;">h5_rank</span> = 1;
// <span style="color: #b22222;">get the dataset handle</span>
<span style="color: #228b22;">hid_t</span> <span style="color: #a0522d;">dset_id</span> = H5Dopen(group_id, dset_name, H5P_DEFAULT);
<span style="color: #a020f0;">if</span> (dset_id &lt;= 0) <span style="color: #a020f0;">return</span> TREXIO_INVALID_ID;
// <span style="color: #b22222;">get the dataspace of the dataset</span>
<span style="color: #228b22;">hid_t</span> <span style="color: #a0522d;">fspace_id</span> = H5Dget_space(dset_id);
<span style="color: #a020f0;">if</span> (fspace_id &lt; 0) {
H5Dclose(dset_id);
<span style="color: #a020f0;">return</span> TREXIO_INVALID_ID;
}
/* <span style="color: #b22222;">get dims of the dset stored in the file to check whether reading with user-provided chunk size</span>
<span style="color: #b22222;"> will reach end of the dataset (i.e. EOF in TEXT back end)</span>
<span style="color: #b22222;"> </span>*/
<span style="color: #228b22;">hsize_t</span> <span style="color: #a0522d;">ddims</span>[1] = {0};
<span style="color: #228b22;">int</span> <span style="color: #a0522d;">rrank</span> = H5Sget_simple_extent_dims(fspace_id, ddims, <span style="color: #008b8b;">NULL</span>);
<span style="color: #228b22;">hsize_t</span> <span style="color: #a0522d;">max_offset</span> = offset_file[0] + size_read[0];
<span style="color: #228b22;">int</span> <span style="color: #a0522d;">is_EOF</span> = 0;
// <span style="color: #b22222;">if max_offset exceed current dim of the dset =&gt; EOF</span>
<span style="color: #a020f0;">if</span> (max_offset &gt; ddims[0]) {
is_EOF = 1;
// <span style="color: #b22222;">lower the value of count to reduce the number of elements which will be read</span>
size_read[0] -= max_offset - ddims[0];
// <span style="color: #b22222;">modified the value of eof_read_size passed by address</span>
<span style="color: #a020f0;">if</span> (eof_read_size != <span style="color: #008b8b;">NULL</span>) *eof_read_size = size_read[0];
}
// <span style="color: #b22222;">special case when reading int indices</span>
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size_ranked</span> = (<span style="color: #228b22;">int64_t</span>) size_read[0];
<span style="color: #228b22;">void</span>* <span style="color: #a0522d;">index_p</span>;
// <span style="color: #b22222;">read the datatype from the dataset and compare with the pre-defined values</span>
<span style="color: #228b22;">hid_t</span> <span style="color: #a0522d;">dtype</span> = H5Dget_type(dset_id);
<span style="color: #a020f0;">if</span> (is_index == 1) {
<span style="color: #a020f0;">if</span> (H5Tequal(dtype, H5T_NATIVE_UINT8) &gt; 0) {
<span style="color: #228b22;">uint8_t</span>* <span style="color: #a0522d;">index</span> = CALLOC(size_ranked, uint8_t);
<span style="color: #a020f0;">if</span> (index == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_ALLOCATION_FAILED;
index_p = index;
} <span style="color: #a020f0;">else</span> <span style="color: #a020f0;">if</span> (H5Tequal(dtype, H5T_NATIVE_UINT16) &gt; 0) {
<span style="color: #228b22;">uint16_t</span>* <span style="color: #a0522d;">index</span> = CALLOC(size_ranked, uint16_t);
<span style="color: #a020f0;">if</span> (index == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_ALLOCATION_FAILED;
index_p = index;
} <span style="color: #a020f0;">else</span> {
index_p = data_sparse;
}
}
<span style="color: #228b22;">herr_t</span> <span style="color: #a0522d;">status</span> = H5Sselect_hyperslab(fspace_id, H5S_SELECT_SET, offset_file, <span style="color: #008b8b;">NULL</span>, size_read, <span style="color: #008b8b;">NULL</span>);
<span style="color: #a020f0;">if</span> (status &lt; 0) {
H5Sclose(fspace_id);
H5Dclose(dset_id);
<span style="color: #a020f0;">if</span> (index_p != data_sparse) FREE(index_p);
<span style="color: #a020f0;">return</span> TREXIO_INVALID_ID;
}
<span style="color: #228b22;">hid_t</span> <span style="color: #a0522d;">memspace_id</span> = H5Screate_simple(h5_rank, size_read, <span style="color: #008b8b;">NULL</span>);
<span style="color: #a020f0;">if</span> (memspace_id &lt; 0) {
H5Sclose(fspace_id);
H5Dclose(dset_id);
<span style="color: #a020f0;">if</span> (index_p != data_sparse) FREE(index_p);
<span style="color: #a020f0;">return</span> TREXIO_INVALID_ID;
}
<span style="color: #a020f0;">if</span> (is_index == 1) {
status = H5Dread(dset_id,
dtype,
memspace_id, fspace_id, H5P_DEFAULT,
index_p);
} <span style="color: #a020f0;">else</span> {
status = H5Dread(dset_id,
dtype,
memspace_id, fspace_id, H5P_DEFAULT,
data_sparse);
}
H5Sclose(fspace_id);
H5Sclose(memspace_id);
H5Dclose(dset_id);
<span style="color: #a020f0;">if</span> (status &lt; 0) {
<span style="color: #a020f0;">if</span> (index_p != data_sparse) FREE(index_p);
<span style="color: #a020f0;">return</span> TREXIO_FAILURE;
}
<span style="color: #a020f0;">if</span> (is_index == 1) {
<span style="color: #a020f0;">if</span> (H5Tequal(dtype, H5T_NATIVE_UINT8) &gt; 0) {
<span style="color: #228b22;">uint8_t</span>* <span style="color: #a0522d;">index</span> = (<span style="color: #228b22;">uint8_t</span>*) index_p;
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">i</span>=0; i&lt;size_ranked; ++i){
((<span style="color: #228b22;">int32_t</span>*)data_sparse)[i] = (<span style="color: #228b22;">int32_t</span>) index[i];
}
FREE(index_p);
} <span style="color: #a020f0;">else</span> <span style="color: #a020f0;">if</span> (H5Tequal(dtype, H5T_NATIVE_UINT16) &gt; 0) {
<span style="color: #228b22;">uint16_t</span>* <span style="color: #a0522d;">index</span> = (<span style="color: #228b22;">uint16_t</span>*) index_p;
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">i</span>=0; i&lt;size_ranked; ++i){
((<span style="color: #228b22;">int32_t</span>*)data_sparse)[i] = (<span style="color: #228b22;">int32_t</span>) index[i];
}
FREE(index_p);
}
}
<span style="color: #a020f0;">if</span> (is_EOF == 1) <span style="color: #a020f0;">return</span> TREXIO_END;
<span style="color: #a020f0;">return</span> TREXIO_SUCCESS;
}
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="postamble" class="status">
<p class="author">Author: TREX-CoE</p>
<p class="date">Created: 2021-12-15 Wed 12:52</p>
<p class="date">Created: 2021-12-17 Fri 16:14</p>
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
</body>

View File

@ -3,7 +3,7 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2021-12-15 Wed 12:52 -->
<!-- 2021-12-17 Fri 16:14 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>TEXT back end</title>
@ -311,36 +311,28 @@ for the JavaScript code in this tag.
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#org2b8d2f5">1. TEXT back end</a>
<li><a href="#orgb6137fc">1. TEXT back end</a>
<ul>
<li><a href="#org6a20649">1.1. Template for group-related structures in text back end</a></li>
<li><a href="#org013ce67">1.2. Template for general structure in text back end</a></li>
<li><a href="#orgc7e54d4">1.3. Initialize function (constant part)</a></li>
<li><a href="#orgd03286c">1.4. Deinitialize function (templated part)</a></li>
<li><a href="#org1895b33">1.5. Template for text read struct</a></li>
<li><a href="#org06643a4">1.6. Template for text flush struct</a></li>
<li><a href="#org114eb05">1.7. Template for text free memory</a></li>
<li><a href="#org2de53e4">1.8. Template for has/read/write the numerical attribute</a></li>
<li><a href="#org8041127">1.9. Template for has/read/write the dataset of numerical data</a></li>
<li><a href="#org7453c6c">1.10. Template for has/read/write the dataset of strings</a></li>
<li><a href="#orgea2ce26">1.11. Template for has/read/write the string attribute</a></li>
<li><a href="#org3b0405f">1.12. RDM struct (hard-coded)</a>
<ul>
<li><a href="#org8804736">1.12.1. Read the complete struct</a></li>
<li><a href="#org547f3a8">1.12.2. Flush the complete struct</a></li>
<li><a href="#orga2fca0b">1.12.3. Free memory</a></li>
<li><a href="#org81035e6">1.12.4. Read/Write the one<sub>e</sub> attribute</a></li>
<li><a href="#org971e9fb">1.12.5. Read/Write the two<sub>e</sub> attribute</a></li>
</ul>
</li>
<li><a href="#org3b6d6e0">1.1. Template for group-related structures in text back end</a></li>
<li><a href="#orgca531b9">1.2. Template for general structure in text back end</a></li>
<li><a href="#orgb9e5edc">1.3. Initialize function (constant part)</a></li>
<li><a href="#org85aea02">1.4. Deinitialize function (templated part)</a></li>
<li><a href="#orgcc6ff55">1.5. Template for text read struct</a></li>
<li><a href="#orge4ef072">1.6. Template for text flush struct</a></li>
<li><a href="#org50aeb6d">1.7. Template for text free memory</a></li>
<li><a href="#orgd9d26b4">1.8. Template for has/read/write the numerical attribute</a></li>
<li><a href="#orgd38d1f4">1.9. Template for has/read/write the dataset of numerical data</a></li>
<li><a href="#org4ee4f98">1.10. Template for has/read/write the dataset of strings</a></li>
<li><a href="#orge83df4c">1.11. Template for has/read/write the string attribute</a></li>
<li><a href="#org71ffd4f">1.12. Template for has/read/write the dataset of sparse data</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div id="outline-container-org2b8d2f5" class="outline-2">
<h2 id="org2b8d2f5"><span class="section-number-2">1</span> TEXT back end</h2>
<div id="outline-container-orgb6137fc" class="outline-2">
<h2 id="orgb6137fc"><span class="section-number-2">1</span> TEXT back end</h2>
<div class="outline-text-2" id="text-1">
<p>
The "file" produced by the text back end is a directory with one
@ -361,8 +353,8 @@ The file is written when closed, or when the flush function is called.
</p>
</div>
<div id="outline-container-org6a20649" class="outline-3">
<h3 id="org6a20649"><span class="section-number-3">1.1</span> Template for group-related structures in text back end</h3>
<div id="outline-container-org3b6d6e0" class="outline-3">
<h3 id="org3b6d6e0"><span class="section-number-3">1.1</span> Template for group-related structures in text back end</h3>
<div class="outline-text-3" id="text-1-1">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #a020f0;">typedef</span> <span style="color: #a020f0;">struct</span> $group$_s {
@ -381,26 +373,13 @@ The file is written when closed, or when the flush function is called.
</div>
</div>
<div id="outline-container-org013ce67" class="outline-3">
<h3 id="org013ce67"><span class="section-number-3">1.2</span> Template for general structure in text back end</h3>
<div id="outline-container-orgca531b9" class="outline-3">
<h3 id="orgca531b9"><span class="section-number-3">1.2</span> Template for general structure in text back end</h3>
<div class="outline-text-3" id="text-1-2">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #a020f0;">typedef</span> <span style="color: #a020f0;">struct</span> <span style="color: #228b22;">rdm_s</span> {
<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">dim_one_e</span>;
<span style="color: #228b22;">uint32_t</span> <span style="color: #a0522d;">to_flush</span>;
<span style="color: #228b22;">uint32_t</span> <span style="color: #a0522d;">padding</span>;
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">one_e</span>;
<span style="color: #228b22;">char</span> <span style="color: #a0522d;">file_name</span>[TREXIO_MAX_FILENAME_LENGTH];
<span style="color: #228b22;">char</span> <span style="color: #a0522d;">two_e_file_name</span>[TREXIO_MAX_FILENAME_LENGTH];
} <span style="color: #228b22;">rdm_t</span>;
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #a020f0;">typedef</span> <span style="color: #a020f0;">struct</span> <span style="color: #228b22;">trexio_text_s</span> {
<span style="color: #228b22;">trexio_t</span> <span style="color: #a0522d;">parent</span> ;
$group$_t* $group$;
<span style="color: #228b22;">rdm_t</span>* <span style="color: #a0522d;">rdm</span>;
<span style="color: #228b22;">int</span> <span style="color: #a0522d;">lock_file</span>;
} <span style="color: #228b22;">trexio_text_t</span>;
</pre>
@ -408,8 +387,8 @@ The file is written when closed, or when the flush function is called.
</div>
</div>
<div id="outline-container-orgc7e54d4" class="outline-3">
<h3 id="orgc7e54d4"><span class="section-number-3">1.3</span> Initialize function (constant part)</h3>
<div id="outline-container-orgb9e5edc" class="outline-3">
<h3 id="orgb9e5edc"><span class="section-number-3">1.3</span> Initialize function (constant part)</h3>
<div class="outline-text-3" id="text-1-3">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">trexio_exit_code</span>
@ -540,8 +519,8 @@ The file is written when closed, or when the flush function is called.
</div>
</div>
<div id="outline-container-orgd03286c" class="outline-3">
<h3 id="orgd03286c"><span class="section-number-3">1.4</span> Deinitialize function (templated part)</h3>
<div id="outline-container-org85aea02" class="outline-3">
<h3 id="org85aea02"><span class="section-number-3">1.4</span> Deinitialize function (templated part)</h3>
<div class="outline-text-3" id="text-1-4">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">trexio_exit_code</span>
@ -555,9 +534,6 @@ The file is written when closed, or when the flush function is called.
/* <span style="color: #b22222;">Error handling for this call is added by the generator </span>*/
rc = trexio_text_free_$group$( (<span style="color: #228b22;">trexio_text_t</span>*) file);
rc = trexio_text_free_rdm( (<span style="color: #228b22;">trexio_text_t</span>*) file);
<span style="color: #a020f0;">if</span> (rc != TREXIO_SUCCESS) <span style="color: #a020f0;">return</span> rc;
<span style="color: #a020f0;">return</span> TREXIO_SUCCESS;
}
@ -566,8 +542,8 @@ The file is written when closed, or when the flush function is called.
</div>
</div>
<div id="outline-container-org1895b33" class="outline-3">
<h3 id="org1895b33"><span class="section-number-3">1.5</span> Template for text read struct</h3>
<div id="outline-container-orgcc6ff55" class="outline-3">
<h3 id="orgcc6ff55"><span class="section-number-3">1.5</span> Template for text read struct</h3>
<div class="outline-text-3" id="text-1-5">
<div class="org-src-container">
<pre class="src src-c">$group$_t*
@ -697,7 +673,7 @@ trexio_text_read_$group$ (<span style="color: #228b22;">trexio_text_t</span>* <s
<span style="color: #a020f0;">return</span> <span style="color: #008b8b;">NULL</span>;
}
rc = fscanf(f, <span style="color: #8b2252;">"%$group_num_std_dtype_in$"</span>, &amp;($group$-&gt;$group_num$));
rc = fscanf(f, <span style="color: #8b2252;">"%$group_num_format_scanf$"</span>, &amp;($group$-&gt;$group_num$));
assert(!(rc != 1));
<span style="color: #a020f0;">if</span> (rc != 1) {
FREE(buffer);
@ -785,7 +761,7 @@ trexio_text_read_$group$ (<span style="color: #228b22;">trexio_text_t</span>* <s
}
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;size_$group_dset$ ; ++i) {
rc = fscanf(f, <span style="color: #8b2252;">"%$group_dset_std_dtype_in$"</span>, &amp;($group$-&gt;$group_dset$[i]));
rc = fscanf(f, <span style="color: #8b2252;">"%$group_dset_format_scanf$"</span>, &amp;($group$-&gt;$group_dset$[i]));
assert(!(rc != 1));
<span style="color: #a020f0;">if</span> (rc != 1) {
FREE(buffer);
@ -821,7 +797,7 @@ trexio_text_read_$group$ (<span style="color: #228b22;">trexio_text_t</span>* <s
}
/* <span style="color: #b22222;">WARNING: this tmp array allows to avoid allocation of space for each element of array of string</span>
<span style="color: #b22222;"> , BUT it's size has to be number_of_str*max_len_str where max_len_str is somewhat arbitrary, e.g. 32.</span>
<span style="color: #b22222;"> BUT it's size has to be number_of_str*max_len_str where max_len_str is somewhat arbitrary, e.g. 32.</span>
<span style="color: #b22222;"> </span>*/
<span style="color: #228b22;">char</span>* <span style="color: #a0522d;">tmp_$group_dset$</span>;
tmp_$group_dset$ = CALLOC(size_$group_dset$*32, <span style="color: #228b22;">char</span>);
@ -861,8 +837,8 @@ trexio_text_read_$group$ (<span style="color: #228b22;">trexio_text_t</span>* <s
</div>
</div>
<div id="outline-container-org06643a4" class="outline-3">
<h3 id="org06643a4"><span class="section-number-3">1.6</span> Template for text flush struct</h3>
<div id="outline-container-orge4ef072" class="outline-3">
<h3 id="orge4ef072"><span class="section-number-3">1.6</span> Template for text flush struct</h3>
<div class="outline-text-3" id="text-1-6">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">trexio_exit_code</span>
@ -899,7 +875,7 @@ trexio_text_read_$group$ (<span style="color: #228b22;">trexio_text_t</span>* <s
// <span style="color: #b22222;">START REPEAT GROUP_NUM</span>
fprintf(f, <span style="color: #8b2252;">"$group_num$_isSet %u \n"</span>, $group$-&gt;$group_num$_isSet);
<span style="color: #a020f0;">if</span> ($group$-&gt;$group_num$_isSet == <span style="color: #008b8b;">true</span>) fprintf(f, <span style="color: #8b2252;">"$group_num$ %$group_num_std_dtype_out$ \n"</span>, $group$-&gt;$group_num$);
<span style="color: #a020f0;">if</span> ($group$-&gt;$group_num$_isSet == <span style="color: #008b8b;">true</span>) fprintf(f, <span style="color: #8b2252;">"$group_num$ %$group_num_format_printf$ \n"</span>, $group$-&gt;$group_num$);
// <span style="color: #b22222;">END REPEAT GROUP_NUM</span>
// <span style="color: #b22222;">START REPEAT GROUP_ATTR_STR</span>
@ -913,7 +889,7 @@ trexio_text_read_$group$ (<span style="color: #228b22;">trexio_text_t</span>* <s
fprintf(f, <span style="color: #8b2252;">"$group_dset$\n"</span>);
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;size_$group_dset$ ; ++i) {
fprintf(f, <span style="color: #8b2252;">"%$group_dset_std_dtype_out$\n"</span>, $group$-&gt;$group_dset$[i]);
fprintf(f, <span style="color: #8b2252;">"%$group_dset_format_printf$\n"</span>, $group$-&gt;$group_dset$[i]);
}
// <span style="color: #b22222;">END REPEAT GROUP_DSET_ALL</span>
@ -927,8 +903,8 @@ trexio_text_read_$group$ (<span style="color: #228b22;">trexio_text_t</span>* <s
</div>
</div>
<div id="outline-container-org114eb05" class="outline-3">
<h3 id="org114eb05"><span class="section-number-3">1.7</span> Template for text free memory</h3>
<div id="outline-container-org50aeb6d" class="outline-3">
<h3 id="org50aeb6d"><span class="section-number-3">1.7</span> Template for text free memory</h3>
<div class="outline-text-3" id="text-1-7">
<p>
Memory is allocated when reading. The following function frees memory.
@ -973,8 +949,8 @@ Memory is allocated when reading. The following function frees memory.
</div>
</div>
<div id="outline-container-org2de53e4" class="outline-3">
<h3 id="org2de53e4"><span class="section-number-3">1.8</span> Template for has/read/write the numerical attribute</h3>
<div id="outline-container-orgd9d26b4" class="outline-3">
<h3 id="orgd9d26b4"><span class="section-number-3">1.8</span> Template for has/read/write the numerical attribute</h3>
<div class="outline-text-3" id="text-1-8">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">trexio_exit_code</span>
@ -1037,8 +1013,8 @@ Memory is allocated when reading. The following function frees memory.
</div>
</div>
<div id="outline-container-org8041127" class="outline-3">
<h3 id="org8041127"><span class="section-number-3">1.9</span> Template for has/read/write the dataset of numerical data</h3>
<div id="outline-container-orgd38d1f4" class="outline-3">
<h3 id="orgd38d1f4"><span class="section-number-3">1.9</span> Template for has/read/write the dataset of numerical data</h3>
<div class="outline-text-3" id="text-1-9">
<p>
The <code>group_dset</code> array is assumed allocated with the appropriate size.
@ -1134,8 +1110,8 @@ The <code>group_dset</code> array is assumed allocated with the appropriate size
</div>
</div>
</div>
<div id="outline-container-org7453c6c" class="outline-3">
<h3 id="org7453c6c"><span class="section-number-3">1.10</span> Template for has/read/write the dataset of strings</h3>
<div id="outline-container-org4ee4f98" class="outline-3">
<h3 id="org4ee4f98"><span class="section-number-3">1.10</span> Template for has/read/write the dataset of strings</h3>
<div class="outline-text-3" id="text-1-10">
<p>
The <code>group_dset</code> array is assumed allocated with the appropriate size.
@ -1236,8 +1212,8 @@ The <code>group_dset</code> array is assumed allocated with the appropriate size
</div>
</div>
</div>
<div id="outline-container-orgea2ce26" class="outline-3">
<h3 id="orgea2ce26"><span class="section-number-3">1.11</span> Template for has/read/write the string attribute</h3>
<div id="outline-container-orge83df4c" class="outline-3">
<h3 id="orge83df4c"><span class="section-number-3">1.11</span> Template for has/read/write the string attribute</h3>
<div class="outline-text-3" id="text-1-11">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">trexio_exit_code</span>
@ -1311,355 +1287,277 @@ The <code>group_dset</code> array is assumed allocated with the appropriate size
</div>
</div>
</div>
<div id="outline-container-org3b0405f" class="outline-3">
<h3 id="org3b0405f"><span class="section-number-3">1.12</span> RDM struct (hard-coded)</h3>
<div id="outline-container-org71ffd4f" class="outline-3">
<h3 id="org71ffd4f"><span class="section-number-3">1.12</span> Template for has/read/write the dataset of sparse data</h3>
<div class="outline-text-3" id="text-1-12">
</div>
<div id="outline-container-org8804736" class="outline-4">
<h4 id="org8804736"><span class="section-number-4">1.12.1</span> Read the complete struct</h4>
<div class="outline-text-4" id="text-1-12-1">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">rdm_t</span>* <span style="color: #0000ff;">trexio_text_read_rdm</span>(<span style="color: #228b22;">trexio_text_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>);
</pre>
</div>
<p>
Each sparse array is stored in a separate <code>.txt</code> file due to the fact that sparse I/O has to be decoupled
from conventional write/read/flush behaviour of the TEXT back end. Chunks are used to read/write sparse data
to prevent memory overflow. Chunks have a given <code>int64_t size</code>
(size specifies the number of sparse data items, e.g. integrals).
</p>
<p>
User provides indices and values of the sparse array as two separate variables.
</p>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">rdm_t</span>* <span style="color: #0000ff;">trexio_text_read_rdm</span>(<span style="color: #228b22;">trexio_text_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>) {
<span style="color: #a020f0;">if</span> (file == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> <span style="color: #008b8b;">NULL</span>;
<pre class="src src-c"><span style="color: #228b22;">trexio_exit_code</span> <span style="color: #0000ff;">trexio_text_write_$group_dset$</span>(<span style="color: #228b22;">trexio_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">offset_file</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size_max</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size_start</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int32_t</span>* <span style="color: #a0522d;">index_sparse</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">value_sparse</span>)
{
<span style="color: #a020f0;">if</span> (file == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_INVALID_ARG_1;
<span style="color: #a020f0;">if</span> (file-&gt;rdm != <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> file-&gt;rdm;
/* <span style="color: #b22222;">Build the name of the file with sparse data</span>*/
/* <span style="color: #b22222;">The $group_dset$.txt is limited to 256 symbols for the moment. What are the chances that it will exceed? </span>*/
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">char</span> $group_dset$_file_name[256] = <span style="color: #8b2252;">"/$group_dset$.txt"</span>;
/* <span style="color: #b22222;">The full path to the destination TXT file with sparse data. This will include TREXIO directory name. </span>*/
<span style="color: #228b22;">char</span> <span style="color: #a0522d;">file_full_path</span>[TREXIO_MAX_FILENAME_LENGTH];
/* <span style="color: #b22222;">Allocate the data structure </span>*/
<span style="color: #228b22;">rdm_t</span>* <span style="color: #a0522d;">rdm</span> = MALLOC(rdm_t);
assert (rdm != <span style="color: #008b8b;">NULL</span>);
/* <span style="color: #b22222;">Copy directory name in file_full_path </span>*/
strncpy (file_full_path, file-&gt;file_name, TREXIO_MAX_FILENAME_LENGTH);
/* <span style="color: #b22222;">Append name of the file with sparse data </span>*/
strncat (file_full_path, $group_dset$_file_name,
TREXIO_MAX_FILENAME_LENGTH-strlen($group_dset$_file_name));
rdm-&gt;one_e = <span style="color: #008b8b;">NULL</span>;
rdm-&gt;two_e_file_name[0] = <span style="color: #8b2252;">'\0'</span>;
rdm-&gt;to_flush = 0;
/* <span style="color: #b22222;">Open the file in "a" (append) mode to guarantee that no truncation happens upon consecutive writes </span>*/
<span style="color: #228b22;">FILE</span>* <span style="color: #a0522d;">f</span> = fopen(file_full_path, <span style="color: #8b2252;">"a"</span>);
<span style="color: #a020f0;">if</span>(f == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_FILE_ERROR;
/* <span style="color: #b22222;">Try to open the file. If the file does not exist, return </span>*/
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">char</span>* <span style="color: #a0522d;">rdm_file_name</span> = <span style="color: #8b2252;">"/rdm.txt"</span>;
strncpy (rdm-&gt;file_name, file-&gt;parent.file_name, TREXIO_MAX_FILENAME_LENGTH);
/* <span style="color: #b22222;">Specify the line length in order to offset properly. For example, for 4-index quantities</span>
<span style="color: #b22222;"> the line_length is 69 because 10 per index + 4 spaces + 24 for floating point value + 1 for the new line char.</span>
<span style="color: #b22222;"> CURRENTLY NO OFFSET IS USED WHEN WRITING !</span>
<span style="color: #b22222;"> </span>*/
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">line_length</span> = 0L;
<span style="color: #228b22;">char</span> <span style="color: #a0522d;">format_str</span>[256] = <span style="color: #8b2252;">"\0"</span>;
strncat (rdm-&gt;file_name, rdm_file_name,
TREXIO_MAX_FILENAME_LENGTH-strlen(rdm_file_name));
<span style="color: #a020f0;">if</span> (rdm-&gt;file_name[TREXIO_MAX_FILENAME_LENGTH-1] != <span style="color: #8b2252;">'\0'</span>) {
FREE(rdm);
<span style="color: #a020f0;">return</span> <span style="color: #008b8b;">NULL</span>;
/* <span style="color: #b22222;">Determine the optimal type for storing indices depending on the size_max (usually mo_num or ao_num) </span>*/
<span style="color: #a020f0;">if</span> (size_max &lt; UINT8_MAX) {
line_length = $sparse_line_length_8$; // <span style="color: #b22222;">41 for 4 indices</span>
strncpy(format_str, $sparse_format_printf_8$, 256);
} <span style="color: #a020f0;">else</span> <span style="color: #a020f0;">if</span> (size_max &lt; UINT16_MAX) {
line_length = $sparse_line_length_16$; // <span style="color: #b22222;">49 for 4 indices</span>
strncpy(format_str, $sparse_format_printf_16$, 256);
} <span style="color: #a020f0;">else</span> {
line_length = $sparse_line_length_32$; //<span style="color: #b22222;">69 for 4 indices</span>
strncpy(format_str, $sparse_format_printf_32$, 256);
}
/* <span style="color: #b22222;">If the file exists, read it </span>*/
<span style="color: #228b22;">FILE</span>* <span style="color: #a0522d;">f</span> = fopen(rdm-&gt;file_name,<span style="color: #8b2252;">"r"</span>);
<span style="color: #a020f0;">if</span> (f != <span style="color: #008b8b;">NULL</span>) {
strncat(format_str, <span style="color: #8b2252;">"\n"</span>, 2);
/* <span style="color: #b22222;">Find size of file to allocate the max size of the string buffer </span>*/
fseek(f, 0L, SEEK_END);
<span style="color: #228b22;">size_t</span> <span style="color: #a0522d;">sz</span> = ftell(f);
fseek(f, 0L, SEEK_SET);
sz = (sz &lt; 1024) ? (1024) : (sz);
<span style="color: #228b22;">char</span>* <span style="color: #a0522d;">buffer</span> = CALLOC(sz, <span style="color: #228b22;">char</span>);
/* <span style="color: #b22222;">Get the starting position of the IO stream to be written in the .size file.</span>
<span style="color: #b22222;"> This is error-prone due to the fact that for large files (&gt;2 GB) in 32-bit systems ftell will fail.</span>
<span style="color: #b22222;"> One can use ftello function which is adapted for large files.</span>
<span style="color: #b22222;"> For now, we can use front-end-provided size_start, which has been checked for INT64_MAX overflow.</span>
<span style="color: #b22222;"> </span>*/
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">io_start_pos</span> = size_start * line_length;
/* <span style="color: #b22222;">Read the dimensioning variables </span>*/
/* <span style="color: #b22222;">Write the data in the file and check the return code of fprintf to verify that &gt; 0 bytes have been written </span>*/
<span style="color: #228b22;">int</span> <span style="color: #a0522d;">rc</span>;
rc = fscanf(f, <span style="color: #8b2252;">"%1023s"</span>, buffer);
assert (rc == 1);
assert (strcmp(buffer, <span style="color: #8b2252;">"dim_one_e"</span>) == 0);
rc = fscanf(f, <span style="color: #8b2252;">"%"</span> SCNu64 <span style="color: #8b2252;">""</span>, &amp;(rdm-&gt;dim_one_e));
assert (rc == 1);
/* <span style="color: #b22222;">Allocate arrays </span>*/
rdm-&gt;one_e = CALLOC(rdm-&gt;dim_one_e, <span style="color: #228b22;">double</span>);
assert (rdm-&gt;one_e != <span style="color: #008b8b;">NULL</span>);
/* <span style="color: #b22222;">Read one_e </span>*/
rc = fscanf(f, <span style="color: #8b2252;">"%1023s"</span>, buffer);
assert (rc == 1);
assert (strcmp(buffer, <span style="color: #8b2252;">"one_e"</span>) == 0);
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;rdm-&gt;dim_one_e; ++i) {
rc = fscanf(f, <span style="color: #8b2252;">"%lf"</span>, &amp;(rdm-&gt;one_e[i]));
assert (rc == 1);
}
/* <span style="color: #b22222;">Read two_e </span>*/
rc = fscanf(f, <span style="color: #8b2252;">"%1023s"</span>, buffer);
assert (rc == 1);
assert (strcmp(buffer, <span style="color: #8b2252;">"two_e_file_name"</span>) == 0);
rc = fscanf(f, <span style="color: #8b2252;">"%1023s"</span>, buffer);
assert (rc == 1);
strncpy(rdm-&gt;two_e_file_name, buffer, 1024);
<span style="color: #a020f0;">if</span> (rdm-&gt;two_e_file_name[TREXIO_MAX_FILENAME_LENGTH-1] != <span style="color: #8b2252;">'\0'</span>) {
FREE(buffer);
FREE(rdm-&gt;one_e);
FREE(rdm);
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">i</span>=0UL; i&lt;size; ++i) {
rc = fprintf(f, format_str,
$group_dset_sparse_indices_printf$,
*(value_sparse + i));
<span style="color: #a020f0;">if</span>(rc &lt;= 0) {
fclose(f);
<span style="color: #a020f0;">return</span> <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> TREXIO_FAILURE;
}
}
FREE(buffer);
fclose(f);
f = <span style="color: #008b8b;">NULL</span>;
}
file-&gt;rdm = rdm ;
<span style="color: #a020f0;">return</span> rdm;
}
</pre>
</div>
</div>
</div>
/* <span style="color: #b22222;">Close the TXT file </span>*/
rc = fclose(f);
<span style="color: #a020f0;">if</span> (rc != 0) <span style="color: #a020f0;">return</span> TREXIO_FILE_ERROR;
<div id="outline-container-org547f3a8" class="outline-4">
<h4 id="org547f3a8"><span class="section-number-4">1.12.2</span> Flush the complete struct</h4>
<div class="outline-text-4" id="text-1-12-2">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">trexio_exit_code</span> <span style="color: #0000ff;">trexio_text_flush_rdm</span>(<span style="color: #228b22;">trexio_text_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>);
</pre>
</div>
/* <span style="color: #b22222;">Append .size to the file_full_path in order to write additional info about the written buffer of data </span>*/
strncat(file_full_path, <span style="color: #8b2252;">".size"</span>, 6);
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">trexio_exit_code</span> <span style="color: #0000ff;">trexio_text_flush_rdm</span>(<span style="color: #228b22;">trexio_text_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>) {
<span style="color: #a020f0;">if</span> (file == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_INVALID_ARG_1;
/* <span style="color: #b22222;">Open the new file in "a" (append) mode to append info about the buffer that has been just written </span>*/
<span style="color: #228b22;">FILE</span> *<span style="color: #a0522d;">f_wSize</span> = fopen(file_full_path, <span style="color: #8b2252;">"a"</span>);
<span style="color: #a020f0;">if</span> (f_wSize == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_FILE_ERROR;
<span style="color: #a020f0;">if</span> (file-&gt;parent.mode == <span style="color: #8b2252;">'r'</span>) <span style="color: #a020f0;">return</span> TREXIO_READONLY;
<span style="color: #228b22;">rdm_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">rdm</span> = file-&gt;rdm;
<span style="color: #a020f0;">if</span> (rdm == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_SUCCESS;
<span style="color: #a020f0;">if</span> (rdm-&gt;to_flush == 0) <span style="color: #a020f0;">return</span> TREXIO_SUCCESS;
<span style="color: #228b22;">FILE</span>* <span style="color: #a0522d;">f</span> = fopen(rdm-&gt;file_name,<span style="color: #8b2252;">"w"</span>);
assert (f != <span style="color: #008b8b;">NULL</span>);
/* <span style="color: #b22222;">Write the dimensioning variables </span>*/
fprintf(f, <span style="color: #8b2252;">"num %"</span> PRIu64 <span style="color: #8b2252;">"\n"</span>, rdm-&gt;dim_one_e);
/* <span style="color: #b22222;">Write arrays </span>*/
fprintf(f, <span style="color: #8b2252;">"one_e\n"</span>);
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">i</span>=0 ; i&lt; rdm-&gt;dim_one_e; ++i) {
fprintf(f, <span style="color: #8b2252;">"%lf\n"</span>, rdm-&gt;one_e[i]);
/* <span style="color: #b22222;">Write the buffer_size </span>*/
rc = fprintf(f_wSize, <span style="color: #8b2252;">"%"</span> PRId64 <span style="color: #8b2252;">" %"</span> PRId64 <span style="color: #8b2252;">"\n"</span>, size, io_start_pos);
<span style="color: #a020f0;">if</span> (rc &lt;= 0) {
fclose(f_wSize);
<span style="color: #a020f0;">return</span> TREXIO_FAILURE;
}
fprintf(f, <span style="color: #8b2252;">"two_e_file_name\n"</span>);
fprintf(f, <span style="color: #8b2252;">"%s\n"</span>, rdm-&gt;two_e_file_name);
/* <span style="color: #b22222;">Close the TXT file </span>*/
rc = fclose(f_wSize);
<span style="color: #a020f0;">if</span> (rc != 0) <span style="color: #a020f0;">return</span> TREXIO_FILE_ERROR;
fclose(f);
rdm-&gt;to_flush = 0;
/* <span style="color: #b22222;">Exit upon success </span>*/
<span style="color: #a020f0;">return</span> TREXIO_SUCCESS;
}
</pre>
</div>
</div>
</div>
<div id="outline-container-orga2fca0b" class="outline-4">
<h4 id="orga2fca0b"><span class="section-number-4">1.12.3</span> Free memory</h4>
<div class="outline-text-4" id="text-1-12-3">
<p>
Memory is allocated when reading. The followig function frees memory.
</p>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">trexio_exit_code</span> <span style="color: #0000ff;">trexio_text_free_rdm</span>(<span style="color: #228b22;">trexio_text_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">trexio_exit_code</span> <span style="color: #0000ff;">trexio_text_free_rdm</span>(<span style="color: #228b22;">trexio_text_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>) {
<span style="color: #a020f0;">if</span> (file == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_INVALID_ARG_1;
<span style="color: #a020f0;">if</span> (file-&gt;parent.mode != <span style="color: #8b2252;">'r'</span>) {
<span style="color: #228b22;">trexio_exit_code</span> <span style="color: #a0522d;">rc</span> = trexio_text_flush_rdm(file);
<span style="color: #a020f0;">if</span> (rc != TREXIO_SUCCESS) <span style="color: #a020f0;">return</span> TREXIO_FAILURE;
}
<span style="color: #228b22;">rdm_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">rdm</span> = file-&gt;rdm;
<span style="color: #a020f0;">if</span> (rdm == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_SUCCESS;
<span style="color: #a020f0;">if</span> (rdm-&gt;one_e != <span style="color: #008b8b;">NULL</span>) {
FREE (rdm-&gt;one_e);
}
free (rdm);
file-&gt;rdm = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> TREXIO_SUCCESS;
}
</pre>
</div>
</div>
</div>
<div id="outline-container-org81035e6" class="outline-4">
<h4 id="org81035e6"><span class="section-number-4">1.12.4</span> Read/Write the one<sub>e</sub> attribute</h4>
<div class="outline-text-4" id="text-1-12-4">
<p>
The <code>one_e</code> array is assumed allocated with the appropriate size.
</p>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">trexio_exit_code</span>
<span style="color: #0000ff;">trexio_text_read_rdm_one_e</span>(<span style="color: #228b22;">trexio_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">one_e</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">dim_one_e</span>);
<span style="color: #228b22;">trexio_exit_code</span>
<span style="color: #0000ff;">trexio_text_write_rdm_one_e</span>(<span style="color: #228b22;">trexio_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">one_e</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">dim_one_e</span>);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">trexio_exit_code</span>
<span style="color: #0000ff;">trexio_text_read_rdm_one_e</span>(<span style="color: #228b22;">trexio_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">one_e</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">dim_one_e</span>)
<pre class="src src-c"><span style="color: #228b22;">trexio_exit_code</span> <span style="color: #0000ff;">trexio_text_read_$group_dset$</span>(<span style="color: #228b22;">trexio_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">offset_file</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size_max</span>,
<span style="color: #228b22;">int64_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">eof_read_size</span>,
<span style="color: #228b22;">int32_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">index_sparse</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">value_sparse</span>)
{
<span style="color: #a020f0;">if</span> (file == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_INVALID_ARG_1;
<span style="color: #a020f0;">if</span> (one_e == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_INVALID_ARG_2;
<span style="color: #a020f0;">if</span> (eof_read_size == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_INVALID_ARG_5;
<span style="color: #228b22;">rdm_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">rdm</span> = trexio_text_read_rdm((<span style="color: #228b22;">trexio_text_t</span>*) file);
<span style="color: #a020f0;">if</span> (rdm == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_FAILURE;
/* <span style="color: #b22222;">Build the name of the file with sparse data.</span>
<span style="color: #b22222;"> The $group_dset$.txt is limited to 256 symbols for the moment. What are the chances that it will exceed?</span>
<span style="color: #b22222;"> </span>*/
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">char</span> $group_dset$_file_name[256] = <span style="color: #8b2252;">"/$group_dset$.txt"</span>;
/* <span style="color: #b22222;">The full path to the destination TXT file with sparse data. This will include TREXIO directory name. </span>*/
<span style="color: #228b22;">char</span> <span style="color: #a0522d;">file_full_path</span>[TREXIO_MAX_FILENAME_LENGTH];
<span style="color: #a020f0;">if</span> (dim_one_e != rdm-&gt;dim_one_e) <span style="color: #a020f0;">return</span> TREXIO_INVALID_ARG_3;
/* <span style="color: #b22222;">Copy directory name in file_full_path </span>*/
strncpy (file_full_path, file-&gt;file_name, TREXIO_MAX_FILENAME_LENGTH);
/* <span style="color: #b22222;">Append name of the file with sparse data </span>*/
strncat (file_full_path, $group_dset$_file_name,
TREXIO_MAX_FILENAME_LENGTH-strlen($group_dset$_file_name));
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;dim_one_e ; ++i) {
one_e[i] = rdm-&gt;one_e[i];
/* <span style="color: #b22222;">Open the file in "r" (read) mode to guarantee that no truncation happens upon consecutive reads </span>*/
<span style="color: #228b22;">FILE</span>* <span style="color: #a0522d;">f</span> = fopen(file_full_path, <span style="color: #8b2252;">"r"</span>);
<span style="color: #a020f0;">if</span>(f == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_FILE_ERROR;
/* <span style="color: #b22222;">Specify the line length in order to offset properly. For example, for 4-index quantities</span>
<span style="color: #b22222;"> the line_length is 69 because 10 per index + 4 spaces + 24 for floating point value + 1 for the new line char</span>
<span style="color: #b22222;"> </span>*/
<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">line_length</span> = 0UL;
/* <span style="color: #b22222;">Determine the line length depending on the size_max (usually mo_num or ao_num) </span>*/
<span style="color: #a020f0;">if</span> (size_max &lt; UINT8_MAX) {
line_length = $sparse_line_length_8$; // <span style="color: #b22222;">41 for 4 indices</span>
} <span style="color: #a020f0;">else</span> <span style="color: #a020f0;">if</span> (size_max &lt; UINT16_MAX) {
line_length = $sparse_line_length_16$; // <span style="color: #b22222;">49 for 4 indices</span>
} <span style="color: #a020f0;">else</span> {
line_length = $sparse_line_length_32$; //<span style="color: #b22222;">69 for 4 indices</span>
}
<span style="color: #a020f0;">return</span> TREXIO_SUCCESS;
}
/* <span style="color: #b22222;">Offset in the file according to the provided value of offset_file and optimal line_length </span>*/
fseek(f, (<span style="color: #228b22;">long</span>) <span style="color: #228b22;">offset_file</span> * <span style="color: #a0522d;">line_length</span>, <span style="color: #a0522d;">SEEK_SET</span>);
/* <span style="color: #b22222;">Read the data from the file and check the return code of fprintf to verify that &gt; 0 bytes have been read or reached EOF </span>*/
<span style="color: #228b22;">int</span> <span style="color: #a0522d;">rc</span>;
<span style="color: #228b22;">char</span> <span style="color: #a0522d;">buffer</span>[1024];
<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">count</span> = 0UL;
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">i</span>=0UL; i&lt;size; ++i) {
<span style="color: #228b22;">trexio_exit_code</span>
<span style="color: #0000ff;">trexio_text_write_rdm_one_e</span>(<span style="color: #228b22;">trexio_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">one_e</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">dim_one_e</span>)
{
<span style="color: #a020f0;">if</span> (file == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_INVALID_ARG_1;
<span style="color: #a020f0;">if</span> (one_e == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_INVALID_ARG_2;
<span style="color: #a020f0;">if</span> (file-&gt;mode != <span style="color: #8b2252;">'r'</span>) <span style="color: #a020f0;">return</span> TREXIO_READONLY;
memset(buffer,0,<span style="color: #a020f0;">sizeof</span>(buffer));
<span style="color: #228b22;">rdm_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">rdm</span> = trexio_text_read_rdm((<span style="color: #228b22;">trexio_text_t</span>*) file);
<span style="color: #a020f0;">if</span> (rdm == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_FAILURE;
<span style="color: #a020f0;">if</span>(fgets(buffer, 1023, f) == <span style="color: #008b8b;">NULL</span>){
rdm-&gt;dim_one_e = dim_one_e;
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;dim_one_e ; ++i) {
rdm-&gt;one_e[i] = one_e[i];
}
rdm-&gt;to_flush = 1;
<span style="color: #a020f0;">return</span> TREXIO_SUCCESS;
}
</pre>
</div>
</div>
</div>
<div id="outline-container-org971e9fb" class="outline-4">
<h4 id="org971e9fb"><span class="section-number-4">1.12.5</span> Read/Write the two<sub>e</sub> attribute</h4>
<div class="outline-text-4" id="text-1-12-5">
<p>
<code>two_e</code> is a sparse data structure, which can be too large to fit
in memory. So we provide functions to read and write it by
chunks.
In the text back end, the easiest way to do it is to create a
file for each sparse float structure.
</p>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">trexio_exit_code</span>
<span style="color: #0000ff;">trexio_text_buffered_read_rdm_two_e</span>(<span style="color: #228b22;">trexio_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">offset</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">size</span>,
<span style="color: #228b22;">int64_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">index</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">value</span>);
<span style="color: #228b22;">trexio_exit_code</span>
<span style="color: #0000ff;">trexio_text_buffered_write_rdm_two_e</span>(<span style="color: #228b22;">trexio_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">offset</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">size</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">index</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">value</span>);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">trexio_exit_code</span>
<span style="color: #0000ff;">trexio_text_buffered_read_rdm_two_e</span>(<span style="color: #228b22;">trexio_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">offset</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">size</span>,
<span style="color: #228b22;">int64_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">index</span>,
<span style="color: #228b22;">double</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">value</span>)
{
<span style="color: #a020f0;">if</span> (file == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_INVALID_ARG_1;
<span style="color: #a020f0;">if</span> (index == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_INVALID_ARG_4;
<span style="color: #a020f0;">if</span> (value == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_INVALID_ARG_5;
<span style="color: #228b22;">rdm_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">rdm</span> = trexio_text_read_rdm((<span style="color: #228b22;">trexio_text_t</span>*) file);
<span style="color: #a020f0;">if</span> (rdm == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_FAILURE;
<span style="color: #228b22;">FILE</span>* <span style="color: #a0522d;">f</span> = fopen(rdm-&gt;two_e_file_name, <span style="color: #8b2252;">"r"</span>);
<span style="color: #a020f0;">if</span> (f == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_END;
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">line_length</span> = 64L;
fseek(f, (<span style="color: #228b22;">long</span>) <span style="color: #228b22;">offset</span> * <span style="color: #a0522d;">line_length</span>, <span style="color: #a0522d;">SEEK_SET</span>);
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;size ; ++i) {
<span style="color: #228b22;">int</span> <span style="color: #a0522d;">rc</span> = fscanf(f, <span style="color: #8b2252;">"%9"</span> SCNd64 <span style="color: #8b2252;">" %9"</span> SCNd64 <span style="color: #8b2252;">" %9"</span> SCNd64 <span style="color: #8b2252;">" %9"</span> SCNd64 <span style="color: #8b2252;">" %24le\n"</span>,
&amp;index[4*i],
&amp;index[4*i+1],
&amp;index[4*i+2],
&amp;index[4*i+3],
&amp;value[i]);
<span style="color: #a020f0;">if</span> (rc == 5) {
/* <span style="color: #b22222;">Do nothing </span>*/
} <span style="color: #a020f0;">else</span> <span style="color: #a020f0;">if</span> (rc == EOF) {
fclose(f);
*eof_read_size = count;
<span style="color: #a020f0;">return</span> TREXIO_END;
} <span style="color: #a020f0;">else</span> {
rc = sscanf(buffer, <span style="color: #8b2252;">"$group_dset_format_scanf$"</span>,
$group_dset_sparse_indices_scanf$,
value_sparse + i);
<span style="color: #a020f0;">if</span>(rc &lt;= 0) {
fclose(f);
<span style="color: #a020f0;">return</span> TREXIO_FAILURE;
}
count += 1UL;
}
}
<span style="color: #a020f0;">return</span> TREXIO_SUCCESS;
}
<span style="color: #228b22;">trexio_exit_code</span>
<span style="color: #0000ff;">trexio_text_buffered_write_rdm_two_e</span>(<span style="color: #228b22;">trexio_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">offset</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">size</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">index</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">double</span>* <span style="color: #a0522d;">value</span>)
{
<span style="color: #a020f0;">if</span> (file == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_INVALID_ARG_1;
<span style="color: #a020f0;">if</span> (index == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_INVALID_ARG_4;
<span style="color: #a020f0;">if</span> (value == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_INVALID_ARG_5;
<span style="color: #a020f0;">if</span> (file-&gt;mode != <span style="color: #8b2252;">'r'</span>) <span style="color: #a020f0;">return</span> TREXIO_READONLY;
<span style="color: #228b22;">rdm_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">rdm</span> = trexio_text_read_rdm((<span style="color: #228b22;">trexio_text_t</span>*) file);
<span style="color: #a020f0;">if</span> (rdm == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_FAILURE;
<span style="color: #228b22;">FILE</span>* <span style="color: #a0522d;">f</span> = fopen(rdm-&gt;two_e_file_name, <span style="color: #8b2252;">"w"</span>);
<span style="color: #a020f0;">if</span> (f == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_FAILURE;
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">line_length</span> = 64L;
fseek(f, (<span style="color: #228b22;">long</span>) <span style="color: #228b22;">offset</span> * <span style="color: #a0522d;">line_length</span>, <span style="color: #a0522d;">SEEK_SET</span>);
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">uint64_t</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;size ; ++i) {
<span style="color: #228b22;">int</span> <span style="color: #a0522d;">rc</span> = fprintf(f, <span style="color: #8b2252;">"%9"</span> PRId64 <span style="color: #8b2252;">" %9"</span> PRId64 <span style="color: #8b2252;">" %9"</span> PRId64 <span style="color: #8b2252;">" %9"</span> PRId64 <span style="color: #8b2252;">" %24le\n"</span>,
index[4*i],
index[4*i+1],
index[4*i+2],
index[4*i+3],
value[i]);
<span style="color: #a020f0;">if</span> (rc != 5) <span style="color: #a020f0;">return</span> TREXIO_FAILURE;
}
/* <span style="color: #b22222;">Close the TXT file </span>*/
rc = fclose(f);
<span style="color: #a020f0;">if</span>(rc != 0) <span style="color: #a020f0;">return</span> TREXIO_FILE_ERROR;
<span style="color: #a020f0;">return</span> TREXIO_SUCCESS;
}
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">trexio_exit_code</span> <span style="color: #0000ff;">trexio_text_read_$group_dset$_size</span>(<span style="color: #228b22;">trexio_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>, <span style="color: #228b22;">int64_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">size_max</span>)
{
<span style="color: #a020f0;">if</span> (file == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_INVALID_ARG_1;
/* <span style="color: #b22222;">Build the name of the file with sparse data.</span>
<span style="color: #b22222;"> The $group_dset$.txt is limited to 256 symbols for the moment. What are the chances that it will exceed?</span>
<span style="color: #b22222;"> </span>*/
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">char</span> $group_dset$_file_name[256] = <span style="color: #8b2252;">"/$group_dset$.txt.size"</span>;
/* <span style="color: #b22222;">The full path to the destination TXT file with sparse data. This will include TREXIO directory name. </span>*/
<span style="color: #228b22;">char</span> <span style="color: #a0522d;">file_full_path</span>[TREXIO_MAX_FILENAME_LENGTH];
/* <span style="color: #b22222;">Copy directory name in file_full_path </span>*/
strncpy (file_full_path, file-&gt;file_name, TREXIO_MAX_FILENAME_LENGTH);
/* <span style="color: #b22222;">Append name of the file with sparse data </span>*/
strncat (file_full_path, $group_dset$_file_name,
TREXIO_MAX_FILENAME_LENGTH-strlen($group_dset$_file_name));
/* <span style="color: #b22222;">Open the file in "r" (read) mode to guarantee that no truncation happens upon consecutive reads </span>*/
<span style="color: #228b22;">FILE</span>* <span style="color: #a0522d;">f</span> = fopen(file_full_path, <span style="color: #8b2252;">"r"</span>);
<span style="color: #a020f0;">if</span>(f == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_FILE_ERROR;
/* <span style="color: #b22222;">Read the data from the file and check the return code of fprintf to verify that &gt; 0 bytes have been read or reached EOF </span>*/
<span style="color: #228b22;">int</span> <span style="color: #a0522d;">rc</span>;
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size_item</span>, <span style="color: #a0522d;">offset_item</span>, <span style="color: #a0522d;">size_accum</span>=0L;
/* <span style="color: #b22222;">Read the values from the file. BEWARE OF POSSIBLE MAX_INT64 OVERFLOW ! </span>*/
<span style="color: #a020f0;">while</span>(fscanf(f, <span style="color: #8b2252;">"%"</span> SCNd64 <span style="color: #8b2252;">" %"</span> SCNd64 <span style="color: #8b2252;">""</span>, &amp;size_item, &amp;offset_item) != EOF) {
/* <span style="color: #b22222;">Check that summation will not overflow the int64_t value </span>*/
<span style="color: #a020f0;">if</span> (INT64_MAX - size_accum &gt; size_item) {
size_accum += size_item;
} <span style="color: #a020f0;">else</span> {
fclose(f);
*size_max = -1L;
<span style="color: #a020f0;">return</span> TREXIO_INT_SIZE_OVERFLOW;
}
}
/* <span style="color: #b22222;">Close the TXT file </span>*/
rc = fclose(f);
<span style="color: #a020f0;">if</span>(rc != 0) <span style="color: #a020f0;">return</span> TREXIO_FILE_ERROR;
/* <span style="color: #b22222;">Overwrite the value at the input address and return TREXIO_SUCCESS </span>*/
*size_max = size_accum;
<span style="color: #a020f0;">return</span> TREXIO_SUCCESS;
}
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">trexio_exit_code</span> <span style="color: #0000ff;">trexio_text_has_$group_dset$</span>(<span style="color: #228b22;">trexio_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>)
{
<span style="color: #a020f0;">if</span> (file == <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> TREXIO_INVALID_ARG_1;
/* <span style="color: #b22222;">Build the name of the file with sparse data.</span>
<span style="color: #b22222;"> The $group_dset$.txt is limited to 256 symbols for the moment. What are the chances that it will exceed?</span>
<span style="color: #b22222;"> </span>*/
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">char</span> $group_dset$_file_name[256] = <span style="color: #8b2252;">"/$group_dset$.txt"</span>;
/* <span style="color: #b22222;">The full path to the destination TXT file with sparse data. This will include TREXIO directory name. </span>*/
<span style="color: #228b22;">char</span> <span style="color: #a0522d;">file_full_path</span>[TREXIO_MAX_FILENAME_LENGTH];
/* <span style="color: #b22222;">Copy directory name in file_full_path </span>*/
strncpy (file_full_path, file-&gt;file_name, TREXIO_MAX_FILENAME_LENGTH);
/* <span style="color: #b22222;">Append name of the file with sparse data </span>*/
strncat (file_full_path, $group_dset$_file_name,
TREXIO_MAX_FILENAME_LENGTH-strlen($group_dset$_file_name));
/* <span style="color: #b22222;">Check the return code of access function to determine whether the file with sparse data exists or not </span>*/
<span style="color: #a020f0;">if</span> (access(file_full_path, F_OK) == 0){
<span style="color: #a020f0;">return</span> TREXIO_SUCCESS;
} <span style="color: #a020f0;">else</span> {
<span style="color: #a020f0;">return</span> TREXIO_HAS_NOT;
}
}
</pre>
</div>
</div>
</div>
@ -1667,7 +1565,7 @@ file for each sparse float structure.
</div>
<div id="postamble" class="status">
<p class="author">Author: TREX-CoE</p>
<p class="date">Created: 2021-12-15 Wed 12:52</p>
<p class="date">Created: 2021-12-17 Fri 16:14</p>
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
</body>

196
trex.html
View File

@ -3,7 +3,7 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2021-12-15 Wed 12:52 -->
<!-- 2021-12-17 Fri 16:14 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>TREX Configuration file</title>
@ -333,33 +333,33 @@ for the JavaScript code in this tag.
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#orga4b6d95">1. Metadata (metadata group)</a></li>
<li><a href="#org53a6c1a">2. Electron (electron group)</a></li>
<li><a href="#orgca1b0fa">3. Nucleus (nucleus group)</a></li>
<li><a href="#orgc1089f8">4. Effective core potentials (ecp group)</a>
<li><a href="#orgd2dc4f9">1. Metadata (metadata group)</a></li>
<li><a href="#orgdaa99a8">2. Electron (electron group)</a></li>
<li><a href="#org29f1fd5">3. Nucleus (nucleus group)</a></li>
<li><a href="#org276b1f9">4. Effective core potentials (ecp group)</a>
<ul>
<li><a href="#orgd0a36b5">4.1. Example</a></li>
<li><a href="#org271f4aa">4.1. Example</a></li>
</ul>
</li>
<li><a href="#org87eeb97">5. Basis set (basis group)</a>
<li><a href="#org309a163">5. Basis set (basis group)</a>
<ul>
<li><a href="#org0661d44">5.1. Example</a></li>
<li><a href="#org404d6e3">5.1. Example</a></li>
</ul>
</li>
<li><a href="#orgeb82a41">6. Atomic orbitals (ao group)</a>
<li><a href="#orga3ce8a9">6. Atomic orbitals (ao group)</a>
<ul>
<li><a href="#ao_one_e">6.1. One-electron integrals (<code>ao_1e_int</code> group)</a></li>
<li><a href="#ao_two_e">6.2. Two-electron integrals (<code>ao_2e_int</code> group)</a></li>
</ul>
</li>
<li><a href="#org38158ff">7. Molecular orbitals (mo group)</a>
<li><a href="#orgdff4a60">7. Molecular orbitals (mo group)</a>
<ul>
<li><a href="#org458f567">7.1. One-electron integrals (<code>mo_1e_int</code> group)</a></li>
<li><a href="#org334c599">7.2. Two-electron integrals (<code>mo_2e_int</code> group)</a></li>
<li><a href="#orga81c8db">7.1. One-electron integrals (<code>mo_1e_int</code> group)</a></li>
<li><a href="#orgcf3f1ee">7.2. Two-electron integrals (<code>mo_2e_int</code> group)</a></li>
</ul>
</li>
<li><a href="#org42982ec">8. <span class="todo TODO">TODO</span> Slater determinants</a></li>
<li><a href="#org4b3b24b">9. <span class="todo TODO">TODO</span> Reduced density matrices (rdm group)</a></li>
<li><a href="#orgec590d1">8. <span class="todo TODO">TODO</span> Slater determinants</a></li>
<li><a href="#org80e8789">9. Reduced density matrices (rdm group)</a></li>
</ul>
</div>
</div>
@ -367,40 +367,50 @@ for the JavaScript code in this tag.
This page contains information about the general structure of the
TREXIO library. The source code of the library can be automatically
generated based on the contents of the <code>trex.json</code> configuration file,
which itself is compiled from different sections (groups) presented below.
which itself is compiled from different sections (groups) presented
below.
</p>
<p>
For more information about the automatic generation on the source code
or regarding possible modifications, please contact the TREXIO developers.
or regarding possible modifications, please contact the TREXIO
developers.
</p>
<p>
All quantities are saved in TREXIO file in atomic units.
The dimensions of the arrays in the tables below are given in
column-major order (as in Fortran), and the ordering of the dimensions
is reversed in the produced <code>trex.json</code> configuration file as the library is
All quantities are saved in TREXIO file in atomic units. The
dimensions of the arrays in the tables below are given in column-major
order (as in Fortran), and the ordering of the dimensions is reversed
in the produced <code>trex.json</code> configuration file as the library is
written in C.
</p>
<p>
TREXIO currently supports <code>int</code>, <code>float</code> and <code>str</code> types for both single attributes and arrays.
Note, that some attributes might have <code>dim</code> type (e.g. <code>num</code> of the <code>nucleus</code> group).
This type is treated exactly the same as <code>int</code> with the only difference that <code>dim</code> variables
cannot be negative or zero. This additional constraint is required because <code>dim</code> attributes
are used internally to allocate memory and to check array boundaries in the memory-safe API.
Most of the times, the <code>dim</code> variables contain <code>num</code> suffix.
TREXIO currently supports <code>int</code>, <code>float</code> and <code>str</code> types for both
single attributes and arrays. Note, that some attributes might have
<code>dim</code> type (e.g. <code>num</code> of the <code>nucleus</code> group). This type is treated
exactly the same as <code>int</code> with the only difference that <code>dim</code>
variables cannot be negative. This additional constraint is required
because <code>dim</code> attributes are used internally to allocate memory and to
check array boundaries in the memory-safe API. Most of the times, the
<code>dim</code> variables contain the <code>num</code> suffix.
</p>
<p>
In Fortran, the arrays are 1-based and in most other languages the
arrays are 0-based. Hence, we introduce the <code>index</code> type which is an
1-based <code>int</code> in the Fortran interface and 0-based otherwise.
</p>
<div id="outline-container-orga4b6d95" class="outline-2">
<h2 id="orga4b6d95"><span class="section-number-2">1</span> Metadata (metadata group)</h2>
<p>
For sparse data structures such as electron replusion integrals,
the data can be too large to fit in memory and the data needs to be
fetched using multiple function calls to perform I/O on buffers.
</p>
<div id="outline-container-orgd2dc4f9" class="outline-2">
<h2 id="orgd2dc4f9"><span class="section-number-2">1</span> Metadata (metadata group)</h2>
<div class="outline-text-2" id="text-1">
<p>
As we expect our files to be archived in open-data repositories, we
@ -410,7 +420,7 @@ which have participated to the creation of the file, a list of
authors of the file, and a textual description.
</p>
<table id="org3ddc984" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<table id="orge8de5b9" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
@ -477,15 +487,15 @@ authors of the file, and a textual description.
</div>
</div>
<div id="outline-container-org53a6c1a" class="outline-2">
<h2 id="org53a6c1a"><span class="section-number-2">2</span> Electron (electron group)</h2>
<div id="outline-container-orgdaa99a8" class="outline-2">
<h2 id="orgdaa99a8"><span class="section-number-2">2</span> Electron (electron group)</h2>
<div class="outline-text-2" id="text-2">
<p>
We consider wave functions expressed in the spin-free formalism, where
the number of &uarr; and &darr; electrons is fixed.
</p>
<table id="org752c516" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<table id="org48808a6" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
@ -524,15 +534,15 @@ the number of &uarr; and &darr; electrons is fixed.
</div>
</div>
<div id="outline-container-orgca1b0fa" class="outline-2">
<h2 id="orgca1b0fa"><span class="section-number-2">3</span> Nucleus (nucleus group)</h2>
<div id="outline-container-org29f1fd5" class="outline-2">
<h2 id="org29f1fd5"><span class="section-number-2">3</span> Nucleus (nucleus group)</h2>
<div class="outline-text-2" id="text-3">
<p>
The nuclei are considered as fixed point charges. Coordinates are
given in Cartesian \((x,y,z)\) format.
</p>
<table id="org5512202" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<table id="org6b8fe1d" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
@ -587,13 +597,20 @@ given in Cartesian \((x,y,z)\) format.
<td class="org-left">&#xa0;</td>
<td class="org-left">Symmetry point group</td>
</tr>
<tr>
<td class="org-left"><code>repulsion</code></td>
<td class="org-left"><code>float</code></td>
<td class="org-left">&#xa0;</td>
<td class="org-left">Nuclear repulsion energy</td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="outline-container-orgc1089f8" class="outline-2">
<h2 id="orgc1089f8"><span class="section-number-2">4</span> Effective core potentials (ecp group)</h2>
<div id="outline-container-org276b1f9" class="outline-2">
<h2 id="org276b1f9"><span class="section-number-2">4</span> Effective core potentials (ecp group)</h2>
<div class="outline-text-2" id="text-4">
<p>
An effective core potential (ECP) \(V_A^{\text{ECP}}\) replacing the
@ -626,7 +643,7 @@ The functions \(V_{A\ell}\) are parameterized as:
See <a href="http://dx.doi.org/10.1063/1.4984046">http://dx.doi.org/10.1063/1.4984046</a> or <a href="https://doi.org/10.1063/1.5121006">https://doi.org/10.1063/1.5121006</a> for more info.
</p>
<table id="org179fc63" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<table id="orged79c36" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
@ -724,8 +741,8 @@ The latter causes issues when written before <code>ang_mom</code> in the TREXIO
</p>
</div>
<div id="outline-container-orgd0a36b5" class="outline-3">
<h3 id="orgd0a36b5"><span class="section-number-3">4.1</span> Example</h3>
<div id="outline-container-org271f4aa" class="outline-3">
<h3 id="org271f4aa"><span class="section-number-3">4.1</span> Example</h3>
<div class="outline-text-3" id="text-4-1">
<p>
For example, consider H<sub>2</sub> molecule with the following
@ -788,8 +805,8 @@ power = [
</div>
</div>
<div id="outline-container-org87eeb97" class="outline-2">
<h2 id="org87eeb97"><span class="section-number-2">5</span> Basis set (basis group)</h2>
<div id="outline-container-org309a163" class="outline-2">
<h2 id="org309a163"><span class="section-number-2">5</span> Basis set (basis group)</h2>
<div class="outline-text-2" id="text-5">
<p>
We consider here basis functions centered on nuclei. Hence, we enable
@ -842,7 +859,7 @@ If the the basis function is not considered normalized, \(\mathcal{N}_s=1\).
All the basis set parameters are stored in one-dimensional arrays:
</p>
<table id="orgceeba88" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<table id="orgdff4428" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
@ -936,8 +953,8 @@ All the basis set parameters are stored in one-dimensional arrays:
</table>
</div>
<div id="outline-container-org0661d44" class="outline-3">
<h3 id="org0661d44"><span class="section-number-3">5.1</span> Example</h3>
<div id="outline-container-org404d6e3" class="outline-3">
<h3 id="org404d6e3"><span class="section-number-3">5.1</span> Example</h3>
<div class="outline-text-3" id="text-5-1">
<p>
For example, consider H<sub>2</sub> with the following basis set (in GAMESS
@ -1015,8 +1032,8 @@ prim_factor =
</div>
</div>
<div id="outline-container-orgeb82a41" class="outline-2">
<h2 id="orgeb82a41"><span class="section-number-2">6</span> Atomic orbitals (ao group)</h2>
<div id="outline-container-orga3ce8a9" class="outline-2">
<h2 id="orga3ce8a9"><span class="section-number-2">6</span> Atomic orbitals (ao group)</h2>
<div class="outline-text-2" id="text-6">
<p>
Going from the atomic basis set to AOs implies a systematic
@ -1064,13 +1081,13 @@ shell, as in the GAMESS convention where
<p>
In such a case, one should set the normalization of the shell (in
the <a href="#org87eeb97">Basis set</a> section) to \(\mathcal{N}_{z^2}\), which is the
the <a href="#org309a163">Basis set</a> section) to \(\mathcal{N}_{z^2}\), which is the
normalization factor of the atomic orbitals in spherical coordinates.
The normalization factor of the \(xy\) function which should be
introduced here should be \(\frac{\mathcal{N}_{xy}}{\mathcal{N}_{z^2}}\).
</p>
<table id="org9a807ea" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<table id="orgd5e5519" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
@ -1122,8 +1139,8 @@ introduced here should be \(\frac{\mathcal{N}_{xy}}{\mathcal{N}_{z^2}}\).
</table>
</div>
<div id="outline-container-org66434c4" class="outline-3">
<h3 id="ao_one_e"><a id="org66434c4"></a><span class="section-number-3">6.1</span> One-electron integrals (<code>ao_1e_int</code> group)</h3>
<div id="outline-container-org9bbd0b8" class="outline-3">
<h3 id="ao_one_e"><a id="org9bbd0b8"></a><span class="section-number-3">6.1</span> One-electron integrals (<code>ao_1e_int</code> group)</h3>
<div class="outline-text-3" id="text-ao_one_e">
<ul class="org-ul">
<li>\[ \hat{V}_{\text{ne}} = \sum_{A=1}^{N_\text{nucl}}
@ -1141,7 +1158,7 @@ The one-electron integrals for a one-electron operator \(\hat{O}\) are
over atomic orbitals.
</p>
<table id="orgd2e958f" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<table id="orgfa84965" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
@ -1208,8 +1225,8 @@ over atomic orbitals.
</div>
</div>
<div id="outline-container-org8e1dc5c" class="outline-3">
<h3 id="ao_two_e"><a id="org8e1dc5c"></a><span class="section-number-3">6.2</span> Two-electron integrals (<code>ao_2e_int</code> group)</h3>
<div id="outline-container-org9fd7389" class="outline-3">
<h3 id="ao_two_e"><a id="org9fd7389"></a><span class="section-number-3">6.2</span> Two-electron integrals (<code>ao_2e_int</code> group)</h3>
<div class="outline-text-3" id="text-ao_two_e">
<p>
The two-electron integrals for a two-electron operator \(\hat{O}\) are
@ -1230,7 +1247,7 @@ notation.
\mathbf{r}_j \vert)}{\vert \mathbf{r}_i - \mathbf{r}_j \vert} \] : electron-electron long range potential</li>
</ul>
<table id="org8c6a6c7" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<table id="org36bcc3a" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
@ -1270,10 +1287,10 @@ notation.
</div>
</div>
<div id="outline-container-org38158ff" class="outline-2">
<h2 id="org38158ff"><span class="section-number-2">7</span> Molecular orbitals (mo group)</h2>
<div id="outline-container-orgdff4a60" class="outline-2">
<h2 id="orgdff4a60"><span class="section-number-2">7</span> Molecular orbitals (mo group)</h2>
<div class="outline-text-2" id="text-7">
<table id="orgc1d6a25" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<table id="orgf1a8164" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
@ -1339,8 +1356,8 @@ notation.
</table>
</div>
<div id="outline-container-org458f567" class="outline-3">
<h3 id="org458f567"><span class="section-number-3">7.1</span> One-electron integrals (<code>mo_1e_int</code> group)</h3>
<div id="outline-container-orga81c8db" class="outline-3">
<h3 id="orga81c8db"><span class="section-number-3">7.1</span> One-electron integrals (<code>mo_1e_int</code> group)</h3>
<div class="outline-text-3" id="text-7-1">
<p>
The operators as the same as those defined in the
@ -1348,7 +1365,7 @@ The operators as the same as those defined in the
the basis of molecular orbitals.
</p>
<table id="org17e3c5f" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<table id="orga769fa0" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
@ -1415,8 +1432,8 @@ the basis of molecular orbitals.
</div>
</div>
<div id="outline-container-org334c599" class="outline-3">
<h3 id="org334c599"><span class="section-number-3">7.2</span> Two-electron integrals (<code>mo_2e_int</code> group)</h3>
<div id="outline-container-orgcf3f1ee" class="outline-3">
<h3 id="orgcf3f1ee"><span class="section-number-3">7.2</span> Two-electron integrals (<code>mo_2e_int</code> group)</h3>
<div class="outline-text-3" id="text-7-2">
<p>
The operators as the same as those defined in the
@ -1424,7 +1441,7 @@ The operators as the same as those defined in the
the basis of molecular orbitals.
</p>
<table id="orgf2c4f89" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<table id="org214e7ba" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
@ -1464,13 +1481,13 @@ the basis of molecular orbitals.
</div>
</div>
<div id="outline-container-org42982ec" class="outline-2">
<h2 id="org42982ec"><span class="section-number-2">8</span> <span class="todo TODO">TODO</span> Slater determinants</h2>
<div id="outline-container-orgec590d1" class="outline-2">
<h2 id="orgec590d1"><span class="section-number-2">8</span> <span class="todo TODO">TODO</span> Slater determinants</h2>
</div>
<div id="outline-container-org4b3b24b" class="outline-2">
<h2 id="org4b3b24b"><span class="section-number-2">9</span> <span class="todo TODO">TODO</span> Reduced density matrices (rdm group)</h2>
<div id="outline-container-org80e8789" class="outline-2">
<h2 id="org80e8789"><span class="section-number-2">9</span> Reduced density matrices (rdm group)</h2>
<div class="outline-text-2" id="text-9">
<table id="orga6f991a" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<table id="orgb582c17" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
@ -1492,31 +1509,52 @@ the basis of molecular orbitals.
</thead>
<tbody>
<tr>
<td class="org-left"><code>one_e</code></td>
<td class="org-left"><code>1e</code></td>
<td class="org-left"><code>float</code></td>
<td class="org-left"><code>(mo.num, mo.num)</code></td>
<td class="org-left">&#xa0;</td>
<td class="org-left">One body density matrix</td>
</tr>
<tr>
<td class="org-left"><code>one_e_up</code></td>
<td class="org-left"><code>1e_up</code></td>
<td class="org-left"><code>float</code></td>
<td class="org-left"><code>(mo.num, mo.num)</code></td>
<td class="org-left">&#xa0;</td>
<td class="org-left">&uarr;-spin component of the one body density matrix</td>
</tr>
<tr>
<td class="org-left"><code>one_e_dn</code></td>
<td class="org-left"><code>1e_dn</code></td>
<td class="org-left"><code>float</code></td>
<td class="org-left"><code>(mo.num, mo.num)</code></td>
<td class="org-left">&#xa0;</td>
<td class="org-left">&darr;-spin component of the one body density matrix</td>
</tr>
<tr>
<td class="org-left"><code>two_e</code></td>
<td class="org-left"><code>2e</code></td>
<td class="org-left"><code>float sparse</code></td>
<td class="org-left"><code>(mo.num, mo.num, mo.num, mo.num)</code></td>
<td class="org-left">&#xa0;</td>
<td class="org-left">Two-body reduced density matrix (spin trace)</td>
</tr>
<tr>
<td class="org-left"><code>2e_upup</code></td>
<td class="org-left"><code>float sparse</code></td>
<td class="org-left"><code>(mo.num, mo.num, mo.num, mo.num)</code></td>
<td class="org-left">&uarr;&uarr; component of the two-body reduced density matrix</td>
</tr>
<tr>
<td class="org-left"><code>2e_dndn</code></td>
<td class="org-left"><code>float sparse</code></td>
<td class="org-left"><code>(mo.num, mo.num, mo.num, mo.num)</code></td>
<td class="org-left">&darr;&darr; component of the two-body reduced density matrix</td>
</tr>
<tr>
<td class="org-left"><code>2e_updn</code></td>
<td class="org-left"><code>float sparse</code></td>
<td class="org-left"><code>(mo.num, mo.num, mo.num, mo.num)</code></td>
<td class="org-left">&uarr;&darr; component of the two-body reduced density matrix</td>
</tr>
</tbody>
</table>
@ -1525,7 +1563,7 @@ the basis of molecular orbitals.
</div>
<div id="postamble" class="status">
<p class="author">Author: TREX-CoE</p>
<p class="date">Created: 2021-12-15 Wed 12:52</p>
<p class="date">Created: 2021-12-17 Fri 16:14</p>
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
</body>