1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-07-15 23:51:05 +02:00

Moved documentation in share/doc

This commit is contained in:
Anthony Scemama 2021-04-30 01:26:19 +02:00
parent 79c9651021
commit e2e46d0714
24 changed files with 451 additions and 404 deletions

View File

@ -21,29 +21,29 @@ jobs:
run: sudo apt-get install emacs26 run: sudo apt-get install emacs26
- name: install htmlize - name: install htmlize
run: git clone https://github.com/hniksic/emacs-htmlize && cp emacs-htmlize/htmlize.el docs/ run: git clone https://github.com/hniksic/emacs-htmlize && cp emacs-htmlize/htmlize.el share/doc/qmckl/html/
- name: make - name: make
run: make -C src/ doc && ls -sh ./docs/ run: make -C src/ doc && ls -sh ./share/doc/qmckl/html/
- name: pwd - name: pwd
run: pwd run: pwd
- name: ls - name: ls
run: ls -sh ./docs run: ls -sh ./share/doc/qmckl/html/
# - name: Deploy # - name: Deploy
# uses: peaceiris/actions-gh-pages@v3 # uses: peaceiris/actions-gh-pages@v3
# with: # with:
# github_token: ${{ secrets.GITHUB_TOKEN }} # github_token: ${{ secrets.GITHUB_TOKEN }}
# publish_dir: ./docs # publish_dir: ./share/doc/qmckl/html/
- name: Deploy - name: Deploy
uses: JamesIves/github-pages-deploy-action@4.1.0 uses: JamesIves/github-pages-deploy-action@4.1.0
with: with:
branch: gh-pages branch: gh-pages
folder: ./docs folder: ./share/doc/qmckl/html/
# github_token: ${{ secrets.GITHUB_TOKEN }} # github_token: ${{ secrets.GITHUB_TOKEN }}
# publish_dir: ./docs # publish_dir: ./share/doc/qmckl/html/

3
.gitmodules vendored
View File

@ -1,6 +1,3 @@
[submodule "munit"] [submodule "munit"]
path = munit path = munit
url = https://github.com/nemequ/munit/ url = https://github.com/nemequ/munit/
[submodule "docs/org-html-themes"]
path = docs/org-html-themes
url = https://github.com/fniessen/org-html-themes.git

View File

