Skip to content

Commit

Permalink
change generation & add other tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-24 committed Apr 7, 2024
1 parent 183a41b commit 1428cb1
Show file tree
Hide file tree
Showing 11 changed files with 438 additions and 69 deletions.
43 changes: 7 additions & 36 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,46 +36,17 @@ jobs:
if: contains(github.ref, 'tags')
run: |
echo "REF=${{ github.ref_name }}" >> "$GITHUB_ENV"
- name: Fetch & Generate
- name: Generate
run: |
# clone and checkout
git clone https://github.com/sunqm/libcint.git
cd libcint/
git checkout ${{ matrix.libcint_ref }}
# generate
../patch.sh
sed -i "s/#VERSION#/${{ matrix.libcint_ref }}/g" meson.build
# create archive
tar -czf libcint.tar.gz src/ include/ cmake/ meson.build meson_options.txt CMakeLists.txt
# create wrap
HASH=$(sha256sum libcint.tar.gz | cut -d " " -f 1 )
sed -i "s/#REF#/${{ env.REF }}/g" libcint.wrap
sed -i "s/#VERSION#/${{ matrix.libcint_ref }}/g" libcint.wrap
sed -i "s/#HASH#/${HASH}/g" libcint.wrap
- name: Test package with GCC
./generate.sh "${{ matrix.libcint_ref }}" "${{ env.REF }}"
- name: Test archive (GCC)
run: |
mkdir workdir_gcc
cd workdir_gcc
tar -xzf ../libcint/libcint.tar.gz
meson setup _build
meson compile -C _build
- name: Test package with clang
export CC=gcc
./tests.sh
- name: Test archive (Clang)
run: |
mkdir workdir_clang
cd workdir_clang
tar -xzf ../libcint/libcint.tar.gz
export CC=clang
meson setup _build
meson compile -C _build
- name: Test package with cmake
run: |
mkdir workdir_cmake
cd workdir_cmake
tar -xzf ../libcint/libcint.tar.gz
mkdir build
cd build
cmake ..
cmake --build .
./tests.sh
- name: Upload archive
uses: svenstaro/upload-release-action@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
libcint/
workdir/
testsdir/
venv/
*.tar.gz
37 changes: 37 additions & 0 deletions for-tests/test_meson_base/EXPECTED
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
sizeof(FINT)=4
ibas=0 (N=1), jbas=0 (N=1)
1.00000
ibas=1 (N=1), jbas=0 (N=1)
0.23670
ibas=1 (N=1), jbas=1 (N=1)
1.00000
ibas=2 (N=3), jbas=0 (N=1)
0.00000
0.00000 0.00000
0.00000 0.00000 0.00000
ibas=2 (N=3), jbas=1 (N=1)
0.00000
0.00000 0.00000
0.00000 0.00000 0.00000
ibas=2 (N=3), jbas=2 (N=3)
1.00000
0.00000 1.00000
0.00000 0.00000 1.00000
ibas=3 (N=1), jbas=0 (N=1)
0.05255
ibas=3 (N=1), jbas=1 (N=1)
0.46742
ibas=3 (N=1), jbas=2 (N=3)
0.00000
ibas=3 (N=1), jbas=3 (N=1)
1.00000
ibas=4 (N=1), jbas=0 (N=1)
0.05255
ibas=4 (N=1), jbas=1 (N=1)
0.46742
ibas=4 (N=1), jbas=2 (N=3)
0.00000
ibas=4 (N=1), jbas=3 (N=1)
0.24822
ibas=4 (N=1), jbas=4 (N=1)
1.00000
88 changes: 88 additions & 0 deletions for-tests/test_meson_base/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#include <stdio.h>
#include <stdlib.h>

#include <cint_funcs.h>

