From cc0e17b9326346e4b1561f7a2ceb3f8efba14529 Mon Sep 17 00:00:00 2001 From: Sebastian Ehlert <28669218+awvwgk@users.noreply.github.com> Date: Thu, 21 Oct 2021 14:52:22 +0200 Subject: [PATCH 1/2] Make sure to not allow filling more electrons than orbitals available --- src/scf_module.F90 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/scf_module.F90 b/src/scf_module.F90 index 8ddeb86ea..c475d4648 100644 --- a/src/scf_module.F90 +++ b/src/scf_module.F90 @@ -336,6 +336,10 @@ subroutine scf(env, mol, wfn, basis, pcem, xtbData, solvation, & ! fill levels if(wfn%nel.ne.0) then + if (wfn%nel > 2*size(basis%nao)) then + call env%error("Not enough basis functions for filling orbitals", source) + return + end if call occu(basis%nao,wfn%nel,wfn%nopen,wfn%ihomoa,wfn%ihomob,wfn%focca,wfn%foccb) wfn%focc = wfn%focca + wfn%foccb wfn%ihomo=wfn%ihomoa From b42d9ebf041632b09836bbd31b3fe47b284b806b Mon Sep 17 00:00:00 2001 From: Sebastian Ehlert <28669218+awvwgk@users.noreply.github.com> Date: Thu, 21 Oct 2021 16:34:46 +0200 Subject: [PATCH 2/2] Fix error --- src/scf_module.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scf_module.F90 b/src/scf_module.F90 index c475d4648..7098dbb68 100644 --- a/src/scf_module.F90 +++ b/src/scf_module.F90 @@ -336,7 +336,7 @@ subroutine scf(env, mol, wfn, basis, pcem, xtbData, solvation, & ! fill levels if(wfn%nel.ne.0) then - if (wfn%nel > 2*size(basis%nao)) then + if (wfn%nel > 2*basis%nao) then call env%error("Not enough basis functions for filling orbitals", source) return end if