1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-06-14 01:05:41 +02:00

Workflows

This commit is contained in:
Anthony Scemama 2023-09-12 11:12:55 +02:00
parent cbc8b9bd58
commit 85e7592a6a
2 changed files with 224 additions and 57 deletions

View File

@ -147,60 +147,46 @@ jobs:
name: test-report-ubuntu-debug
path: _build_hpc/test-suite.log
# x86_macos:
#
# runs-on: macos-latest
# name: x86 MacOS latest
#
# steps:
# - uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791
# - 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: Test TREXIO
# run: make -j 4 check
# working-directory: trexio
#
# - name: Archive TREXIO test log file
# if: failure()
# uses: actions/upload-artifact@82c141cc518b40d92cc801eee768e7aafc9c2fa2
# with:
# name: test-report-trexio-macos
# path: trexio/test-suite.log
#
# - name: Build QMCkl
# run: |
# export PKG_CONFIG_PATH=${PWD}/trexio/_install/lib/pkgconfig:$PKG_CONFIG_PATH
# ./autogen.sh
# ./configure CC=gcc-10 FC=gfortran-10 --enable-silent-rules
# make -j 4
#
# - name: Run test
# run: make -j 4 check
#
# - name: Archive test log file
# if: failure()
# uses: actions/upload-artifact@82c141cc518b40d92cc801eee768e7aafc9c2fa2
# with:
# name: test-report-macos
# path: test-suite.log
macos:
runs-on: macos-12
name: x86 MacOS 12
steps:
- uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791
- name: Install dependencies
run: |
brew install emacs
brew install automake
brew install hdf5
brew --prefix hdf5
- name: Install the latest TREXIO from the GitHub clone
run: |
git clone https://github.com/TREX-CoE/trexio.git
cd trexio
./autogen.sh
./configure FC=gfortran-12 --enable-silent-rules
make -j 4
sudo make install
- name: Compile QMCkl in HPC mode
run: |
./autogen.sh
mkdir _build_hpc
cd _build_hpc
../configure --enable-hpc FC=gfortran-12
make -j2
- name: Run test
run: make -j2 check
working-directory: _build_hpc
- name: Archive test log file
if: failure()
uses: actions/upload-artifact@82c141cc518b40d92cc801eee768e7aafc9c2fa2
with:
name: test-report-macos-x86
path: _build_hpc/test-suite.log

View File

