grimme-lab / xtb

Semiempirical Extended Tight-Binding Program Package
https://xtb-docs.readthedocs.io/
GNU Lesser General Public License v3.0
594 stars 148 forks source link

compilation of `xtb` 6.7.1 failing #1091

Open boegel opened 3 months ago

boegel commented 3 months ago

Describe the bug

compilation of xtb 6.7.1 is failing with GCC 12.3.0 is failing with:

[526/899] Compiling Fortran object libxtb.so.6.7.1.p/src_dipro_xtb.F90.o
FAILED: libxtb.so.6.7.1.p/src_dipro_xtb.F90.o libxtb.so.6.7.1.p/xtb_dipro_xtb.mod
gfortran -Ilibxtb.so.6.7.1.p -I. -I../xtb-6.7.1 -I../xtb-6.7.1/include -Isubprojects/mctc-lib/libmctc-lib.a.p -Isubprojects/json-fortran-8.2.5/libjsonfortran.a.p -I../xtb-6.7.1/subprojects/tblite/include -Isubprojects/tblite/libtblite.a.p -Isubprojects/dftd4/libdftd4.a.p -I../xtb-6.7.1/subprojects/dftd4/include -Isubprojects/multicharge/libmulticharge.a.p -Isubprojects/s-dftd3/libs-dftd3.a.p -I../xtb-6.7.1/subprojects/s-dftd3/include -Isubprojects/toml-f/libtoml-f.a.p -Isubprojects/numsa/libnumsa.a.p -Isubprojects/cpx/libcpx.a.p -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -O2 -fdefault-real-8 -fdefault-double-8 -ffree-line-length-none -fbacktrace -O2 -ftree-vectorize -march=native -fno-math-errno -fPIC -fopenmp -pthread -fopenmp -DWITH_TBLITE=1 -DWITH_CPCMX=1 -Jlibxtb.so.6.7.1.p -o libxtb.so.6.7.1.p/src_dipro_xtb.F90.o -c ../xtb-6.7.1/src/dipro/xtb.F90
../xtb-6.7.1/src/dipro/xtb.F90:53:42:

   53 |       call new_gfn2_calculator(xcalc, mol)
      |                                          1
Error: Missing actual argument for argument error at (1)
../xtb-6.7.1/src/dipro/xtb.F90:55:42:

   55 |       call new_gfn1_calculator(xcalc, mol)
      |                                          1
Error: Missing actual argument for argument error at (1)
../xtb-6.7.1/src/dipro/xtb.F90:57:43:

   57 |       call new_ipea1_calculator(xcalc, mol)
      |                                           1
Error: Missing actual argument for argument error at (1)

To Reproduce

export FFLAGS="-O2 -ftree-vectorize -march=native -fno-math-errno"
meson setup --prefix /tmp/xtb-6.7.1 -Dlapack='custom' -Dcustom_libraries='flexiblas' --buildtype release  -Dlibdir=lib  /tmp/xtb-6.7.1
ninja -j 8

Expected behaviour

Compilation works (as it did before).

Additional context

Same problem with xtb 6.7.0, which we know worked fine before, it start of failing all of a sudden, probably because xtb downloads the latest version of tblite and due to https://github.com/tblite/tblite/pull/188, see also https://github.com/easybuilders/easybuild-easyconfigs/issues/21243.

Can we somehow prevent that xtb downloads whatever the latest version of tblite (or others) is, which makes the build essentially not reproducible?

boegel commented 3 months ago

It seems like #1072 probably fixes this, but that doesn't change that anyone trying to build xtb 6.7.1 will be hitting this problem...

How can we prevent similar situations going forward?

marcelmbn commented 3 months ago