int main() {
printf("sizeof(FINT)=%ld\n", sizeof(FINT));

/* water, STO-3G USING
```c
printf("int atm[%d =%d*6 ] = {\n", bs->natm * 6, bs->natm);
for (int iatm = 0; iatm < bs->natm; ++iatm) {
printf(" ");
for (int ipos = 0; ipos < 6; ++ipos)
printf("%d,", bs->atm[iatm * 6 + ipos]);
printf("\n");
}
printf("};\n");
printf("int bas[%d =%d*8] = {\n", bs->nbas * 8, bs->nbas);
for (int ibas = 0; ibas < bs->nbas; ++ibas) {
printf(" ");
for (int ipos = 0; ipos < 8; ++ipos)
printf("%d,", bs->bas[ibas * 8 + ipos]);
printf("\n");
}
printf("};\n");
printf("double env[%ld] = {\n", bs->env_size);
for(size_t ipos=0; ipos < bs->env_size; ipos++) {
printf("%f,", bs->env[ipos]);
}
printf("};\n");
```
*/

FINT natm = 3;
FINT atm[18 /* =3*6 */] = {
8,20,0,0,0,0,
1,23,0,0,0,0,
1,26,0,0,0,0,
};

FINT nbas = 5;
FINT bas[40 /* =5*8 */] = {
0,0,6,1,0,29,50,0,
0,0,6,1,0,35,56,0,
0,1,3,1,0,41,62,0,
1,0,3,1,0,44,65,0,
2,0,3,1,0,47,68,0,
};
double env[71] = {
/* twenty zeros */ .0,.0,.0,.0,.0,.0,.0,.0,.0,.0,.0,.0,.0,.0,.0,.0,.0,.0,.0,.0,
/* pos O */ .0,.0,0.226017,
/* pos H1 */ .0,1.439618, -0.904064,
/* pos H2 */ .0,-1.439618, -0.904064,
/* 21 exponents */
/* 1st basis */ 130.709320,23.808861,6.443608,5.033151,1.169596,0.380389,
/* 2nd basis */ 130.709320,23.808861,6.443608,5.033151,1.169596,0.380389,
/* 3rd basis */ 5.033151,1.169596,0.380389,
/* 4th basis */ 3.425251,0.623914,0.168855,
/* 5th basis */ 3.425251,0.623914,0.168855,
/* 21 coefs. (renormalized) */
/* 1st basis */ 15.072747,14.577702,4.543234,.0,.0,.0,
/* 2nd basis */ .0,.0,.0,-0.848697,1.135201,0.856753,
/* 3rd basis */ 3.429066,2.156289,0.341592,
/* 4th basis */ 0.981707,0.949464,0.295906,
/* 5th basis */ 0.981707,0.949464,0.295906,
};

FINT si, sj;
double buff[CART_MAX * CART_MAX];

for(FINT ibas=0; ibas < nbas; ibas++) {
si = CINTcgtos_cart(ibas, bas);
for(FINT jbas=0; jbas <= ibas; jbas++) {
sj = CINTcgtos_cart(jbas, bas);
int1e_ovlp_cart(buff, NULL, (FINT[]) {ibas, jbas}, atm, natm, bas, nbas, env, NULL, NULL);
printf("ibas=%ld (N=%ld), jbas=%ld (N=%ld)\n", ibas, si, jbas, sj);
for (FINT ielm=0; ielm < si; ielm++) {
for(FINT jelm=0; jelm < ielm + 1; jelm++)
printf(" %.5f", buff[ielm * si + jelm]);
printf("\n");
}
}
}
}
34 changes: 34 additions & 0 deletions for-tests/test_meson_base/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
project('test_libcint', 'c',
version : '0.1.0',
default_options : ['warning_level=3'],
)

cc = meson.get_compiler('c')

# configure dependencies
project_dep = []

build_args = [
'-DPROJECT_NAME="lib' + meson.project_name() + '"',
'-DPROJECT_VERSION="' + meson.project_version() + '"',
]

libcint_dep = cc.find_library('libcint', required: false)
if not libcint_dep.found()
libcint_proj = subproject('libcint', default_options: [])
libcint_dep = libcint_proj.get_variable('libcint_dep')
endif
project_dep += libcint_dep


# fetch sources and includes
srcs = ['main.c']

# Executable
stda_exe = executable(
meson.project_name(),
srcs,
dependencies: project_dep,
c_args : build_args,
install: true
)
37 changes: 37 additions & 0 deletions for-tests/test_meson_i8/EXPECTED
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
sizeof(FINT)=8
ibas=0 (N=1), jbas=0 (N=1)
1.00000
ibas=1 (N=1), jbas=0 (N=1)
0.23670
ibas=1 (N=1), jbas=1 (N=1)
1.00000
ibas=2 (N=3), jbas=0 (N=1)
0.00000
0.00000 0.00000
0.00000 0.00000 0.00000
ibas=2 (N=3), jbas=1 (N=1)
0.00000
0.00000 0.00000
0.00000 0.00000 0.00000
ibas=2 (N=3), jbas=2 (N=3)
1.00000
0.00000 1.00000
0.00000 0.00000 1.00000
ibas=3 (N=1), jbas=0 (N=1)
0.05255
ibas=3 (N=1), jbas=1 (N=1)
0.46742
ibas=3 (N=1), jbas=2 (N=3)
0.00000
ibas=3 (N=1), jbas=3 (N=1)
1.00000
ibas=4 (N=1), jbas=0 (N=1)
0.05255
ibas=4 (N=1), jbas=1 (N=1)
0.46742
ibas=4 (N=1), jbas=2 (N=3)
0.00000
ibas=4 (N=1), jbas=3 (N=1)
0.24822
ibas=4 (N=1), jbas=4 (N=1)
1.00000
88 changes: 88 additions & 0 deletions for-tests/test_meson_i8/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#include <stdio.h>
#include <stdlib.h>

