1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-06-01 02:45:43 +02:00
qmckl/qmckl_trexio.html

1806 lines
84 KiB
HTML

<?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>
<!-- 2024-04-10 Wed 14:39 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>TREXIO I/O library</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; }
.equation-container {
display: table;
text-align: center;
width: 100%;
}
.equation {
vertical-align: middle;
}
.equation-label {
display: table-cell;
text-align: right;
vertical-align: middle;
}
.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="qmckl.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-2020 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-2020 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-2020 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="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">TREXIO I/O library</h1>
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#org6bfd9ff">1. Local functions</a>
<ul>
<li><a href="#orgf9421ab">1.1. Open file</a></li>
<li><a href="#orgdd1c622">1.2. Electron</a></li>
<li><a href="#org68d68d6">1.3. Nucleus</a>
<ul>
<li><a href="#org7749f1b">1.3.1. Number of nuclei</a></li>
<li><a href="#orgbe9e0cb">1.3.2. Nuclear charges</a></li>
<li><a href="#orgc60777f">1.3.3. Nuclear coordinates</a></li>
</ul>
</li>
<li><a href="#orgff90674">1.4. Basis set and AOs</a>
<ul>
<li><a href="#org7a3529a">1.4.1. Basis set type</a></li>
<li><a href="#orgff8c99b">1.4.2. Number of shells</a></li>
<li><a href="#org283a1e7">1.4.3. Number of primitives</a></li>
<li><a href="#org0b75ec8">1.4.4. Number of atomic orbitals</a></li>
<li><a href="#orgfca4425">1.4.5. Nucleus<sub>index</sub> array</a></li>
<li><a href="#org39f6d09">1.4.6. Number of shells per nucleus</a></li>
<li><a href="#orgb2b0a36">1.4.7. Angular momentum</a></li>
<li><a href="#org32b3ccd">1.4.8. Number of primitives per shell</a></li>
<li><a href="#orgf1b130d">1.4.9. Indices of the primitives</a></li>
<li><a href="#org8caac4c">1.4.10. Normalization of the shells</a></li>
<li><a href="#org688b9cd">1.4.11. Exponents</a></li>
<li><a href="#org8412f7a">1.4.12. Coefficients</a></li>
<li><a href="#orga399c6d">1.4.13. Normalization of the primitivies</a></li>
<li><a href="#org91fa49a">1.4.14. AO Normalization</a></li>
</ul>
</li>
<li><a href="#org30faeac">1.5. Molecular orbitals</a>
<ul>
<li><a href="#org9433bf2">1.5.1. Number of MOs</a></li>
<li><a href="#org09ad567">1.5.2. MO coefficients</a></li>
</ul>
</li>
<li><a href="#org7a83c32">1.6. <span class="todo TODO">TODO</span> ECP</a></li>
</ul>
</li>
<li><a href="#org125eb64">2. Read everything</a></li>
<li><a href="#orge3c9e17">3. Test</a>
<ul>
<li>
<ul>
<li><a href="#org3eb8bdb">3.0.1. Electrons</a></li>
<li><a href="#orgeceb2d5">3.0.2. Nuclei</a></li>
<li><a href="#orgcfadbb4">3.0.3. Atomic basis</a></li>
<li><a href="#org7fa02bb">3.0.4. MO Basis</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div id="outline-container-org6bfd9ff" class="outline-2">
<h2 id="org6bfd9ff"><span class="section-number-2">1</span> Local functions</h2>
<div class="outline-text-2" id="text-1">
<p>
Functions defined in this section are all local: they should not be
exposed in the API. To identify them, we append <code>_X</code> to
their name.
</p>
<p>
Users are not able to call directly these functions, so by
construction the context can't be <code>NULL</code>, hence we can check this
with an <code>assert</code> statement.
</p>
<p>
In the functions defined in this section, we use as local variables
</p>
<ul class="org-ul">
<li><code>rc</code>: the return code for QMCkl functions</li>
<li><code>rcio</code>: the return code for TREXIO functions.</li>
</ul>
</div>
<div id="outline-container-orgf9421ab" class="outline-3">
<h3 id="orgf9421ab"><span class="section-number-3">1.1</span> Open file</h3>
<div class="outline-text-3" id="text-1-1">
<p>
We first define a helper function to open a file by first trying to
use the TEXT back end, and then the HDF5 back end. If both
strategies fail, a <code>NULL</code> pointer is returned. This will allow to
open only once the file and call multiple small functions to read
groups of data by passing the <code>trexio_t</code> handle.
</p>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #483d8b;">#ifdef</span> HAVE_TREXIO
<span style="color: #228b22;">trexio_t</span>* <span style="color: #0000ff;">qmckl_trexio_open_X</span>(<span style="color: #a020f0;">const</span> <span style="color: #228b22;">char</span>* <span style="color: #a0522d;">file_name</span>, <span style="color: #228b22;">qmckl_exit_code</span>* <span style="color: #a0522d;">rc</span>)
{
*rc = QMCKL_SUCCESS;
<span style="color: #228b22;">trexio_t</span>* <span style="color: #a0522d;">file</span> = <span style="color: #008b8b;">NULL</span>;
file = trexio_open(file_name, <span style="color: #8b2252;">'r'</span>, TREXIO_TEXT, rc);
<span style="color: #a020f0;">if</span> (file != <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> file;
file = trexio_open(file_name, <span style="color: #8b2252;">'r'</span>, TREXIO_HDF5, rc);
<span style="color: #a020f0;">if</span> (file != <span style="color: #008b8b;">NULL</span>) <span style="color: #a020f0;">return</span> file;
*rc = QMCKL_FAILURE;
/* <span style="color: #b22222;">TODO</span>
<span style="color: #b22222;"> return qmckl_failwith( context,</span>
<span style="color: #b22222;"> QMCKL_FAILURE,</span>
<span style="color: #b22222;"> "trexio_read_electron_up_num",</span>
<span style="color: #b22222;"> trexio_string_of_error(rcio));</span>
*/
<span style="color: #a020f0;">return</span> <span style="color: #008b8b;">NULL</span>;
}
<span style="color: #483d8b;">#endif</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-orgdd1c622" class="outline-3">
<h3 id="orgdd1c622"><span class="section-number-3">1.2</span> Electron</h3>
<div class="outline-text-3" id="text-1-2">
<p>
In this section we read all the data into the electron data structure.
We read the number of up-spin and down-spin electrons.
</p>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #483d8b;">#ifdef</span> HAVE_TREXIO
<span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_trexio_read_electron_X</span>(<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>, <span style="color: #228b22;">trexio_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>)
{
assert (context != (<span style="color: #228b22;">qmckl_context</span>) 0);
assert (file != <span style="color: #008b8b;">NULL</span>);
<span style="color: #228b22;">int</span> <span style="color: #a0522d;">rcio</span> = 0;
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">up_num</span> = 0L;
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">dn_num</span> = 0L;
rcio = trexio_read_electron_up_num_64(file, &amp;up_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_electron_up_num"</span>,
trexio_string_of_error(rcio));
}
assert (up_num &gt;= 0L);
rcio = trexio_read_electron_dn_num_64(file, &amp;dn_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_electron_dn_num"</span>,
trexio_string_of_error(rcio));
}
assert (dn_num &gt;= 0L);
<span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #a0522d;">rc</span>;
rc = qmckl_set_electron_num(context, up_num, dn_num);
<span style="color: #a020f0;">return</span> rc;
}
<span style="color: #483d8b;">#endif</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org68d68d6" class="outline-3">
<h3 id="org68d68d6"><span class="section-number-3">1.3</span> Nucleus</h3>
<div class="outline-text-3" id="text-1-3">
<p>
In this section we read the number of nuclei, the molecular geometry and nuclear charges.
</p>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #483d8b;">#ifdef</span> HAVE_TREXIO
<span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_trexio_read_nucleus_X</span>(<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>, <span style="color: #228b22;">trexio_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>)
{
assert (context != (<span style="color: #228b22;">qmckl_context</span>) 0);
assert (file != <span style="color: #008b8b;">NULL</span>);
<span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #a0522d;">rc</span>;
<span style="color: #228b22;">int</span> <span style="color: #a0522d;">rcio</span> = 0;
</pre>
</div>
</div>
<div id="outline-container-org7749f1b" class="outline-4">
<h4 id="org7749f1b"><span class="section-number-4">1.3.1</span> Number of nuclei</h4>
<div class="outline-text-4" id="text-1-3-1">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">nucleus_num</span> = 0L;
rcio = trexio_read_nucleus_num_64(file, &amp;nucleus_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_nucleus_num"</span>,
trexio_string_of_error(rcio));
}
<span style="color: #0000ff;">assert</span> (nucleus_num &gt; 0);
rc = qmckl_set_nucleus_num(context, nucleus_num);
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
</pre>
</div>
</div>
</div>
<div id="outline-container-orgbe9e0cb" class="outline-4">
<h4 id="orgbe9e0cb"><span class="section-number-4">1.3.2</span> Nuclear charges</h4>
<div class="outline-text-4" id="text-1-3-2">
<div class="org-src-container">
<pre class="src src-c">{
<span style="color: #228b22;">qmckl_memory_info_struct</span> <span style="color: #a0522d;">mem_info</span> = qmckl_memory_info_struct_zero;
mem_info.size = nucleus_num * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>);
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">nucl_charge</span> = (<span style="color: #228b22;">double</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (nucl_charge == <span style="color: #008b8b;">NULL</span>) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_nucleus_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (nucl_charge != <span style="color: #008b8b;">NULL</span>);
rcio = trexio_read_safe_nucleus_charge_64(file, nucl_charge, nucleus_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_nucleus_charge"</span>,
trexio_string_of_error(rcio));
}
rc = qmckl_set_nucleus_charge(context, nucl_charge, nucleus_num);
qmckl_free(context, nucl_charge);
nucl_charge = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
}
</pre>
</div>
</div>
</div>
<div id="outline-container-orgc60777f" class="outline-4">
<h4 id="orgc60777f"><span class="section-number-4">1.3.3</span> Nuclear coordinates</h4>
<div class="outline-text-4" id="text-1-3-3">
<p>
Now, we read the molecular geometry. It is stored in normal format
in the TREXIO file (<code>'N'</code>), so it will be automatically transposed internally.
</p>
<div class="org-src-container">
<pre class="src src-c">{
<span style="color: #228b22;">qmckl_memory_info_struct</span> <span style="color: #a0522d;">mem_info</span> = qmckl_memory_info_struct_zero;
mem_info.size = nucleus_num * 3 * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>);
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">nucl_coord</span> = (<span style="color: #228b22;">double</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (nucl_coord == <span style="color: #008b8b;">NULL</span>) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_nucleus_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (nucl_coord != <span style="color: #008b8b;">NULL</span>);
rcio = trexio_read_safe_nucleus_coord_64(file, nucl_coord, 3*nucleus_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_nucleus_charge"</span>,
trexio_string_of_error(rcio));
}
rc = qmckl_set_nucleus_coord(context, <span style="color: #8b2252;">'N'</span>, nucl_coord, 3*nucleus_num);
qmckl_free(context, nucl_coord);
nucl_coord = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS) {
<span style="color: #a020f0;">return</span> rc;
}
}
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"> <span style="color: #0000ff;">assert</span> ( <span style="color: #228b22;">qmckl_nucleus_provided</span>(<span style="color: #a0522d;">context</span>) );
<span style="color: #a020f0;">return</span> QMCKL_SUCCESS;
}
<span style="color: #483d8b;">#endif</span>
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-orgff90674" class="outline-3">
<h3 id="orgff90674"><span class="section-number-3">1.4</span> Basis set and AOs</h3>
<div class="outline-text-3" id="text-1-4">
<p>
In this section we read the atomic basis set and atomic orbitals.
</p>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #483d8b;">#ifdef</span> HAVE_TREXIO
<span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_trexio_read_ao_X</span>(<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>, <span style="color: #228b22;">trexio_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>)
{
assert (context != (<span style="color: #228b22;">qmckl_context</span>) 0);
assert (file != <span style="color: #008b8b;">NULL</span>);
<span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #a0522d;">rc</span>;
<span style="color: #228b22;">int</span> <span style="color: #a0522d;">rcio</span> = 0;
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">nucleus_num</span> = 0L;
rc = qmckl_get_nucleus_num(context, &amp;nucleus_num);
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
</pre>
</div>
</div>
<div id="outline-container-org7a3529a" class="outline-4">
<h4 id="org7a3529a"><span class="section-number-4">1.4.1</span> Basis set type</h4>
<div class="outline-text-4" id="text-1-4-1">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #483d8b;">#define</span> <span style="color: #a0522d;">MAX_STR_LEN</span> 1024
<span style="color: #228b22;">char</span> <span style="color: #a0522d;">basis_type</span>[MAX_STR_LEN];
rcio = trexio_read_basis_type(file, basis_type, MAX_STR_LEN);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_type"</span>,
trexio_string_of_error(rcio));
}
<span style="color: #a020f0;">if</span> (basis_type[0] == <span style="color: #8b2252;">'G'</span>) {
rc = qmckl_set_ao_basis_type(context, basis_type[0]);
} <span style="color: #a020f0;">else</span> {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_type"</span>,
<span style="color: #8b2252;">"Invalid basis type"</span>);
}
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
</pre>
</div>
</div>
</div>
<div id="outline-container-orgff8c99b" class="outline-4">
<h4 id="orgff8c99b"><span class="section-number-4">1.4.2</span> Number of shells</h4>
<div class="outline-text-4" id="text-1-4-2">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">shell_num</span> = 0L;
rcio = trexio_read_basis_shell_num_64(file, &amp;shell_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_shell_num"</span>,
trexio_string_of_error(rcio));
}
<span style="color: #0000ff;">assert</span> (shell_num &gt; 0);
rc = qmckl_set_ao_basis_shell_num(context, shell_num);
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
</pre>
</div>
</div>
</div>
<div id="outline-container-org283a1e7" class="outline-4">
<h4 id="org283a1e7"><span class="section-number-4">1.4.3</span> Number of primitives</h4>
<div class="outline-text-4" id="text-1-4-3">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">prim_num</span> = 0L;
rcio = trexio_read_basis_prim_num_64(file, &amp;prim_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_prim_num"</span>,
trexio_string_of_error(rcio));
}
<span style="color: #0000ff;">assert</span> (prim_num &gt; 0);
rc = qmckl_set_ao_basis_prim_num(context, prim_num);
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
</pre>
</div>
</div>
</div>
<div id="outline-container-org0b75ec8" class="outline-4">
<h4 id="org0b75ec8"><span class="section-number-4">1.4.4</span> Number of atomic orbitals</h4>
<div class="outline-text-4" id="text-1-4-4">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">ao_num</span> = 0;
rcio = trexio_read_ao_num_64(file, &amp;ao_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_ao_num"</span>,
trexio_string_of_error(rcio));
}
<span style="color: #0000ff;">assert</span> (ao_num &gt; 0);
rc = qmckl_set_ao_basis_ao_num(context, ao_num);
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
</pre>
</div>
</div>
</div>
<div id="outline-container-orgfca4425" class="outline-4">
<h4 id="orgfca4425"><span class="section-number-4">1.4.5</span> Nucleus<sub>index</sub> array</h4>
<div class="outline-text-4" id="text-1-4-5">
<div class="org-src-container">
<pre class="src src-c">{
<span style="color: #228b22;">qmckl_memory_info_struct</span> <span style="color: #a0522d;">mem_info</span> = qmckl_memory_info_struct_zero;
/* <span style="color: #b22222;">Allocate array for data</span> */
mem_info.size = nucleus_num * <span style="color: #a020f0;">sizeof</span>(int64_t);
<span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">nucleus_index</span> = (<span style="color: #228b22;">int64_t</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (nucleus_index == <span style="color: #008b8b;">NULL</span>) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_basis_nucleus_index_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (nucleus_index != <span style="color: #008b8b;">NULL</span>);
/* <span style="color: #b22222;">Allocate temporary array</span> */
mem_info.size = shell_num * <span style="color: #a020f0;">sizeof</span>(int64_t);
<span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">tmp_array</span> = (<span style="color: #228b22;">int64_t</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (tmp_array == <span style="color: #008b8b;">NULL</span>) {
qmckl_free(context, nucleus_index);
nucleus_index = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_basis_nucleus_index_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (tmp_array != <span style="color: #008b8b;">NULL</span>);
/* <span style="color: #b22222;">Read in the temporary array</span> */
rcio = trexio_read_safe_basis_nucleus_index_64(file, tmp_array, shell_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
qmckl_free(context, tmp_array);
tmp_array = <span style="color: #008b8b;">NULL</span>;
qmckl_free(context, nucleus_index);
nucleus_index = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_nucleus_index"</span>,
trexio_string_of_error(rcio));
}
/* <span style="color: #b22222;">Reformat data</span> */
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span>=shell_num-1 ; i&gt;=0 ; --i) {
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int</span> <span style="color: #a0522d;">k</span> = tmp_array[i];
<span style="color: #a020f0;">if</span> (k &lt; 0 || k &gt;= nucleus_num) {
qmckl_free(context, tmp_array);
tmp_array = <span style="color: #008b8b;">NULL</span>;
qmckl_free(context, nucleus_index);
nucleus_index = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_nucleus_index"</span>,
<span style="color: #8b2252;">"Irrelevant data in TREXIO file"</span>);
}
nucleus_index[k] = i;
}
qmckl_free(context, tmp_array);
tmp_array = <span style="color: #008b8b;">NULL</span>;
/* <span style="color: #b22222;">Store data</span> */
rc = qmckl_set_ao_basis_nucleus_index(context, nucleus_index, shell_num);
qmckl_free(context, nucleus_index);
nucleus_index = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
}
</pre>
</div>
</div>
</div>
<div id="outline-container-org39f6d09" class="outline-4">
<h4 id="org39f6d09"><span class="section-number-4">1.4.6</span> Number of shells per nucleus</h4>
<div class="outline-text-4" id="text-1-4-6">
<div class="org-src-container">
<pre class="src src-c">{
<span style="color: #228b22;">qmckl_memory_info_struct</span> <span style="color: #a0522d;">mem_info</span> = qmckl_memory_info_struct_zero;
/* <span style="color: #b22222;">Allocate array for data</span> */
mem_info.size = nucleus_num * <span style="color: #a020f0;">sizeof</span>(int64_t);
<span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">nucleus_shell_num</span> = (<span style="color: #228b22;">int64_t</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (nucleus_shell_num == <span style="color: #008b8b;">NULL</span>) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_basis_nucleus_shell_num_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (nucleus_shell_num != <span style="color: #008b8b;">NULL</span>);
/* <span style="color: #b22222;">Allocate temporary array</span> */
mem_info.size = shell_num * <span style="color: #a020f0;">sizeof</span>(int64_t);
<span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">tmp_array</span> = (<span style="color: #228b22;">int64_t</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (tmp_array == <span style="color: #008b8b;">NULL</span>) {
qmckl_free(context, nucleus_shell_num);
nucleus_shell_num = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_basis_nucleus_shell_num_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (tmp_array != <span style="color: #008b8b;">NULL</span>);
/* <span style="color: #b22222;">Read in the temporary array</span> */
rcio = trexio_read_safe_basis_nucleus_index_64(file, tmp_array, shell_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
qmckl_free(context, tmp_array);
tmp_array = <span style="color: #008b8b;">NULL</span>;
qmckl_free(context, nucleus_shell_num);
nucleus_shell_num = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_nucleus_shell_num"</span>,
trexio_string_of_error(rcio));
}
/* <span style="color: #b22222;">Reformat data</span> */
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;nucleus_num ; ++i) {
nucleus_shell_num[i] = 0;
}
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;shell_num ; ++i) {
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int</span> <span style="color: #a0522d;">k</span> = tmp_array[i];
<span style="color: #a020f0;">if</span> (k &lt; 0 || k &gt;= nucleus_num) {
qmckl_free(context, tmp_array);
tmp_array = <span style="color: #008b8b;">NULL</span>;
qmckl_free(context, nucleus_shell_num);
nucleus_shell_num = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_nucleus_shell_num"</span>,
<span style="color: #8b2252;">"Irrelevant data in TREXIO file"</span>);
}
nucleus_shell_num[k] += 1;
}
qmckl_free(context, tmp_array);
tmp_array = <span style="color: #008b8b;">NULL</span>;
/* <span style="color: #b22222;">Store data</span> */
rc = qmckl_set_ao_basis_nucleus_shell_num(context, nucleus_shell_num, shell_num);
qmckl_free(context, nucleus_shell_num);
nucleus_shell_num = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
}
</pre>
</div>
</div>
</div>
<div id="outline-container-orgb2b0a36" class="outline-4">
<h4 id="orgb2b0a36"><span class="section-number-4">1.4.7</span> Angular momentum</h4>
<div class="outline-text-4" id="text-1-4-7">
<div class="org-src-container">
<pre class="src src-c">{
<span style="color: #228b22;">qmckl_memory_info_struct</span> <span style="color: #a0522d;">mem_info</span> = qmckl_memory_info_struct_zero;
/* <span style="color: #b22222;">Allocate array for data</span> */
mem_info.size = shell_num * <span style="color: #a020f0;">sizeof</span>(int32_t);
<span style="color: #228b22;">int32_t</span>* <span style="color: #a0522d;">shell_ang_mom</span> = (<span style="color: #228b22;">int32_t</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (shell_ang_mom == <span style="color: #008b8b;">NULL</span>) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_basis_shell_ang_mom_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (shell_ang_mom != <span style="color: #008b8b;">NULL</span>);
/* <span style="color: #b22222;">Read data</span> */
rcio = trexio_read_safe_basis_shell_ang_mom_32(file, shell_ang_mom, shell_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
qmckl_free(context, shell_ang_mom);
shell_ang_mom = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_shell_ang_mom"</span>,
trexio_string_of_error(rcio));
}
/* <span style="color: #b22222;">Store data</span> */
rc = qmckl_set_ao_basis_shell_ang_mom(context, shell_ang_mom, shell_num);
qmckl_free(context, shell_ang_mom);
shell_ang_mom = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
}
</pre>
</div>
</div>
</div>
<div id="outline-container-org32b3ccd" class="outline-4">
<h4 id="org32b3ccd"><span class="section-number-4">1.4.8</span> Number of primitives per shell</h4>
<div class="outline-text-4" id="text-1-4-8">
<div class="org-src-container">
<pre class="src src-c">{
<span style="color: #228b22;">qmckl_memory_info_struct</span> <span style="color: #a0522d;">mem_info</span> = qmckl_memory_info_struct_zero;
/* <span style="color: #b22222;">Allocate array for data</span> */
mem_info.size = shell_num * <span style="color: #a020f0;">sizeof</span>(int64_t);
<span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">shell_prim_num</span> = (<span style="color: #228b22;">int64_t</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (shell_prim_num == <span style="color: #008b8b;">NULL</span>) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_basis_shell_index"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (shell_prim_num != <span style="color: #008b8b;">NULL</span>);
/* <span style="color: #b22222;">Allocate temporary array</span> */
mem_info.size = prim_num * <span style="color: #a020f0;">sizeof</span>(int64_t);
<span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">tmp_array</span> = (<span style="color: #228b22;">int64_t</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (tmp_array == <span style="color: #008b8b;">NULL</span>) {
qmckl_free(context, shell_prim_num);
shell_prim_num = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_basis_shell_index"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (tmp_array != <span style="color: #008b8b;">NULL</span>);
/* <span style="color: #b22222;">Read data</span> */
rcio = trexio_read_safe_basis_shell_index_64 (file, tmp_array, prim_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
qmckl_free(context, shell_prim_num);
shell_prim_num = <span style="color: #008b8b;">NULL</span>;
qmckl_free(context, tmp_array);
tmp_array = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"qmckl_trexio_read_basis_shell_index"</span>,
trexio_string_of_error(rcio));
}
/* <span style="color: #b22222;">Reformat data</span> */
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;shell_num ; ++i) {
shell_prim_num[i] = 0;
}
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;prim_num ; ++i) {
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int</span> <span style="color: #a0522d;">k</span> = tmp_array[i];
<span style="color: #a020f0;">if</span> (k &lt; 0 || k &gt;= shell_num) {
qmckl_free(context, tmp_array);
qmckl_free(context, shell_prim_num);
<span style="color: #228b22;">char</span> <span style="color: #a0522d;">msg</span>[128];
sprintf(&amp;msg[0], <span style="color: #8b2252;">"Irrelevant data in TREXIO file: k = %d"</span>, k);
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"qmckl_trexio_read_basis_shell_index"</span>,
&amp;msg[0]);
}
shell_prim_num[k] += 1;
}
qmckl_free(context, tmp_array);
tmp_array = <span style="color: #008b8b;">NULL</span>;
/* <span style="color: #b22222;">Store data</span> */
rc = qmckl_set_ao_basis_shell_prim_num(context, shell_prim_num, shell_num);
qmckl_free(context, shell_prim_num);
shell_prim_num = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
}
</pre>
</div>
</div>
</div>
<div id="outline-container-orgf1b130d" class="outline-4">
<h4 id="orgf1b130d"><span class="section-number-4">1.4.9</span> Indices of the primitives</h4>
<div class="outline-text-4" id="text-1-4-9">
<div class="org-src-container">
<pre class="src src-c">{
<span style="color: #228b22;">qmckl_memory_info_struct</span> <span style="color: #a0522d;">mem_info</span> = qmckl_memory_info_struct_zero;
/* <span style="color: #b22222;">Allocate array for data</span> */
mem_info.size = shell_num * <span style="color: #a020f0;">sizeof</span>(int64_t);
<span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">shell_prim_index</span> = (<span style="color: #228b22;">int64_t</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (shell_prim_index == <span style="color: #008b8b;">NULL</span>) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_basis_shell_prim_index_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (shell_prim_index != <span style="color: #008b8b;">NULL</span>);
/* <span style="color: #b22222;">Allocate temporary array</span> */
mem_info.size = prim_num * <span style="color: #a020f0;">sizeof</span>(int64_t);
<span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">tmp_array</span> = (<span style="color: #228b22;">int64_t</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (tmp_array == <span style="color: #008b8b;">NULL</span>) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_basis_shell_prim_index_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (tmp_array != <span style="color: #008b8b;">NULL</span>);
/* <span style="color: #b22222;">Read data</span> */
rcio = trexio_read_safe_basis_shell_index_64(file, tmp_array, prim_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
qmckl_free(context, shell_prim_index);
shell_prim_index = <span style="color: #008b8b;">NULL</span>;
qmckl_free(context, tmp_array);
tmp_array = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_shell_prim_index"</span>,
trexio_string_of_error(rcio));
}
/* <span style="color: #b22222;">Reformat data</span> */
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span>=prim_num-1 ; i&gt;=0 ; --i) {
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int</span> <span style="color: #a0522d;">k</span> = tmp_array[i];
<span style="color: #a020f0;">if</span> (k &lt; 0 || k &gt;= shell_num) {
qmckl_free(context, tmp_array);
tmp_array = <span style="color: #008b8b;">NULL</span>;
qmckl_free(context, shell_prim_index);
shell_prim_index = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_shell_prim_index"</span>,
<span style="color: #8b2252;">"Irrelevant data in TREXIO file"</span>);
}
shell_prim_index[k] = i;
}
qmckl_free(context, tmp_array);
tmp_array = <span style="color: #008b8b;">NULL</span>;
/* <span style="color: #b22222;">Store data</span> */
rc = qmckl_set_ao_basis_shell_prim_index(context, shell_prim_index, shell_num);
qmckl_free(context, shell_prim_index);
shell_prim_index = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
}
</pre>
</div>
</div>
</div>
<div id="outline-container-org8caac4c" class="outline-4">
<h4 id="org8caac4c"><span class="section-number-4">1.4.10</span> Normalization of the shells</h4>
<div class="outline-text-4" id="text-1-4-10">
<div class="org-src-container">
<pre class="src src-c">{
<span style="color: #228b22;">qmckl_memory_info_struct</span> <span style="color: #a0522d;">mem_info</span> = qmckl_memory_info_struct_zero;
/* <span style="color: #b22222;">Allocate array for data</span> */
mem_info.size = shell_num * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>);
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">shell_factor</span> = (<span style="color: #228b22;">double</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (shell_factor == <span style="color: #008b8b;">NULL</span>) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_basis_shell_factor_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (shell_factor != <span style="color: #008b8b;">NULL</span>);
/* <span style="color: #b22222;">Read data</span> */
rcio = trexio_read_safe_basis_shell_factor_64(file, shell_factor, shell_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
qmckl_free(context, shell_factor);
shell_factor = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_shell_factor"</span>,
trexio_string_of_error(rcio));
}
/* <span style="color: #b22222;">Store data</span> */
rc = qmckl_set_ao_basis_shell_factor(context, shell_factor, shell_num);
qmckl_free(context, shell_factor);
shell_factor = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
}
</pre>
</div>
</div>
</div>
<div id="outline-container-org688b9cd" class="outline-4">
<h4 id="org688b9cd"><span class="section-number-4">1.4.11</span> Exponents</h4>
<div class="outline-text-4" id="text-1-4-11">
<div class="org-src-container">
<pre class="src src-c">{
<span style="color: #228b22;">qmckl_memory_info_struct</span> <span style="color: #a0522d;">mem_info</span> = qmckl_memory_info_struct_zero;
/* <span style="color: #b22222;">Allocate array for data</span> */
mem_info.size = prim_num * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>);
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">exponent</span> = (<span style="color: #228b22;">double</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (exponent == <span style="color: #008b8b;">NULL</span>) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_basis_exponent_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (exponent != <span style="color: #008b8b;">NULL</span>);
/* <span style="color: #b22222;">Read data</span> */
rcio = trexio_read_safe_basis_exponent_64(file, exponent, prim_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
qmckl_free(context, exponent);
exponent = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_exponent"</span>,
trexio_string_of_error(rcio));
}
/* <span style="color: #b22222;">Store data</span> */
rc = qmckl_set_ao_basis_exponent(context, exponent, prim_num);
qmckl_free(context, exponent);
exponent = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
}
</pre>
</div>
</div>
</div>
<div id="outline-container-org8412f7a" class="outline-4">
<h4 id="org8412f7a"><span class="section-number-4">1.4.12</span> Coefficients</h4>
<div class="outline-text-4" id="text-1-4-12">
<div class="org-src-container">
<pre class="src src-c">{
<span style="color: #228b22;">qmckl_memory_info_struct</span> <span style="color: #a0522d;">mem_info</span> = qmckl_memory_info_struct_zero;
/* <span style="color: #b22222;">Allocate array for data</span> */
mem_info.size = prim_num * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>);
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">coefficient</span> = (<span style="color: #228b22;">double</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (coefficient == <span style="color: #008b8b;">NULL</span>) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_basis_coefficient_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (coefficient != <span style="color: #008b8b;">NULL</span>);
/* <span style="color: #b22222;">Read data</span> */
rcio = trexio_read_safe_basis_coefficient_64(file, coefficient, prim_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
qmckl_free(context, coefficient);
coefficient = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_coefficient"</span>,
trexio_string_of_error(rcio));
}
/* <span style="color: #b22222;">Store data</span> */
rc = qmckl_set_ao_basis_coefficient(context, coefficient, prim_num);
qmckl_free(context, coefficient);
coefficient = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
}
</pre>
</div>
</div>
</div>
<div id="outline-container-orga399c6d" class="outline-4">
<h4 id="orga399c6d"><span class="section-number-4">1.4.13</span> Normalization of the primitivies</h4>
<div class="outline-text-4" id="text-1-4-13">
<div class="org-src-container">
<pre class="src src-c">{
<span style="color: #228b22;">qmckl_memory_info_struct</span> <span style="color: #a0522d;">mem_info</span> = qmckl_memory_info_struct_zero;
/* <span style="color: #b22222;">Allocate array for data</span> */
mem_info.size = prim_num * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>);
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">prim_factor</span> = (<span style="color: #228b22;">double</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (prim_factor == <span style="color: #008b8b;">NULL</span>) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_basis_prim_factor_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (prim_factor != <span style="color: #008b8b;">NULL</span>);
/* <span style="color: #b22222;">Read data</span> */
rcio = trexio_read_safe_basis_prim_factor_64(file, prim_factor, prim_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
qmckl_free(context, prim_factor);
prim_factor = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_basis_prim_factor"</span>,
trexio_string_of_error(rcio));
}
/* <span style="color: #b22222;">Read data</span> */
rc = qmckl_set_ao_basis_prim_factor(context, prim_factor, prim_num);
qmckl_free(context, prim_factor);
prim_factor = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
}
</pre>
</div>
</div>
</div>
<div id="outline-container-org91fa49a" class="outline-4">
<h4 id="org91fa49a"><span class="section-number-4">1.4.14</span> AO Normalization</h4>
<div class="outline-text-4" id="text-1-4-14">
<div class="org-src-container">
<pre class="src src-c">{
<span style="color: #228b22;">qmckl_memory_info_struct</span> <span style="color: #a0522d;">mem_info</span> = qmckl_memory_info_struct_zero;
/* <span style="color: #b22222;">Allocate array for data</span> */
mem_info.size = ao_num * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>);
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">ao_normalization</span> = (<span style="color: #228b22;">double</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (ao_normalization == <span style="color: #008b8b;">NULL</span>) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_ao_normalization_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (ao_normalization != <span style="color: #008b8b;">NULL</span>);
/* <span style="color: #b22222;">Read data</span> */
rcio = trexio_read_safe_ao_normalization_64(file, ao_normalization, ao_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
qmckl_free(context, ao_normalization);
ao_normalization = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_ao_normalization"</span>,
trexio_string_of_error(rcio));
}
/* <span style="color: #b22222;">Store data</span> */
rc = qmckl_set_ao_basis_ao_factor(context, ao_normalization, ao_num);
qmckl_free(context, ao_normalization);
ao_normalization = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
}
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c">
<span style="color: #a020f0;">return</span> QMCKL_SUCCESS;
}
<span style="color: #483d8b;">#endif</span>
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-org30faeac" class="outline-3">
<h3 id="org30faeac"><span class="section-number-3">1.5</span> Molecular orbitals</h3>
<div class="outline-text-3" id="text-1-5">
<p>
In this section we read the MO coefficients.
</p>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #483d8b;">#ifdef</span> HAVE_TREXIO
<span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_trexio_read_mo_X</span>(<span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>, <span style="color: #228b22;">trexio_t</span>* <span style="color: #a020f0;">const</span> <span style="color: #a0522d;">file</span>)
{
assert (context != (<span style="color: #228b22;">qmckl_context</span>) 0);
assert (file != <span style="color: #008b8b;">NULL</span>);
<span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #a0522d;">rc</span>;
<span style="color: #228b22;">int</span> <span style="color: #a0522d;">rcio</span> = 0;
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">ao_num</span> = 0L;
rc = qmckl_get_ao_basis_ao_num(context, &amp;ao_num);
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
</pre>
</div>
</div>
<div id="outline-container-org9433bf2" class="outline-4">
<h4 id="org9433bf2"><span class="section-number-4">1.5.1</span> Number of MOs</h4>
<div class="outline-text-4" id="text-1-5-1">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">mo_num</span> = 0L;
rcio = trexio_read_mo_num_64(file, &amp;mo_num);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_mo_num"</span>,
trexio_string_of_error(rcio));
}
<span style="color: #0000ff;">assert</span> (mo_num &gt; 0);
rc = qmckl_set_mo_basis_mo_num(context, mo_num);
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
</pre>
</div>
</div>
</div>
<div id="outline-container-org09ad567" class="outline-4">
<h4 id="org09ad567"><span class="section-number-4">1.5.2</span> MO coefficients</h4>
<div class="outline-text-4" id="text-1-5-2">
<div class="org-src-container">
<pre class="src src-c">{
<span style="color: #228b22;">qmckl_memory_info_struct</span> <span style="color: #a0522d;">mem_info</span> = qmckl_memory_info_struct_zero;
mem_info.size = ao_num * mo_num * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>);
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">mo_coef</span> = (<span style="color: #228b22;">double</span>*) qmckl_malloc(context, mem_info);
<span style="color: #a020f0;">if</span> (mo_coef == <span style="color: #008b8b;">NULL</span>) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED,
<span style="color: #8b2252;">"qmckl_trexio_read_mo_X"</span>,
<span style="color: #008b8b;">NULL</span>);
}
assert (mo_coef != <span style="color: #008b8b;">NULL</span>);
rcio = trexio_read_mo_coefficient_64(file, mo_coef);
<span style="color: #a020f0;">if</span> (rcio != TREXIO_SUCCESS) {
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"trexio_read_mo_coefficient"</span>,
trexio_string_of_error(rcio));
}
rc = qmckl_set_mo_basis_coefficient(context, mo_coef, ao_num*mo_num);
qmckl_free(context, mo_coef);
mo_coef = <span style="color: #008b8b;">NULL</span>;
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS)
<span style="color: #a020f0;">return</span> rc;
}
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c">
<span style="color: #a020f0;">return</span> QMCKL_SUCCESS;
}
<span style="color: #483d8b;">#endif</span>
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-org7a83c32" class="outline-3">
<h3 id="org7a83c32"><span class="section-number-3">1.6</span> <span class="todo TODO">TODO</span> ECP</h3>
</div>
</div>
<div id="outline-container-org125eb64" class="outline-2">
<h2 id="org125eb64"><span class="section-number-2">2</span> Read everything</h2>
<div class="outline-text-2" id="text-2">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_trexio_read</span>(<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">char</span>* <span style="color: #a0522d;">file_name</span>,
<span style="color: #a020f0;">const</span> <span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">size_max</span>);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-c"><span style="color: #228b22;">qmckl_exit_code</span>
<span style="color: #0000ff;">qmckl_trexio_read</span>(<span style="color: #a020f0;">const</span> <span style="color: #228b22;">qmckl_context</span> <span style="color: #a0522d;">context</span>, <span style="color: #a020f0;">const</span> <span style="color: #228b22;">char</span>* <span style="color: #a0522d;">file_name</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;">if</span> (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
<span style="color: #a020f0;">return</span> <span style="color: #008b8b;">false</span>;
}
<span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #a0522d;">rc</span>;
<span style="color: #228b22;">char</span> <span style="color: #a0522d;">file_name_new</span>[size_max+1];
strncpy(file_name_new, file_name, size_max);
file_name_new[size_max] = <span style="color: #8b2252;">'\0'</span>;
<span style="color: #483d8b;">#ifdef</span> HAVE_TREXIO
<span style="color: #228b22;">trexio_t</span>* <span style="color: #a0522d;">file</span> = qmckl_trexio_open_X(file_name_new, &amp;rc);
<span style="color: #a020f0;">if</span> (file == <span style="color: #008b8b;">NULL</span>) {
trexio_close(file);
<span style="color: #a020f0;">return</span> qmckl_failwith( context,
QMCKL_INVALID_ARG_2,
<span style="color: #8b2252;">"qmckl_trexio_read"</span>,
trexio_string_of_error(rc));
}
assert (file != <span style="color: #008b8b;">NULL</span>);
rc = qmckl_trexio_read_electron_X(context, file);
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS) {
trexio_close(file);
<span style="color: #a020f0;">return</span> rc;
}
rc = qmckl_trexio_read_nucleus_X(context, file);
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS) {
trexio_close(file);
<span style="color: #a020f0;">return</span> rc;
}
rc = qmckl_trexio_read_ao_X(context, file);
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS) {
trexio_close(file);
<span style="color: #a020f0;">return</span> rc;
}
rc = qmckl_trexio_read_mo_X(context, file);
<span style="color: #a020f0;">if</span> (rc != QMCKL_SUCCESS) {
trexio_close(file);
<span style="color: #a020f0;">return</span> rc;
}
trexio_close(file);
file = <span style="color: #008b8b;">NULL</span>;
<span style="color: #483d8b;">#else</span>
rc = qmckl_failwith( context,
QMCKL_FAILURE,
<span style="color: #8b2252;">"qmckl_trexio_read"</span>,
<span style="color: #8b2252;">"QMCkl was compiled without TREXIO"</span>);
<span style="color: #483d8b;">#endif</span>
<span style="color: #a020f0;">return</span> rc;
}
</pre>
</div>
</div>
</div>
<div id="outline-container-orge3c9e17" class="outline-2">
<h2 id="orge3c9e17"><span class="section-number-2">3</span> Test</h2>
<div class="outline-text-2" id="text-3">
<div class="org-src-container">
<pre class="src src-c"><span style="color: #483d8b;">#ifdef</span> HAVE_TREXIO
<span style="color: #228b22;">qmckl_exit_code</span> <span style="color: #a0522d;">rc</span>;
<span style="color: #228b22;">char</span> <span style="color: #a0522d;">filename</span>[256];
<span style="color: #483d8b;">#if</span><span style="color: #483d8b;">n</span><span style="color: #483d8b;">def</span> QMCKL_TEST_DIR
<span style="color: #483d8b;">#error</span> <span style="color: #8b2252;">"QMCKL_TEST_DIR is not defined"</span>
<span style="color: #483d8b;">#endif</span>
<span style="color: #0000ff;">strncpy</span>(filename, QMCKL_TEST_DIR,255);
<span style="color: #0000ff;">strncat</span>(filename, <span style="color: #8b2252;">"/chbrclf"</span>, 255);
printf(<span style="color: #8b2252;">"Test file: %s\n"</span>, filename);
rc = qmckl_trexio_read(context, filename, 255);
<span style="color: #0000ff;">qmckl_check</span>(context, rc);
</pre>
</div>
</div>
<div id="outline-container-org3eb8bdb" class="outline-4">
<h4 id="org3eb8bdb"><span class="section-number-4">3.0.1</span> Electrons</h4>
<div class="outline-text-4" id="text-3-0-1">
<div class="org-src-container">
<pre class="src src-c">printf(<span style="color: #8b2252;">"Electrons\n"</span>);
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">up_num</span>, <span style="color: #a0522d;">dn_num</span>;
rc = qmckl_get_electron_up_num(context, &amp;up_num);
<span style="color: #0000ff;">qmckl_check</span>(context, rc);
<span style="color: #0000ff;">assert</span> (up_num == chbrclf_elec_up_num);
rc = qmckl_get_electron_down_num(context, &amp;dn_num);
<span style="color: #0000ff;">qmckl_check</span>(context, rc);
<span style="color: #0000ff;">assert</span> (dn_num == chbrclf_elec_dn_num);
</pre>
</div>
</div>
</div>
<div id="outline-container-orgeceb2d5" class="outline-4">
<h4 id="orgeceb2d5"><span class="section-number-4">3.0.2</span> Nuclei</h4>
<div class="outline-text-4" id="text-3-0-2">
<div class="org-src-container">
<pre class="src src-c">printf(<span style="color: #8b2252;">"Nuclei\n"</span>);
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">nucl_num</span>;
rc = qmckl_get_nucleus_num(context, &amp;nucl_num);
<span style="color: #0000ff;">qmckl_check</span>(context, rc);
<span style="color: #0000ff;">assert</span> (nucl_num == chbrclf_nucl_num);
printf(<span style="color: #8b2252;">"Nuclear charges\n"</span>);
<span style="color: #228b22;">double</span> * <span style="color: #a0522d;">charge</span> = (<span style="color: #228b22;">double</span>*) <span style="color: #0000ff;">malloc</span> (<span style="color: #228b22;">nucl_num</span> * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>));
rc = qmckl_get_nucleus_charge(context, charge, nucl_num);
<span style="color: #0000ff;">qmckl_check</span>(context, rc);
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;nucl_num ; i++) {
assert (charge[i] == chbrclf_charge[i]);
}
<span style="color: #0000ff;">free</span>(charge);
charge = <span style="color: #008b8b;">NULL</span>;
printf(<span style="color: #8b2252;">"Nuclear coordinates\n"</span>);
<span style="color: #228b22;">double</span> * <span style="color: #a0522d;">coord</span> = (<span style="color: #228b22;">double</span>*) <span style="color: #0000ff;">malloc</span> (<span style="color: #228b22;">nucl_num</span> * 3 * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>));
rc = qmckl_get_nucleus_coord(context, <span style="color: #8b2252;">'T'</span>, coord, 3*nucl_num);
<span style="color: #0000ff;">qmckl_check</span>(context, rc);
<span style="color: #228b22;">int</span> <span style="color: #a0522d;">k</span>=0;
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">j</span>=0 ; j&lt;3 ; ++j) {
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;nucl_num ; ++i) {
// <span style="color: #b22222;">printf("%f %f\n", coord[k], chbrclf_nucl_coord[j][i]);</span>
assert (coord[k] == chbrclf_nucl_coord[j][i]);
++k;
}
}
<span style="color: #0000ff;">free</span>(coord);
coord = <span style="color: #008b8b;">NULL</span>;
</pre>
</div>
</div>
</div>
<div id="outline-container-orgcfadbb4" class="outline-4">
<h4 id="orgcfadbb4"><span class="section-number-4">3.0.3</span> Atomic basis</h4>
<div class="outline-text-4" id="text-3-0-3">
<div class="org-src-container">
<pre class="src src-c">printf(<span style="color: #8b2252;">"Atomic basis\n"</span>);
<span style="color: #228b22;">char</span> <span style="color: #a0522d;">basis_type</span>;
rc = qmckl_get_ao_basis_type(context, &amp;basis_type);
<span style="color: #0000ff;">assert</span> (basis_type == <span style="color: #8b2252;">'G'</span>);
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">shell_num</span>;
rc = qmckl_get_ao_basis_shell_num(context, &amp;shell_num);
<span style="color: #0000ff;">assert</span> (shell_num == chbrclf_shell_num);
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">prim_num</span>;
rc = qmckl_get_ao_basis_prim_num(context, &amp;prim_num);
<span style="color: #0000ff;">assert</span> (prim_num == chbrclf_prim_num);
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">ao_num</span>;
rc = qmckl_get_ao_basis_ao_num(context, &amp;ao_num);
<span style="color: #0000ff;">assert</span> (ao_num == chbrclf_ao_num);
<span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">nucleus_index</span> = (<span style="color: #228b22;">int64_t</span>*) <span style="color: #0000ff;">malloc</span> (<span style="color: #228b22;">nucl_num</span> * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">int64_t</span>));
rc = qmckl_get_ao_basis_nucleus_index(context, nucleus_index, nucl_num);
<span style="color: #0000ff;">qmckl_check</span>(context, rc);
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;nucl_num ; i++) {
assert (nucleus_index[i] == chbrclf_basis_nucleus_index[i]);
}
<span style="color: #0000ff;">free</span>(nucleus_index);
nucleus_index = <span style="color: #008b8b;">NULL</span>;
<span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">nucleus_shell_num</span> = (<span style="color: #228b22;">int64_t</span>*) <span style="color: #0000ff;">malloc</span> (<span style="color: #228b22;">nucl_num</span> * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">int64_t</span>));
rc = qmckl_get_ao_basis_nucleus_shell_num(context, nucleus_shell_num, nucl_num);
<span style="color: #0000ff;">qmckl_check</span>(context, rc);
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;nucl_num ; i++) {
assert (nucleus_shell_num[i] == chbrclf_basis_nucleus_shell_num[i]);
}
<span style="color: #0000ff;">free</span>(nucleus_shell_num);
nucleus_shell_num = <span style="color: #008b8b;">NULL</span>;
<span style="color: #228b22;">int32_t</span>* <span style="color: #a0522d;">shell_ang_mom</span> = (<span style="color: #228b22;">int32_t</span>*) <span style="color: #0000ff;">malloc</span> (<span style="color: #228b22;">shell_num</span> * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">int32_t</span>));
rc = qmckl_get_ao_basis_shell_ang_mom(context, shell_ang_mom, shell_num);
<span style="color: #0000ff;">qmckl_check</span>(context, rc);
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;shell_num ; i++) {
assert (shell_ang_mom[i] == chbrclf_basis_shell_ang_mom[i]);
}
<span style="color: #0000ff;">free</span>(shell_ang_mom);
shell_ang_mom = <span style="color: #008b8b;">NULL</span>;
<span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">shell_prim_num</span> = (<span style="color: #228b22;">int64_t</span>*) <span style="color: #0000ff;">malloc</span> (<span style="color: #228b22;">shell_num</span> * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">int64_t</span>));
rc = qmckl_get_ao_basis_shell_prim_num(context, shell_prim_num, shell_num);
<span style="color: #0000ff;">qmckl_check</span>(context, rc);
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;shell_num ; i++) {
assert (shell_prim_num[i] == chbrclf_basis_shell_prim_num[i]);
}
<span style="color: #0000ff;">free</span>(shell_prim_num);
shell_prim_num = <span style="color: #008b8b;">NULL</span>;
<span style="color: #228b22;">int64_t</span>* <span style="color: #a0522d;">shell_prim_index</span> = (<span style="color: #228b22;">int64_t</span>*) <span style="color: #0000ff;">malloc</span> (<span style="color: #228b22;">shell_num</span> * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">int64_t</span>));
rc = qmckl_get_ao_basis_shell_prim_index(context, shell_prim_index, shell_num);
<span style="color: #0000ff;">qmckl_check</span>(context, rc);
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;shell_num ; i++) {
assert (shell_prim_index[i] == chbrclf_basis_shell_prim_index[i]);
}
<span style="color: #0000ff;">free</span>(shell_prim_index);
shell_prim_index = <span style="color: #008b8b;">NULL</span>;
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">shell_factor</span> = (<span style="color: #228b22;">double</span>*) <span style="color: #0000ff;">malloc</span> (<span style="color: #228b22;">shell_num</span> * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>));
rc = qmckl_get_ao_basis_shell_factor(context, shell_factor, shell_num);
<span style="color: #0000ff;">qmckl_check</span>(context, rc);
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;shell_num ; i++) {
assert (fabs(shell_factor[i] - chbrclf_basis_shell_factor[i]) &lt; 1.e-6);
}
<span style="color: #0000ff;">free</span>(shell_factor);
shell_factor = <span style="color: #008b8b;">NULL</span>;
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">exponent</span> = (<span style="color: #228b22;">double</span>*) <span style="color: #0000ff;">malloc</span> (<span style="color: #228b22;">prim_num</span> * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>));
rc = qmckl_get_ao_basis_exponent(context, exponent, prim_num);
<span style="color: #0000ff;">qmckl_check</span>(context, rc);
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;prim_num ; i++) {
assert (fabs((exponent[i] - chbrclf_basis_exponent[i])/chbrclf_basis_exponent[i]) &lt; 1.e-7);
}
<span style="color: #0000ff;">free</span>(exponent);
exponent = <span style="color: #008b8b;">NULL</span>;
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">coefficient</span> = (<span style="color: #228b22;">double</span>*) <span style="color: #0000ff;">malloc</span> (<span style="color: #228b22;">prim_num</span> * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>));
rc = qmckl_get_ao_basis_coefficient(context, coefficient, prim_num);
<span style="color: #0000ff;">qmckl_check</span>(context, rc);
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;prim_num ; i++) {
assert (fabs((coefficient[i] - chbrclf_basis_coefficient[i])/chbrclf_basis_coefficient[i]) &lt; 1.e-7);
}
<span style="color: #0000ff;">free</span>(coefficient);
coefficient = <span style="color: #008b8b;">NULL</span>;
<span style="color: #228b22;">double</span>* <span style="color: #a0522d;">prim_factor</span> = (<span style="color: #228b22;">double</span>*) <span style="color: #0000ff;">malloc</span> (<span style="color: #228b22;">prim_num</span> * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>));
rc = qmckl_get_ao_basis_prim_factor(context, prim_factor, prim_num);
<span style="color: #0000ff;">qmckl_check</span>(context, rc);
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;prim_num ; i++) {
assert (fabs((prim_factor[i] - chbrclf_basis_prim_factor[i])/chbrclf_basis_prim_factor[i]) &lt; 1.e-7);
}
<span style="color: #0000ff;">free</span>(prim_factor);
prim_factor = <span style="color: #008b8b;">NULL</span>;
<span style="color: #483d8b;">#endif</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org7fa02bb" class="outline-4">
<h4 id="org7fa02bb"><span class="section-number-4">3.0.4</span> MO Basis</h4>
<div class="outline-text-4" id="text-3-0-4">
<div class="org-src-container">
<pre class="src src-c">printf(<span style="color: #8b2252;">"MOs\n"</span>);
<span style="color: #228b22;">int64_t</span> <span style="color: #a0522d;">mo_num</span>;
rc = qmckl_get_mo_basis_mo_num(context, &amp;mo_num);
<span style="color: #0000ff;">qmckl_check</span>(context, rc);
<span style="color: #0000ff;">assert</span> (mo_num == chbrclf_mo_num);
printf(<span style="color: #8b2252;">"MO coefs\n"</span>);
<span style="color: #228b22;">double</span> * <span style="color: #a0522d;">mo_coef</span> = (<span style="color: #228b22;">double</span>*) <span style="color: #0000ff;">malloc</span> (<span style="color: #228b22;">ao_num</span> * <span style="color: #0000ff;">mo_num</span> * <span style="color: #a020f0;">sizeof</span>(<span style="color: #228b22;">double</span>));
rc = qmckl_get_mo_basis_coefficient(context, mo_coef, mo_num*ao_num);
<span style="color: #0000ff;">qmckl_check</span>(context, rc);
<span style="color: #a020f0;">for</span> (<span style="color: #228b22;">int</span> <span style="color: #a0522d;">i</span>=0 ; i&lt;ao_num * mo_num ; i++) {
printf(<span style="color: #8b2252;">"%d %e %e %e\n"</span>, i, mo_coef[i], chbrclf_mo_coef[i],
( fabs(mo_coef[i] - chbrclf_mo_coef[i])/fabs(mo_coef[i])) );
assert ( fabs(mo_coef[i] - chbrclf_mo_coef[i])/fabs(mo_coef[i]) &lt; 1.e-12 );
}
<span style="color: #0000ff;">free</span>(mo_coef);
charge = <span style="color: #008b8b;">NULL</span>;
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="postamble" class="status">
<p class="author">Author: TREX CoE</p>
<p class="date">Created: 2024-04-10 Wed 14:39</p>
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
</body>
</html>