The error is somewhat expected because xtb fetches always the latest commit of tblite (as defined here: https://github.com/grimme-lab/xtb/blob/main/subprojects/tblite.wrap). A solution for the future would be either i) more regular tblite releases so that we could always point to a fixed release, or ii) we try to point to a specific commit (but not sure if that's possible. The fact that tblite updates break the API probably can't be ruled out in the future. Btw, the statically linked release binaries are not affected in general.

Another alternativ is building xtb-light (see CI and Docs for instructions) which does not include the tblite dependency (depending on your needs).

boegel commented 3 months ago

@marcelmbn Thanks for the reply.

I also noticed that the latest head of tblite is automatically pulled in, which of course inevitably leads to a broken build at some point.

That's also my main motivation for reporting this particular build problem. Although it's relatively easy to fix this time (thanks to the changes in #1072), it's bound to happen again, and frankly it's a bit worrying that the from-source build of xtb is not reproducible over time.

I hope that xtb can at least go forward with downloading specific versions/commits of dependencies like tblite, so builds are reproducible going forward.

What would be even better is if there's a (documented) way of "seeding in" specific versions of these dependencies, so that they're not being downloaded on the fly during the build (which makes offline building impossible).

Is the latter already possible somehow, can the downloading of dependencies be avoided somehow?

marcelmbn commented 3 months ago

What would be even better is if there's a (documented) way of "seeding in" specific versions of these dependencies, so that they're not being downloaded on the fly during the build (which makes offline building impossible).

Is the latter already possible somehow, can the downloading of dependencies be avoided somehow?

The dependencies are downloaded during the setup of the build meson setup ... because meson expects them to be there but does not find them. Not sure if that is exactly what you mean, but it can of course be simply circumvented by setting up the build at one given point of time then make changes to the code and meson compile whenever necessary. Then, dependencies won't be downloaded again, but only if you delete them by rm -rf subprojects or similar.

marcelmbn commented 3 months ago

@marcelmbn Thanks for the reply.

I also noticed that the latest head of tblite is automatically pulled in, which of course inevitably leads to a broken build at some point.

That's also my main motivation for reporting this particular build problem. Although it's relatively easy to fix this time (thanks to the changes in #1072), it's bound to happen again, and frankly it's a bit worrying that the from-source build of xtb is not reproducible over time.

I hope that xtb can at least go forward with downloading specific versions/commits of dependencies like tblite, so builds are reproducible going forward.

Definitely agree with that! I will leave the issue open and ASAP introduce a specific commit/tag/release into the tblite dependency so that we always pull the same code and only update it with more recent xtb versions.

marcelmbn commented 3 months ago

Maybe also something to have in mind for you, @Albkat

marcelmbn commented 3 days ago

Related to this issue: https://github.com/grimme-lab/homebrew-qc/issues/43

awvwgk commented 3 days ago

For building xtb 6.7.1 with the latest tblite 0.4.0 I am applying the following patch (based on #1072):

diff --git a/src/dipro.F90 b/src/dipro.F90
index 42a1363..ab64e07 100644
--- a/src/dipro.F90
+++ b/src/dipro.F90
@@ -130,6 +130,10 @@ subroutine get_jab(env, tblite, mol, fragment, dipro)
 !=========================set up calculator===========================================   

    call get_calculator(xcalc, struc, tblite%method, error)  
+   if (allocated(error)) then
+      call env%error(error%message, source)
+      return
+   end if
    call new_wavefunction(wfn, struc%nat, xcalc%bas%nsh, xcalc%bas%nao, & 
       & 1, set%etemp * ktoau)
    wfn%nspin=1
@@ -258,6 +262,10 @@ subroutine get_jab(env, tblite, mol, fragment, dipro)
       write(*,'(A,I2)') "unpaired e- of fragment : ", mfrag(ifr)%uhf

       call get_calculator(fcalc(ifr), mfrag(ifr), tblite%method, error)
+      if (allocated(error)) then
+         call env%error(error%message, source)
+         return
+      end if
       !> mol%charge is updated automatically from wfn by tblite library 
       call new_wavefunction(wfx(ifr), mfrag(ifr)%nat, fcalc(ifr)%bas%nsh, fcalc(ifr)%bas%nao, &
          & 1, set%etemp * ktoau)
diff --git a/src/dipro/xtb.F90 b/src/dipro/xtb.F90
index 95aff78..4db948a 100644
--- a/src/dipro/xtb.F90
+++ b/src/dipro/xtb.F90
@@ -50,11 +50,11 @@ subroutine get_calculator(xcalc, mol, method, error)
       call fatal_error(error, "Unknown method '"//method//"' requested")
 !      error stop
    case("gfn2")
-      call new_gfn2_calculator(xcalc, mol)
+      call new_gfn2_calculator(xcalc, mol, error)
    case("gfn1")
-      call new_gfn1_calculator(xcalc, mol)
+      call new_gfn1_calculator(xcalc, mol, error)
    case("ipea1")
-      call new_ipea1_calculator(xcalc, mol)
+      call new_ipea1_calculator(xcalc, mol, error)
    end select
 end subroutine get_calculator
 #endif
diff --git a/src/tblite/calculator.F90 b/src/tblite/calculator.F90
index 653e6b2..f050874 100644
--- a/src/tblite/calculator.F90
+++ b/src/tblite/calculator.F90
@@ -150,16 +150,16 @@ subroutine newTBLiteCalculator(env, mol, calc, input)
       case default
          call fatal_error(error, "Unknown method '"//method//"' requested")
       case("gfn2")
-         call new_gfn2_calculator(calc%tblite, struc)
+         call new_gfn2_calculator(calc%tblite, struc, error)
       case("gfn1")
-         call new_gfn1_calculator(calc%tblite, struc)
+         call new_gfn1_calculator(calc%tblite, struc, error)
       case("ipea1")
-         call new_ipea1_calculator(calc%tblite, struc)
+         call new_ipea1_calculator(calc%tblite, struc, error)
       case("ceh")
          calc%guess = method
          calc%nspin = 1
-         calc%etemp = 5000.0_wp * kt
-         call new_ceh_calculator(calc%tblite, struc)
+         calc%etemp = 4000.0_wp * kt
+         call new_ceh_calculator(calc%tblite, struc, error)
       end select
    end if
    if (allocated(error)) then
@@ -244,18 +244,18 @@ subroutine newTBLiteWavefunction(env, mol, calc, chk)
          block 
             use tblite_context, only : context_type, context_terminal
             use tblite_context_terminal, only : escape
-            use tblite_ceh_singlepoint, only : ceh_guess
+            use tblite_ceh_singlepoint, only : ceh_singlepoint
             use tblite_lapack_solver, only : lapack_solver 
             use tblite_lapack_solver, only : lapack_algorithm
             type(context_type) :: ctx
-            
+
             ctx%solver = lapack_solver(lapack_algorithm%gvd)
             ctx%terminal = context_terminal(calc%color)

             write (env%unit, '(1x,a)') escape(ctx%terminal%cyan) // "Calculation of CEH charges" // &
                & escape(ctx%terminal%reset)
-            
-            call ceh_guess(ctx, calc%tblite, struc, error, wfn, calc%accuracy, 1)
+
+            call ceh_singlepoint(ctx, calc%tblite, struc, wfn, calc%accuracy, 1)
          end block
       end select
    end associate
diff --git a/subprojects/mstore.wrap b/subprojects/mstore.wrap
index acf5df9..0dfe716 100644
--- a/subprojects/mstore.wrap
+++ b/subprojects/mstore.wrap
@@ -1,4 +1,4 @@
 [wrap-git]
 directory = mstore
 url = https://github.com/grimme-lab/mstore
-revision = v0.2.0
+revision = v0.3.0
diff --git a/test/unit/test_ptb.F90 b/test/unit/test_ptb.F90
index 16c14cb..5e585f9 100644
--- a/test/unit/test_ptb.F90
+++ b/test/unit/test_ptb.F90
@@ -186,12 +186,37 @@ contains
       !> (Scaled) overlap matrix
       character(len=:), allocatable :: message
       real(wp), parameter :: overlap_exp(6) = [ &
-      & 0.93209460_wp, & ! 1,2
-      & 0.35489609_wp, & ! 1,3
-      & 0.65682608_wp, & ! 2,3
-      & 0.05627743_wp, & ! 1,15
-      & -0.14217162_wp, &  ! 1,24; diffferent because of tblite ordering
-      & 0.41844087_wp] ! 14,23; diffferent because of tblite ordering
+      & 0.93209460_wp, & ! s(Mg)-s(Mg)
+      & 0.35489609_wp, & ! s(Mg)-s(Mg)
+      & 0.65682608_wp, & ! s(Mg)-s(Mg)
+      & 0.05627743_wp, & ! s(Mg)-s(H)
+      & -0.14217162_wp, & ! s(Mg)-pz(H)
+      & 0.41844087_wp] ! dyz(Mg)-py(H)
+      ! 1: s(Mg)
+      ! 2: s(Mg)
+      ! 3: s(Mg)
+      ! 4: py(Mg)
+      ! 5: pz(Mg)
+      ! 6: px(Mg)
+      ! 7: py(Mg)
+      ! 8: pz(Mg)
+      ! 9: px(Mg)
+      ! 10: dxy(Mg)
+      ! 11: dyz(Mg)
+      ! 12: dz2(Mg)
+      ! 13: dxz(Mg)
+      ! 14: dx2-y2(Mg)
+      ! 15: s(H)
+      ! 16: s(H)
+      ! 17: py(H)
+      ! 18: pz(H)
+      ! 19: px(H)
+      ! 20: s(H)
+      ! 21: s(H)
+      ! 22: py(H)
+      ! 23: pz(H)
+      ! 24: px(H)
+
       real(wp), allocatable :: lattr(:, :)
       real(wp) :: cutoff

@@ -215,7 +240,7 @@ contains
       call check_(error, ints%overlap(2, 3), overlap_exp(3), thr=thr)
       call check_(error, ints%overlap(1, 15), overlap_exp(4), thr=thr)
       call check_(error, ints%overlap(1, 23), overlap_exp(5), thr=thr)
-      call check_(error, ints%overlap(12, 22), overlap_exp(6), thr=thr)
+      call check_(error, ints%overlap(11, 22), overlap_exp(6), thr=thr)

    end subroutine test_ptb_overlap

@@ -249,12 +274,37 @@ contains
       type(error_type), allocatable, intent(out) :: error
       character(len=:), allocatable :: message
       real(wp), parameter :: overlap_exp(6) = [ &
-      & 0.95689468_wp, & ! 1,2
-      & 0.39195790_wp, & ! 1,3
-      & 0.62961212_wp, & ! 2,3
-      & 0.03782850_wp, & ! 1,15
-      &-0.13826216_wp, &  ! 1,24; diffferent because of tblite ordering
-      & 0.43334922_wp] ! 14,23; diffferent because of tblite ordering
+      & 0.95689468_wp, & ! s(Mg)-s(Mg)
+      & 0.39195790_wp, & ! s(Mg)-s(Mg)
+      & 0.62961212_wp, & ! s(Mg)-s(Mg)
+      & 0.03782850_wp, & ! s(Mg)-s(H)
+      &-0.13826216_wp, & ! s(Mg)-pz(H)
+      & 0.43334922_wp] ! dyz(Mg)-py(H)
+      ! 1: s(Mg)
+      ! 2: s(Mg)
+      ! 3: s(Mg)
+      ! 4: py(Mg)
+      ! 5: pz(Mg)
+      ! 6: px(Mg)
+      ! 7: py(Mg)
+      ! 8: pz(Mg)
+      ! 9: px(Mg)
+      ! 10: dxy(Mg)
+      ! 11: dyz(Mg)
+      ! 12: dz2(Mg)
+      ! 13: dxz(Mg)
+      ! 14: dx2-y2(Mg)
+      ! 15: s(H)
+      ! 16: s(H)
+      ! 17: py(H)
+      ! 18: pz(H)
+      ! 19: px(H)
+      ! 20: s(H)
+      ! 21: s(H)
+      ! 22: py(H)
+      ! 23: pz(H)
+      ! 24: px(H)
+
       real(wp), allocatable :: lattr(:, :)
       real(wp) :: cutoff

@@ -286,7 +336,7 @@ contains
       & message=message)
       call check_(error, auxints%overlap_h0_1(1, 23), overlap_exp(5), thr=thr, &
       & message=message)
-      call check_(error, auxints%overlap_h0_1(12, 22), overlap_exp(6), thr=thr, &
+      call check_(error, auxints%overlap_h0_1(11, 22), overlap_exp(6), thr=thr, &
       & message=message)

    end subroutine test_ptb_overlap_h0
@@ -319,12 +369,37 @@ contains
       real(wp), allocatable :: overlap_sx(:, :), overlap_oneminusx(:, :)
       character(len=:), allocatable :: message
       real(wp), parameter :: overlap_oneminusx_exp(6) = [ &
-      & 0.70788_wp, & ! 1,2
-      & 0.16203_wp, & ! 1,3
-      & 0.41532_wp, & ! 2,3
-      & 0.01449_wp, & ! 1,15
-      &-0.07203_wp, &  ! 1,24; diffferent because of tblite ordering
-      & 0.28751_wp] ! 14,23; diffferent because of tblite ordering
+      & 0.70788_wp, & ! s(Mg)-s(Mg)
+      & 0.16203_wp, & ! s(Mg)-s(Mg)
+      & 0.41532_wp, & ! s(Mg)-s(Mg)
+      & 0.01449_wp, & ! s(Mg)-s(H)
+      &-0.07203_wp, & ! s(Mg)-pz(H)
+      & 0.28751_wp] ! dyz(Mg)-py(H)
+      ! 1: s(Mg)
+      ! 2: s(Mg)
+      ! 3: s(Mg)
+      ! 4: py(Mg)
+      ! 5: pz(Mg)
+      ! 6: px(Mg)
+      ! 7: py(Mg)
+      ! 8: pz(Mg)
+      ! 9: px(Mg)
+      ! 10: dxy(Mg)
+      ! 11: dyz(Mg)
+      ! 12: dz2(Mg)
+      ! 13: dxz(Mg)
+      ! 14: dx2-y2(Mg)
+      ! 15: s(H)
+      ! 16: s(H)
+      ! 17: py(H)
+      ! 18: pz(H)
+      ! 19: px(H)
+      ! 20: s(H)
+      ! 21: s(H)
+      ! 22: py(H)
+      ! 23: pz(H)
+      ! 24: px(H)
+
       real(wp), allocatable :: lattr(:, :)
       real(wp) :: cutoff

@@ -356,7 +431,7 @@ contains
       & message=message)
       call check_(error, overlap_oneminusx(1, 23), overlap_oneminusx_exp(5), thr=thr2, &
       & message=message)
-      call check_(error, overlap_oneminusx(12, 22), overlap_oneminusx_exp(6), thr=thr2, &
+      call check_(error, overlap_oneminusx(11, 22), overlap_oneminusx_exp(6), thr=thr2, &
       & message=message)

    end subroutine test_ptb_overlap_SX
@@ -392,10 +467,37 @@ contains
       type(error_type), allocatable, intent(out) :: error
       character(len=:), allocatable :: message
       real(wp), parameter :: vecp_ref(4) = [ &
-      &  0.077719_wp, & ! 1,1 ; diffferent because of tblite ordering
-      & -0.059122_wp, & ! 1,3 ; diffferent because of tblite ordering
-      &  0.052775_wp, & ! 3,5 ; diffferent because of tblite ordering
-      &  0.117176_wp]   ! 9,9 ; diffferent because of tblite ordering
+      &  0.077719_wp, & ! s(B)-s(B)
+      & -0.059122_wp, & ! s(B)-px(B)
+      &  0.052775_wp, & ! px(B)-px(B)
+      &  0.117176_wp]   ! dx2-y2(B)-dx2-y2(B)
+      ! 1: s(B)
+      ! 2: s(B)
+      ! 3: py(B)
+      ! 4: pz(B)
+      ! 5: px(B)
+      ! 6: py(B)
+      ! 7: pz(B)
+      ! 8: px(B)
+      ! 9: dxy(B)
+      ! 10: dyz(B)
+      ! 11: dz2(B)
+      ! 12: dxz(B)
+      ! 13: dx2-y2(B)
+      ! 14: s(Cl)
+      ! 15: s(Cl)
+      ! 16: py(Cl)
+      ! 17: pz(Cl)
+      ! 18: px(Cl)
+      ! 19: py(Cl)
+      ! 20: pz(Cl)
+      ! 21: px(Cl)
+      ! 22: dxy(Cl)
+      ! 23: dyz(Cl)
+      ! 24: dz2(Cl)
+      ! 25: dxz(Cl)
+      ! 26: dx2-y2(Cl)
+
       real(wp), parameter :: xyz(3, 2) = reshape([ &
       & 2.0_wp, 0.0_wp, 0.0_wp, &
       & 0.0_wp, 0.0_wp, 0.0_wp], [3, 2])
@@ -434,7 +536,7 @@ contains
       & message=message)
       call check_(error, vecp(5, 8), vecp_ref(3), thr=thr2, &
       & message=message)
-      call check_(error, vecp(12, 12), vecp_ref(4), thr=thr2, &
+      call check_(error, vecp(13, 13), vecp_ref(4), thr=thr2, &
       & message=message)
    end subroutine test_ptb_V_ECP

@@ -629,12 +731,39 @@ contains
       real(wp), allocatable :: vecp(:, :)

       real(wp), parameter :: h0_ref(6) = [ &
-      &  -1.59330281_wp, & ! 1,1
-      &  -2.24996207_wp, & ! 1,2
-      &   0.34974782_wp, & ! 1,23 ; diffferent because of tblite ordering
-      &   0.0_wp, & ! 7,11 ; different because of tblite ordering
-      &  -1.17757007_wp, & ! 3,6 ; different because of tblite ordering
-      &   0.48301561_wp]   ! 11,24 ; diffferent because of tblite ordering
+      &  -1.59330281_wp, & ! s(B)-s(B)
+      &  -2.24996207_wp, & ! s(B)-s(B)
+      &   0.34974782_wp, & ! s(B)-py(Cl)
+      &   0.0_wp, & ! dx2-y2(B)-py(B)
+      &  -1.17757007_wp, & ! px(B)-px(B)
+      &   0.48301561_wp]   ! dxy(B)-dxy(Cl)
+      ! 1: s(B)
+      ! 2: s(B)
+      ! 3: py(B)
+      ! 4: pz(B)
+      ! 5: px(B)
+      ! 6: py(B)
+      ! 7: pz(B)
+      ! 8: px(B)
+      ! 9: dxy(B)
+      ! 10: dyz(B)
+      ! 11: dz2(B)
+      ! 12: dxz(B)
+      ! 13: dx2-y2(B)
+      ! 14: s(Cl)
+      ! 15: s(Cl)
+      ! 16: py(Cl)
+      ! 17: pz(Cl)
+      ! 18: px(Cl)
+      ! 19: py(Cl)
+      ! 20: pz(Cl)
+      ! 21: px(Cl)
+      ! 22: dxy(Cl)
+      ! 23: dyz(Cl)
+      ! 24: dz2(Cl)
+      ! 25: dxz(Cl)
+      ! 26: dx2-y2(Cl)
+
       real(wp), parameter :: levels(10) = [ &
       &    -0.796651404_wp, &
       &    -0.269771638_wp, &
@@ -665,15 +794,16 @@ contains
          & alpha_scal=id_to_atom(mol, ptbData%hamiltonian%kalphah0l))
       allocate (vecp(bas%nao, bas%nao), source=0.0_wp)

+      ints%hamiltonian = 0.0_wp
       call get_hamiltonian(mol, list, bas, ptbData%hamiltonian, ptbData%hamiltonian%kla, auxints%overlap_h0_1, &
       & levels, ints%hamiltonian, ptbGlobals%kpol, ptbGlobals%kitr, ptbGlobals%kitocod)
       message = "H0 matrix element not matching to expected value."
       call check_(error, ints%hamiltonian(1, 1), h0_ref(1), thr=thr)
       call check_(error, ints%hamiltonian(1, 2), h0_ref(2), thr=thr)
-      call check_(error, ints%hamiltonian(1, 22), h0_ref(3), thr=thr)
+      call check_(error, ints%hamiltonian(1, 24), h0_ref(3), thr=thr)
       call check_(error, ints%hamiltonian(13, 6), h0_ref(4), thr=thr)
       call check_(error, ints%hamiltonian(8, 5), h0_ref(5), thr=thr)
-      call check_(error, ints%hamiltonian(13, 26), h0_ref(6), thr=thr)
+      call check_(error, ints%hamiltonian(9, 22), h0_ref(6), thr=thr)
    end subroutine test_ptb_hamiltonian_h0

    subroutine test_ptb_V_XC(error)
@@ -708,10 +838,37 @@ contains
       type(error_type), allocatable, intent(out) :: error
       character(len=:), allocatable :: message
       real(wp), parameter :: Vxc_ref(4) = [ &
-      & -0.92793357_wp, & ! 1,1
-      & -0.85981333_wp, & ! 1,2
-      &  0.06632750_wp, & ! 1,23 ; diffferent because of tblite ordering
-      &  0.00151880_wp]   ! 11,24 ; diffferent because of tblite ordering
+      & -0.92793357_wp, & ! s(B)-s(B)
+      & -0.85981333_wp, & ! s(B)-s(B)
+      &  0.06632750_wp, & ! s(B)-dz2(Cl)
+      &  0.00151880_wp]   ! dxy(B)-dxy(Cl)
+      ! 1: s(B)
+      ! 2: s(B)
+      ! 3: py(B)
+      ! 4: pz(B)
+      ! 5: px(B)
+      ! 6: py(B)
+      ! 7: pz(B)
+      ! 8: px(B)
+      ! 9: dxy(B)
+      ! 10: dyz(B)
+      ! 11: dz2(B)
+      ! 12: dxz(B)
+      ! 13: dx2-y2(B)
+      ! 14: s(Cl)
+      ! 15: s(Cl)
+      ! 16: py(Cl)
+      ! 17: pz(Cl)
+      ! 18: px(Cl)
+      ! 19: py(Cl)
+      ! 20: pz(Cl)
+      ! 21: px(Cl)
+      ! 22: dxy(Cl)
+      ! 23: dyz(Cl)
+      ! 24: dz2(Cl)
+      ! 25: dxz(Cl)
+      ! 26: dx2-y2(Cl)
+
       real(wp), parameter :: xyz(3, 2) = reshape([ &
       & 2.0_wp, 0.0_wp, 0.0_wp, &
       & 0.0_wp, 0.0_wp, 0.0_wp], [3, 2])
