diff --git a/INSTALL.rst b/INSTALL.rst index 51f6ca73..70111858 100644 --- a/INSTALL.rst +++ b/INSTALL.rst @@ -99,7 +99,7 @@ to Parameters (IRP) method. the downloaded archive in the :file:`${QP_ROOT}/external` directory * Extract the archive and go into the :file:`irpf90-*` directory to run - :command:`make`` + :command:`make` * Create scripts to facilitate the access to :command:`irpf90` and :command:`irpman` as follows diff --git a/config/bull.cfg b/config/bull.cfg new file mode 100644 index 00000000..0ea76c92 --- /dev/null +++ b/config/bull.cfg @@ -0,0 +1,61 @@ +# Common flags +############## +# +# -mkl=[parallel|sequential] : Use the MKL library +# --ninja : Allow the utilisation of ninja. It is mandatory ! +# --align=32 : Align all provided arrays on a 32-byte boundary +# +[COMMON] +FC : mpiifort -shared-libgcc -shared-intel -fpic +LAPACK_LIB : -mkl=parallel +IRPF90 : irpf90 +IRPF90_FLAGS : --ninja --align=32 -DMPI + +# Global options +################ +# +# 1 : Activate +# 0 : Deactivate +# +[OPTION] +MODE : OPT ; [ OPT | PROFILE | DEBUG ] : Chooses the section below +CACHE : 1 ; Enable cache_compile.py +OPENMP : 1 ; Append OpenMP flags + +# Optimization flags +#################### +# +# -xHost : Compile a binary optimized for the current architecture +# -O2 : O3 not better than O2. +# -ip : Inter-procedural optimizations +# -ftz : Flushes denormal results to zero +# +[OPT] +FCFLAGS : -xCORE-AVX2 -O2 -ip -ftz -g -traceback -qopt-prefetch=5 -qopt-prefetch-issue-excl-hint -unroll-aggressive +# Profiling flags +################# +# +[PROFILE] +FC : -p -g +FCFLAGS : -xSSE4.2 -O2 -ip -ftz -qopt-prefetch + +# Debugging flags +################# +# +# -traceback : Activate backtrace on runtime +# -fpe0 : All floating point exaceptions +# -C : Checks uninitialized variables, array subscripts, etc... +# -g : Extra debugging information +# -xSSE2 : Valgrind needs a very simple x86 executable +# +[DEBUG] +FC : -g -traceback +FCFLAGS : -xCORE-AVX2 -C -fpe0 -traceback + +# OpenMP flags +################# +# +[OPENMP] +FC : -qopenmp +IRPF90_FLAGS : --openmp + diff --git a/src/Determinants/occ_pattern.irp.f b/src/Determinants/occ_pattern.irp.f index 1f485c80..bc0d5fa0 100644 --- a/src/Determinants/occ_pattern.irp.f +++ b/src/Determinants/occ_pattern.irp.f @@ -61,13 +61,13 @@ subroutine occ_pattern_to_dets(o,d,sze,n_alpha,Nint) integer(bit_kind),intent(in) :: o(Nint,2) ! Occ patters integer(bit_kind),intent(out) :: d(Nint,2,sze) ! Output determinants - integer :: i, k, n, ispin + integer :: i, k, n, ispin, ispin2 ! Extract list of singly occupied MOs as (int,pos) pairs ! ------------------------------------------------------ integer :: iint(2*n_alpha), ipos(2*n_alpha) - integer(bit_kind) :: v, t, tt + integer(bit_kind) :: v, t, tt, diff, v_prev integer :: n_alpha_in_single n=0 @@ -84,26 +84,103 @@ subroutine occ_pattern_to_dets(o,d,sze,n_alpha,Nint) enddo v = shiftl(1,n_alpha_in_single) - 1 - sze = int(binom_int(n,n_alpha_in_single),4) - do i=1,sze - ! Initialize with doubly occupied MOs - d(:,1,i) = o(:,2) - d(:,2,i) = o(:,2) - do k=1,n - if (btest(v,k-1)) then - ispin = 1 - else - ispin = 2 - endif - d(iint(k), ispin, i) = ibset( d(iint(k), ispin, i), ipos(k) ) + sze = int(binom_int(n,n_alpha_in_single),4) + if (shiftl(n_alpha_in_single,1) == n) then + + ! Initialize first determinant + d(:,1,1) = o(:,2) + d(:,2,1) = o(:,2) + + do k=1,n_alpha_in_single + d(iint(k),1,1) = ibset( d(iint(k),1,1), ipos(k) ) enddo - ! Generate next permutation with Anderson's algorithm - t = ior(v,v-1) - tt = t+1 - v = ior(tt, shiftr( and(not(t),tt) - 1, trailz(v)+1) ) - enddo + do k=n_alpha_in_single+1,n + d(iint(k),2,1) = ibset( d(iint(k),2,1), ipos(k) ) + enddo + + ! Time reversal symmetry + d(:,1,2) = d(:,2,1) + d(:,2,2) = d(:,1,1) + + do i=3,sze,2 + ! Generate next permutation with Anderson's algorithm + v_prev = v + t = ior(v,v-1) + tt = t+1 + v = ior(tt, shiftr( and(not(t),tt) - 1, trailz(v)+1) ) + + ! Find what has changed between v_prev and v + diff = ieor(v,v_prev) + + ! Initialize with previous determinant + d(:,1,i) = d(:,1,i-2) + d(:,2,i) = d(:,2,i-2) + + ! Swap bits only where they have changed from v_prev to v + do while (diff /= 0_bit_kind) + k = trailz(diff)+1 + if (btest(v,k-1)) then + d(iint(k),1,i) = ibset( d(iint(k),1,i), ipos(k) ) + d(iint(k),2,i) = ibclr( d(iint(k),2,i), ipos(k) ) + else + d(iint(k),1,i) = ibclr( d(iint(k),1,i), ipos(k) ) + d(iint(k),2,i) = ibset( d(iint(k),2,i), ipos(k) ) + endif + diff = iand(diff,diff-1_bit_kind) + enddo + + ! Time reversal symmetry + d(:,1,i+1) = d(:,2,i) + d(:,2,i+1) = d(:,1,i) + + enddo + + else + + ! Initialize first determinant + d(:,1,1) = o(:,2) + d(:,2,1) = o(:,2) + + do k=1,n_alpha_in_single + d(iint(k),1,1) = ibset( d(iint(k),1,1), ipos(k) ) + enddo + + do k=n_alpha_in_single+1,n + d(iint(k),2,1) = ibset( d(iint(k),2,1), ipos(k) ) + enddo + + do i=2,sze + ! Generate next permutation with Anderson's algorithm + v_prev = v + t = ior(v,v-1) + tt = t+1 + v = ior(tt, shiftr( and(not(t),tt) - 1, trailz(v)+1) ) + + ! Find what has changed between v_prev and v + diff = ieor(v,v_prev) + + ! Initialize with previous determinant + d(:,1,i) = d(:,1,i-1) + d(:,2,i) = d(:,2,i-1) + + ! Swap bits only where they have changed from v_prev to v + do while (diff /= 0_bit_kind) + k = trailz(diff)+1 + if (btest(v,k-1)) then + d(iint(k),1,i) = ibset( d(iint(k),1,i), ipos(k) ) + d(iint(k),2,i) = ibclr( d(iint(k),2,i), ipos(k) ) + else + d(iint(k),1,i) = ibclr( d(iint(k),1,i), ipos(k) ) + d(iint(k),2,i) = ibset( d(iint(k),2,i), ipos(k) ) + endif + diff = iand(diff,diff-1_bit_kind) + enddo + + enddo + + endif end diff --git a/src/Hartree_Fock/Roothaan_Hall_SCF.irp.f b/src/Hartree_Fock/Roothaan_Hall_SCF.irp.f index 0351046c..e860496f 100644 --- a/src/Hartree_Fock/Roothaan_Hall_SCF.irp.f +++ b/src/Hartree_Fock/Roothaan_Hall_SCF.irp.f @@ -115,7 +115,7 @@ END_DOC endif dim_DIIS=0 enddo - level_shift = level_shift * 0.5d0 + level_shift = level_shift * 0.75d0 SOFT_TOUCH level_shift energy_SCF_previous = energy_SCF