@ -16,15 +16,19 @@ static_lib=$(QMCKL_ROOT)/lib/libqmckl.a
qmckl_h=$(QMCKL_ROOT)/include/qmckl.h qmckl_h=$(QMCKL_ROOT)/include/qmckl.h
qmckl_f=$(QMCKL_ROOT)/share/qmckl/fortran/qmckl_f.f90 qmckl_f=$(QMCKL_ROOT)/share/qmckl/fortran/qmckl_f.f90
docdir=$(prefix)/share/doc/qmckl
libdir=$(prefix)/lib
includedir=$(prefix)/include
fortrandir=$(prefix)/share/qmckl/fortran
export prefix shared_lib static_lib qmckl_h qmckl_f export prefix shared_lib static_lib qmckl_h qmckl_f
all clean doc check install uninstall: all clean doc install uninstall check:
$(MAKE) -C src $@ $(MAKE) -C src $@
dist: $(distdir).tar.gz dist: $(distdir).tar.gz
$(distdir).tar.gz: $(distdir) $(distdir).tar.gz: $(distdir)
tar chof - $(distdir) | gzip -9 -c > $@ tar chof - $(distdir) | gzip -9 -c > $@
rm -rf $(distdir) rm -rf $(distdir)
@ -39,15 +43,15 @@ $(distdir): $(qmckl_h) $(qmckl_f) $(static_lib) $(shared_lib) src/Makefile.gener
mkdir -p $(distdir)/share/doc/qmckl/html/ mkdir -p $(distdir)/share/doc/qmckl/html/
mkdir -p $(distdir)/share/doc/qmckl/text/ mkdir -p $(distdir)/share/doc/qmckl/text/
mkdir -p $(distdir)/man mkdir -p $(distdir)/man
cp munit/munit.h munit/munit.c $(distdir)/munit/ cp $(QMCKL_ROOT)/munit/munit.h munit/munit.c $(distdir)/munit/
cp src/*.c src/*.h src/*.f90 $(distdir)/src/ cp $(QMCKL_ROOT)/src/*.c src/*.h src/*.f90 $(distdir)/src/
cp src/Makefile.generated $(distdir)/src/Makefile cp $(QMCKL_ROOT)/src/Makefile.generated $(distdir)/src/Makefile
cp include/* $(distdir)/include cp $(qmckl_h) $(distdir)/include
cp Makefile $(distdir)/ cp $(QMCKL_ROOT)/Makefile $(distdir)/
cp docs/*.html $(distdir)/share/doc/qmckl/html/ cp $(QMCKL_ROOT)/share/doc/qmckl/html/*.html $(distdir)/share/doc/qmckl/html/
cp docs/*.css $(distdir)/share/doc/qmckl/html/ cp $(QMCKL_ROOT)/share/doc/qmckl/html/*.css $(distdir)/share/doc/qmckl/html/
cp docs/*.txt $(distdir)/share/doc/qmckl/text/ cp $(QMCKL_ROOT)/share/doc/qmckl/text/*.txt $(distdir)/share/doc/qmckl/text/
cp share/qmckl/fortran/* $(distdir)/share/qmckl/fortran cp $(qmckl_f) $(distdir)/share/qmckl/fortran/
mkdir -p $(distdir)/lib mkdir -p $(distdir)/lib
@ -58,21 +62,27 @@ FORCE:
distcheck: $(distdir).tar.gz distcheck: $(distdir).tar.gz
gzip -cd $(distdir).tar.gz | tar xvf - gzip -cd $(distdir).tar.gz | tar xvf -
cd $(distdir) && $(MAKE) all check cd $(distdir) && $(MAKE) all
rm $(distdir)/lib/libqmckl.so cd $(distdir) && $(MAKE) check
rm $(distdir)/include/qmckl.h cd $(distdir) && $(MAKE) prefix=$${PWD}/_inst install
rm $(distdir)/share/qmckl/fortran/qmckl_f.f90 cd $(distdir) && $(MAKE) prefix=$${PWD}/_inst uninstall
rm $(distdir)/share/doc/qmckl/html/*.html @remaining="`find $${PWD}/$(distdir)/_inst -type f | wc -l`" ;\
rm $(distdir)/share/doc/qmckl/html/*.css if test "$${remaining}" -ne 0; then \
rm $(distdir)/share/doc/qmckl/text/*.txt echo "*** $${remaining} file(s) remaining in stage directory"; \
exit 1; \
fi
cd $(distdir) && $(MAKE) clean cd $(distdir) && $(MAKE) clean
rm -rf $(distdir) rm -rf $(distdir)
@echo "*** Package $(distdir).tar.gz is ready for distribution." @echo "*** Package $(distdir).tar.gz is ready for distribution."
$(qmckl_h) $(qmckl_f) $(static_lib) $(shared_lib) src/Makefile.generated: $(qmckl_h) $(qmckl_f) $(static_lib) $(shared_lib):
$(MAKE) -C src $@ $(MAKE) -C src $@
src/Makefile.generated:
$(MAKE) -C src Makefile.generated
veryclean: FORCE clean
.PHONY: all clean dist doc install uninstall FORCE .PHONY: all veryclean clean dist doc install uninstall FORCE

1
docs/.gitignore vendored
View File

@ -1 +0,0 @@
*.txt

@ -1 +0,0 @@
Subproject commit f7224a489462abc2c2174edbf7d4e82c0e276183

View File

@ -1,16 +0,0 @@
# -*- mode: org; -*-
#+HTML_LINK_HOME: index.html
#+OPTIONS: H:4 num:t toc:t \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t d:(HIDE)
# SETUPFILE: ../docs/org-html-themes/org/theme-readtheorg.setup
#+INFOJS_OPT: toc:t mouse:underline path:org-info.js
#+HTML_HEAD: <link rel="stylesheet" title="Standard" href="qmckl.css" type="text/css" />
#+STARTUP: align fold nodlcheck hidestars oddeven lognotestate
#+AUTHOR: TREX CoE
#+LANGUAGE: en

12
qmckl.pc Normal file
View File

@ -0,0 +1,12 @@
prefix=/usr
exec_prefix=${prefix}
includedir=${exec_prefix}/include
libdir=${exec_prefix}/lib
Name: QMCkl
Description: Quantum Monte Carlo kernel library
URL: https://github.com/trex-coe/qmckl
Version: 1.0.0
Cflags: -I${includedir}
Libs: -L${libdir} -lqmckl
Requires.private: blas

0
share/doc/qmckl/html/.gitignore vendored Normal file
View File

0
share/doc/qmckl/text/.gitignore vendored Normal file
View File

View File

@ -92,10 +92,13 @@ endif
# The Makefile.generated is the one that will be distributed with the library. # The Makefile.generated is the one that will be distributed with the library.
.PHONY: clean shared static doc all check install uninstall syntax .PHONY: clean shared static doc all check install uninstall
.SECONDARY: # Needed to keep the produced C and Fortran files .SECONDARY: # Needed to keep the produced C and Fortran files
$(shared_lib) $(static_lib) install uninstall: $(qmckl_h) $(qmckl_f) Makefile.generated $(shared_lib) $(static_lib): $(qmckl_h) $(qmckl_f) Makefile.generated
$(MAKE) -f Makefile.generated $@
install uninstall: Makefile.generated
$(MAKE) -f Makefile.generated $@ $(MAKE) -f Makefile.generated $@
$(qmckl_f) $(qmckl_h): Makefile.generated $(qmckl_f) $(qmckl_h): Makefile.generated
@ -108,8 +111,11 @@ all: shared static doc check
check: $(static_lib) check: $(static_lib)
$(MAKE) -f Makefile.generated check $(MAKE) -f Makefile.generated check
syntax: cppcheck:
cppcheck --addon=cert qmckl_*.c cppcheck \
--addon=cert \
--enable=warning,style,performance,portability,information \
qmckl_*.c
doc: $(ORG_SOURCE_FILES) doc: $(ORG_SOURCE_FILES)
$(QMCKL_ROOT)/tools/build_doc.sh $(QMCKL_ROOT)/tools/build_doc.sh
@ -122,10 +128,10 @@ clean:
Makefile.generated *.html *.txt Makefile.generated *.html *.txt
veryclean: clean FORCE veryclean: clean FORCE
- $(RM) $(QMCKL_ROOT)/docs/*.html \ - $(RM) $(QMCKL_ROOT)/share/doc/qmckl/html/*.html \
$(QMCKL_ROOT)/docs/*.txt $(QMCKL_ROOT)/share/doc/qmckl/text/*.txt
Makefile.generated: Makefile $(QMCKL_ROOT)/tools/create_makefile.sh $(ORG_SOURCE_FILES) Makefile.generated: Makefile $(QMCKL_ROOT)/tools/create_makefile.sh $(ORG_SOURCE_FILES) ../tools/Building.org
$(QMCKL_ROOT)/tools/create_makefile.sh $(QMCKL_ROOT)/tools/create_makefile.sh

View File

@ -1,6 +1,6 @@
#+TITLE: QMCkl source code documentation #+TITLE: QMCkl source code documentation
#+PROPERTY: comments org #+PROPERTY: comments org
#+SETUPFILE: ../docs/theme.setup #+SETUPFILE: ../tools/theme.setup
------------------ ------------------
@ -14,7 +14,7 @@
#+begin_src sh :exports none #+begin_src sh :exports none
grep TITLE $(cat table_of_contents) | tr ':' ' ' grep TITLE $(cat table_of_contents) | tr ':' ' '
#+end_src #+end_src
#+RESULTS: toc #+RESULTS: toc
| qmckl.org | #+TITLE | Header | files | | qmckl.org | #+TITLE | Header | files |
| qmckl_error.org | #+TITLE | Error | handling | | qmckl_error.org | #+TITLE | Error | handling |
@ -43,7 +43,7 @@ return '\n'.join(result)
- [[./qmckl_distance.html][Distances]] - [[./qmckl_distance.html][Distances]]
- [[./qmckl_ao.html][Atomic Orbitals]] - [[./qmckl_ao.html][Atomic Orbitals]]
- [[./test_qmckl.html][Testing]] - [[./test_qmckl.html][Testing]]
-------------------------------- --------------------------------
@ -65,4 +65,4 @@ return '\n'.join(result)
[[https://trex-coe.eu/sites/default/files/inline-images/euflag.jpg]] [[https://trex-coe.eu][TREX: Targeting Real Chemical Accuracy at the Exascale]] project has received funding from the European Unions Horizon 2020 - Research and Innovation program - under grant agreement no. 952165. The content of this document does not represent the opinion of the European Union, and the European Union is not responsible for any use that might be made of such content. [[https://trex-coe.eu/sites/default/files/inline-images/euflag.jpg]] [[https://trex-coe.eu][TREX: Targeting Real Chemical Accuracy at the Exascale]] project has received funding from the European Unions Horizon 2020 - Research and Innovation program - under grant agreement no. 952165. The content of this document does not represent the opinion of the European Union, and the European Union is not responsible for any use that might be made of such content.
# -*- mode: org -*- # -*- mode: org -*-

View File

@ -1,6 +1,6 @@
#+TITLE: Introduction #+TITLE: Introduction
#+PROPERTY: comments org #+PROPERTY: comments org
#+SETUPFILE: ../docs/theme.setup #+SETUPFILE: ../tools/theme.setup
# -*- mode: org -*- # -*- mode: org -*-
* Using QMCkl * Using QMCkl

View File

@ -1,5 +1,5 @@
#+TITLE: Atomic Orbitals #+TITLE: Atomic Orbitals
#+SETUPFILE: ../docs/theme.setup #+SETUPFILE: ../tools/theme.setup
#+INCLUDE: ../tools/lib.org #+INCLUDE: ../tools/lib.org
The atomic basis set is defined as a list of shells. Each shell $s$ is The atomic basis set is defined as a list of shells. Each shell $s$ is
@ -11,7 +11,7 @@ Gaussian ($p=2$):
\[ \[
R_s(\mathbf{r}) = \mathcal{N}_s |\mathbf{r}-\mathbf{R}_A|^{n_s} R_s(\mathbf{r}) = \mathcal{N}_s |\mathbf{r}-\mathbf{R}_A|^{n_s}
\sum_{k=1}^{N_{\text{prim}}} a_{ks} \sum_{k=1}^{N_{\text{prim}}} a_{ks}
\exp \left( - \gamma_{ks} | \mathbf{r}-\mathbf{R}_A | ^p \right). \exp \left( - \gamma_{ks} | \mathbf{r}-\mathbf{R}_A | ^p \right).
\] \]
In the case of Gaussian functions, $n_s$ is always zero. In the case of Gaussian functions, $n_s$ is always zero.
@ -26,7 +26,7 @@ Atomic orbitals (AOs) are defined as
\[ \[
\chi_i (\mathbf{r}) = P_{\eta(i)}(\mathbf{r})\, R_{\theta(i)} (\mathbf{r}) \chi_i (\mathbf{r}) = P_{\eta(i)}(\mathbf{r})\, R_{\theta(i)} (\mathbf{r})
\] \]
where $\theta(i)$ returns the shell on which the AO is expanded, where $\theta(i)$ returns the shell on which the AO is expanded,
and $\eta(i)$ denotes which angular function is chosen. and $\eta(i)$ denotes which angular function is chosen.
@ -34,7 +34,7 @@ In this section we describe the kernels used to compute the values,
gradients and Laplacian of the atomic basis functions. gradients and Laplacian of the atomic basis functions.
* Headers :noexport: * Headers :noexport:
#+begin_src elisp :noexport :results none #+begin_src elisp :noexport :results none
(org-babel-lob-ingest "../tools/lib.org") (org-babel-lob-ingest "../tools/lib.org")
#+end_src #+end_src
@ -74,7 +74,7 @@ MunitResult test_<<filename()>>() {
* Context * Context
The following arrays are stored in the context: The following arrays are stored in the context:
| ~type~ | | Gaussian (~'G'~) or Slater (~'S'~) | | ~type~ | | Gaussian (~'G'~) or Slater (~'S'~) |
| ~shell_num~ | | Number of shells | | ~shell_num~ | | Number of shells |
| ~prim_num~ | | Total number of primitives | | ~prim_num~ | | Total number of primitives |
@ -150,9 +150,9 @@ typedef struct qmckl_ao_basis_struct {
initialization function which has not bee called. It becomes equal initialization function which has not bee called. It becomes equal
to zero after all initialization functions have been called. The to zero after all initialization functions have been called. The
struct is then initialized and ~provided == true~. struct is then initialized and ~provided == true~.
** Access functions ** Access functions
#+begin_src c :comments org :tangle (eval h_private_func) :exports none #+begin_src c :comments org :tangle (eval h_private_func) :exports none
char qmckl_get_ao_basis_type (const qmckl_context context); char qmckl_get_ao_basis_type (const qmckl_context context);
int64_t qmckl_get_ao_basis_shell_num (const qmckl_context context); int64_t qmckl_get_ao_basis_shell_num (const qmckl_context context);
@ -179,7 +179,7 @@ if ( (ctx->ao_basis.uninitialized & mask) != 0) {
return NULL; return NULL;
} }
#+end_src #+end_src
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
char qmckl_get_ao_basis_type (const qmckl_context context) { char qmckl_get_ao_basis_type (const qmckl_context context) {
@ -385,12 +385,12 @@ bool qmckl_ao_basis_provided(const qmckl_context context) {
return ctx->ao_basis.provided; return ctx->ao_basis.provided;
} }
#+end_src #+end_src
** Initialization functions ** Initialization functions
To set the basis set, all the following functions need to be To set the basis set, all the following functions need to be
called. When called. When
#+begin_src c :comments org :tangle (eval h_func) #+begin_src c :comments org :tangle (eval h_func)
qmckl_exit_code qmckl_set_ao_basis_type (qmckl_context context, const char t); qmckl_exit_code qmckl_set_ao_basis_type (qmckl_context context, const char t);
qmckl_exit_code qmckl_set_ao_basis_shell_num (qmckl_context context, const int64_t shell_num); qmckl_exit_code qmckl_set_ao_basis_shell_num (qmckl_context context, const int64_t shell_num);
@ -415,12 +415,12 @@ qmckl_context_struct* const ctx = (qmckl_context_struct* const) context;
#+NAME:post2 #+NAME:post2
#+begin_src c :exports none #+begin_src c :exports none
ctx->ao_basis.uninitialized &= ~mask; ctx->ao_basis.uninitialized &= ~mask;
ctx->ao_basis.provided = (ctx->ao_basis.uninitialized == 0); ctx->ao_basis.provided = (ctx->ao_basis.uninitialized == 0);
return QMCKL_SUCCESS; return QMCKL_SUCCESS;
#+end_src #+end_src
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
qmckl_exit_code qmckl_set_ao_basis_type(qmckl_context context, const char t) { qmckl_exit_code qmckl_set_ao_basis_type(qmckl_context context, const char t) {
@ -464,7 +464,7 @@ qmckl_exit_code qmckl_set_ao_basis_shell_num(qmckl_context context, const int64_
<<post2>> <<post2>>
} }
qmckl_exit_code qmckl_set_ao_basis_prim_num(qmckl_context context, const int64_t prim_num) { qmckl_exit_code qmckl_set_ao_basis_prim_num(qmckl_context context, const int64_t prim_num) {
<<pre2>> <<pre2>>
@ -490,7 +490,7 @@ qmckl_exit_code qmckl_set_ao_basis_prim_num(qmckl_context context, const int64_
<<post2>> <<post2>>
} }
qmckl_exit_code qmckl_set_ao_basis_shell_center(qmckl_context context, const int64_t* shell_center) { qmckl_exit_code qmckl_set_ao_basis_shell_center(qmckl_context context, const int64_t* shell_center) {
<<pre2>> <<pre2>>
@ -504,11 +504,11 @@ qmckl_exit_code qmckl_set_ao_basis_shell_center(qmckl_context context, const in
"qmckl_set_ao_basis_shell_center", "qmckl_set_ao_basis_shell_center",
"shell_num is not set"); "shell_num is not set");
} }
if (ctx->ao_basis.shell_center != NULL) { if (ctx->ao_basis.shell_center != NULL) {
qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.shell_center); qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.shell_center);
if (rc != QMCKL_SUCCESS) { if (rc != QMCKL_SUCCESS) {
return qmckl_failwith( context, rc, return qmckl_failwith( context, rc,
"qmckl_set_ao_basis_shell_center", "qmckl_set_ao_basis_shell_center",
NULL); NULL);
} }
@ -526,13 +526,13 @@ qmckl_exit_code qmckl_set_ao_basis_shell_center(qmckl_context context, const in
} }
memcpy(new_array, shell_center, mem_info.size); memcpy(new_array, shell_center, mem_info.size);
ctx->ao_basis.shell_center = new_array; ctx->ao_basis.shell_center = new_array;
<<post2>> <<post2>>
} }
qmckl_exit_code qmckl_set_ao_basis_shell_ang_mom(qmckl_context context, const char* shell_ang_mom) { qmckl_exit_code qmckl_set_ao_basis_shell_ang_mom(qmckl_context context, const char* shell_ang_mom) {
<<pre2>> <<pre2>>
@ -545,17 +545,17 @@ qmckl_exit_code qmckl_set_ao_basis_shell_ang_mom(qmckl_context context, const c
"qmckl_set_ao_basis_shell_ang_mom", "qmckl_set_ao_basis_shell_ang_mom",
"shell_num is not set"); "shell_num is not set");
} }
if (ctx->ao_basis.shell_ang_mom != NULL) { if (ctx->ao_basis.shell_ang_mom != NULL) {
qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.shell_ang_mom); qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.shell_ang_mom);
if (rc != QMCKL_SUCCESS) { if (rc != QMCKL_SUCCESS) {
return qmckl_failwith( context, rc, return qmckl_failwith( context, rc,
"qmckl_set_ao_basis_shell_ang_mom", "qmckl_set_ao_basis_shell_ang_mom",
NULL); NULL);
} }
} }
qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero;
mem_info.size = shell_num * sizeof(char); mem_info.size = shell_num * sizeof(char);
char* new_array = (char*) qmckl_malloc(context, mem_info); char* new_array = (char*) qmckl_malloc(context, mem_info);
@ -568,12 +568,12 @@ qmckl_exit_code qmckl_set_ao_basis_shell_ang_mom(qmckl_context context, const c
} }
memcpy(new_array, shell_ang_mom, mem_info.size); memcpy(new_array, shell_ang_mom, mem_info.size);
ctx->ao_basis.shell_ang_mom = new_array; ctx->ao_basis.shell_ang_mom = new_array;
<<post2>> <<post2>>
} }
qmckl_exit_code qmckl_set_ao_basis_shell_prim_num(qmckl_context context, const int64_t* shell_prim_num) { qmckl_exit_code qmckl_set_ao_basis_shell_prim_num(qmckl_context context, const int64_t* shell_prim_num) {
<<pre2>> <<pre2>>
@ -587,17 +587,17 @@ qmckl_exit_code qmckl_set_ao_basis_shell_prim_num(qmckl_context context, const
"qmckl_set_ao_basis_shell_prim_num", "qmckl_set_ao_basis_shell_prim_num",
"shell_num is not set"); "shell_num is not set");
} }
if (ctx->ao_basis.shell_prim_num != NULL) { if (ctx->ao_basis.shell_prim_num != NULL) {
qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.shell_prim_num); qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.shell_prim_num);
if (rc != QMCKL_SUCCESS) { if (rc != QMCKL_SUCCESS) {
return qmckl_failwith( context, rc, return qmckl_failwith( context, rc,
"qmckl_set_ao_basis_shell_prim_num", "qmckl_set_ao_basis_shell_prim_num",
NULL); NULL);
} }
} }
qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero;
mem_info.size = shell_num * sizeof(int64_t); mem_info.size = shell_num * sizeof(int64_t);
int64_t* new_array = (int64_t*) qmckl_malloc(context, mem_info); int64_t* new_array = (int64_t*) qmckl_malloc(context, mem_info);
@ -610,13 +610,13 @@ qmckl_exit_code qmckl_set_ao_basis_shell_prim_num(qmckl_context context, const
} }
memcpy(new_array, shell_prim_num, mem_info.size); memcpy(new_array, shell_prim_num, mem_info.size);
ctx->ao_basis.shell_prim_num = new_array; ctx->ao_basis.shell_prim_num = new_array;
<<post2>> <<post2>>
} }
qmckl_exit_code qmckl_set_ao_basis_shell_prim_index(qmckl_context context, const int64_t* shell_prim_index) { qmckl_exit_code qmckl_set_ao_basis_shell_prim_index(qmckl_context context, const int64_t* shell_prim_index) {
<<pre2>> <<pre2>>
@ -629,16 +629,16 @@ qmckl_exit_code qmckl_set_ao_basis_shell_prim_index(qmckl_context context, cons
"qmckl_set_ao_basis_shell_prim_index", "qmckl_set_ao_basis_shell_prim_index",
"shell_num is not set"); "shell_num is not set");
} }
if (ctx->ao_basis.shell_prim_index != NULL) { if (ctx->ao_basis.shell_prim_index != NULL) {
qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.shell_prim_index); qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.shell_prim_index);
if (rc != QMCKL_SUCCESS) { if (rc != QMCKL_SUCCESS) {
return qmckl_failwith( context, rc, return qmckl_failwith( context, rc,
"qmckl_set_ao_basis_shell_prim_index", "qmckl_set_ao_basis_shell_prim_index",
NULL); NULL);
} }
} }
qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero;
mem_info.size = shell_num * sizeof(int64_t); mem_info.size = shell_num * sizeof(int64_t);
int64_t* new_array = (int64_t*) qmckl_malloc(context, mem_info); int64_t* new_array = (int64_t*) qmckl_malloc(context, mem_info);
@ -651,13 +651,13 @@ qmckl_exit_code qmckl_set_ao_basis_shell_prim_index(qmckl_context context, cons
} }
memcpy(new_array, shell_prim_index, mem_info.size); memcpy(new_array, shell_prim_index, mem_info.size);
ctx->ao_basis.shell_prim_index = new_array; ctx->ao_basis.shell_prim_index = new_array;
<<post2>> <<post2>>
} }
qmckl_exit_code qmckl_set_ao_basis_shell_factor(qmckl_context context, const double* shell_factor) { qmckl_exit_code qmckl_set_ao_basis_shell_factor(qmckl_context context, const double* shell_factor) {
<<pre2>> <<pre2>>
@ -670,17 +670,17 @@ qmckl_exit_code qmckl_set_ao_basis_shell_factor(qmckl_context context, const do
"qmckl_set_ao_basis_shell_factor", "qmckl_set_ao_basis_shell_factor",
"shell_num is not set"); "shell_num is not set");
} }
if (ctx->ao_basis.shell_factor != NULL) { if (ctx->ao_basis.shell_factor != NULL) {
qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.shell_factor); qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.shell_factor);
if (rc != QMCKL_SUCCESS) { if (rc != QMCKL_SUCCESS) {
return qmckl_failwith( context, rc, return qmckl_failwith( context, rc,
"qmckl_set_ao_basis_shell_factor", "qmckl_set_ao_basis_shell_factor",
NULL); NULL);
} }
} }
qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero;
mem_info.size = shell_num * sizeof(double); mem_info.size = shell_num * sizeof(double);
double* new_array = (double*) qmckl_malloc(context, mem_info); double* new_array = (double*) qmckl_malloc(context, mem_info);
@ -693,12 +693,12 @@ qmckl_exit_code qmckl_set_ao_basis_shell_factor(qmckl_context context, const do
} }
memcpy(new_array, shell_factor, mem_info.size); memcpy(new_array, shell_factor, mem_info.size);
ctx->ao_basis.shell_factor = new_array; ctx->ao_basis.shell_factor = new_array;
<<post2>> <<post2>>
} }
qmckl_exit_code qmckl_set_ao_basis_exponent(qmckl_context context, const double* exponent) { qmckl_exit_code qmckl_set_ao_basis_exponent(qmckl_context context, const double* exponent) {
<<pre2>> <<pre2>>
@ -711,16 +711,16 @@ qmckl_exit_code qmckl_set_ao_basis_exponent(qmckl_context context, const double
"qmckl_set_ao_basis_exponent", "qmckl_set_ao_basis_exponent",
"prim_num is not set"); "prim_num is not set");
} }
if (ctx->ao_basis.exponent != NULL) { if (ctx->ao_basis.exponent != NULL) {
qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.exponent); qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.exponent);
if (rc != QMCKL_SUCCESS) { if (rc != QMCKL_SUCCESS) {
return qmckl_failwith( context, rc, return qmckl_failwith( context, rc,
"qmckl_set_ao_basis_exponent", "qmckl_set_ao_basis_exponent",
NULL); NULL);
} }
} }
qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero;
mem_info.size = prim_num * sizeof(double); mem_info.size = prim_num * sizeof(double);
double* new_array = (double*) qmckl_malloc(context, mem_info); double* new_array = (double*) qmckl_malloc(context, mem_info);
@ -733,12 +733,12 @@ qmckl_exit_code qmckl_set_ao_basis_exponent(qmckl_context context, const double
} }
memcpy(new_array, exponent, mem_info.size); memcpy(new_array, exponent, mem_info.size);
ctx->ao_basis.exponent = new_array; ctx->ao_basis.exponent = new_array;
<<post2>> <<post2>>
} }
qmckl_exit_code qmckl_set_ao_basis_coefficient(qmckl_context context, const double* coefficient) { qmckl_exit_code qmckl_set_ao_basis_coefficient(qmckl_context context, const double* coefficient) {
<<pre2>> <<pre2>>
@ -751,16 +751,16 @@ qmckl_exit_code qmckl_set_ao_basis_coefficient(qmckl_context context, const dou
"qmckl_set_ao_basis_coefficient", "qmckl_set_ao_basis_coefficient",
"prim_num is not set"); "prim_num is not set");
} }
if (ctx->ao_basis.coefficient != NULL) { if (ctx->ao_basis.coefficient != NULL) {
qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.coefficient); qmckl_exit_code rc = qmckl_free(context, ctx->ao_basis.coefficient);
if (rc != QMCKL_SUCCESS) { if (rc != QMCKL_SUCCESS) {
return qmckl_failwith( context, rc, return qmckl_failwith( context, rc,
"qmckl_set_ao_basis_coefficient", "qmckl_set_ao_basis_coefficient",
NULL); NULL);
} }
} }
qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero;
mem_info.size = prim_num * sizeof(double); mem_info.size = prim_num * sizeof(double);
double* new_array = (double*) qmckl_malloc(context, mem_info); double* new_array = (double*) qmckl_malloc(context, mem_info);
@ -773,12 +773,12 @@ qmckl_exit_code qmckl_set_ao_basis_coefficient(qmckl_context context, const dou
} }
memcpy(new_array, coefficient, mem_info.size); memcpy(new_array, coefficient, mem_info.size);
ctx->ao_basis.coefficient = new_array; ctx->ao_basis.coefficient = new_array;
<<post2>> <<post2>>
} }
#+end_src #+end_src
** TODO Fortran interfaces ** TODO Fortran interfaces
@ -817,7 +817,7 @@ double coefficient [prim_num] =
1.0, 1.0, 1.0, 1.0, 1.0, 0.006068, 0.045308, 0.202822, 1.0, 1.0, 1.0, 1.0, 1.0, 0.006068, 0.045308, 0.202822,
0.503903, 0.383421, 1.0, 1.0, 1.0, 1.0, 1.0 }; 0.503903, 0.383421, 1.0, 1.0, 1.0, 1.0, 1.0 };
/* --- */ /* --- */
qmckl_exit_code rc; qmckl_exit_code rc;
munit_assert(!qmckl_ao_basis_provided(context)); munit_assert(!qmckl_ao_basis_provided(context));
@ -875,11 +875,11 @@ munit_assert(qmckl_ao_basis_provided(context));
:CRetType: qmckl_exit_code :CRetType: qmckl_exit_code
:FRetType: qmckl_exit_code :FRetType: qmckl_exit_code
:END: :END:
The ~qmckl_ao_power~ function computes all the powers of the ~n~ The ~qmckl_ao_power~ function computes all the powers of the ~n~
input data up to the given maximum value given in input for each of input data up to the given maximum value given in input for each of
the $n$ points: the $n$ points:
\[ P_{ik} = X_i^k \] \[ P_{ik} = X_i^k \]
#+NAME: qmckl_ao_power_args #+NAME: qmckl_ao_power_args
@ -911,12 +911,12 @@ munit_assert(qmckl_ao_basis_provided(context));
const double* X, const double* X,
const int32_t* LMAX, const int32_t* LMAX,
double* const P, double* const P,
const int64_t ldp ); const int64_t ldp );
#+end_src #+end_src
*** Source *** Source
#+begin_src f90 :tangle (eval f) #+begin_src f90 :tangle (eval f)
integer function qmckl_ao_power_f(context, n, X, LMAX, P, ldp) result(info) integer function qmckl_ao_power_f(context, n, X, LMAX, P, ldp) result(info)
use qmckl use qmckl
implicit none implicit none
@ -955,12 +955,12 @@ integer function qmckl_ao_power_f(context, n, X, LMAX, P, ldp) result(info)
do i=1,n do i=1,n
P(1,i) = X(i) P(1,i) = X(i)
do k=2,LMAX(i) do k=2,LMAX(i)
P(k,i) = P(k-1,i) * X(i) P(k,i) = P(k-1,i) * X(i)
end do end do
end do end do
end function qmckl_ao_power_f end function qmckl_ao_power_f
#+end_src #+end_src
*** C interface *** C interface
#+CALL: generate_c_interface(table=qmckl_ao_power_args,rettyp=get_value("CRetType"),fname="qmckl_ao_power") #+CALL: generate_c_interface(table=qmckl_ao_power_args,rettyp=get_value("CRetType"),fname="qmckl_ao_power")
@ -1015,15 +1015,15 @@ end function qmckl_ao_power_f
*** Test *** Test
#+begin_src f90 :tangle (eval f_test) #+begin_src f90 :tangle (eval f_test)
integer(c_int32_t) function test_qmckl_ao_power(context) bind(C) integer(c_int32_t) function test_qmckl_ao_power(context) bind(C)
use qmckl use qmckl
implicit none implicit none
integer(qmckl_context), intent(in), value :: context integer(qmckl_context), intent(in), value :: context
integer*8 :: n, LDP integer*8 :: n, LDP
integer, allocatable :: LMAX(:) integer, allocatable :: LMAX(:)
double precision, allocatable :: X(:), P(:,:) double precision, allocatable :: X(:), P(:,:)
integer*8 :: i,j integer*8 :: i,j
double precision :: epsilon double precision :: epsilon
@ -1040,7 +1040,7 @@ integer(c_int32_t) function test_qmckl_ao_power(context) bind(C)
LMAX(j) = 1 + int(mod(j, 5),4) LMAX(j) = 1 + int(mod(j, 5),4)
end do end do
test_qmckl_ao_power = qmckl_ao_power(context, n, X, LMAX, P, LDP) test_qmckl_ao_power = qmckl_ao_power(context, n, X, LMAX, P, LDP)
if (test_qmckl_ao_power /= QMCKL_SUCCESS) return if (test_qmckl_ao_power /= QMCKL_SUCCESS) return
test_qmckl_ao_power = QMCKL_FAILURE test_qmckl_ao_power = QMCKL_FAILURE
@ -1073,29 +1073,29 @@ munit_assert_int(0, ==, test_qmckl_ao_power(context));
:END: :END:
A polynomial is centered on a nucleus $\mathbf{R}_i$ A polynomial is centered on a nucleus $\mathbf{R}_i$
\[ \[
P_l(\mathbf{r},\mathbf{R}_i) = (x-X_i)^a (y-Y_i)^b (z-Z_i)^c P_l(\mathbf{r},\mathbf{R}_i) = (x-X_i)^a (y-Y_i)^b (z-Z_i)^c
\] \]
The gradients with respect to electron coordinates are The gradients with respect to electron coordinates are
\begin{eqnarray*} \begin{eqnarray*}
\frac{\partial }{\partial x} P_l\left(\mathbf{r},\mathbf{R}_i \right) & \frac{\partial }{\partial x} P_l\left(\mathbf{r},\mathbf{R}_i \right) &
= & a (x-X_i)^{a-1} (y-Y_i)^b (z-Z_i)^c \\ = & a (x-X_i)^{a-1} (y-Y_i)^b (z-Z_i)^c \\
\frac{\partial }{\partial y} P_l\left(\mathbf{r},\mathbf{R}_i \right) & \frac{\partial }{\partial y} P_l\left(\mathbf{r},\mathbf{R}_i \right) &
= & b (x-X_i)^a (y-Y_i)^{b-1} (z-Z_i)^c \\ = & b (x-X_i)^a (y-Y_i)^{b-1} (z-Z_i)^c \\
\frac{\partial }{\partial z} P_l\left(\mathbf{r},\mathbf{R}_i \right) & \frac{\partial }{\partial z} P_l\left(\mathbf{r},\mathbf{R}_i \right) &
= & c (x-X_i)^a (y-Y_i)^b (z-Z_i)^{c-1} \\ = & c (x-X_i)^a (y-Y_i)^b (z-Z_i)^{c-1} \\
\end{eqnarray*} \end{eqnarray*}
and the Laplacian is and the Laplacian is
\begin{eqnarray*} \begin{eqnarray*}
\left( \frac{\partial }{\partial x^2} + \left( \frac{\partial }{\partial x^2} +
\frac{\partial }{\partial y^2} + \frac{\partial }{\partial y^2} +
\frac{\partial }{\partial z^2} \right) P_l \frac{\partial }{\partial z^2} \right) P_l
\left(\mathbf{r},\mathbf{R}_i \right) & = & \left(\mathbf{r},\mathbf{R}_i \right) & = &
a(a-1) (x-X_i)^{a-2} (y-Y_i)^b (z-Z_i)^c + \\ a(a-1) (x-X_i)^{a-2} (y-Y_i)^b (z-Z_i)^c + \\
&& b(b-1) (x-X_i)^a (y-Y_i)^{b-1} (z-Z_i)^c + \\ && b(b-1) (x-X_i)^a (y-Y_i)^{b-1} (z-Z_i)^c + \\
&& c(c-1) (x-X_i)^a (y-Y_i)^b (z-Z_i)^{c-1}. && c(c-1) (x-X_i)^a (y-Y_i)^b (z-Z_i)^{c-1}.
@ -1115,7 +1115,7 @@ munit_assert_int(0, ==, test_qmckl_ao_power(context));
| int64_t | ldl | in | Leading dimension of ~L~ | | int64_t | ldl | in | Leading dimension of ~L~ |
| double | VGL[n][ldv] | out | Value, gradients and Laplacian of the polynomials | | double | VGL[n][ldv] | out | Value, gradients and Laplacian of the polynomials |
| int64_t | ldv | in | Leading dimension of array ~VGL~ | | int64_t | ldv | in | Leading dimension of array ~VGL~ |
*** Requirements *** Requirements
- ~context~ is not ~QMCKL_NULL_CONTEXT~ - ~context~ is not ~QMCKL_NULL_CONTEXT~
@ -1150,7 +1150,7 @@ munit_assert_int(0, ==, test_qmckl_ao_power(context));
int32_t* const L, int32_t* const L,
const int64_t ldl, const int64_t ldl,
double* const VGL, double* const VGL,
const int64_t ldv ); const int64_t ldv );
#+end_src #+end_src
*** Source *** Source
@ -1212,9 +1212,9 @@ integer function qmckl_ao_polynomial_vgl_f(context, X, R, lmax, n, L, ldl, VGL,
else if (lmax > 0) then else if (lmax > 0) then
pows(-2:0,1:3) = 1.d0 pows(-2:0,1:3) = 1.d0
do i=1,lmax do i=1,lmax
pows(i,1) = pows(i-1,1) * Y(1) pows(i,1) = pows(i-1,1) * Y(1)
pows(i,2) = pows(i-1,2) * Y(2) pows(i,2) = pows(i-1,2) * Y(2)
pows(i,3) = pows(i-1,3) * Y(3) pows(i,3) = pows(i-1,3) * Y(3)
end do end do
VGL(1:5,1:4) = 0.d0 VGL(1:5,1:4) = 0.d0
@ -1282,8 +1282,8 @@ integer function qmckl_ao_polynomial_vgl_f(context, X, R, lmax, n, L, ldl, VGL,
info = QMCKL_SUCCESS info = QMCKL_SUCCESS
end function qmckl_ao_polynomial_vgl_f end function qmckl_ao_polynomial_vgl_f
#+end_src #+end_src
*** C interface *** C interface
#+CALL: generate_c_interface(table=qmckl_ao_polynomial_vgl_args,rettyp=get_value("CRetType"),fname=get_value("Name")) #+CALL: generate_c_interface(table=qmckl_ao_polynomial_vgl_args,rettyp=get_value("CRetType"),fname=get_value("Name"))
@ -1341,7 +1341,7 @@ end function qmckl_ao_polynomial_vgl_f
end function qmckl_ao_polynomial_vgl end function qmckl_ao_polynomial_vgl
end interface end interface
#+end_src #+end_src
*** Test *** Test
#+begin_src f90 :tangle (eval f_test) #+begin_src f90 :tangle (eval f_test)
@ -1419,13 +1419,13 @@ integer(c_int32_t) function test_qmckl_ao_polynomial_vgl(context) bind(C)
test_qmckl_ao_polynomial_vgl = QMCKL_FAILURE test_qmckl_ao_polynomial_vgl = QMCKL_FAILURE
w = 0.d0 w = 0.d0
if (L(1,j) > 1) then if (L(1,j) > 1) then
w = w + L(1,j) * (L(1,j)-1) * Y(1)**(L(1,j)-2) * Y(2)**L(2,j) * Y(3)**L(3,j) w = w + L(1,j) * (L(1,j)-1) * Y(1)**(L(1,j)-2) * Y(2)**L(2,j) * Y(3)**L(3,j)
end if end if
if (L(2,j) > 1) then if (L(2,j) > 1) then
w = w + L(2,j) * (L(2,j)-1) * Y(1)**L(1,j) * Y(2)**(L(2,j)-2) * Y(3)**L(3,j) w = w + L(2,j) * (L(2,j)-1) * Y(1)**L(1,j) * Y(2)**(L(2,j)-2) * Y(3)**L(3,j)
end if end if
if (L(3,j) > 1) then if (L(3,j) > 1) then
w = w + L(3,j) * (L(3,j)-1) * Y(1)**L(1,j) * Y(2)**L(2,j) * Y(3)**(L(3,j)-2) w = w + L(3,j) * (L(3,j)-1) * Y(1)**L(1,j) * Y(2)**L(2,j) * Y(3)**(L(3,j)-2)
end if end if
if (dabs(1.d0 - VGL(5,j) / w) > epsilon ) return if (dabs(1.d0 - VGL(5,j) / w) > epsilon ) return
end do end do
@ -1440,14 +1440,14 @@ end function test_qmckl_ao_polynomial_vgl
int test_qmckl_ao_polynomial_vgl(qmckl_context context); int test_qmckl_ao_polynomial_vgl(qmckl_context context);
munit_assert_int(0, ==, test_qmckl_ao_polynomial_vgl(context)); munit_assert_int(0, ==, test_qmckl_ao_polynomial_vgl(context));
#+end_src #+end_src
* Radial part * Radial part
** Gaussian basis functions ** Gaussian basis functions
~qmckl_ao_gaussian_vgl~ computes the values, gradients and ~qmckl_ao_gaussian_vgl~ computes the values, gradients and
Laplacians at a given point of ~n~ Gaussian functions centered at Laplacians at a given point of ~n~ Gaussian functions centered at
the same point: the same point:
\[ v_i = \exp(-a_i |X-R|^2) \] \[ v_i = \exp(-a_i |X-R|^2) \]
\[ \nabla_x v_i = -2 a_i (X_x - R_x) v_i \] \[ \nabla_x v_i = -2 a_i (X_x - R_x) v_i \]
\[ \nabla_y v_i = -2 a_i (X_y - R_y) v_i \] \[ \nabla_y v_i = -2 a_i (X_y - R_y) v_i \]
@ -1461,7 +1461,7 @@ munit_assert_int(0, ==, test_qmckl_ao_polynomial_vgl(context));
| ~A(n)~ | input | Exponents of the Gaussians | | ~A(n)~ | input | Exponents of the Gaussians |
| ~VGL(ldv,5)~ | output | Value, gradients and Laplacian of the Gaussians | | ~VGL(ldv,5)~ | output | Value, gradients and Laplacian of the Gaussians |
| ~ldv~ | input | Leading dimension of array ~VGL~ | | ~ldv~ | input | Leading dimension of array ~VGL~ |
Requirements Requirements
- ~context~ is not 0 - ~context~ is not 0
@ -1483,7 +1483,7 @@ qmckl_ao_gaussian_vgl(const qmckl_context context,
const double *VGL, const double *VGL,
const int64_t ldv); const int64_t ldv);
#+end_src #+end_src
#+begin_src f90 :tangle (eval f) #+begin_src f90 :tangle (eval f)
integer function qmckl_ao_gaussian_vgl_f(context, X, R, n, A, VGL, ldv) result(info) integer function qmckl_ao_gaussian_vgl_f(context, X, R, n, A, VGL, ldv) result(info)
use qmckl use qmckl
@ -1497,30 +1497,30 @@ integer function qmckl_ao_gaussian_vgl_f(context, X, R, n, A, VGL, ldv) result(i
integer*8 :: i,j integer*8 :: i,j
real*8 :: Y(3), r2, t, u, v real*8 :: Y(3), r2, t, u, v
info = QMCKL_SUCCESS info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) then if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT info = QMCKL_INVALID_CONTEXT
return return
endif endif
if (n <= 0) then if (n <= 0) then
info = QMCKL_INVALID_ARG_4 info = QMCKL_INVALID_ARG_4
return return
endif endif
if (ldv < n) then if (ldv < n) then
info = QMCKL_INVALID_ARG_7 info = QMCKL_INVALID_ARG_7
return return
endif endif
do i=1,3 do i=1,3
Y(i) = X(i) - R(i) Y(i) = X(i) - R(i)
end do end do
r2 = Y(1)*Y(1) + Y(2)*Y(2) + Y(3)*Y(3) r2 = Y(1)*Y(1) + Y(2)*Y(2) + Y(3)*Y(3)
do i=1,n do i=1,n
VGL(i,1) = dexp(-A(i) * r2) VGL(i,1) = dexp(-A(i) * r2)
end do end do
@ -1545,7 +1545,7 @@ integer function qmckl_ao_gaussian_vgl_f(context, X, R, n, A, VGL, ldv) result(i
end do end do
end function qmckl_ao_gaussian_vgl_f end function qmckl_ao_gaussian_vgl_f
#+end_src #+end_src
#+begin_src f90 :tangle (eval f) :exports none #+begin_src f90 :tangle (eval f) :exports none
integer(c_int32_t) function qmckl_ao_gaussian_vgl(context, X, R, n, A, VGL, ldv) & integer(c_int32_t) function qmckl_ao_gaussian_vgl(context, X, R, n, A, VGL, ldv) &
@ -1560,14 +1560,14 @@ integer(c_int32_t) function qmckl_ao_gaussian_vgl(context, X, R, n, A, VGL, ldv)
integer (c_int64_t) , intent(in) , value :: ldv integer (c_int64_t) , intent(in) , value :: ldv
integer, external :: qmckl_ao_gaussian_vgl_f integer, external :: qmckl_ao_gaussian_vgl_f
info = qmckl_ao_gaussian_vgl_f(context, X, R, n, A, VGL, ldv) info = qmckl_ao_gaussian_vgl_f(context, X, R, n, A, VGL, ldv)
end function qmckl_ao_gaussian_vgl end function qmckl_ao_gaussian_vgl
#+end_src #+end_src
#+begin_src f90 :tangle (eval fh_func) :exports none #+begin_src f90 :tangle (eval fh_func) :exports none
interface interface
integer(c_int32_t) function qmckl_ao_gaussian_vgl(context, X, R, n, A, VGL, ldv) & integer(c_int32_t) function qmckl_ao_gaussian_vgl(context, X, R, n, A, VGL, ldv) &
bind(C) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer (c_int64_t) , intent(in) , value :: context integer (c_int64_t) , intent(in) , value :: context
integer (c_int64_t) , intent(in) , value :: ldv integer (c_int64_t) , intent(in) , value :: ldv
@ -1585,7 +1585,7 @@ integer(c_int32_t) function test_qmckl_ao_gaussian_vgl(context) bind(C)
implicit none implicit none
integer(c_int64_t), intent(in), value :: context integer(c_int64_t), intent(in), value :: context
integer*8 :: n, ldv, j, i integer*8 :: n, ldv, j, i
double precision :: X(3), R(3), Y(3), r2 double precision :: X(3), R(3), Y(3), r2
double precision, allocatable :: VGL(:,:), A(:) double precision, allocatable :: VGL(:,:), A(:)
@ -1618,22 +1618,22 @@ integer(c_int32_t) function test_qmckl_ao_gaussian_vgl(context) bind(C)
if (dabs(1.d0 - VGL(i,1) / (& if (dabs(1.d0 - VGL(i,1) / (&
dexp(-A(i) * r2) & dexp(-A(i) * r2) &
)) > epsilon ) return )) > epsilon ) return
test_qmckl_ao_gaussian_vgl = -12 test_qmckl_ao_gaussian_vgl = -12
if (dabs(1.d0 - VGL(i,2) / (& if (dabs(1.d0 - VGL(i,2) / (&
-2.d0 * A(i) * Y(1) * dexp(-A(i) * r2) & -2.d0 * A(i) * Y(1) * dexp(-A(i) * r2) &
)) > epsilon ) return )) > epsilon ) return
test_qmckl_ao_gaussian_vgl = -13 test_qmckl_ao_gaussian_vgl = -13
if (dabs(1.d0 - VGL(i,3) / (& if (dabs(1.d0 - VGL(i,3) / (&
-2.d0 * A(i) * Y(2) * dexp(-A(i) * r2) & -2.d0 * A(i) * Y(2) * dexp(-A(i) * r2) &
)) > epsilon ) return )) > epsilon ) return
test_qmckl_ao_gaussian_vgl = -14 test_qmckl_ao_gaussian_vgl = -14
if (dabs(1.d0 - VGL(i,4) / (& if (dabs(1.d0 - VGL(i,4) / (&
-2.d0 * A(i) * Y(3) * dexp(-A(i) * r2) & -2.d0 * A(i) * Y(3) * dexp(-A(i) * r2) &
)) > epsilon ) return )) > epsilon ) return
test_qmckl_ao_gaussian_vgl = -15 test_qmckl_ao_gaussian_vgl = -15
if (dabs(1.d0 - VGL(i,5) / (& if (dabs(1.d0 - VGL(i,5) / (&
A(i) * (4.d0*r2*A(i) - 6.d0) * dexp(-A(i) * r2) & A(i) * (4.d0*r2*A(i) - 6.d0) * dexp(-A(i) * r2) &
@ -1641,7 +1641,7 @@ integer(c_int32_t) function test_qmckl_ao_gaussian_vgl(context) bind(C)
end do end do
test_qmckl_ao_gaussian_vgl = 0 test_qmckl_ao_gaussian_vgl = 0
deallocate(VGL) deallocate(VGL)
end function test_qmckl_ao_gaussian_vgl end function test_qmckl_ao_gaussian_vgl
#+end_src #+end_src
@ -1650,13 +1650,13 @@ end function test_qmckl_ao_gaussian_vgl
int test_qmckl_ao_gaussian_vgl(qmckl_context context); int test_qmckl_ao_gaussian_vgl(qmckl_context context);
munit_assert_int(0, ==, test_qmckl_ao_gaussian_vgl(context)); munit_assert_int(0, ==, test_qmckl_ao_gaussian_vgl(context));
#+end_src #+end_src
** TODO Slater basis functions ** TODO Slater basis functions
** TODO Radial functions on a grid ** TODO Radial functions on a grid
* Combining radial and polynomial parts * Combining radial and polynomial parts
* End of files :noexport: * End of files :noexport:
#+begin_src c :tangle (eval h_private_type) #+begin_src c :tangle (eval h_private_type)
#endif #endif
#+end_src #+end_src
@ -1668,35 +1668,35 @@ munit_assert_int(0, ==, test_qmckl_ao_gaussian_vgl(context));
return MUNIT_OK; return MUNIT_OK;
} }
#+end_src #+end_src
**✸ Compute file names **✸ Compute file names
#+begin_src emacs-lisp #+begin_src emacs-lisp
; The following is required to compute the file names ; The following is required to compute the file names
(setq pwd (file-name-directory buffer-file-name)) (setq pwd (file-name-directory buffer-file-name))
(setq name (file-name-nondirectory (substring buffer-file-name 0 -4))) (setq name (file-name-nondirectory (substring buffer-file-name 0 -4)))
(setq f (concat pwd name "_f.f90")) (setq f (concat pwd name "_f.f90"))
(setq fh (concat pwd name "_fh.f90")) (setq fh (concat pwd name "_fh.f90"))
(setq c (concat pwd name ".c")) (setq c (concat pwd name ".c"))
(setq h (concat name ".h")) (setq h (concat name ".h"))
(setq h_private (concat name "_private.h")) (setq h_private (concat name "_private.h"))
(setq c_test (concat pwd "test_" name ".c")) (setq c_test (concat pwd "test_" name ".c"))
(setq f_test (concat pwd "test_" name "_f.f90")) (setq f_test (concat pwd "test_" name "_f.f90"))
; Minted ; Minted
(require 'ox-latex) (require 'ox-latex)
(setq org-latex-listings 'minted) (setq org-latex-listings 'minted)
(add-to-list 'org-latex-packages-alist '("" "listings")) (add-to-list 'org-latex-packages-alist '("" "listings"))
(add-to-list 'org-latex-packages-alist '("" "color")) (add-to-list 'org-latex-packages-alist '("" "color"))
#+end_src #+end_src
#+RESULTS: #+RESULTS:
| | color | | | color |
| | listings | | | listings |
# -*- mode: org -*- # -*- mode: org -*-
# vim: syntax=c # vim: syntax=c

View File

@ -1,6 +1,6 @@
#+TITLE: Context #+TITLE: Context
#+SETUPFILE: ../docs/theme.setup #+SETUPFILE: ../tools/theme.setup
#+INCLUDE: ../tools/lib.org #+INCLUDE: ../tools/lib.org
* Headers :noexport: * Headers :noexport:
@ -24,7 +24,7 @@ MunitResult test_<<filename()>>() {
#include "qmckl_ao_private_type.h" #include "qmckl_ao_private_type.h"
#+end_src #+end_src
#+begin_src c :tangle (eval c) #+begin_src c :tangle (eval c)
#include <stdint.h> #include <stdint.h>
#include <assert.h> #include <assert.h>
#include <math.h> #include <math.h>
@ -63,7 +63,7 @@ typedef int64_t qmckl_context ;
integer , parameter :: qmckl_context = c_int64_t integer , parameter :: qmckl_context = c_int64_t
integer*8, parameter :: QMCKL_NULL_CONTEXT = 0 integer*8, parameter :: QMCKL_NULL_CONTEXT = 0
#+end_src #+end_src
An immutable context would have required to implement a garbage An immutable context would have required to implement a garbage
collector. To keep the library simple, we have chosen to implement collector. To keep the library simple, we have chosen to implement
the context as a mutable data structure, so it has to be handled the context as a mutable data structure, so it has to be handled
@ -73,7 +73,7 @@ typedef int64_t qmckl_context ;
and ~ctx~ is a ~qmckl_context_struct*~ pointer. and ~ctx~ is a ~qmckl_context_struct*~ pointer.
** Data structure ** Data structure
#+begin_src c :comments org :tangle (eval h_private_type) :noweb yes :exports none #+begin_src c :comments org :tangle (eval h_private_type) :noweb yes :exports none
typedef struct qmckl_context_struct { typedef struct qmckl_context_struct {
/* -- State of the library -- */ /* -- State of the library -- */
@ -113,11 +113,11 @@ typedef struct qmckl_context_struct {
The context keeps a ``date'' that allows to check which data needs The context keeps a ``date'' that allows to check which data needs
to be recomputed. The date is incremented when the electron to be recomputed. The date is incremented when the electron
coordinates are updated. coordinates are updated.
When a new element is added to the context, the functions When a new element is added to the context, the functions
[[Creation][qmckl_context_create]], [[Destroy][qmckl_context_destroy]] and [[Copy][qmckl_context_copy]] [[Creation][qmckl_context_create]], [[Destroy][qmckl_context_destroy]] and [[Copy][qmckl_context_copy]]
should be updated inorder to make deep copies. should be updated inorder to make deep copies.
A tag is used internally to check if the memory domain pointed A tag is used internally to check if the memory domain pointed
by a pointer is a valid context. This allows to check that even if by a pointer is a valid context. This allows to check that even if
@ -155,7 +155,7 @@ qmckl_context qmckl_context_check(const qmckl_context context) {
#+end_src #+end_src
** Creation ** Creation
To create a new context, ~qmckl_context_create()~ should be used. To create a new context, ~qmckl_context_create()~ should be used.
- Upon success, it returns a pointer to a new context with the ~qmckl_context~ type - Upon success, it returns a pointer to a new context with the ~qmckl_context~ type
- It returns ~QMCKL_NULL_CONTEXT~ upon failure to allocate the internal data structure - It returns ~QMCKL_NULL_CONTEXT~ upon failure to allocate the internal data structure
@ -185,17 +185,17 @@ qmckl_context qmckl_context_create() {
{ {
pthread_mutexattr_t attr; pthread_mutexattr_t attr;
int rc; int rc;
rc = pthread_mutexattr_init(&attr); rc = pthread_mutexattr_init(&attr);
assert (rc == 0); assert (rc == 0);
(void) pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); (void) pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
rc = pthread_mutex_init ( &(ctx->mutex), &attr); rc = pthread_mutex_init ( &(ctx->mutex), &attr);
assert (rc == 0); assert (rc == 0);
(void) pthread_mutexattr_destroy(&attr); (void) pthread_mutexattr_destroy(&attr);
} }
/* Initialize data */ /* Initialize data */
ctx->tag = VALID_TAG; ctx->tag = VALID_TAG;
@ -215,15 +215,15 @@ qmckl_context qmckl_context_create() {
qmckl_memory_info_struct * new_array = calloc(size, sizeof(qmckl_memory_info_struct)); qmckl_memory_info_struct * new_array = calloc(size, sizeof(qmckl_memory_info_struct));
if (new_array == NULL) { if (new_array == NULL) {
free(ctx); free(ctx);
return QMCKL_NULL_CONTEXT; return QMCKL_NULL_CONTEXT;
} }
memset( &(new_array[0]), 0, size * sizeof(qmckl_memory_info_struct) ); memset( &(new_array[0]), 0, size * sizeof(qmckl_memory_info_struct) );
ctx->memory.element = new_array; ctx->memory.element = new_array;
ctx->memory.array_size = size; ctx->memory.array_size = size;
ctx->memory.n_allocated = (size_t) 0; ctx->memory.n_allocated = (size_t) 0;
} }
return (qmckl_context) ctx; return (qmckl_context) ctx;
} }
#+end_src #+end_src
@ -304,7 +304,7 @@ void qmckl_unlock(const qmckl_context context) {
qmckl_context qmckl_context_copy(const qmckl_context context); qmckl_context qmckl_context_copy(const qmckl_context context);
#+end_src #+end_src
# Source # Source
#+begin_src c :tangle (eval c) #+begin_src c :tangle (eval c)
qmckl_context qmckl_context_copy(const qmckl_context context) { qmckl_context qmckl_context_copy(const qmckl_context context) {
@ -318,24 +318,24 @@ qmckl_context qmckl_context_copy(const qmckl_context context) {
/* /*
qmckl_lock(context); qmckl_lock(context);
{ {
const qmckl_context_struct* const old_ctx = const qmckl_context_struct* const old_ctx =
(qmckl_context_struct* const) checked_context; (qmckl_context_struct* const) checked_context;
qmckl_context_struct* const new_ctx = qmckl_context_struct* const new_ctx =
(qmckl_context_struct* const) malloc (context, sizeof(qmckl_context_struct)); (qmckl_context_struct* const) malloc (context, sizeof(qmckl_context_struct));
if (new_ctx == NULL) { if (new_ctx == NULL) {
qmckl_unlock(context); qmckl_unlock(context);
return QMCKL_NULL_CONTEXT; return QMCKL_NULL_CONTEXT;
} }
* Copy the old context on the new one * * Copy the old context on the new one *
* TODO Deep copies should be done here * * TODO Deep copies should be done here *
memcpy(new_ctx, old_ctx, sizeof(qmckl_context_struct)); memcpy(new_ctx, old_ctx, sizeof(qmckl_context_struct));
qmckl_unlock( (qmckl_context) new_ctx ); qmckl_unlock( (qmckl_context) new_ctx );
return (qmckl_context) new_ctx; return (qmckl_context) new_ctx;
} }
qmckl_unlock(context); qmckl_unlock(context);
@ -456,4 +456,4 @@ return MUNIT_OK;
} }
#+end_src #+end_src

View File

@ -1,11 +1,11 @@
#+TITLE: Inter-particle distances #+TITLE: Inter-particle distances
#+SETUPFILE: ../docs/theme.setup #+SETUPFILE: ../tools/theme.setup
#+INCLUDE: ../tools/lib.org #+INCLUDE: ../tools/lib.org
Functions for the computation of distances between particles. Functions for the computation of distances between particles.
* Headers :noexport: * Headers :noexport:
#+begin_src elisp :noexport :results none #+begin_src elisp :noexport :results none
(org-babel-lob-ingest "../tools/lib.org") (org-babel-lob-ingest "../tools/lib.org")
#+end_src #+end_src
@ -56,11 +56,11 @@ MunitResult test_<<filename()>>() {
- ~lda >= m~ if ~transa == 'T'~ - ~lda >= m~ if ~transa == 'T'~
- ~ldb >= 3~ if ~transb == 'N'~ - ~ldb >= 3~ if ~transb == 'N'~
- ~ldb >= n~ if ~transb == 'T'~ - ~ldb >= n~ if ~transb == 'T'~
- ~ldc >= m~ - ~ldc >= m~
- ~A~ is allocated with at least $3 \times m \times 8$ bytes - ~A~ is allocated with at least $3 \times m \times 8$ bytes
- ~B~ is allocated with at least $3 \times n \times 8$ bytes - ~B~ is allocated with at least $3 \times n \times 8$ bytes
- ~C~ is allocated with at least $m \times n \times 8$ bytes - ~C~ is allocated with at least $m \times n \times 8$ bytes
*** C header *** C header
#+CALL: generate_c_header(table=qmckl_distance_sq_args,rettyp=get_value("CRetType"),fname=get_value("Name")) #+CALL: generate_c_header(table=qmckl_distance_sq_args,rettyp=get_value("CRetType"),fname=get_value("Name"))
@ -78,7 +78,7 @@ MunitResult test_<<filename()>>() {
const double* B, const double* B,
const int64_t ldb, const int64_t ldb,
double* const C, double* const C,
const int64_t ldc ); const int64_t ldc );
#+end_src #+end_src
*** Source *** Source
@ -137,7 +137,7 @@ integer function qmckl_distance_sq_f(context, transa, transb, m, n, &
if (transab < 0) then if (transab < 0) then
info = QMCKL_INVALID_ARG_1 info = QMCKL_INVALID_ARG_1
return return
endif endif
if (iand(transab,1) == 0 .and. LDA < 3) then if (iand(transab,1) == 0 .and. LDA < 3) then
@ -211,8 +211,8 @@ integer function qmckl_distance_sq_f(context, transa, transb, m, n, &
end function qmckl_distance_sq_f end function qmckl_distance_sq_f
#+end_src #+end_src
*** Performance *** Performance
This function might be more efficient when ~A~ and ~B~ are This function might be more efficient when ~A~ and ~B~ are
transposed. transposed.
@ -220,7 +220,7 @@ end function qmckl_distance_sq_f
** C interface :noexport: ** C interface :noexport:
#+CALL: generate_c_interface(table=qmckl_distance_sq_args,rettyp=get_value("FRetType"),fname=get_value("Name")) #+CALL: generate_c_interface(table=qmckl_distance_sq_args,rettyp=get_value("FRetType"),fname=get_value("Name"))
#+RESULTS: #+RESULTS:
#+begin_src f90 :tangle (eval f) :comments org :exports none #+begin_src f90 :tangle (eval f) :comments org :exports none
integer(c_int32_t) function qmckl_distance_sq & integer(c_int32_t) function qmckl_distance_sq &
@ -287,7 +287,7 @@ integer(qmckl_exit_code) function test_qmckl_distance_sq(context) bind(C)
double precision, allocatable :: A(:,:), B(:,:), C(:,:) double precision, allocatable :: A(:,:), B(:,:), C(:,:)
integer*8 :: m, n, LDA, LDB, LDC integer*8 :: m, n, LDA, LDB, LDC
double precision :: x double precision :: x
integer*8 :: i,j integer*8 :: i,j
m = 5 m = 5
n = 6 n = 6
@ -311,17 +311,17 @@ integer(qmckl_exit_code) function test_qmckl_distance_sq(context) bind(C)
test_qmckl_distance_sq = & test_qmckl_distance_sq = &
qmckl_distance_sq(context, 'X', 't', m, n, A, LDA, B, LDB, C, LDC) qmckl_distance_sq(context, 'X', 't', m, n, A, LDA, B, LDB, C, LDC)
if (test_qmckl_distance_sq == 0) return if (test_qmckl_distance_sq == 0) return
test_qmckl_distance_sq = & test_qmckl_distance_sq = &
qmckl_distance_sq(context, 't', 'X', m, n, A, LDA, B, LDB, C, LDC) qmckl_distance_sq(context, 't', 'X', m, n, A, LDA, B, LDB, C, LDC)
if (test_qmckl_distance_sq == 0) return if (test_qmckl_distance_sq == 0) return
test_qmckl_distance_sq = & test_qmckl_distance_sq = &
qmckl_distance_sq(context, 'T', 't', m, n, A, LDA, B, LDB, C, LDC) qmckl_distance_sq(context, 'T', 't', m, n, A, LDA, B, LDB, C, LDC)
if (test_qmckl_distance_sq /= 0) return if (test_qmckl_distance_sq /= 0) return
test_qmckl_distance_sq = -1 test_qmckl_distance_sq = -1
@ -337,7 +337,7 @@ integer(qmckl_exit_code) function test_qmckl_distance_sq(context) bind(C)
test_qmckl_distance_sq = & test_qmckl_distance_sq = &
qmckl_distance_sq(context, 'n', 'T', m, n, A, LDA, B, LDB, C, LDC) qmckl_distance_sq(context, 'n', 'T', m, n, A, LDA, B, LDB, C, LDC)
if (test_qmckl_distance_sq /= 0) return if (test_qmckl_distance_sq /= 0) return
test_qmckl_distance_sq = -1 test_qmckl_distance_sq = -1
@ -353,7 +353,7 @@ integer(qmckl_exit_code) function test_qmckl_distance_sq(context) bind(C)
test_qmckl_distance_sq = & test_qmckl_distance_sq = &
qmckl_distance_sq(context, 'T', 'n', m, n, A, LDA, B, LDB, C, LDC) qmckl_distance_sq(context, 'T', 'n', m, n, A, LDA, B, LDB, C, LDC)
if (test_qmckl_distance_sq /= 0) return if (test_qmckl_distance_sq /= 0) return
test_qmckl_distance_sq = -1 test_qmckl_distance_sq = -1
@ -369,7 +369,7 @@ integer(qmckl_exit_code) function test_qmckl_distance_sq(context) bind(C)
test_qmckl_distance_sq = & test_qmckl_distance_sq = &
qmckl_distance_sq(context, 'n', 'N', m, n, A, LDA, B, LDB, C, LDC) qmckl_distance_sq(context, 'n', 'N', m, n, A, LDA, B, LDB, C, LDC)
if (test_qmckl_distance_sq /= 0) return if (test_qmckl_distance_sq /= 0) return
test_qmckl_distance_sq = -1 test_qmckl_distance_sq = -1
@ -387,7 +387,7 @@ integer(qmckl_exit_code) function test_qmckl_distance_sq(context) bind(C)
deallocate(A,B,C) deallocate(A,B,C)
end function test_qmckl_distance_sq end function test_qmckl_distance_sq
#+end_src #+end_src
#+begin_src c :comments link :tangle (eval c_test) #+begin_src c :comments link :tangle (eval c_test)
int test_qmckl_distance_sq(qmckl_context context); int test_qmckl_distance_sq(qmckl_context context);
munit_assert_int(0, ==, test_qmckl_distance_sq(context)); munit_assert_int(0, ==, test_qmckl_distance_sq(context));
@ -430,11 +430,11 @@ munit_assert_int(0, ==, test_qmckl_distance_sq(context));
- ~lda >= m~ if ~transa == 'T'~ - ~lda >= m~ if ~transa == 'T'~
- ~ldb >= 3~ if ~transb == 'N'~ - ~ldb >= 3~ if ~transb == 'N'~
- ~ldb >= n~ if ~transb == 'T'~ - ~ldb >= n~ if ~transb == 'T'~
- ~ldc >= m~ - ~ldc >= m~
- ~A~ is allocated with at least $3 \times m \times 8$ bytes - ~A~ is allocated with at least $3 \times m \times 8$ bytes
- ~B~ is allocated with at least $3 \times n \times 8$ bytes - ~B~ is allocated with at least $3 \times n \times 8$ bytes
- ~C~ is allocated with at least $m \times n \times 8$ bytes - ~C~ is allocated with at least $m \times n \times 8$ bytes
*** C header *** C header
#+CALL: generate_c_header(table=qmckl_distance_args,rettyp=get_value("CRetType"),fname=get_value("Name")) #+CALL: generate_c_header(table=qmckl_distance_args,rettyp=get_value("CRetType"),fname=get_value("Name"))
@ -452,7 +452,7 @@ munit_assert_int(0, ==, test_qmckl_distance_sq(context));
const double* B, const double* B,
const int64_t ldb, const int64_t ldb,
double* const C, double* const C,
const int64_t ldc ); const int64_t ldc );
#+end_src #+end_src
*** Source *** Source
@ -511,7 +511,7 @@ integer function qmckl_distance_f(context, transa, transb, m, n, &
if (transab < 0) then if (transab < 0) then
info = QMCKL_INVALID_ARG_1 info = QMCKL_INVALID_ARG_1
return return
endif endif
if (iand(transab,1) == 0 .and. LDA < 3) then if (iand(transab,1) == 0 .and. LDA < 3) then
@ -589,8 +589,8 @@ integer function qmckl_distance_f(context, transa, transb, m, n, &
end function qmckl_distance_f end function qmckl_distance_f
#+end_src #+end_src
*** Performance *** Performance
This function might be more efficient when ~A~ and ~B~ are This function might be more efficient when ~A~ and ~B~ are
transposed. transposed.
@ -598,7 +598,7 @@ end function qmckl_distance_f
** C interface :noexport: ** C interface :noexport:
#+CALL: generate_c_interface(table=qmckl_distance_args,rettyp=get_value("FRetType"),fname=get_value("Name")) #+CALL: generate_c_interface(table=qmckl_distance_args,rettyp=get_value("FRetType"),fname=get_value("Name"))
#+RESULTS: #+RESULTS:
#+begin_src f90 :tangle (eval f) :comments org :exports none #+begin_src f90 :tangle (eval f) :comments org :exports none
integer(c_int32_t) function qmckl_distance & integer(c_int32_t) function qmckl_distance &
@ -665,7 +665,7 @@ integer(qmckl_exit_code) function test_qmckl_dist(context) bind(C)
double precision, allocatable :: A(:,:), B(:,:), C(:,:) double precision, allocatable :: A(:,:), B(:,:), C(:,:)
integer*8 :: m, n, LDA, LDB, LDC integer*8 :: m, n, LDA, LDB, LDC
double precision :: x double precision :: x
integer*8 :: i,j integer*8 :: i,j
m = 5 m = 5
n = 6 n = 6
@ -689,17 +689,17 @@ integer(qmckl_exit_code) function test_qmckl_dist(context) bind(C)
test_qmckl_dist = & test_qmckl_dist = &
qmckl_distance(context, 'X', 't', m, n, A, LDA, B, LDB, C, LDC) qmckl_distance(context, 'X', 't', m, n, A, LDA, B, LDB, C, LDC)
if (test_qmckl_dist == 0) return if (test_qmckl_dist == 0) return
test_qmckl_dist = & test_qmckl_dist = &
qmckl_distance(context, 't', 'X', m, n, A, LDA, B, LDB, C, LDC) qmckl_distance(context, 't', 'X', m, n, A, LDA, B, LDB, C, LDC)
if (test_qmckl_dist == 0) return if (test_qmckl_dist == 0) return
test_qmckl_dist = & test_qmckl_dist = &
qmckl_distance(context, 'T', 't', m, n, A, LDA, B, LDB, C, LDC) qmckl_distance(context, 'T', 't', m, n, A, LDA, B, LDB, C, LDC)
if (test_qmckl_dist /= 0) return if (test_qmckl_dist /= 0) return
test_qmckl_dist = -1 test_qmckl_dist = -1
@ -715,7 +715,7 @@ integer(qmckl_exit_code) function test_qmckl_dist(context) bind(C)
test_qmckl_dist = & test_qmckl_dist = &
qmckl_distance(context, 'n', 'T', m, n, A, LDA, B, LDB, C, LDC) qmckl_distance(context, 'n', 'T', m, n, A, LDA, B, LDB, C, LDC)
if (test_qmckl_dist /= 0) return if (test_qmckl_dist /= 0) return
test_qmckl_dist = -1 test_qmckl_dist = -1
@ -731,7 +731,7 @@ integer(qmckl_exit_code) function test_qmckl_dist(context) bind(C)
test_qmckl_dist = & test_qmckl_dist = &
qmckl_distance(context, 'T', 'n', m, n, A, LDA, B, LDB, C, LDC) qmckl_distance(context, 'T', 'n', m, n, A, LDA, B, LDB, C, LDC)
if (test_qmckl_dist /= 0) return if (test_qmckl_dist /= 0) return
test_qmckl_dist = -1 test_qmckl_dist = -1
@ -747,7 +747,7 @@ integer(qmckl_exit_code) function test_qmckl_dist(context) bind(C)
test_qmckl_dist = & test_qmckl_dist = &
qmckl_distance(context, 'n', 'N', m, n, A, LDA, B, LDB, C, LDC) qmckl_distance(context, 'n', 'N', m, n, A, LDA, B, LDB, C, LDC)
if (test_qmckl_dist /= 0) return if (test_qmckl_dist /= 0) return
test_qmckl_dist = -1 test_qmckl_dist = -1
@ -765,7 +765,7 @@ integer(qmckl_exit_code) function test_qmckl_dist(context) bind(C)
deallocate(A,B,C) deallocate(A,B,C)
end function test_qmckl_dist end function test_qmckl_dist
#+end_src #+end_src
#+begin_src c :comments link :tangle (eval c_test) #+begin_src c :comments link :tangle (eval c_test)
int test_qmckl_dist(qmckl_context context); int test_qmckl_dist(qmckl_context context);
munit_assert_int(0, ==, test_qmckl_dist(context)); munit_assert_int(0, ==, test_qmckl_dist(context));
@ -779,7 +779,7 @@ munit_assert_int(0, ==, test_qmckl_dist(context));
} }
#+end_src #+end_src
# -*- mode: org -*- # -*- mode: org -*-
# vim: syntax=c # vim: syntax=c

View File

@ -1,5 +1,5 @@
#+TITLE: Electrons #+TITLE: Electrons
#+SETUPFILE: ../docs/theme.setup #+SETUPFILE: ../tools/theme.setup
#+INCLUDE: ../tools/lib.org #+INCLUDE: ../tools/lib.org
In conventional QMC simulations, up-spin and down-spin electrons are In conventional QMC simulations, up-spin and down-spin electrons are
@ -7,7 +7,7 @@ different. The ~electron~ data structure contains the number of
up-spin and down-spin electrons, and the electron coordinates. up-spin and down-spin electrons, and the electron coordinates.
* Headers :noexport: * Headers :noexport:
#+begin_src elisp :noexport :results none #+begin_src elisp :noexport :results none
(org-babel-lob-ingest "../tools/lib.org") (org-babel-lob-ingest "../tools/lib.org")
#+end_src #+end_src
@ -51,7 +51,7 @@ MunitResult test_<<filename()>>() {
* Context * Context
The following data stored in the context: The following data stored in the context:
| ~uninitialized~ | int32_t | Keeps bit set for uninitialized data | | ~uninitialized~ | int32_t | Keeps bit set for uninitialized data |
| ~num~ | int64_t | Total number of electrons | | ~num~ | int64_t | Total number of electrons |
| ~up_num~ | int64_t | Number of up-spin electrons | | ~up_num~ | int64_t | Number of up-spin electrons |
@ -86,7 +86,7 @@ typedef struct qmckl_electron_struct {
initialization function which has not bee called. It becomes equal initialization function which has not bee called. It becomes equal
to zero after all initialization functions have been called. The to zero after all initialization functions have been called. The
struct is then initialized and ~provided == true~. struct is then initialized and ~provided == true~.
** Access functions ** Access functions
#+begin_src c :comments org :tangle (eval h_private_func) :exports none #+begin_src c :comments org :tangle (eval h_private_func) :exports none
@ -111,7 +111,7 @@ if ( (ctx->electron.uninitialized & mask) != 0) {
return NULL; return NULL;
} }
#+end_src #+end_src
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
int64_t qmckl_get_electron_num (const qmckl_context context) { int64_t qmckl_get_electron_num (const qmckl_context context) {
@ -203,13 +203,13 @@ bool qmckl_electron_provided(const qmckl_context context) {
return ctx->electron.provided; return ctx->electron.provided;
} }
#+end_src #+end_src
** Initialization functions ** Initialization functions
To set the data relative to the electrons in the context, the To set the data relative to the electrons in the context, the
following functions need to be called. When the data structure is following functions need to be called. When the data structure is
initialized, the ~coord_new~ and ~coord_old~ arrays are both allocated. initialized, the ~coord_new~ and ~coord_old~ arrays are both allocated.
#+begin_src c :comments org :tangle (eval h_func) #+begin_src c :comments org :tangle (eval h_func)
qmckl_exit_code qmckl_set_electron_num (qmckl_context context, const int64_t up_num, const int64_t down_num); qmckl_exit_code qmckl_set_electron_num (qmckl_context context, const int64_t up_num, const int64_t down_num);
qmckl_exit_code qmckl_set_electron_walk_num (qmckl_context context, const int64_t walk_num); qmckl_exit_code qmckl_set_electron_walk_num (qmckl_context context, const int64_t walk_num);
@ -227,7 +227,7 @@ qmckl_context_struct* const ctx = (qmckl_context_struct* const) context;
#+NAME:post2 #+NAME:post2
#+begin_src c :exports none #+begin_src c :exports none
ctx->electron.uninitialized &= ~mask; ctx->electron.uninitialized &= ~mask;
ctx->electron.provided = (ctx->electron.uninitialized == 0); ctx->electron.provided = (ctx->electron.uninitialized == 0);
if (ctx->electron.provided) { if (ctx->electron.provided) {
@ -265,11 +265,11 @@ if (ctx->electron.provided) {
return QMCKL_SUCCESS; return QMCKL_SUCCESS;
#+end_src #+end_src
To set the number of electrons, we give the number of up-spin and To set the number of electrons, we give the number of up-spin and
down-spin electrons to the context and we set the number of walkers. down-spin electrons to the context and we set the number of walkers.
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
qmckl_exit_code qmckl_set_electron_num(qmckl_context context, qmckl_exit_code qmckl_set_electron_num(qmckl_context context,
const int64_t up_num, const int64_t up_num,
const int64_t down_num) { const int64_t down_num) {
@ -298,9 +298,9 @@ qmckl_exit_code qmckl_set_electron_num(qmckl_context context,
<<post2>> <<post2>>
} }
#+end_src #+end_src
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
qmckl_exit_code qmckl_set_electron_walk_num(qmckl_context context, const int64_t walk_num) { qmckl_exit_code qmckl_set_electron_walk_num(qmckl_context context, const int64_t walk_num) {
<<pre2>> <<pre2>>
@ -317,14 +317,14 @@ qmckl_exit_code qmckl_set_electron_walk_num(qmckl_context context, const int64_t
<<post2>> <<post2>>
} }
#+end_src #+end_src
The following function sets the electron coordinates of all the The following function sets the electron coordinates of all the
walkers. When this is done, the pointers to the old and new sets walkers. When this is done, the pointers to the old and new sets
of coordinates are swapped, and the new coordinates are of coordinates are swapped, and the new coordinates are
overwritten. This can be done only when the data relative to overwritten. This can be done only when the data relative to
electrons have been set. electrons have been set.
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
qmckl_exit_code qmckl_set_electron_coord(qmckl_context context, const double* coord) { qmckl_exit_code qmckl_set_electron_coord(qmckl_context context, const double* coord) {
<<pre2>> <<pre2>>
@ -336,7 +336,7 @@ qmckl_exit_code qmckl_set_electron_coord(qmckl_context context, const double* c
"qmckl_set_electron_coord", "qmckl_set_electron_coord",
"num is not set"); "num is not set");
} }
const int64_t walk_num = qmckl_get_electron_walk_num(context); const int64_t walk_num = qmckl_get_electron_walk_num(context);
if (walk_num == 0L) { if (walk_num == 0L) {
return qmckl_failwith( context, return qmckl_failwith( context,
@ -344,11 +344,11 @@ qmckl_exit_code qmckl_set_electron_coord(qmckl_context context, const double* c
"qmckl_set_electron_coord", "qmckl_set_electron_coord",
"walk_num is not set"); "walk_num is not set");
} }
/* If num and walk_num are set, the arrays should be allocated */ /* If num and walk_num are set, the arrays should be allocated */
assert (ctx->electron.coord_old != NULL); assert (ctx->electron.coord_old != NULL);
assert (ctx->electron.coord_new != NULL); assert (ctx->electron.coord_new != NULL);
/* Increment the date of the context */ /* Increment the date of the context */
ctx->date += 1UL; ctx->date += 1UL;
@ -357,12 +357,12 @@ qmckl_exit_code qmckl_set_electron_coord(qmckl_context context, const double* c
swap = ctx->electron.coord_old; swap = ctx->electron.coord_old;
ctx->electron.coord_old = ctx->electron.coord_new; ctx->electron.coord_old = ctx->electron.coord_new;
ctx->electron.coord_new = swap; ctx->electron.coord_new = swap;
memcpy(ctx->electron.coord_new, coord, walk_num * num * 3 * sizeof(double)); memcpy(ctx->electron.coord_new, coord, walk_num * num * 3 * sizeof(double));
ctx->electron.coord_new_date = ctx->date; ctx->electron.coord_new_date = ctx->date;
return QMCKL_SUCCESS; return QMCKL_SUCCESS;
} }
#+end_src #+end_src
@ -377,7 +377,7 @@ qmckl_exit_code qmckl_set_electron_coord(qmckl_context context, const double* c
#define num (up_num+down_num) #define num (up_num+down_num)
double coord[walk_num*3*num] = double coord[walk_num*3*num] =
{ 7.303633091022677881e+00, 1.375868694453235719e+01, 1.167371490471771217e-01, { 7.303633091022677881e+00, 1.375868694453235719e+01, 1.167371490471771217e-01,
4.547755371567960836e+00, 3.245907105524011182e+00, 2.410764357550297110e-01, 4.547755371567960836e+00, 3.245907105524011182e+00, 2.410764357550297110e-01,
5.932816068137344523e+00, 1.491671465549257469e+01, 3.825374039119375236e-01, 5.932816068137344523e+00, 1.491671465549257469e+01, 3.825374039119375236e-01,
7.347336142660052083e+00, 1.341946976062362129e+00, 1.648917914228352322e+00, 7.347336142660052083e+00, 1.341946976062362129e+00, 1.648917914228352322e+00,
@ -387,9 +387,9 @@ double coord[walk_num*3*num] =
1.484094322159507051e+01, 9.777903829455864226e+00, 5.243007994024882767e-02, 1.484094322159507051e+01, 9.777903829455864226e+00, 5.243007994024882767e-02,
9.081723054990456845e+00, 5.499568496038920173e+00, 2.910446438899221347e-02, 9.081723054990456845e+00, 5.499568496038920173e+00, 2.910446438899221347e-02,
2.583154239492383653e+00, 1.442282811294904432e+00, 6.387191629878670451e-02 }; 2.583154239492383653e+00, 1.442282811294904432e+00, 6.387191629878670451e-02 };
/* --- */ /* --- */
qmckl_exit_code rc; qmckl_exit_code rc;
munit_assert(!qmckl_electron_provided(context)); munit_assert(!qmckl_electron_provided(context));
@ -408,7 +408,7 @@ munit_assert_int64(rc, ==, QMCKL_SUCCESS);
#+end_src #+end_src
* Computation * Computation
The computed data is stored in the context so that it can be reused The computed data is stored in the context so that it can be reused
by different kernels. To ensure that the data is valid, for each by different kernels. To ensure that the data is valid, for each
computed data the date of the context is stored when it is computed. computed data the date of the context is stored when it is computed.
@ -416,16 +416,16 @@ munit_assert_int64(rc, ==, QMCKL_SUCCESS);
the dependencies are more recent than the date of the data to the dependencies are more recent than the date of the data to
compute. If it is the case, then the data is recomputed and the compute. If it is the case, then the data is recomputed and the
current date is stored. current date is stored.
** Electron-electron distances ** Electron-electron distances
*** Get *** Get
#+begin_src c :comments org :tangle (eval h_func) :noweb yes #+begin_src c :comments org :tangle (eval h_func) :noweb yes
qmckl_exit_code qmckl_get_electron_ee_distance(qmckl_context context, double* distance); qmckl_exit_code qmckl_get_electron_ee_distance(qmckl_context context, double* distance);
#+end_src #+end_src
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
qmckl_exit_code qmckl_get_electron_ee_distance(qmckl_context context, double* distance) qmckl_exit_code qmckl_get_electron_ee_distance(qmckl_context context, double* distance)
{ {
/* Check input parameters */ /* Check input parameters */
@ -446,12 +446,12 @@ qmckl_exit_code qmckl_get_electron_ee_distance(qmckl_context context, double* di
} }
#+end_src #+end_src
*** Provide :noexport: *** Provide :noexport:
#+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none #+begin_src c :comments org :tangle (eval h_private_func) :noweb yes :exports none
qmckl_exit_code qmckl_provide_ee_distance(qmckl_context context); qmckl_exit_code qmckl_provide_ee_distance(qmckl_context context);
#+end_src #+end_src
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
qmckl_exit_code qmckl_provide_ee_distance(qmckl_context context) qmckl_exit_code qmckl_provide_ee_distance(qmckl_context context)
{ {
/* Check input parameters */ /* Check input parameters */
@ -462,19 +462,18 @@ qmckl_exit_code qmckl_provide_ee_distance(qmckl_context context)
qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; qmckl_context_struct* const ctx = (qmckl_context_struct* const) context;
assert (ctx != NULL); assert (ctx != NULL);
/* Compute if necessary */ /* Compute if necessary */
if (ctx->electron.coord_new_date > ctx->electron.ee_distance_date) { if (ctx->electron.coord_new_date > ctx->electron.ee_distance_date) {
fprintf(stderr, "%10ld: provide ee_distance", ctx->date);
/* Allocate array */ /* Allocate array */
if (ctx->electron.ee_distance == NULL) { if (ctx->electron.ee_distance == NULL) {
qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero;
mem_info.size = ctx->electron.num * ctx->electron.num * mem_info.size = ctx->electron.num * ctx->electron.num *
ctx->electron.walk_num * sizeof(double); ctx->electron.walk_num * sizeof(double);
double* ee_distance = (double*) qmckl_malloc(context, mem_info); double* ee_distance = (double*) qmckl_malloc(context, mem_info);
if (ee_distance == NULL) { if (ee_distance == NULL) {
return qmckl_failwith( context, return qmckl_failwith( context,
QMCKL_ALLOCATION_FAILED, QMCKL_ALLOCATION_FAILED,
@ -486,7 +485,7 @@ qmckl_exit_code qmckl_provide_ee_distance(qmckl_context context)
qmckl_exit_code rc = qmckl_exit_code rc =
qmckl_compute_ee_distance(context, qmckl_compute_ee_distance(context,
ctx->electron.num, ctx->electron.num,
ctx->electron.walk_num, ctx->electron.walk_num,
ctx->electron.coord_new, ctx->electron.coord_new,
ctx->electron.ee_distance); ctx->electron.ee_distance);
@ -507,7 +506,7 @@ qmckl_exit_code qmckl_provide_ee_distance(qmckl_context context)
:CRetType: qmckl_exit_code :CRetType: qmckl_exit_code
:FRetType: qmckl_exit_code :FRetType: qmckl_exit_code
:END: :END:
#+NAME: qmckl_ee_distance_args #+NAME: qmckl_ee_distance_args
| qmckl_context | context | in | Global state | | qmckl_context | context | in | Global state |
| int64_t | elec_num | in | Number of electrons | | int64_t | elec_num | in | Number of electrons |
@ -530,19 +529,19 @@ integer function qmckl_compute_ee_distance_f(context, elec_num, walk_num, coord,
info = QMCKL_SUCCESS info = QMCKL_SUCCESS
if (context == QMCKL_NULL_CONTEXT) then if (context == QMCKL_NULL_CONTEXT) then
info = QMCKL_INVALID_CONTEXT info = QMCKL_INVALID_CONTEXT
return return
endif endif
if (elec_num <= 0) then if (elec_num <= 0) then
info = QMCKL_INVALID_ARG_2 info = QMCKL_INVALID_ARG_2
return return
endif endif
if (walk_num <= 0) then if (walk_num <= 0) then
info = QMCKL_INVALID_ARG_3 info = QMCKL_INVALID_ARG_3
return return
endif endif
!$OMP PARALLEL DO DEFAULT(NONE) & !$OMP PARALLEL DO DEFAULT(NONE) &
@ -565,11 +564,11 @@ end function qmckl_compute_ee_distance_f
const int64_t elec_num, const int64_t elec_num,
const int64_t walk_num, const int64_t walk_num,
const double* coord, const double* coord,
double* const ee_distance ); double* const ee_distance );
#+end_src #+end_src
#+CALL: generate_c_interface(table=qmckl_ee_distance_args,rettyp=get_value("CRetType"),fname=get_value("Name")) #+CALL: generate_c_interface(table=qmckl_ee_distance_args,rettyp=get_value("CRetType"),fname=get_value("Name"))
#+RESULTS: #+RESULTS:
#+begin_src f90 :tangle (eval f) :comments org :exports none #+begin_src f90 :tangle (eval f) :comments org :exports none
integer(c_int32_t) function qmckl_compute_ee_distance & integer(c_int32_t) function qmckl_compute_ee_distance &
@ -609,7 +608,7 @@ munit_assert_double_equal(distance[1], 8.6114953086801, 12);
#+end_src #+end_src
* End of files :noexport: * End of files :noexport:
#+begin_src c :tangle (eval h_private_type) #+begin_src c :tangle (eval h_private_type)
#endif #endif
#+end_src #+end_src
@ -621,35 +620,35 @@ munit_assert_double_equal(distance[1], 8.6114953086801, 12);
return MUNIT_OK; return MUNIT_OK;
} }
#+end_src #+end_src
**✸ Compute file names **✸ Compute file names
#+begin_src emacs-lisp #+begin_src emacs-lisp
; The following is required to compute the file names ; The following is required to compute the file names
(setq pwd (file-name-directory buffer-file-name)) (setq pwd (file-name-directory buffer-file-name))
(setq name (file-name-nondirectory (substring buffer-file-name 0 -4))) (setq name (file-name-nondirectory (substring buffer-file-name 0 -4)))
(setq f (concat pwd name "_f.f90")) (setq f (concat pwd name "_f.f90"))
(setq fh (concat pwd name "_fh.f90")) (setq fh (concat pwd name "_fh.f90"))
(setq c (concat pwd name ".c")) (setq c (concat pwd name ".c"))
(setq h (concat name ".h")) (setq h (concat name ".h"))
(setq h_private (concat name "_private.h")) (setq h_private (concat name "_private.h"))
(setq c_test (concat pwd "test_" name ".c")) (setq c_test (concat pwd "test_" name ".c"))
(setq f_test (concat pwd "test_" name "_f.f90")) (setq f_test (concat pwd "test_" name "_f.f90"))
; Minted ; Minted
(require 'ox-latex) (require 'ox-latex)
(setq org-latex-listings 'minted) (setq org-latex-listings 'minted)
(add-to-list 'org-latex-packages-alist '("" "listings")) (add-to-list 'org-latex-packages-alist '("" "listings"))
(add-to-list 'org-latex-packages-alist '("" "color")) (add-to-list 'org-latex-packages-alist '("" "color"))
#+end_src #+end_src
#+RESULTS: #+RESULTS:
| | color | | | color |
| | listings | | | listings |
# -*- mode: org -*- # -*- mode: org -*-
# vim: syntax=c # vim: syntax=c

View File

@ -1,6 +1,6 @@
#+TITLE: Error handling #+TITLE: Error handling
#+SETUPFILE: ../docs/theme.setup #+SETUPFILE: ../tools/theme.setup
#+INCLUDE: ../tools/lib.org #+INCLUDE: ../tools/lib.org
* Headers :noexport: * Headers :noexport:
@ -32,7 +32,7 @@ MunitResult test_<<filename()>>() {
#+end_src #+end_src
* *
:PROPERTIES: :PROPERTIES:
:UNNUMBERED: t :UNNUMBERED: t
:END: :END:
@ -40,7 +40,7 @@ MunitResult test_<<filename()>>() {
The library should never make the calling programs abort, nor The library should never make the calling programs abort, nor
perform any input/output operations. This decision has to be taken perform any input/output operations. This decision has to be taken
by the developer of the code calling the library. by the developer of the code calling the library.
All the functions return with an exit code, defined as All the functions return with an exit code, defined as
#+NAME: type-exit-code #+NAME: type-exit-code
#+begin_src c :comments org :tangle (eval h_type) #+begin_src c :comments org :tangle (eval h_type)
@ -82,20 +82,20 @@ typedef int32_t qmckl_exit_code;
| ~QMCKL_INVALID_EXIT_CODE~ | 106 | 'Invalid exit code' | | ~QMCKL_INVALID_EXIT_CODE~ | 106 | 'Invalid exit code' |
# We need to force Emacs not to indent the Python code: # We need to force Emacs not to indent the Python code:
# -*- org-src-preserve-indentation: t # -*- org-src-preserve-indentation: t
#+begin_src python :var table=table-exit-codes :results drawer :exports none #+begin_src python :var table=table-exit-codes :results drawer :exports none
""" This script generates the C and Fortran constants for the error """ This script generates the C and Fortran constants for the error
codes from the org-mode table. codes from the org-mode table.
""" """
result = [ "#+begin_src c :comments org :tangle (eval h_type) :exports none" ] result = [ "#+begin_src c :comments org :tangle (eval h_type) :exports none" ]
for (text, code,_) in table: for (text, code,_) in table:
text=text.replace("~","") text=text.replace("~","")
result += [ f"#define {text:30s} ((qmckl_exit_code) {code:d})" ] result += [ f"#define {text:30s} ((qmckl_exit_code) {code:d})" ]
result += [ "#+end_src" ] result += [ "#+end_src" ]
result += [ "" ] result += [ "" ]
result += [ "#+begin_src f90 :comments org :tangle (eval fh_type) :exports none" ] result += [ "#+begin_src f90 :comments org :tangle (eval fh_type) :exports none" ]
for (text, code,_) in table: for (text, code,_) in table:
@ -157,7 +157,7 @@ return '\n'.join(result)
* Decoding errors * Decoding errors
To decode the error messages, ~qmckl_string_of_error~ converts an To decode the error messages, ~qmckl_string_of_error~ converts an
error code into a string. error code into a string.
#+NAME: MAX_STRING_LENGTH #+NAME: MAX_STRING_LENGTH
: 128 : 128
@ -167,7 +167,7 @@ const char* qmckl_string_of_error(const qmckl_exit_code error);
void qmckl_string_of_error_f(const qmckl_exit_code error, void qmckl_string_of_error_f(const qmckl_exit_code error,
char result[<<MAX_STRING_LENGTH()>>]); char result[<<MAX_STRING_LENGTH()>>]);
#+end_src #+end_src
The text strings are extracted from the previous table. The text strings are extracted from the previous table.
#+NAME:cases #+NAME:cases
@ -179,7 +179,7 @@ void qmckl_string_of_error_f(const qmckl_exit_code error,
result = [] result = []
for (text, code, message) in table: for (text, code, message) in table:
text = text.replace("~","") text = text.replace("~","")
message = message.replace("'",'"') message = message.replace("'",'"')
result += [ f"""case {text}: result += [ f"""case {text}:
return {message}; return {message};
break;""" ] break;""" ]
@ -187,7 +187,7 @@ return '\n'.join(result)
#+end_src #+end_src
# Source # Source
#+begin_src c :comments org :tangle (eval c) :noweb yes #+begin_src c :comments org :tangle (eval c) :noweb yes
const char* qmckl_string_of_error(const qmckl_exit_code error) { const char* qmckl_string_of_error(const qmckl_exit_code error) {
switch (error) { switch (error) {
@ -200,7 +200,7 @@ void qmckl_string_of_error_f(const qmckl_exit_code error, char result[<<MAX_STRI
strncpy(result, qmckl_string_of_error(error), <<MAX_STRING_LENGTH()>>); strncpy(result, qmckl_string_of_error(error), <<MAX_STRING_LENGTH()>>);
} }
#+end_src #+end_src
# Fortran interface # Fortran interface
#+begin_src f90 :tangle (eval fh_func) :noexport :noweb yes #+begin_src f90 :tangle (eval fh_func) :noexport :noweb yes
interface interface
@ -232,7 +232,7 @@ typedef struct qmckl_error_struct {
#+end_src #+end_src
* Updating errors in the context * Updating errors in the context
The error is updated in the context using ~qmckl_set_error~. The error is updated in the context using ~qmckl_set_error~.
When the error is set in the context, it is mandatory to specify When the error is set in the context, it is mandatory to specify
from which function the error is triggered, and a message from which function the error is triggered, and a message
@ -271,13 +271,13 @@ qmckl_set_error(qmckl_context context,
{ {
qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; qmckl_context_struct* const ctx = (qmckl_context_struct* const) context;
assert (ctx != NULL); /* Impossible because the context is valid. */ assert (ctx != NULL); /* Impossible because the context is valid. */
ctx->error.exit_code = exit_code; ctx->error.exit_code = exit_code;
strncpy(ctx->error.function, function_name, QMCKL_MAX_FUN_LEN); strncpy(ctx->error.function, function_name, QMCKL_MAX_FUN_LEN);
strncpy(ctx->error.message, message, QMCKL_MAX_MSG_LEN); strncpy(ctx->error.message, message, QMCKL_MAX_MSG_LEN);
} }
qmckl_unlock(context); qmckl_unlock(context);
return QMCKL_SUCCESS; return QMCKL_SUCCESS;
} }
#+end_src #+end_src
@ -316,13 +316,13 @@ qmckl_exit_code qmckl_failwith(qmckl_context context,
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT)
return QMCKL_INVALID_CONTEXT; return QMCKL_INVALID_CONTEXT;
if (message == NULL) { if (message == NULL) {
qmckl_exit_code rc = qmckl_exit_code rc =
qmckl_set_error(context, exit_code, function, qmckl_string_of_error(exit_code)); qmckl_set_error(context, exit_code, function, qmckl_string_of_error(exit_code));
assert (rc == QMCKL_SUCCESS); assert (rc == QMCKL_SUCCESS);
} else { } else {
qmckl_exit_code rc = qmckl_exit_code rc =
qmckl_set_error(context, exit_code, function, message); qmckl_set_error(context, exit_code, function, message);
assert (rc == QMCKL_SUCCESS); assert (rc == QMCKL_SUCCESS);
} }
@ -337,11 +337,11 @@ qmckl_exit_code qmckl_failwith(qmckl_context context,
if (x < 0) { if (x < 0) {
return qmckl_failwith(context, return qmckl_failwith(context,
QMCKL_INVALID_ARG_2, QMCKL_INVALID_ARG_2,
"qmckl_function", "qmckl_function",
"Expected x >= 0"); "Expected x >= 0");
} }
#+end_src #+end_src
* End of files :noexport: * End of files :noexport:

View File

@ -1,6 +1,6 @@
#+TITLE: Memory management #+TITLE: Memory management
#+SETUPFILE: ../docs/theme.setup #+SETUPFILE: ../tools/theme.setup
#+INCLUDE: ../tools/lib.org #+INCLUDE: ../tools/lib.org
We override the allocation functions to enable the possibility of We override the allocation functions to enable the possibility of
optimized libraries to fine-tune the memory allocation. optimized libraries to fine-tune the memory allocation.
@ -43,10 +43,10 @@ MunitResult test_<<filename()>>() {
#+end_src #+end_src
* Memory data structure for the context * Memory data structure for the context
Every time a new block of memory is allocated, the information Every time a new block of memory is allocated, the information
relative to the allocation is stored in a new ~qmckl_memory_info_struct~. relative to the allocation is stored in a new ~qmckl_memory_info_struct~.
A ~qmckl_memory_info_struct~ contains the pointer to the memory block, A ~qmckl_memory_info_struct~ contains the pointer to the memory block,
its size in bytes, and extra implementation-specific information such as its size in bytes, and extra implementation-specific information such as
alignment, pinning, if the memory should be allocated on CPU or GPU alignment, pinning, if the memory should be allocated on CPU or GPU
/etc/. /etc/.
@ -63,11 +63,11 @@ static const qmckl_memory_info_struct qmckl_memory_info_struct_zero =
.pointer = NULL .pointer = NULL
}; };
#+end_src #+end_src
The ~memory~ element of the context is a data structure which The ~memory~ element of the context is a data structure which
contains an array of ~qmckl_memory_info_struct~, the size of the contains an array of ~qmckl_memory_info_struct~, the size of the
array, and the number of allocated blocks. array, and the number of allocated blocks.
#+begin_src c :tangle (eval h_private_type) :noweb yes #+begin_src c :tangle (eval h_private_type) :noweb yes
typedef struct qmckl_memory_struct { typedef struct qmckl_memory_struct {
size_t n_allocated; size_t n_allocated;
@ -80,7 +80,7 @@ typedef struct qmckl_memory_struct {
Passing information to the allocation routine should be done by Passing information to the allocation routine should be done by
passing an instance of a ~qmckl_memory_info_struct~. passing an instance of a ~qmckl_memory_info_struct~.
* Allocation/deallocation functions * Allocation/deallocation functions
Memory allocation inside the library should be done with Memory allocation inside the library should be done with
@ -97,7 +97,7 @@ typedef struct qmckl_memory_struct {
void* qmckl_malloc(qmckl_context context, void* qmckl_malloc(qmckl_context context,
const qmckl_memory_info_struct info); const qmckl_memory_info_struct info);
#+end_src #+end_src
# Source # Source
#+begin_src c :tangle (eval c) #+begin_src c :tangle (eval c)
void* qmckl_malloc(qmckl_context context, const qmckl_memory_info_struct info) { void* qmckl_malloc(qmckl_context context, const qmckl_memory_info_struct info) {
@ -126,12 +126,12 @@ void* qmckl_malloc(qmckl_context context, const qmckl_memory_info_struct info) {
free(pointer); free(pointer);
return NULL; return NULL;
} }
memset( &(new_array[old_size]), 0, old_size * sizeof(qmckl_memory_info_struct) ); memset( &(new_array[old_size]), 0, old_size * sizeof(qmckl_memory_info_struct) );
ctx->memory.element = new_array; ctx->memory.element = new_array;
ctx->memory.array_size = 2L * old_size; ctx->memory.array_size = 2L * old_size;
} }
/* Find first NULL entry */ /* Find first NULL entry */
size_t pos = (size_t) 0; size_t pos = (size_t) 0;
while ( pos < ctx->memory.array_size && ctx->memory.element[pos].size > (size_t) 0) { while ( pos < ctx->memory.array_size && ctx->memory.element[pos].size > (size_t) 0) {
@ -145,7 +145,7 @@ void* qmckl_malloc(qmckl_context context, const qmckl_memory_info_struct info) {
ctx->memory.n_allocated += (size_t) 1; ctx->memory.n_allocated += (size_t) 1;
} }
qmckl_unlock(context); qmckl_unlock(context);
return pointer; return pointer;
} }
#+end_src #+end_src
@ -154,7 +154,7 @@ void* qmckl_malloc(qmckl_context context, const qmckl_memory_info_struct info) {
# Test :noexport: # Test :noexport:
#+begin_src c :tangle (eval c_test) #+begin_src c :tangle (eval c_test)
/* Create a context */ /* Create a context */
qmckl_context context = qmckl_context_create(); qmckl_context context = qmckl_context_create();
qmckl_memory_info_struct info = qmckl_memory_info_struct_zero; qmckl_memory_info_struct info = qmckl_memory_info_struct_zero;
info.size = (size_t) 3; info.size = (size_t) 3;
@ -197,14 +197,14 @@ qmckl_exit_code qmckl_free(qmckl_context context, void * const ptr) {
"qmckl_free", "qmckl_free",
NULL); NULL);
} }
if (ptr == NULL) { if (ptr == NULL) {
return qmckl_failwith(context, return qmckl_failwith(context,
QMCKL_INVALID_ARG_2, QMCKL_INVALID_ARG_2,
"qmckl_free", "qmckl_free",
"NULL pointer"); "NULL pointer");
} }
qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; qmckl_context_struct* const ctx = (qmckl_context_struct* const) context;
qmckl_lock(context); qmckl_lock(context);
@ -214,7 +214,7 @@ qmckl_exit_code qmckl_free(qmckl_context context, void * const ptr) {
while ( pos < ctx->memory.array_size && ctx->memory.element[pos].pointer != ptr) { while ( pos < ctx->memory.array_size && ctx->memory.element[pos].pointer != ptr) {
pos += (size_t) 1; pos += (size_t) 1;
} }
if (pos >= ctx->memory.array_size) { if (pos >= ctx->memory.array_size) {
/* Not found */ /* Not found */
qmckl_unlock(context); qmckl_unlock(context);
@ -276,7 +276,7 @@ munit_assert(rc == QMCKL_SUCCESS);
} }
#+end_src #+end_src
# -*- mode: org -*- # -*- mode: org -*-
# vim: syntax=c # vim: syntax=c

View File

@ -1,6 +1,6 @@
#+TITLE: Numerical precision #+TITLE: Numerical precision
#+SETUPFILE: ../docs/theme.setup #+SETUPFILE: ../tools/theme.setup
#+INCLUDE: ../tools/lib.org #+INCLUDE: ../tools/lib.org
* Headers :noexport: * Headers :noexport:
@ -17,7 +17,7 @@ MunitResult test_<<filename()>>() {
#include <stdint.h> #include <stdint.h>
#+end_src #+end_src
#+begin_src c :tangle (eval c) #+begin_src c :tangle (eval c)
#include <stdint.h> #include <stdint.h>
#include <assert.h> #include <assert.h>
#include <math.h> #include <math.h>
@ -92,7 +92,7 @@ typedef struct qmckl_numprec_struct {
uint32_t range; uint32_t range;
} qmckl_numprec_struct; } qmckl_numprec_struct;
#+end_src #+end_src
The following functions set and get the required precision and The following functions set and get the required precision and
range. ~precision~ is an integer between 2 and 53, and ~range~ is an range. ~precision~ is an integer between 2 and 53, and ~range~ is an
integer between 2 and 11. integer between 2 and 11.
@ -180,7 +180,7 @@ int qmckl_get_numprec_precision(const qmckl_context context) {
return ctx->numprec.precision; return ctx->numprec.precision;
} }
#+end_src #+end_src
# Fortran interface # Fortran interface
#+begin_src f90 :tangle (eval fh_func) #+begin_src f90 :tangle (eval fh_func)
interface interface
@ -193,7 +193,7 @@ int qmckl_get_numprec_precision(const qmckl_context context) {
#+end_src #+end_src
* Range * Range
~qmckl_set_numprec_range~ modifies the parameter for the numerical ~qmckl_set_numprec_range~ modifies the parameter for the numerical
range in a given context. range in a given context.

View File

@ -1,5 +1,5 @@
#+TITLE: Testing #+TITLE: Testing
#+SETUPFILE: ../docs/theme.setup #+SETUPFILE: ../tools/theme.setup
* QMCkl test :noexport: * QMCkl test :noexport:
@ -8,7 +8,7 @@
First, we use a script to find the list of all the generated test files: First, we use a script to find the list of all the generated test files:
#+NAME: test-files #+NAME: test-files
#+begin_src sh :exports none #+begin_src sh :exports none
FILES=$(cat table_of_contents) FILES=$(cat table_of_contents)
grep begin_src $FILES \ grep begin_src $FILES \
| grep c_test \ | grep c_test \
@ -48,7 +48,7 @@ echo "#+end_src"
MunitResult test_qmckl_distance(); MunitResult test_qmckl_distance();
#+end_src #+end_src
:end: :end:
and the required function calls: and the required function calls:
#+begin_src sh :var files=test-files :exports output :results drawer #+begin_src sh :var files=test-files :exports output :results drawer
echo "#+NAME: calls" echo "#+NAME: calls"
@ -60,7 +60,7 @@ do
done done
echo "#+end_src" echo "#+end_src"
#+end_src #+end_src
#+RESULTS: #+RESULTS:
:results: :results:
#+NAME: calls #+NAME: calls
@ -78,7 +78,7 @@ echo "#+end_src"
allocations with ~mtrace~. Memory allocations will be traced in the allocations with ~mtrace~. Memory allocations will be traced in the
file specified by the ~MALLOC_TRACE~ environment variable. file specified by the ~MALLOC_TRACE~ environment variable.
#+begin_src c :comments link :noweb yes :tangle test_qmckl.c #+begin_src c :comments link :noweb yes :tangle test_qmckl.c
#include "qmckl.h" #include "qmckl.h"
#include "munit.h" #include "munit.h"
#include "mcheck.h" #include "mcheck.h"
@ -97,10 +97,10 @@ int main(int argc, char* argv[MUNIT_ARRAY_PARAM(argc + 1)]) {
(char*) "", test_suite_tests, NULL, 1, MUNIT_SUITE_OPTION_NONE (char*) "", test_suite_tests, NULL, 1, MUNIT_SUITE_OPTION_NONE
}; };
int result = munit_suite_main(&test_suite, (void*) "µnit", argc, argv); int result = munit_suite_main(&test_suite, (void*) "µnit", argc, argv);
muntrace(); muntrace();
return result; return result;
} }
#+end_src #+end_src

View File

@ -167,7 +167,10 @@ endif
.PHONY: clean shared static doc all check install uninstall .PHONY: clean shared static doc all check install uninstall
.SECONDARY: # Needed to keep the produced C and Fortran files .SECONDARY: # Needed to keep the produced C and Fortran files
$(shared_lib) $(static_lib) install uninstall: $(qmckl_h) $(qmckl_f) Makefile.generated $(shared_lib) $(static_lib): $(qmckl_h) $(qmckl_f) Makefile.generated
$(MAKE) -f Makefile.generated $@
install uninstall: Makefile.generated
$(MAKE) -f Makefile.generated $@ $(MAKE) -f Makefile.generated $@
$(qmckl_f) $(qmckl_h): Makefile.generated $(qmckl_f) $(qmckl_h): Makefile.generated
@ -180,6 +183,12 @@ all: shared static doc check
check: $(static_lib) check: $(static_lib)
$(MAKE) -f Makefile.generated check $(MAKE) -f Makefile.generated check
cppcheck:
cppcheck \
--addon=cert \
--enable=warning,style,performance,portability,information \
qmckl_*.c
doc: $(ORG_SOURCE_FILES) doc: $(ORG_SOURCE_FILES)
$(QMCKL_ROOT)/tools/build_doc.sh $(QMCKL_ROOT)/tools/build_doc.sh
@ -191,10 +200,10 @@ clean:
Makefile.generated *.html *.txt Makefile.generated *.html *.txt
veryclean: clean FORCE veryclean: clean FORCE
- $(RM) $(QMCKL_ROOT)/docs/*.html \ - $(RM) $(QMCKL_ROOT)/share/doc/qmckl/html/*.html \
$(QMCKL_ROOT)/docs/*.txt $(QMCKL_ROOT)/share/doc/qmckl/text/*.txt
Makefile.generated: Makefile $(QMCKL_ROOT)/tools/create_makefile.sh $(ORG_SOURCE_FILES) Makefile.generated: Makefile $(QMCKL_ROOT)/tools/create_makefile.sh $(ORG_SOURCE_FILES) ../tools/Building.org
$(QMCKL_ROOT)/tools/create_makefile.sh $(QMCKL_ROOT)/tools/create_makefile.sh
@ -361,15 +370,29 @@ check: test_qmckl test_qmckl_shared
clean: clean:
\$(RM) -- *.o *.mod \$(shared_lib) \$(static_lib) test_qmckl \$(RM) -- *.o *.mod \$(shared_lib) \$(static_lib) test_qmckl
install: install:
install -d \$(prefix)/lib install -d \$(prefix)/lib
install -d \$(prefix)/include install -d \$(prefix)/include
install -d \$(prefix)/share/qmckl/fortran install -d \$(prefix)/share/qmckl/fortran
install -d \$(prefix)/man install -d \$(prefix)/share/doc/qmckl/html/
install \$(shared_lib) \$(prefix)/lib install -d \$(prefix)/share/doc/qmckl/text/
install \$(static_lib) \$(prefix)/lib install \$(shared_lib) \$(prefix)/lib
install \$(qmckl_h) \$(prefix)/include install \$(static_lib) \$(prefix)/lib
install \$(qmckl_f) \$(prefix)/share/qmckl/fortran install \$(qmckl_h) \$(prefix)/include
install \$(qmckl_f) \$(prefix)/share/qmckl/fortran
install \$(QMCKL_ROOT)/share/doc/qmckl/html/*.html \$(prefix)/share/doc/qmckl/html/
install \$(QMCKL_ROOT)/share/doc/qmckl/html/*.css \$(prefix)/share/doc/qmckl/html/
install \$(QMCKL_ROOT)/share/doc/qmckl/text/*.txt \$(prefix)/share/doc/qmckl/text/
uninstall:
rm \$(prefix)/lib/libqmckl.so
rm \$(prefix)/lib/libqmckl.a
rm \$(prefix)/include/qmckl.h
rm -rf \$(prefix)/share/qmckl/
rm -rf \$(prefix)/share/doc/qmckl/
.SUFFIXES: .c .f90 .o .SUFFIXES: .c .f90 .o
@ -379,7 +402,7 @@ install:
.f90.o: qmckl_f.o .f90.o: qmckl_f.o
\$(FC) \$(FFLAGS) -c \$*.f90 -o \$*.o \$(FC) \$(FFLAGS) -c \$*.f90 -o \$*.o
.PHONY: check clean all .PHONY: check cppcheck clean all
EOF EOF
#+end_src #+end_src
@ -495,9 +518,9 @@ EOF
First define readonly global variables. First define readonly global variables.
#+begin_src bash :noweb yes #+begin_src bash :noweb yes
readonly DOCS=${QMCKL_ROOT}/docs/ readonly DOCS=${QMCKL_ROOT}/share/doc/qmckl/
readonly SRC=${QMCKL_ROOT}/src/ readonly SRC=${QMCKL_ROOT}/src/
readonly HTMLIZE=${DOCS}/htmlize.el readonly HTMLIZE=${DOCS}/html/htmlize.el
readonly CONFIG_DOC=${QMCKL_ROOT}/tools/config_doc.el readonly CONFIG_DOC=${QMCKL_ROOT}/tools/config_doc.el
readonly CONFIG_TANGLE=${QMCKL_ROOT}/tools/config_tangle.el readonly CONFIG_TANGLE=${QMCKL_ROOT}/tools/config_tangle.el
#+end_src #+end_src
@ -513,7 +536,7 @@ function check_preconditions()
exit 1 exit 1
fi fi
for dir in ${DOCS} ${SRC} for dir in ${DOCS}/html ${DOCS}/text ${SRC}
do do
if [[ ! -d ${dir} ]] if [[ ! -d ${dir} ]]
then then
@ -543,7 +566,7 @@ function install_htmlize()
local repo="emacs-htmlize" local repo="emacs-htmlize"
[[ -f ${HTMLIZE} ]] || ( [[ -f ${HTMLIZE} ]] || (
cd ${DOCS} cd ${DOCS}/html
git clone ${url} \ git clone ${url} \
&& cp ${repo}/htmlize.el ${HTMLIZE} \ && cp ${repo}/htmlize.el ${HTMLIZE} \
&& rm -rf ${repo} && rm -rf ${repo}
@ -564,7 +587,8 @@ function extract_doc()
local org=$1 local org=$1
local local_html=${SRC}/${org%.org}.html local local_html=${SRC}/${org%.org}.html
local local_text=${SRC}/${org%.org}.txt local local_text=${SRC}/${org%.org}.txt
local html=${DOCS}/${org%.org}.html local html=${DOCS}/html/${org%.org}.html
local text=${DOCS}/text/${org%.org}.txt
if [[ -f ${html} && ${org} -ot ${html} ]] if [[ -f ${html} && ${org} -ot ${html} ]]
then then
@ -577,7 +601,8 @@ function extract_doc()
--load ${CONFIG_TANGLE} \ --load ${CONFIG_TANGLE} \
-f org-html-export-to-html \ -f org-html-export-to-html \
-f org-ascii-export-to-ascii -f org-ascii-export-to-ascii
mv ${local_html} ${local_text} ${DOCS} mv ${local_html} ${DOCS}/html
mv ${local_text} ${DOCS}/text
} }
#+end_src #+end_src
@ -605,7 +630,7 @@ function main() {
if [[ $? -eq 0 ]] if [[ $? -eq 0 ]]
then then
cd ${DOCS} cd ${DOCS}/html
rm -f index.html rm -f index.html
ln README.html index.html ln README.html index.html
exit 0 exit 0

View File

@ -7,9 +7,9 @@
# First define readonly global variables. # First define readonly global variables.
readonly DOCS=${QMCKL_ROOT}/docs/ readonly DOCS=${QMCKL_ROOT}/share/doc/qmckl/
readonly SRC=${QMCKL_ROOT}/src/ readonly SRC=${QMCKL_ROOT}/src/
readonly HTMLIZE=${DOCS}/htmlize.el readonly HTMLIZE=${DOCS}/html/htmlize.el
readonly CONFIG_DOC=${QMCKL_ROOT}/tools/config_doc.el readonly CONFIG_DOC=${QMCKL_ROOT}/tools/config_doc.el
readonly CONFIG_TANGLE=${QMCKL_ROOT}/tools/config_tangle.el readonly CONFIG_TANGLE=${QMCKL_ROOT}/tools/config_tangle.el
@ -26,7 +26,7 @@ function check_preconditions()
exit 1 exit 1
fi fi
for dir in ${DOCS} ${SRC} for dir in ${DOCS}/html ${DOCS}/text ${SRC}
do do
if [[ ! -d ${dir} ]] if [[ ! -d ${dir} ]]
then then
@ -57,7 +57,7 @@ function install_htmlize()
local repo="emacs-htmlize" local repo="emacs-htmlize"
[[ -f ${HTMLIZE} ]] || ( [[ -f ${HTMLIZE} ]] || (
cd ${DOCS} cd ${DOCS}/html
git clone ${url} \ git clone ${url} \
&& cp ${repo}/htmlize.el ${HTMLIZE} \ && cp ${repo}/htmlize.el ${HTMLIZE} \
&& rm -rf ${repo} && rm -rf ${repo}
@ -79,7 +79,8 @@ function extract_doc()
local org=$1 local org=$1
local local_html=${SRC}/${org%.org}.html local local_html=${SRC}/${org%.org}.html
local local_text=${SRC}/${org%.org}.txt local local_text=${SRC}/${org%.org}.txt
local html=${DOCS}/${org%.org}.html local html=${DOCS}/html/${org%.org}.html
local text=${DOCS}/text/${org%.org}.txt
if [[ -f ${html} && ${org} -ot ${html} ]] if [[ -f ${html} && ${org} -ot ${html} ]]
then then
@ -92,7 +93,8 @@ function extract_doc()
--load ${CONFIG_TANGLE} \ --load ${CONFIG_TANGLE} \
-f org-html-export-to-html \ -f org-html-export-to-html \
-f org-ascii-export-to-ascii -f org-ascii-export-to-ascii
mv ${local_html} ${local_text} ${DOCS} mv ${local_html} ${DOCS}/html
mv ${local_text} ${DOCS}/text
} }
@ -121,7 +123,7 @@ function main() {
if [[ $? -eq 0 ]] if [[ $? -eq 0 ]]
then then
cd ${DOCS} cd ${DOCS}/html
rm -f index.html rm -f index.html
ln README.html index.html ln README.html index.html
exit 0 exit 0

View File

@ -117,15 +117,29 @@ check: test_qmckl test_qmckl_shared
clean: clean:
\$(RM) -- *.o *.mod \$(shared_lib) \$(static_lib) test_qmckl \$(RM) -- *.o *.mod \$(shared_lib) \$(static_lib) test_qmckl
install: install:
install -d \$(prefix)/lib install -d \$(prefix)/lib
install -d \$(prefix)/include install -d \$(prefix)/include
install -d \$(prefix)/share/qmckl/fortran install -d \$(prefix)/share/qmckl/fortran
install -d \$(prefix)/man install -d \$(prefix)/share/doc/qmckl/html/
install \$(shared_lib) \$(prefix)/lib install -d \$(prefix)/share/doc/qmckl/text/
install \$(static_lib) \$(prefix)/lib install \$(shared_lib) \$(prefix)/lib
install \$(qmckl_h) \$(prefix)/include install \$(static_lib) \$(prefix)/lib
install \$(qmckl_f) \$(prefix)/share/qmckl/fortran install \$(qmckl_h) \$(prefix)/include
install \$(qmckl_f) \$(prefix)/share/qmckl/fortran
install \$(QMCKL_ROOT)/share/doc/qmckl/html/*.html \$(prefix)/share/doc/qmckl/html/
install \$(QMCKL_ROOT)/share/doc/qmckl/html/*.css \$(prefix)/share/doc/qmckl/html/
install \$(QMCKL_ROOT)/share/doc/qmckl/text/*.txt \$(prefix)/share/doc/qmckl/text/
uninstall:
rm \$(prefix)/lib/libqmckl.so
rm \$(prefix)/lib/libqmckl.a
rm \$(prefix)/include/qmckl.h
rm -rf \$(prefix)/share/qmckl/
rm -rf \$(prefix)/share/doc/qmckl/
.SUFFIXES: .c .f90 .o .SUFFIXES: .c .f90 .o
@ -135,5 +149,5 @@ install:
.f90.o: qmckl_f.o .f90.o: qmckl_f.o
\$(FC) \$(FFLAGS) -c \$*.f90 -o \$*.o \$(FC) \$(FFLAGS) -c \$*.f90 -o \$*.o
.PHONY: check clean all .PHONY: check cppcheck clean all
EOF EOF