@ -490,6 +490,17 @@ Execution time : 5.608000 seconds
printf("\n");
}
// Clean-up and exit
free(mo_value);
free(overlap);
rc = qmckl_context_destroy(context);
if (rc != QMCKL_SUCCESS) {
fprintf(stderr, "Error destroying context)\n");
exit(1);
}
return 0;
}
#+end_src
@ -499,6 +510,176 @@ Execution time : 5.608000 seconds
200 0.039017 -0.013066 -0.000000 -0.001935 -0.000000 -0.003829 -0.000000 0.000996 -0.000000 0.000000 -0.003733 0.000000 0.000065 -0.000000 -0.000000 -0.002220 -0.000000 -0.001961 0.000000 0.000000 -0.004182 0.000000 -0.000000 -0.000165 -0.002445 0.000000 -0.000000 0.000000 0.001985 0.000000 0.001685 -0.000000 -0.002899 0.000000 0.000000 0.000000 -0.000000 0.002591 0.000000 -0.000000 0.000000 0.002385 0.000000 -0.011086 0.000000 -0.003885 0.000000 -0.000000 0.003602 -0.000000 0.000000 -0.003241 0.000000 0.000000 0.002613 -0.007344 -0.000000 -0.000000 0.000000 0.000017 0.000000 0.000000 0.000000 -0.008719 0.000000 -0.001358 -0.003233 0.000000 -0.000000 -0.000000 -0.000000 0.000000 0.003778 0.000000 0.000000 -0.000000 0.000000 0.000000 -0.001190 0.000000 0.000000 -0.000000 0.005578 -0.000000 -0.001502 0.003899 -0.000000 -0.000000 0.000000 -0.003291 -0.001775 -0.000000 -0.002374 0.000000 -0.000000 -0.000000 -0.000000 -0.001290 -0.000000 0.002178 0.000000 0.000000 0.000000 -0.001252 0.000000 -0.000000 -0.000926 0.000000 -0.000000 -0.013130 -0.000000 0.012124 0.000000 -0.000000 -0.000000 -0.000000 0.000000 0.025194 0.000343 -0.000000 0.000000 -0.000000 -0.004421 0.000000 0.000000 -0.000599 -0.000000 0.005289 0.000000 -0.000000 0.012826 -0.000000 0.000000 0.006190 0.000000 0.000000 -0.000000 0.000000 -0.000321 0.000000 -0.000000 -0.000000 0.000000 -0.000000 0.001499 -0.006629 0.000000 0.000000 0.000000 -0.000000 0.008737 -0.000000 0.006880 0.000000 -0.001851 -0.000000 -0.000000 0.000000 -0.007464 0.000000 0.010298 -0.000000 -0.000000 -0.000000 -0.000000 -0.000000 0.000000 0.000540 0.000000 -0.006616 -0.000000 0.000000 -0.002927 -0.000000 0.000000 0.010352 0.000000 -0.003103 -0.000000 -0.007640 -0.000000 -0.000000 0.005302 0.000000 0.000000 -0.000000 -0.000000 -0.010181 0.000000 -0.001108 0.000000 0.000000 -0.000000 0.000000 0.000000 -0.000998 -0.009754 0.013562 0.000000 -0.000000 0.887510
#+end_example
** Fortran
Here is the same piece of code translated in Fortran
#+begin_src f90
#include <qmckl_f.F90>
program main
use iso_c_binding
use qmckl
implicit none
! Declare variables
integer :: argc
character(128) :: trexio_filename, err_msg
integer(qmckl_exit_code) :: rc
integer(qmckl_context) :: context
integer*8 :: nucl_num, mo_num, point_num
double precision, allocatable :: nucl_coord(:,:)
integer*8 :: nx(3)
double precision, dimension(3) :: shift, step, rmin, rmax
double precision, allocatable :: mo_value(:,:), overlap(:,:), point(:), linspace(:,:)
double precision :: before, after, dr
integer*8 :: i,j,k,m
! Initialize variables
err_msg = ' '
argc = command_argument_count()
if (argc /= 1) then
print *, "Usage: ./program <TREXIO filename>"
stop -1
end if
call get_command_argument(1, trexio_filename)
rc = QMCKL_SUCCESS
! Create a QMCkl context
context = qmckl_context_create()
! Read the TREXIO file into the context
rc = qmckl_trexio_read(context, trim(trexio_filename), len(trexio_filename)*1_8)
if (rc /= QMCKL_SUCCESS) then
call qmckl_string_of_error(rc, err_msg)
write(*,*) "Error reading TREXIO file:", err_msg
stop -1
end if
! Retrieve the number of nuclei
rc = qmckl_get_nucleus_num(context, nucl_num)
if (rc /= QMCKL_SUCCESS) then
call qmckl_string_of_error(rc, err_msg)
write(*,*) "Error getting nucl_num:", err_msg
stop -1
end if
! Retrieve the nuclear coordinates
allocate(nucl_coord(3, nucl_num))
rc = qmckl_get_nucleus_coord(context, 'N', nucl_coord, nucl_num * 3_8)
if (rc /= QMCKL_SUCCESS) then
call qmckl_string_of_error(rc, err_msg)
write(*,*) "Error getting nucl_coord:", err_msg
stop -1
end if
! Retrieve the number of MOs
rc = qmckl_get_mo_basis_mo_num(context, mo_num)
if (rc /= QMCKL_SUCCESS) then
call qmckl_string_of_error(rc, err_msg)
write(*,*) "Error getting mo_num:", err_msg
stop -1
end if
! Initialize grid points for the calculation
nx = (/ 120, 120, 120 /)
shift = (/ 5.d0, 5.d0, 5.d0 /)
point_num = nx(1) * nx(2) * nx(3)
! Initialize rmin and rmax
rmin = nucl_coord(:,1)
rmax = nucl_coord(:,1)
! Update rmin and rmax based on nucl_coord
do i = 1, 3
do j = 1, nucl_num
rmin(i) = min(nucl_coord(i,j), rmin(i))
rmax(i) = max(nucl_coord(i,j), rmax(i))
end do
end do
! Apply shift
rmin = rmin - shift
rmax = rmax + shift
! Initialize linspace and step
allocate(linspace(3, maxval(nx)))
do i = 1, 3
step(i) = (rmax(i) - rmin(i)) / real(nx(i) - 1, 8)
do j = 1, nx(i)
linspace(i, j) = rmin(i) + (j - 1) * step(i)
end do
end do
! Initialize point array
allocate(point(3 * point_num))
m = 1
do i = 1, nx(1)
do j = 1, nx(2)
do k = 1, nx(3)
point(m) = linspace(1, i); m = m + 1
point(m) = linspace(2, j); m = m + 1
point(m) = linspace(3, k); m = m + 1
end do
end do
end do
deallocate(linspace)
! Set points in QMCKL context
rc = qmckl_set_point(context, 'N', point_num, point, point_num * 3)
if (rc /= QMCKL_SUCCESS) then
call qmckl_string_of_error(rc, err_msg)
write(*,*) "Error setting point:", err_msg
stop -1
end if
! Perform the actual calculation and measure the time taken
call cpu_time(before)
allocate(mo_value(point_num, mo_num))
rc = qmckl_get_mo_basis_mo_value(context, mo_value, point_num * mo_num)
if (rc /= QMCKL_SUCCESS) then
call qmckl_string_of_error(rc, err_msg)
write(*,*) "Error getting mo_value:", err_msg
stop
end if
call cpu_time(after)
write(*,*) "Number of MOs:", mo_num
write(*,*) "Number of grid points:", point_num
write(*,*) "Execution time:", (after - before), "seconds"
! Compute the overlap matrix
dr = step(1) * step(2) * step(3)
allocate(overlap(mo_num, mo_num))
rc = qmckl_dgemm(context, 'N', 'T', mo_num, mo_num, point_num, dr, &
mo_value, mo_num, mo_value, mo_num, 0.d0, overlap, mo_num)
! Print the overlap matrix
do i = 1, mo_num
write(*,'(i4)', advance='no') i
do j = 1, mo_num
write(*,'(f8.4)', advance='no') overlap(i, j)
end do
write(*,*)
end do
! Clean-up and exit
deallocate(mo_value, overlap)
rc = qmckl_context_destroy(context)
if (rc /= QMCKL_SUCCESS) then
call qmckl_string_of_error(rc, err_msg)
write(*,*) "Error destroying context:", err_msg
stop -1
end if
end program main
#+end_src
* Fortran
** Checking errors