@@ -769,9 +926,9 @@ contains
       & message=message)
       call check_(error, Vxc(1, 2), Vxc_ref(2), thr=thr, &
       & message=message)
-      call check_(error, Vxc(1, 22), Vxc_ref(3), thr=thr, &
+      call check_(error, Vxc(1, 24), Vxc_ref(3), thr=thr, &
       & message=message)
-      call check_(error, Vxc(13, 26), Vxc_ref(4), thr=thr, &
+      call check_(error, Vxc(9, 22), Vxc_ref(4), thr=thr, &
       & message=message)

    end subroutine test_ptb_V_XC
@@ -957,10 +1114,35 @@ contains
       !> Conversion factor from temperature to energy
       real(wp), parameter :: kt = 3.166808578545117e-06_wp
       real(wp), parameter :: coulomb_pot_ref(4) = [ &
-      &  -0.05693153_wp, & ! 1,1
-      &  -0.33917531_wp, & ! 1,2
-      &  -0.00539212_wp, & ! 1,21 ; diffferent because of tblite ordering
-      &   0.01305793_wp]   ! 6,24 ; diffferent because of tblite ordering
+      &  -0.05693153_wp, & ! s(Mg)-s(Mg)
+      &  -0.33917531_wp, & ! s(Mg)-s(Mg)
+      &  -0.00539212_wp, & ! s(Mg)-s(H)
+      &   0.01305793_wp]   ! pz(Mg)-pz(H)
+      ! 1: s(Mg)
+      ! 2: s(Mg)
+      ! 3: s(Mg)
+      ! 4: py(Mg)
+      ! 5: pz(Mg)
+      ! 6: px(Mg)
+      ! 7: py(Mg)
+      ! 8: pz(Mg)
+      ! 9: px(Mg)
+      ! 10: dxy(Mg)
+      ! 11: dyz(Mg)
+      ! 12: dz2(Mg)
+      ! 13: dxz(Mg)
+      ! 14: dx2-y2(Mg)
+      ! 15: s(H)
+      ! 16: s(H)
+      ! 17: py(H)
+      ! 18: pz(H)
+      ! 19: px(H)
+      ! 20: s(H)
+      ! 21: s(H)
+      ! 22: py(H)
+      ! 23: pz(H)
+      ! 24: px(H)
+
       real(wp), allocatable :: lattr(:, :)
       real(wp) :: cutoff

@@ -1044,10 +1226,36 @@ contains
       integer, parameter :: nat = 2
       integer, parameter :: at(nat) = [5, 17]
       real(wp), parameter :: plusU_pot_ref(4) = [ &
-      &  -0.0023185_wp, & ! 1,1
-      &  -0.0018289_wp, & ! 1,2
-      &  -0.5266562_wp, & ! 1,21 ; diffferent because of tblite ordering
-      &  -1.6745659_wp]   ! 6,24 ; diffferent because of tblite ordering
+      &  -0.0023185_wp, & ! s(B)-s(B)
+      &  -0.0018289_wp, & ! s(B)-s(B)
+      &  -0.5266562_wp, & ! s(B)-pz(Cl)
+      &  -1.6745659_wp]   ! px(B)-dxy(Cl)
+      ! 1: s(B)
+      ! 2: s(B)
+      ! 3: py(B)
+      ! 4: pz(B)
+      ! 5: px(B)
+      ! 6: py(B)
+      ! 7: pz(B)
+      ! 8: px(B)
+      ! 9: dxy(B)
+      ! 10: dyz(B)
+      ! 11: dz2(B)
+      ! 12: dxz(B)
+      ! 13: dx2-y2(B)
+      ! 14: s(Cl)
+      ! 15: s(Cl)
+      ! 16: py(Cl)
+      ! 17: pz(Cl)
+      ! 18: px(Cl)
+      ! 19: py(Cl)
+      ! 20: pz(Cl)
+      ! 21: px(Cl)
+      ! 22: dxy(Cl)
+      ! 23: dyz(Cl)
+      ! 24: dz2(Cl)
+      ! 25: dxz(Cl)
+      ! 26: dx2-y2(Cl)

       call new(mol, at, xyz)
       allocate (ptbData)
@@ -1067,7 +1275,7 @@ contains
       call check_(error, wfn%coeff(1, 1, 1), plusU_pot_ref(1), thr=thr)
       call check_(error, wfn%coeff(1, 2, 1), plusU_pot_ref(2), thr=thr)
       call check_(error, wfn%coeff(1, 20, 1), plusU_pot_ref(3), thr=thr)
-      call check_(error, wfn%coeff(8, 26, 1), plusU_pot_ref(4), thr=thr)
+      call check_(error, wfn%coeff(8, 22, 1), plusU_pot_ref(4), thr=thr)

    end subroutine test_ptb_plus_U_potential
marcelmbn commented 3 days ago

In the long term, fixed version dependencies (i.e. pointing to tblite-0.4.0 in https://github.com/grimme-lab/xtb/blob/main/subprojects/tblite.wrap) are the way forward for xtb. This would mean that API changes would no longer affect the xtb build process.