1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-12-22 20:36:01 +01:00

Merge branch 'master' of github.com:TREX-CoE/qmckl

This commit is contained in:
Anthony Scemama 2022-02-15 11:10:49 +01:00
commit ce9909a6f7
15 changed files with 1468 additions and 1319 deletions

View File

@ -18,70 +18,94 @@ jobs:
- name: Install dependencies
run: sudo apt-get install emacs autoconf libhdf5-dev
- name: Install trexio
#- name: Install trexio from the distribution tarball
# run: |
# export TAG=v2.1.0
# export VERSION=2.1.0
# wget https://github.com/TREX-CoE/trexio/releases/download/${TAG}/trexio-${VERSION}.tar.gz
# tar -zxf trexio-${VERSION}.tar.gz
# cd trexio-${VERSION}
# ./configure --prefix=/usr
# make -j 4
# sudo make install
- name: Install the latest TREXIO from the GitHub clone
run: |
export TAG=v2.1.0
export VERSION=2.1.0
wget https://github.com/TREX-CoE/trexio/releases/download/${TAG}/trexio-${VERSION}.tar.gz
tar -zxf trexio-${VERSION}.tar.gz
cd trexio-${VERSION}
git clone https://github.com/TREX-CoE/trexio.git
cd trexio
./autogen.sh
./configure --prefix=/usr
make -j 8
make -j 4
sudo make install
- name: Build
- name: Build QMCkl
run: |
./autogen.sh
./configure --enable-silent-rules --enable-debug
make -j 8
make -j 4
- name: Run test
run: |
make -j check
run: make -j 4 check
- name: Archive test log file
if: failure()
uses: actions/upload-artifact@v2
with:
name: test-report
name: test-report-ubuntu
path: test-suite.log
- name: Dist test
run: |
make distcheck
run: make distcheck
- name: Archive test log file
if: failure()
uses: actions/upload-artifact@v2
with:
name: dist-report
name: dist-report-ubuntu
path: test-suite.log
x86_macos:
# x86_macos:
#
# runs-on: macos-latest
# name: x86 MacOS latest
#
# steps:
# - uses: actions/checkout@v2
# - name: install dependencies
# run: |
# brew install gfortran-10
# brew install emacs
# brew install autoconf automake libtool
# - name: install trexio
# run: |
# wget https://github.com/TREX-CoE/trexio/releases/download/v1.0/trexio-1.0.0.tar.gz
# tar -zxf trexio-1.0.0.tar.gz
# cd trexio-1.0.0
# ./configure
# make -j 8
# sudo make install
# - name: Run test
# run: |
# ./autogen.sh
# ./configure --enable-silent-rules --enable-debug
# make -j 8
# make -j check
# make distcheck
runs-on: macos-latest
name: x86 MacOS latest
steps:
- uses: actions/checkout@v2
- name: install dependencies
run: brew install emacs hdf5 automake pkg-config
- name: Symlink gfortran (macOS)
if: runner.os == 'macOS'
run: |
# make sure gfortran is available
# https://github.com/actions/virtual-environments/issues/2524
# https://github.com/cbg-ethz/dce/blob/master/.github/workflows/pkgdown.yaml
sudo ln -s /usr/local/bin/gfortran-10 /usr/local/bin/gfortran
sudo mkdir /usr/local/gfortran
sudo ln -s /usr/local/Cellar/gcc@10/*/lib/gcc/10 /usr/local/gfortran/lib
gfortran --version
- name: Install the latest TREXIO from the GitHub clone
run: |
git clone https://github.com/TREX-CoE/trexio.git
cd trexio
./autogen.sh
./configure --prefix=${PWD}/_install --enable-silent-rules
make -j 4
make install
- name: Build QMCkl
run: |
export PKG_CONFIG_PATH=${PWD}/trexio/_install/lib/pkgconfig:$PKG_CONFIG_PATH
./autogen.sh
./configure --enable-silent-rules --enable-debug
make -j 4
- name: Run test
run: make -j 4 check
- name: Archive test log file
if: failure()
uses: actions/upload-artifact@v2
with:
name: test-report-macos
path: test-suite.log

View File

@ -47,9 +47,9 @@ pkgconfig_DATA = pkgconfig/qmckl.pc
qmckl_h = include/qmckl.h
include_HEADERS = $(qmckl_h)
test_qmckl_f = tests/qmckl_f.f90
test_qmckl_f = tests/qmckl_f.F90
test_qmckl_fo = tests/qmckl_f.o
src_qmckl_f = src/qmckl_f.f90
src_qmckl_f = src/qmckl_f.F90
src_qmckl_fo = src/qmckl_f.o
header_tests = tests/chbrclf.h tests/n2.h
@ -139,7 +139,7 @@ cat_h_verbose_0 = @echo " HEADER $@";
## Rules
## =====
SUFFIXES = .f90 .h .org .c _f.f90 _func.h _type.h _private_func.h _private_type.h
SUFFIXES = .F90 .h .org .c _f.F90 _func.h _type.h _private_func.h _private_type.h
$(test_qmckl_f): $(src_qmckl_f)
cp $(src_qmckl_f) $(test_qmckl_f)

View File

@ -46,6 +46,22 @@ AS_IF([test -d ${srcdir}/.git],
[enable_maintainer_mode="no"]
)
AC_ARG_WITH(ifort, [AS_HELP_STRING([--with-ifort],[Use Intel Fortran compiler])], with_ifort=$withval, with_ifort=no)
AS_IF([test "$with_ifort" == "yes"], [
FC=ifort
FCFLAGS="-xHost -ip -O2 -ftz -finline -g -mkl=sequential" ])
AC_ARG_WITH(icc, [AS_HELP_STRING([--with-icc],[Use Intel C compiler])], with_icc=$withval, with_icc=no)
AS_IF([test "$with_icc" == "yes"], [
FC=icc
CFLAGS="-xHost -ip -O2 -ftz -finline -g -mkl=sequential" ])
AS_IF([test "$with_icc"."$with_ifort" == "yes.yes"], [
ax_blas_ok="yes"
ax_lapack_ok="yes"
BLAS_LIBS=""
LAPACK_LIBS=""])
AM_PROG_AR
AM_MAINTAINER_MODE()
LT_INIT
@ -71,14 +87,16 @@ AC_LANG(C)
# Checks for programs.
AC_PROG_CC
AC_PROG_F77
# Make sure the c compiler supports C99
m4_version_prereq([2.70],[], [AC_PROG_CC_C99])
AS_IF([test "$ac_cv_prog_cc_c99" = "no"], [AC_MSG_ERROR([The compiler does not support C99])])
AC_PROG_CC_C_O
AC_PROG_F77
AC_PROG_FC
AC_PROG_FC_C_O
AC_FC_SRCEXT([f90])
AC_FC_PP_DEFINE
AC_FC_SRCEXT([F90])
AC_FC_FREEFORM
LT_INIT
AC_PROG_INSTALL
@ -175,6 +193,7 @@ AX_BLAS([], [AC_MSG_ERROR([BLAS was not found.])])
## LAPACK
AX_LAPACK([], [AC_MSG_ERROR([LAPACK was not found.])])
AS_IF([test "$BLAS_LIBS" == "$LAPACK_LIBS"], [BLAS_LIBS=""])
# Specific options required with some compilers
@ -193,6 +212,10 @@ esac
# Options.
AC_ARG_ENABLE(hpc, [AS_HELP_STRING([--enable-hpc],[Use HPC-optimized functions])], HAVE_HPC=$enableval, HAVE_HPC=no)
AS_IF([test "$HAVE_HPC" = "yes"], [
AC_DEFINE([HAVE_HPC], [1], [If defined, activate HPC routines])
])
AC_ARG_ENABLE(debug, [AS_HELP_STRING([--enable-debug],[compile for debugging])], ok=$enableval, ok=no)
if test "$ok" = "yes"; then
@ -308,7 +331,7 @@ fi
#mkl-dynamic-lp64-seq
PKG_LIBS="$PKG_LIBS $LIBS"
LIBS="$BLAS_LIBS $LAPACK_LIBS $BLAS_LIBS $PKG_LIBS"
LIBS="$BLAS_LIBS $LAPACK_LIBS $PKG_LIBS"
CFLAGS="$CFLAGS $PKG_CFLAGS"
AC_SUBST([PKG_LIBS])
AC_SUBST([PKG_CFLAGS])
@ -337,6 +360,7 @@ FCLAGS..........: ${FCFLAGS}
LDFLAGS:........: ${LDFLAGS}
LIBS............: ${LIBS}
USE CHAMELEON...: ${with_chameleon}
HPC version.....: ${HAVE_HPC}
Package features:
${ARGS}

File diff suppressed because it is too large Load Diff

View File

@ -872,7 +872,7 @@ end function test_qmckl_dist
pairs of points in two sets, one point within each set:
\[
C_{ij} = \left( 1 - \exp{-\kappa C_{ij}}\right)/\kappa
C_{ij} = \left( 1 - \exp \left(-\kappa C_{ij} \right) \right)/\kappa
\]
If the input array is normal (~'N'~), the xyz coordinates are in

View File

@ -401,7 +401,7 @@ qmckl_get_electron_rescale_factor_en (const qmckl_context context, double* const
| | Normal | Transposed |
|---------+--------------------------+--------------------------|
| C | ~[walk_num*elec_num][3]~ | ~[3][walk_num*elec_num]~ |
| Fortran | ~(3,walk_num*elec_num)~ | ~(walk_num*elec_num, 3)~ |
| Fortran | ~(3,walk_num*elec_num)~ | ~(walk_num*elec_num, 3)~ |
#+begin_src c :comments org :tangle (eval h_func) :exports none
@ -978,7 +978,7 @@ qmckl_exit_code qmckl_provide_ee_distance(qmckl_context context)
| ~context~ | ~qmckl_context~ | in | Global state |
| ~elec_num~ | ~int64_t~ | in | Number of electrons |
| ~walk_num~ | ~int64_t~ | in | Number of walkers |
| ~coord~ | ~double[3][walk_num][elec_num]~ | in | Electron coordinates |
| ~coord~ | ~double[3][walk_num][elec_num]~ | in | Electron coordinates |
| ~ee_distance~ | ~double[walk_num][elec_num][elec_num]~ | out | Electron-electron distances |
#+begin_src f90 :comments org :tangle (eval f) :noweb yes
@ -2493,7 +2493,7 @@ integer function qmckl_compute_en_distance_rescaled_deriv_e_f(context, elec_num,
integer*8 , intent(in) :: walk_num
double precision , intent(in) :: elec_coord(elec_num,walk_num,3)
double precision , intent(in) :: nucl_coord(nucl_num,3)
double precision , intent(out) :: en_distance_rescaled_deriv_e(elec_num,nucl_num,walk_num)
double precision , intent(out) :: en_distance_rescaled_deriv_e(4,elec_num,nucl_num,walk_num)
integer*8 :: k
@ -2529,7 +2529,7 @@ integer function qmckl_compute_en_distance_rescaled_deriv_e_f(context, elec_num,
info = qmckl_distance_rescaled_deriv_e(context, 'T', 'T', elec_num, nucl_num, &
elec_coord(1,k,1), elec_num*walk_num, &
nucl_coord, nucl_num, &
en_distance_rescaled_deriv_e(1,1,k), elec_num, rescale_factor_kappa_en)
en_distance_rescaled_deriv_e(1,1,1,k), elec_num, rescale_factor_kappa_en)
if (info /= QMCKL_SUCCESS) then
exit
endif

File diff suppressed because it is too large Load Diff

View File

@ -1645,9 +1645,9 @@ end function qmckl_compute_drift_vector_f
#+begin_src c :tangle (eval c_test) :exports none
// Calculate the Drift vector
double drift_vector[walk_num][3];
double drift_vector[walk_num][elec_num][3];
rc = qmckl_get_drift_vector(context, &(drift_vector[0][0]));
rc = qmckl_get_drift_vector(context, &(drift_vector[0][0][0]));
assert (rc == QMCKL_SUCCESS);
#+end_src
* End of files :noexport:

View File

@ -90,11 +90,11 @@ int main() {
Computed data:
|---------------+-------------------------+----------------------------------------------------------------------------------------|
|---------------+-------------------------+----------------------------------------------------------------------------------------|
| ~mo_vgl~ | ~[5][elec_num][mo_num]~ | Value, gradients, Laplacian of the MOs at electron positions |
| ~mo_vgl_date~ | ~uint64_t~ | Late modification date of Value, gradients, Laplacian of the MOs at electron positions |
|---------------+-------------------------+----------------------------------------------------------------------------------------|
|---------------+--------------------------+-------------------------------------------------------------------------------------|
|---------------+--------------------------+-------------------------------------------------------------------------------------|
| ~mo_vgl~ | ~[point_num][5][mo_num]~ | Value, gradients, Laplacian of the MOs at point positions |
| ~mo_vgl_date~ | ~uint64_t~ | Late modification date of Value, gradients, Laplacian of the MOs at point positions |
|---------------+--------------------------+-------------------------------------------------------------------------------------|
** Data structure
@ -388,7 +388,7 @@ qmckl_exit_code qmckl_get_mo_basis_vgl(qmckl_context context, double* const mo_v
qmckl_context_struct* const ctx = (qmckl_context_struct* const) context;
assert (ctx != NULL);
size_t sze = 5 * ctx->electron.num * ctx->mo_basis.mo_num;
size_t sze = 5 * ctx->point.num * ctx->mo_basis.mo_num;
memcpy(mo_vgl, ctx->mo_basis.mo_vgl, sze * sizeof(double));
return QMCKL_SUCCESS;
@ -442,13 +442,6 @@ qmckl_exit_code qmckl_provide_mo_vgl(qmckl_context context)
NULL);
}
if(!(ctx->electron.provided)) {
return qmckl_failwith( context,
QMCKL_NOT_PROVIDED,
"qmckl_electron",
NULL);
}
if (!ctx->mo_basis.provided) {
return qmckl_failwith( context,
QMCKL_NOT_PROVIDED,
@ -457,13 +450,13 @@ qmckl_exit_code qmckl_provide_mo_vgl(qmckl_context context)
}
/* Compute if necessary */
if (ctx->electron.coord_new_date > ctx->mo_basis.mo_vgl_date) {
if (ctx->point.date > ctx->mo_basis.mo_vgl_date) {
/* Allocate array */
if (ctx->mo_basis.mo_vgl == NULL) {
qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero;
mem_info.size = 5 * ctx->electron.num * ctx->mo_basis.mo_num * sizeof(double);
mem_info.size = 5 * ctx->point.num * ctx->mo_basis.mo_num * sizeof(double);
double* mo_vgl = (double*) qmckl_malloc(context, mem_info);
if (mo_vgl == NULL) {
@ -478,7 +471,7 @@ qmckl_exit_code qmckl_provide_mo_vgl(qmckl_context context)
rc = qmckl_compute_mo_basis_vgl(context,
ctx->ao_basis.ao_num,
ctx->mo_basis.mo_num,
ctx->electron.num,
ctx->point.num,
ctx->mo_basis.coefficient,
ctx->ao_basis.ao_vgl,
ctx->mo_basis.mo_vgl);
@ -504,85 +497,46 @@ qmckl_exit_code qmckl_provide_mo_vgl(qmckl_context context)
| ~qmckl_context~ | ~context~ | in | Global state |
| ~int64_t~ | ~ao_num~ | in | Number of AOs |
| ~int64_t~ | ~mo_num~ | in | Number of MOs |
| ~int64_t~ | ~elec_num~ | in | Number of electrons |
| ~int64_t~ | ~point_num~ | in | Number of points |
| ~double~ | ~coef_normalized[mo_num][ao_num]~ | in | AO to MO transformation matrix |
| ~double~ | ~ao_vgl[5][elec_num][ao_num]~ | in | Value, gradients and Laplacian of the AOs |
| ~double~ | ~mo_vgl[5][elec_num][mo_num]~ | out | Value, gradients and Laplacian of the MOs |
| ~double~ | ~ao_vgl[point_num][5][ao_num]~ | in | Value, gradients and Laplacian of the AOs |
| ~double~ | ~mo_vgl[point_num][5][mo_num]~ | out | Value, gradients and Laplacian of the MOs |
#+begin_src f90 :comments org :tangle (eval f) :noweb yes
integer function qmckl_compute_mo_basis_vgl_f(context, &
ao_num, mo_num, elec_num, &
ao_num, mo_num, point_num, &
coef_normalized, ao_vgl, mo_vgl) &
result(info)
use qmckl
implicit none
integer(qmckl_context), intent(in) :: context
integer*8 , intent(in) :: ao_num, mo_num
integer*8 , intent(in) :: elec_num
double precision , intent(in) :: ao_vgl(ao_num,elec_num,5)
integer*8 , intent(in) :: point_num
double precision , intent(in) :: ao_vgl(ao_num,5,point_num)
double precision , intent(in) :: coef_normalized(ao_num,mo_num)
double precision , intent(out) :: mo_vgl(mo_num,elec_num,5)
double precision , intent(out) :: mo_vgl(mo_num,5,point_num)
character :: TransA, TransB
double precision,dimension(:,:),allocatable :: mo_vgl_big
double precision,dimension(:,:),allocatable :: ao_vgl_big
!double precision,dimension(:,:),allocatable :: coef_trans
!double precision,dimension(:),allocatable :: coef_all
double precision :: alpha, beta
integer :: info_qmckl_dgemm_value
integer*8 :: M, N, K, LDA, LDB, LDC, i,j, idx
integer*8 :: inucl, iprim, iwalk, ielec, ishell
double precision :: x, y, z, two_a, ar2, r2, v, cutoff
allocate(mo_vgl_big(mo_num,elec_num*5))
allocate(ao_vgl_big(ao_num,elec_num*5))
!allocate(coef_all(mo_num*ao_num))
!allocate(coef_trans(mo_num,ao_num))
integer*8 :: M, N, K, LDA, LDB, LDC, i,j
TransA = 'T'
TransB = 'N'
alpha = 1.0d0
beta = 0.0d0
M = mo_num
N = point_num*5_8
K = int(ao_num,8)
alpha = 1.d0
beta = 0.d0
LDA = size(coef_normalized,1)
LDB = size(ao_vgl,1)
LDC = size(mo_vgl,1)
info = qmckl_dgemm(context,TransA, TransB, M, N, K, alpha, &
coef_normalized, int(size(coef_normalized,1),8), &
ao_vgl, int(size(ao_vgl,1),8), beta, &
mo_vgl,LDC)
info = QMCKL_SUCCESS
info_qmckl_dgemm_value = QMCKL_SUCCESS
! Don't compute exponentials when the result will be almost zero.
! TODO : Use numerical precision here
cutoff = -dlog(1.d-15)
M = mo_num
N = elec_num*5
K = ao_num * 1_8
LDA = size(coef_normalized,1)
idx = 0
!do j = 1,ao_num
!do i = 1,mo_num
! idx = idx + 1
! coef_all(idx) = coef_normalized(i,j)
!end do
!end do
!idx = 0
!do j = 1,mo_num
!do i = 1,ao_num
! idx = idx + 1
! coef_trans(j,i) = coef_all(idx)
!end do
!end do
ao_vgl_big = reshape(ao_vgl(:, :, :),(/ao_num, elec_num*5_8/))
LDB = size(ao_vgl_big,1)
LDC = size(mo_vgl_big,1)
info = qmckl_dgemm(context,TransA, TransB, M, N, K, alpha, &
coef_normalized,size(coef_normalized,1)*1_8, &
ao_vgl_big, size(ao_vgl_big,1)*1_8, &
beta, &
mo_vgl_big,LDC)
mo_vgl = reshape(mo_vgl_big,(/mo_num,elec_num,5_8/))
deallocate(mo_vgl_big)
deallocate(ao_vgl_big)
end function qmckl_compute_mo_basis_vgl_f
#+end_src
@ -595,7 +549,7 @@ end function qmckl_compute_mo_basis_vgl_f
const qmckl_context context,
const int64_t ao_num,
const int64_t mo_num,
const int64_t elec_num,
const int64_t point_num,
const double* coef_normalized,
const double* ao_vgl,
double* const mo_vgl );
@ -607,7 +561,7 @@ end function qmckl_compute_mo_basis_vgl_f
#+RESULTS:
#+begin_src f90 :tangle (eval f) :comments org :exports none
integer(c_int32_t) function qmckl_compute_mo_basis_vgl &
(context, ao_num, mo_num, elec_num, coef_normalized, ao_vgl, mo_vgl) &
(context, ao_num, mo_num, point_num, coef_normalized, ao_vgl, mo_vgl) &
bind(C) result(info)
use, intrinsic :: iso_c_binding
@ -616,14 +570,14 @@ end function qmckl_compute_mo_basis_vgl_f
integer (c_int64_t) , intent(in) , value :: context
integer (c_int64_t) , intent(in) , value :: ao_num
integer (c_int64_t) , intent(in) , value :: mo_num
integer (c_int64_t) , intent(in) , value :: elec_num
integer (c_int64_t) , intent(in) , value :: point_num
real (c_double ) , intent(in) :: coef_normalized(ao_num,mo_num)
real (c_double ) , intent(in) :: ao_vgl(ao_num,elec_num,5)
real (c_double ) , intent(out) :: mo_vgl(mo_num,elec_num,5)
real (c_double ) , intent(in) :: ao_vgl(ao_num,5,point_num)
real (c_double ) , intent(out) :: mo_vgl(mo_num,5,point_num)
integer(c_int32_t), external :: qmckl_compute_mo_basis_vgl_f
info = qmckl_compute_mo_basis_vgl_f &
(context, ao_num, mo_num, elec_num, coef_normalized, ao_vgl, mo_vgl)
(context, ao_num, mo_num, point_num, coef_normalized, ao_vgl, mo_vgl)
end function qmckl_compute_mo_basis_vgl
#+end_src
@ -799,9 +753,9 @@ assert(rc == QMCKL_SUCCESS);
assert(qmckl_ao_basis_provided(context));
double ao_vgl[5][walk_num][elec_num][chbrclf_ao_num];
double ao_vgl[walk_num*elec_num][5][chbrclf_ao_num];
rc = qmckl_get_ao_basis_ao_vgl(context, &(ao_vgl[0][0][0][0]),
rc = qmckl_get_ao_basis_ao_vgl(context, &(ao_vgl[0][0][0]),
(int64_t) 5*walk_num*elec_num*chbrclf_ao_num);
assert (rc == QMCKL_SUCCESS);
@ -817,7 +771,7 @@ assert (rc == QMCKL_SUCCESS);
assert(qmckl_mo_basis_provided(context));
double mo_vgl[5][elec_num][chbrclf_mo_num];
double mo_vgl[walk_num*elec_num][5][chbrclf_mo_num];
rc = qmckl_get_mo_basis_vgl(context, &(mo_vgl[0][0][0]));
assert (rc == QMCKL_SUCCESS);
@ -863,18 +817,18 @@ assert (rc == QMCKL_SUCCESS);
printf("\n");
printf(" mo_vgl mo_vgl[0][26][219] %25.15e\n", mo_vgl[0][2][3]);
printf(" mo_vgl mo_vgl[1][26][219] %25.15e\n", mo_vgl[1][2][3]);
printf(" mo_vgl mo_vgl[0][26][220] %25.15e\n", mo_vgl[0][2][3]);
printf(" mo_vgl mo_vgl[1][26][220] %25.15e\n", mo_vgl[1][2][3]);
printf(" mo_vgl mo_vgl[0][26][221] %25.15e\n", mo_vgl[0][2][3]);
printf(" mo_vgl mo_vgl[1][26][221] %25.15e\n", mo_vgl[1][2][3]);
printf(" mo_vgl mo_vgl[0][26][222] %25.15e\n", mo_vgl[0][2][3]);
printf(" mo_vgl mo_vgl[1][26][222] %25.15e\n", mo_vgl[1][2][3]);
printf(" mo_vgl mo_vgl[0][26][223] %25.15e\n", mo_vgl[0][2][3]);
printf(" mo_vgl mo_vgl[1][26][223] %25.15e\n", mo_vgl[1][2][3]);
printf(" mo_vgl mo_vgl[0][26][224] %25.15e\n", mo_vgl[0][2][3]);
printf(" mo_vgl mo_vgl[1][26][224] %25.15e\n", mo_vgl[1][2][3]);
printf(" mo_vgl mo_vgl[0][26][219] %25.15e\n", mo_vgl[2][0][3]);
printf(" mo_vgl mo_vgl[1][26][219] %25.15e\n", mo_vgl[2][1][3]);
printf(" mo_vgl mo_vgl[0][26][220] %25.15e\n", mo_vgl[2][0][3]);
printf(" mo_vgl mo_vgl[1][26][220] %25.15e\n", mo_vgl[2][1][3]);
printf(" mo_vgl mo_vgl[0][26][221] %25.15e\n", mo_vgl[2][0][3]);
printf(" mo_vgl mo_vgl[1][26][221] %25.15e\n", mo_vgl[2][1][3]);
printf(" mo_vgl mo_vgl[0][26][222] %25.15e\n", mo_vgl[2][0][3]);
printf(" mo_vgl mo_vgl[1][26][222] %25.15e\n", mo_vgl[2][1][3]);
printf(" mo_vgl mo_vgl[0][26][223] %25.15e\n", mo_vgl[2][0][3]);
printf(" mo_vgl mo_vgl[1][26][223] %25.15e\n", mo_vgl[2][1][3]);
printf(" mo_vgl mo_vgl[0][26][224] %25.15e\n", mo_vgl[2][0][3]);
printf(" mo_vgl mo_vgl[1][26][224] %25.15e\n", mo_vgl[2][1][3]);
printf("\n");
}

View File

@ -2,9 +2,10 @@ rank_metadata_code 0
rank_metadata_author 0
metadata_code_num_isSet 0
metadata_author_num_isSet 0
metadata_unsafe_isSet 0
len_metadata_package_version 6
metadata_package_version
2.0.0
2.2.0
len_metadata_description 0
metadata_description
metadata_code

View File

@ -1,641 +0,0 @@
#+TITLE: Building tools
#+STARTUP: indent overview
#+PROPERTY: header-args: :comments both
This file contains all the tools needed to build the QMCkl library.
* Helper functions
#+NAME: header
#+begin_src sh :tangle no :exports none :output none
echo "This file was created by tools/Building.org"
#+end_src
#+NAME: check-src
#+begin_src bash
if [[ $(basename ${PWD}) != "src" ]] ; then
echo "This script needs to be run in the src directory"
exit -1
fi
#+end_src
#+NAME: url-issues
: https://github.com/trex-coe/qmckl/issues
#+NAME: url-web
: https://trex-coe.github.io/qmckl
#+NAME: license
#+begin_example
BSD 3-Clause License
Copyright (c) 2020, TREX Center of Excellence
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#+end_example
* Makefiles
** Makefile.in
:PROPERTIES:
:header-args: :tangle ../src/Makefile.in :noweb yes :comments org
:END:
This is the main Makefile invoked by the ~make~ command at the root
of the package. To compile the sources, it calls the =Makefile=
located in the =src= directory. This Makefile creates the source
file from the org-mode file, as well as a Makefile,
=Makefile.generated=, dedicated to the compilation of the sources.
*** Header
We want the Makefile to be POSIX-compliant, such that it works not
only with GNU Make.
#+begin_src makefile
# <<header()>>
.POSIX:
#+end_src
*** Compiler options
Compiler variables are obtained from the configure script (see =configure.ac=)
#+begin_src makefile
CC = @CC@
FC = @FC@
CFLAGS = @CFLAGS@
FCFLAGS = @FCFLAGS@
LDFLAGS = @LDFLAGS@
DEFS = @DEFS@
#+end_src
*** Variables
#+begin_src makefile
HAS_CPPCHECK = @HAS_CPPCHECK@
# VPATH-related substitution variables
srcdir = @srcdir@
VPATH = @srcdir@
top_srcdir=$(srcdir)/..
shared_lib=$(top_srcdir)/lib/libqmckl.so
static_lib=$(top_srcdir)/lib/libqmckl.a
qmckl_h=$(top_srcdir)/include/qmckl.h
qmckl_f=$(top_srcdir)/share/qmckl/fortran/qmckl_f.f90
export CC CFLAGS DEFS FC FCFLAGS LIBS top_srcdir
ORG_SOURCE_FILES=$(wildcard $(srcdir)/*.org)
C_SOURCE_FILES=$(patsubst %.org,%.c,$(ORG_SOURCE_FILES))
INCLUDE=-I$(top_srcdir)/include/
#+end_src
*** Rules
The source files are created during the generation of the file ~Makefile.generated~.
The Makefile.generated is the one that will be distributed with the library.
#+begin_src makefile
.PHONY: clean shared static doc all check install uninstall
.SECONDARY: # Needed to keep the produced C and Fortran files
$(shared_lib) $(static_lib): $(qmckl_h) $(qmckl_f) Makefile.generated
$(MAKE) -f Makefile.generated $@
install uninstall: Makefile.generated
$(MAKE) -f Makefile.generated $@
$(qmckl_f) $(qmckl_h): Makefile.generated
$(top_srcdir)/tools/build_qmckl_h.sh
shared: $(shared_lib)
static: $(static_lib)
all: shared static doc check
check: $(static_lib)
$(MAKE) -f Makefile.generated check
ifeq ($(HAS_CPPCHECK),1)
cppcheck:
cppcheck \
--addon=cert \
--enable=warning,style,performance,portability,information \
qmckl_*.c
endif
doc: $(ORG_SOURCE_FILES)
$(top_srcdir)/tools/build_doc.sh
clean:
- $(MAKE) -f Makefile.generated clean
- $(RM) test_qmckl_* test_qmckl.c \
$(qmckl_h) $(qmckl_f) \
qmckl_*.f90 qmckl_*.c qmckl_*.h \
Makefile.generated *.html *.txt
veryclean: clean FORCE
- $(RM) $(top_srcdir)/share/doc/qmckl/html/*.html \
$(top_srcdir)/share/doc/qmckl/text/*.txt
Makefile.generated.in: Makefile $(top_srcdir)/tools/create_makefile.sh $(ORG_SOURCE_FILES) $(top_srcdir)/tools/Building.org
$(top_srcdir)/tools/create_makefile.sh
Makefile.generated: Makefile.generated.in
cd .. ; ./config.status
.SUFFIXES: .org .c
.org.c:
$(top_srcdir)/tools/tangle.sh $<
#+end_src
** Script to generate auto-generated Makefile
:PROPERTIES:
:header-args: :tangle create_makefile.sh :noweb yes :shebang #!/bin/bash :comments org
:END:
This script generates the Makefile that compiles the library.
The ~OUTPUT~ variable contains the name of the generated Makefile,typically
=Makefile.generated=.
#+begin_src bash
# <<header()>>
<<check_src>>
OUTPUT=Makefile.generated.in
#+end_src
We start by tangling all the org-mode files.
#+begin_src bash
${top_srcdir}/tools/tangle.sh *.org
${top_srcdir}/tools/build_qmckl_h.sh
#+end_src
Then we create the list of ~*.o~ files to be created, for library
functions:
#+begin_src bash
OBJECTS="qmckl_f.o"
for i in $(ls qmckl_*.c qmckl_*f.f90) ; do
FILE=${i%.*}
OBJECTS+=" ${FILE}.o"
done >> $OUTPUT
#+end_src
for tests in C:
#+begin_src bash
TESTS=""
for i in $(ls test_qmckl_*.c) ; do
FILE=${i%.c}
TESTS+=" ${FILE}.o"
done >> $OUTPUT
#+end_src
and for tests in Fortran:
#+begin_src bash
TESTS_F=""
for i in $(ls test_qmckl_*_f.f90) ; do
FILE=${i%.f90}
TESTS_F+=" ${FILE}.o"
done >> $OUTPUT
#+end_src
Finally, we append the variables to the Makefile
#+begin_src bash :noweb yes
cat << EOF > ${OUTPUT}
.POSIX:
.SUFFIXES:
package = @PACKAGE_TARNAME@
version = @PACKAGE_VERSION@
# VPATH-related substitution variables
srcdir = @srcdir@
VPATH = @srcdir@
prefix = @prefix@
CC = @CC@
DEFS = @DEFS@
CFLAGS = @CFLAGS@ -I\$(top_srcdir)/munit/ -I\$(top_srcdir)/include -I.
CPPFLAGS = @CPPFLAGS@
LIBS = @LIBS@
FC = @FC@
FCFLAGS= @FCFLAGS@
OBJECT_FILES=$OBJECTS
TESTS = $TESTS
TESTS_F = $TESTS_F
LIBS = @LIBS@
FCLIBS = @FCLIBS@
EOF
export
echo '
<<rules>>
' >> ${OUTPUT}
#+end_src
and the rules:
#+NAME: rules
#+begin_src makefile :tangle no
top_srcdir=$(srcdir)/..
shared_lib=$(top_srcdir)/lib/libqmckl.so
static_lib=$(top_srcdir)/lib/libqmckl.a
qmckl_h=$(top_srcdir)/include/qmckl.h
qmckl_f=$(top_srcdir)/share/qmckl/fortran/qmckl_f.f90
munit=$(top_srcdir)/munit/munit.c
datarootdir=$(prefix)/share
datadir=$(datarootdir)
docdir=$(datarootdir)/doc/$(package)
htmldir=$(docdir)/html
libdir=$(prefix)/lib
includedir=$(prefix)/include
fortrandir=$(datarootdir)/$(package)/fortran
shared: $(shared_lib)
static: $(static_lib)
all: shared static
$(shared_lib): $(OBJECT_FILES)
$(CC) -shared $(OBJECT_FILES) -o $(shared_lib)
$(static_lib): $(OBJECT_FILES)
$(AR) rcs $(static_lib) $(OBJECT_FILES)
# Test
qmckl_f.o: $(qmckl_f)
$(FC) $(FCFLAGS) -c $(qmckl_f) -o $@
test_qmckl: test_qmckl.c $(qmckl_h) $(static_lib) $(TESTS) $(TESTS_F)
$(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) $(munit) $(TESTS) $(TESTS_F) \
$(static_lib) $(LIBS) $(FCLIBS) test_qmckl.c -o $@
test_qmckl_shared: test_qmckl.c $(qmckl_h) $(shared_lib) $(TESTS) $(TESTS_F)
$(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) \
-Wl,-rpath,$(top_srcdir)/lib -L$(top_srcdir)/lib $(munit) $(TESTS) \
$(TESTS_F) -lqmckl $(LIBS) $(FCLIBS) test_qmckl.c -o $@
check: test_qmckl test_qmckl_shared
./test_qmckl
clean:
$(RM) -- *.o *.mod $(shared_lib) $(static_lib) test_qmckl
install:
install -d $(DESTDIR)$(prefix)/lib
install -d $(DESTDIR)$(prefix)/include
install -d $(DESTDIR)$(prefix)/share/qmckl/fortran
install -d $(DESTDIR)$(prefix)/share/doc/qmckl/html/
install -d $(DESTDIR)$(prefix)/share/doc/qmckl/text/
install $(shared_lib) $(DESTDIR)$(libdir)/
install $(static_lib) $(DESTDIR)$(libdir)/
install $(qmckl_h) $(DESTDIR)$(includedir)
install $(qmckl_f) $(DESTDIR)$(fortrandir)
install $(top_srcdir)/share/doc/qmckl/html/*.html $(DESTDIR)$(docdir)/html/
install $(top_srcdir)/share/doc/qmckl/html/*.css $(DESTDIR)$(docdir)/html/
install $(top_srcdir)/share/doc/qmckl/text/*.txt $(DESTDIR)$(docdir)/text/
uninstall:
rm $(DESTDIR)$(libdir)/libqmckl.so
rm $(DESTDIR)$(libdir)/libqmckl.a
rm $(DESTDIR)$(includedir)/qmckl.h
rm -rf $(DESTDIR)$(datarootdir)/$(package)
rm -rf $(DESTDIR)$(docdir)
.SUFFIXES: .c .f90 .o
.c.o:
$(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) -c $*.c -o $*.o
.f90.o: qmckl_f.o
$(FC) $(FCFLAGS) -c $*.f90 -o $*.o
.PHONY: check cppcheck clean all
#+end_src
* Script to tangle the org-mode files
:PROPERTIES:
:header-args: :tangle tangle.sh :noweb yes :shebang #!/bin/bash :comments org
:END:
#+begin_src bash
# <<header()>>
<<check_src>>
#+end_src
This file needs to be run from the QMCKL =src= directory.
It tangles all the files in the directory. It uses the
=config_tangle.el= file, which contains information required to
compute the current file names using for example ~(eval c)~ to get
the name of the produced C file.
The file is not tangled if the last modification date of the org
file is less recent than one of the tangled files.
#+begin_src bash
function tangle()
{
local org_file=$1
local c_file=${org_file%.org}.c
local f_file=${org_file%.org}.f90
if [[ ${org_file} -ot ${c_file} ]] ; then
return
elif [[ ${org_file} -ot ${f_file} ]] ; then
return
fi
emacs --batch ${org_file} --load=${top_srcdir}/tools/config_tangle.el -f org-babel-tangle
}
for i in $@
do
echo "--- ${i} ----"
tangle ${i}
done
#+end_src
* Script to build the final qmckl.h file
:PROPERTIES:
:header-args:bash: :tangle build_qmckl_h.sh :noweb yes :shebang #!/bin/bash :comments org
:END:
#+begin_src bash :noweb yes
# <<header()>>
#+end_src
#+NAME: qmckl-header
#+begin_src text :noweb yes
------------------------------------------
QMCkl - Quantum Monte Carlo kernel library
------------------------------------------
Documentation : <<url-web()>>
Issues : <<url-issues()>>
<<license()>>
#+end_src
All the produced header files are concatenated in the =qmckl.h=
file, located in the include directory. The =*_private.h= files
are excluded.
Put =.h= files in the correct order:
#+begin_src bash
HEADERS=""
for i in $(cat table_of_contents)
do
HEADERS+="${i%.org}_type.h "
done
for i in $(cat table_of_contents)
do
HEADERS+="${i%.org}_func.h "
done
#+end_src
Generate C header file
#+begin_src bash
OUTPUT="${top_srcdir}/include/qmckl.h"
cat << EOF > ${OUTPUT}
/*
,* <<qmckl-header>>
,*/
#ifndef __QMCKL_H__
#define __QMCKL_H__
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
EOF
for i in ${HEADERS}
do
if [[ -f $i ]] ; then
cat $i >> ${OUTPUT}
fi
done
cat << EOF >> ${OUTPUT}
#endif
EOF
#+end_src
Generate Fortran interface file from all =qmckl_*_fh.f90= files
#+begin_src bash
HEADERS_TYPE="qmckl_*_fh_type.f90"
HEADERS="qmckl_*_fh_func.f90"
OUTPUT="${top_srcdir}/share/qmckl/fortran/qmckl_f.f90"
cat << EOF > ${OUTPUT}
!
! <<qmckl-header>>
!
module qmckl
use, intrinsic :: iso_c_binding
EOF
for i in ${HEADERS_TYPE}
do
cat $i >> ${OUTPUT}
done
for i in ${HEADERS}
do
cat $i >> ${OUTPUT}
done
cat << EOF >> ${OUTPUT}
end module qmckl
EOF
#+end_src
* Script to build the documentation
:PROPERTIES:
:header-args:bash: :tangle build_doc.sh :noweb yes :shebang #!/bin/bash :comments org
:END:
First define readonly global variables.
#+begin_src bash :noweb yes
readonly DOCS=${top_srcdir}/share/doc/qmckl/
readonly SRC=${top_srcdir}/src/
readonly HTMLIZE=${DOCS}/html/htmlize.el
readonly CONFIG_DOC=${top_srcdir}/tools/config_doc.el
readonly CONFIG_TANGLE=${top_srcdir}/tools/config_tangle.el
#+end_src
Check that all the defined global variables correspond to files.
#+begin_src bash :noweb yes
function check_preconditions()
{
if [[ -z ${top_srcdir} ]]
then
print "top_srcdir is not defined"
exit 1
fi
for dir in ${DOCS}/html ${DOCS}/text ${SRC}
do
if [[ ! -d ${dir} ]]
then
print "${dir} not found"
exit 2
fi
done
for file in ${CONFIG_DOC} ${CONFIG_TANGLE}
do
if [[ ! -f ${file} ]]
then
print "${file} not found"
exit 3
fi
done
}
#+end_src
~install_htmlize~ installs the htmlize Emacs plugin if the
=htmlize.el= file is not present.
#+begin_src bash :noweb yes
function install_htmlize()
{
local url="https://github.com/hniksic/emacs-htmlize"
local repo="emacs-htmlize"
[[ -f ${HTMLIZE} ]] || (
cd ${DOCS}/html
git clone ${url} \
&& cp ${repo}/htmlize.el ${HTMLIZE} \
&& rm -rf ${repo}
cd -
)
# Assert htmlize is installed
[[ -f ${HTMLIZE} ]] \
|| exit 1
}
#+end_src
Extract documentation from an org-mode file.
#+begin_src bash :noweb yes
function extract_doc()
{
local org=$1
local local_html=${SRC}/${org%.org}.html
local local_text=${SRC}/${org%.org}.txt
local html=${DOCS}/html/${org%.org}.html
local text=${DOCS}/text/${org%.org}.txt
if [[ -f ${html} && ${org} -ot ${html} ]]
then
return
fi
emacs --batch \
--load ${HTMLIZE} \
--load ${CONFIG_DOC} \
${org} \
--load ${CONFIG_TANGLE} \
-f org-html-export-to-html \
-f org-ascii-export-to-ascii
mv ${local_html} ${DOCS}/html
mv ${local_text} ${DOCS}/text
}
#+end_src
The main function of the script.
#+begin_src bash :noweb yes
function main() {
check_preconditions || exit 1
# Install htmlize if needed
install_htmlize || exit 2
# Create documentation
cd ${SRC} \
|| exit 3
for i in *.org
do
echo
echo "======= ${i} ======="
extract_doc ${i}
done
if [[ $? -eq 0 ]]
then
cd ${DOCS}/html
rm -f index.html
ln README.html index.html
exit 0
else
exit 3
fi
}
main
#+end_src

View File

@ -48,7 +48,7 @@ def main():
c_test_o = "tests/test_"+i+".$(OBJEXT)"
f_test_o = "tests/test_"+i+"_f.$(OBJEXT)"
c_test = "tests/test_"+i+".c"
f_test = "tests/test_"+i+"_f.f90"
f_test = "tests/test_"+i+"_f.F90"
html = "share/doc/qmckl/html/"+i+".html"
text = "share/doc/qmckl/text/"+i+".txt"
@ -60,10 +60,10 @@ def main():
h_type=i+"_type.h"
h_private_func=i+"_private_func.h"
h_private_type=i+"_private_type.h"
f90=i+"_f.f90"
F90=i+"_f.F90"
fo=i+"_f.$(OBJEXT)"
fh_func=i+"_fh_func.f90"
fh_type=i+"_fh_type.f90"
fh_func=i+"_fh_func.F90"
fh_type=i+"_fh_type.F90"
ORG_FILES += [org]
TANGLED_FILES += [tangled]
@ -132,17 +132,17 @@ def main():
DEPS[h_private_func] = [tangled]
if "(eval f)" in grep:
F_FILES += [f90]
F_FILES += [F90]
if f90 in DEPS:
DEPS[f90] += [tangled, "$(src_qmckl_fo)"]
if F90 in DEPS:
DEPS[F90] += [tangled, "$(src_qmckl_fo)"]
else:
DEPS[f90] = [tangled, "$(src_qmckl_fo)"]
DEPS[F90] = [tangled, "$(src_qmckl_fo)"]
if fo in DEPS:
DEPS[fo] += [f90, "$(src_qmckl_fo)"]
DEPS[fo] += [F90, "$(src_qmckl_fo)"]
else:
DEPS[fo] = [f90, "$(src_qmckl_fo)"]
DEPS[fo] = [F90, "$(src_qmckl_fo)"]
if "(eval fh_func)" in grep:
FH_FUNC_FILES += [fh_func]

View File

@ -1,9 +1,9 @@
#!/bin/sh
# Script to build the final src/qmckl_f.f90 file
# Script to build the final src/qmckl_f.F90 file
set -e
# All the produced header files are concatenated in the =src/qmckl_f.f90=
# All the produced header files are concatenated in the =src/qmckl_f.F90=
# file, located in the share/qmckl/fortran directory.
@ -30,8 +30,8 @@ fi
# Generate Fortran interface file
# -------------------------------
HEADERS_TYPE="src/qmckl_*_fh_type.f90"
HEADERS="src/qmckl_*_fh_func.f90"
HEADERS_TYPE="src/qmckl_*_fh_type.F90"
HEADERS="src/qmckl_*_fh_func.F90"
cat << EOF > ${src_qmckl_f}
!

View File

@ -39,15 +39,15 @@
(setq src (concat top_builddir "/src/"))
(setq tests (concat top_builddir "/tests/"))
(setq name (file-name-nondirectory (substring buffer-file-name 0 -4)))
(setq f (concat src name "_f.f90"))
(setq fh_func (concat src name "_fh_func.f90"))
(setq fh_type (concat src name "_fh_type.f90"))
(setq f (concat src name "_f.F90"))
(setq fh_func (concat src name "_fh_func.F90"))
(setq fh_type (concat src name "_fh_type.F90"))
(setq c (concat src name ".c"))
(setq h_func (concat src name "_func.h"))
(setq h_type (concat src name "_type.h"))
(setq h_private_type (concat src name "_private_type.h"))
(setq h_private_func (concat src name "_private_func.h"))
(setq c_test (concat tests "test_" name ".c"))
(setq f_test (concat tests "test_" name "_f.f90"))
(setq f_test (concat tests "test_" name "_f.F90"))
(org-babel-lob-ingest (concat srcdir "/tools/lib.org"))

View File

@ -22,7 +22,7 @@ function tangle()
{
local org_file=$1
local c_file=${org_file%.org}.c
local f_file=${org_file%.org}.f90
local f_file=${org_file%.org}.F90
if [[ ${org_file} -ot ${c_file} ]] ; then
return