#include <cint_funcs.h>

int main() {
printf("sizeof(FINT)=%ld\n", sizeof(FINT));

/* water, STO-3G USING
```c
printf("int atm[%d =%d*6 ] = {\n", bs->natm * 6, bs->natm);
for (int iatm = 0; iatm < bs->natm; ++iatm) {
printf(" ");
for (int ipos = 0; ipos < 6; ++ipos)
printf("%d,", bs->atm[iatm * 6 + ipos]);
printf("\n");
}
printf("};\n");
printf("int bas[%d =%d*8] = {\n", bs->nbas * 8, bs->nbas);
for (int ibas = 0; ibas < bs->nbas; ++ibas) {
printf(" ");
for (int ipos = 0; ipos < 8; ++ipos)
printf("%d,", bs->bas[ibas * 8 + ipos]);
printf("\n");
}
printf("};\n");
printf("double env[%ld] = {\n", bs->env_size);
for(size_t ipos=0; ipos < bs->env_size; ipos++) {
printf("%f,", bs->env[ipos]);
}
printf("};\n");
```
*/

FINT natm = 3;
FINT atm[18 /* =3*6 */] = {
8,20,0,0,0,0,
1,23,0,0,0,0,
1,26,0,0,0,0,
};

FINT nbas = 5;
FINT bas[40 /* =5*8 */] = {
0,0,6,1,0,29,50,0,
0,0,6,1,0,35,56,0,
0,1,3,1,0,41,62,0,
1,0,3,1,0,44,65,0,
2,0,3,1,0,47,68,0,
};
double env[71] = {
/* twenty zeros */ .0,.0,.0,.0,.0,.0,.0,.0,.0,.0,.0,.0,.0,.0,.0,.0,.0,.0,.0,.0,
/* pos O */ .0,.0,0.226017,
/* pos H1 */ .0,1.439618, -0.904064,
/* pos H2 */ .0,-1.439618, -0.904064,
/* 21 exponents */
/* 1st basis */ 130.709320,23.808861,6.443608,5.033151,1.169596,0.380389,
/* 2nd basis */ 130.709320,23.808861,6.443608,5.033151,1.169596,0.380389,
/* 3rd basis */ 5.033151,1.169596,0.380389,
/* 4th basis */ 3.425251,0.623914,0.168855,
/* 5th basis */ 3.425251,0.623914,0.168855,
/* 21 coefs. (renormalized) */
/* 1st basis */ 15.072747,14.577702,4.543234,.0,.0,.0,
/* 2nd basis */ .0,.0,.0,-0.848697,1.135201,0.856753,
/* 3rd basis */ 3.429066,2.156289,0.341592,
/* 4th basis */ 0.981707,0.949464,0.295906,
/* 5th basis */ 0.981707,0.949464,0.295906,
};

FINT si, sj;
double buff[CART_MAX * CART_MAX];

for(FINT ibas=0; ibas < nbas; ibas++) {
si = CINTcgtos_cart(ibas, bas);
for(FINT jbas=0; jbas <= ibas; jbas++) {
sj = CINTcgtos_cart(jbas, bas);
int1e_ovlp_cart(buff, NULL, (FINT[]) {ibas, jbas}, atm, natm, bas, nbas, env, NULL, NULL);
printf("ibas=%ld (N=%ld), jbas=%ld (N=%ld)\n", ibas, si, jbas, sj);
for (FINT ielm=0; ielm < si; ielm++) {
for(FINT jelm=0; jelm < ielm + 1; jelm++)
printf(" %.5f", buff[ielm * si + jelm]);
printf("\n");
}
}
}
}
34 changes: 34 additions & 0 deletions for-tests/test_meson_i8/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
project('test_libcint', 'c',
version : '0.1.0',
default_options : ['warning_level=3'],
)

cc = meson.get_compiler('c')

# configure dependencies
project_dep = []

build_args = [
'-DPROJECT_NAME="lib' + meson.project_name() + '"',
'-DPROJECT_VERSION="' + meson.project_version() + '"',
]

libcint_dep = cc.find_library('libcint', required: false)
if not libcint_dep.found()
libcint_proj = subproject('libcint', default_options: ['i8=true'])
libcint_dep = libcint_proj.get_variable('libcint_dep')
endif
project_dep += libcint_dep


# fetch sources and includes
srcs = ['main.c']

# Executable
stda_exe = executable(
meson.project_name(),
srcs,
dependencies: project_dep,
c_args : build_args,
install: true
)
Loading

0 comments on commit 1428cb1

Please sign in to comment.