From 930d03bf1a1457a0b30de5f7dd6f5cf14c14fde7 Mon Sep 17 00:00:00 2001 From: "M. Chandler Bennett" Date: Mon, 31 Jan 2022 11:11:48 -0500 Subject: [PATCH 01/68] Update dependencies --- external/qp2-dependencies | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/qp2-dependencies b/external/qp2-dependencies index bc856147..90ee61f5 160000 --- a/external/qp2-dependencies +++ b/external/qp2-dependencies @@ -1 +1 @@ -Subproject commit bc856147f6e626a6616b20344e5b8e3f30f44a92 +Subproject commit 90ee61f5041c7c94a0c605625a264860292813a0 From 32b8663fa1d0bb6127833d089a8fd6b8a79b1a6f Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 31 Jan 2022 17:23:08 +0100 Subject: [PATCH 02/68] Update submodules --- external/qp2-dependencies | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/qp2-dependencies b/external/qp2-dependencies index bc856147..90ee61f5 160000 --- a/external/qp2-dependencies +++ b/external/qp2-dependencies @@ -1 +1 @@ -Subproject commit bc856147f6e626a6616b20344e5b8e3f30f44a92 +Subproject commit 90ee61f5041c7c94a0c605625a264860292813a0 From 10446b66bd75e906a37a2af35905abaaf068dda5 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 25 Mar 2022 15:29:28 +0100 Subject: [PATCH 03/68] Minor change --- src/cipsi/selection.irp.f | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cipsi/selection.irp.f b/src/cipsi/selection.irp.f index f1ec6ff6..e62d5c8a 100644 --- a/src/cipsi/selection.irp.f +++ b/src/cipsi/selection.irp.f @@ -783,7 +783,9 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d alpha_h_psi = mat(istate, p1, p2) - pt2_data % overlap(:,istate) = pt2_data % overlap(:,istate) + coef(:) * coef(istate) + do k=1,N_states + pt2_data % overlap(k,istate) = pt2_data % overlap(k,istate) + coef(k) * coef(istate) + end do pt2_data % variance(istate) = pt2_data % variance(istate) + alpha_h_psi * alpha_h_psi pt2_data % pt2(istate) = pt2_data % pt2(istate) + e_pert(istate) From e3e403692195d04e2c1e15546d9eea738eab909e Mon Sep 17 00:00:00 2001 From: ydamour Date: Tue, 5 Apr 2022 16:12:47 +0200 Subject: [PATCH 04/68] Fix psi_det_size --- src/determinants/determinants.irp.f | 43 +++++++++++++++-------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/src/determinants/determinants.irp.f b/src/determinants/determinants.irp.f index b8c8658f..eeadf779 100644 --- a/src/determinants/determinants.irp.f +++ b/src/determinants/determinants.irp.f @@ -77,28 +77,31 @@ BEGIN_PROVIDER [ integer, psi_det_size ] END_DOC PROVIDE ezfio_filename logical :: exists - if (mpi_master) then - call ezfio_has_determinants_n_det(exists) - if (exists) then - call ezfio_get_determinants_n_det(psi_det_size) - else - psi_det_size = 1 + psi_det_size = 1 + PROVIDE mpi_master + if (read_wf) then + if (mpi_master) then + call ezfio_has_determinants_n_det(exists) + if (exists) then + call ezfio_get_determinants_n_det(psi_det_size) + else + psi_det_size = 1 + endif + call write_int(6,psi_det_size,'Dimension of the psi arrays') endif - call write_int(6,psi_det_size,'Dimension of the psi arrays') + IRP_IF MPI_DEBUG + print *, irp_here, mpi_rank + call MPI_BARRIER(MPI_COMM_WORLD, ierr) + IRP_ENDIF + IRP_IF MPI + include 'mpif.h' + integer :: ierr + call MPI_BCAST( psi_det_size, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr) + if (ierr /= MPI_SUCCESS) then + stop 'Unable to read psi_det_size with MPI' + endif + IRP_ENDIF endif - IRP_IF MPI_DEBUG - print *, irp_here, mpi_rank - call MPI_BARRIER(MPI_COMM_WORLD, ierr) - IRP_ENDIF - IRP_IF MPI - include 'mpif.h' - integer :: ierr - call MPI_BCAST( psi_det_size, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr) - if (ierr /= MPI_SUCCESS) then - stop 'Unable to read psi_det_size with MPI' - endif - IRP_ENDIF - END_PROVIDER From e6d08356577968e79a81faa56dbbca83a4d62855 Mon Sep 17 00:00:00 2001 From: ydamour Date: Fri, 8 Apr 2022 17:21:03 +0200 Subject: [PATCH 05/68] fix error pt2 from det already in the wf --- src/cipsi/selection.irp.f | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/cipsi/selection.irp.f b/src/cipsi/selection.irp.f index d4d44c2d..2d8d34d5 100644 --- a/src/cipsi/selection.irp.f +++ b/src/cipsi/selection.irp.f @@ -195,7 +195,10 @@ subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_d integer :: l_a, nmax, idx integer, allocatable :: indices(:), exc_degree(:), iorder(:) - double precision, parameter :: norm_thr = 1.d-16 + + ! Removed to avoid introducing determinants already presents in the wf + !double precision, parameter :: norm_thr = 1.d-16 + allocate (indices(N_det), & exc_degree(max(N_det_alpha_unique,N_det_beta_unique))) @@ -215,10 +218,11 @@ subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_d i = psi_bilinear_matrix_rows(l_a) if (nt + exc_degree(i) <= 4) then idx = psi_det_sorted_order(psi_bilinear_matrix_order(l_a)) - if (psi_average_norm_contrib_sorted(idx) > norm_thr) then + ! Removed to avoid introducing determinants already presents in the wf + !if (psi_average_norm_contrib_sorted(idx) > norm_thr) then indices(k) = idx k=k+1 - endif + !endif endif enddo enddo @@ -242,10 +246,11 @@ subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_d idx = psi_det_sorted_order( & psi_bilinear_matrix_order( & psi_bilinear_matrix_transp_order(l_a))) - if (psi_average_norm_contrib_sorted(idx) > norm_thr) then + ! Removed to avoid introducing determinants already presents in the wf + !if (psi_average_norm_contrib_sorted(idx) > norm_thr) then indices(k) = idx k=k+1 - endif + !endif endif enddo enddo @@ -566,6 +571,7 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d double precision, external :: diag_H_mat_elem_fock double precision :: E_shift double precision :: s_weight(N_states,N_states) + logical, external :: is_in_wavefunction PROVIDE dominant_dets_of_cfgs N_dominant_dets_of_cfgs do jstate=1,N_states do istate=1,N_states @@ -830,6 +836,24 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d end select end do + ! To force the inclusion of determinants with a positive pt2 contribution + if (e_pert(istate) > 1d-8) then + w = -huge(1.0) + endif + +!!!BEGIN_DEBUG +! ! To check if the pt2 is taking determinants already in the wf +! if (is_in_wavefunction(det(N_int,1),N_int)) then +! print*, 'A determinant contributing to the pt2 is already in' +! print*, 'the wave function:' +! call print_det(det(N_int,1),N_int) +! print*,'contribution to the pt2 for the states:', e_pert(:) +! print*,'error in the filtering in' +! print*, 'cipsi/selection.irp.f sub: selecte_singles_and_doubles' +! print*, 'abort' +! call abort +! endif +!!!END_DEBUG integer(bit_kind) :: occ(N_int,2), n if (h0_type == 'CFG') then From 52c460367de1ba0e584d4668aca79fa9ec6549a1 Mon Sep 17 00:00:00 2001 From: ydamour Date: Mon, 11 Apr 2022 13:55:00 +0200 Subject: [PATCH 06/68] fix error pt2 --- src/cipsi/selection.irp.f | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/cipsi/selection.irp.f b/src/cipsi/selection.irp.f index 2d8d34d5..1317fcf3 100644 --- a/src/cipsi/selection.irp.f +++ b/src/cipsi/selection.irp.f @@ -834,12 +834,13 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d endif end select - end do - ! To force the inclusion of determinants with a positive pt2 contribution - if (e_pert(istate) > 1d-8) then - w = -huge(1.0) - endif + ! To force the inclusion of determinants with a positive pt2 contribution + if (e_pert(istate) > 1d-8) then + w = -huge(1.0) + endif + + end do !!!BEGIN_DEBUG ! ! To check if the pt2 is taking determinants already in the wf From 19185c06f4c39bbba3dd50d029f4acb8b52f1075 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 11 Apr 2022 23:55:17 +0200 Subject: [PATCH 07/68] Add cipsi_save.sh --- scripts/cipsi_save.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 scripts/cipsi_save.sh diff --git a/scripts/cipsi_save.sh b/scripts/cipsi_save.sh new file mode 100644 index 00000000..a4d9b65e --- /dev/null +++ b/scripts/cipsi_save.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# +# This script runs a CIPSI calculation as a sequence of single CIPSI iterations. +# After each iteration, the EZFIO directory is saved. +# +# Usage: cipsi_save [EZFIO_FILE] [NDET] +# +# Example: cipsi_save file.ezfio 10000 + +EZ=$1 +NDETMAX=$2 + +qp set_file ${EZ} +qp reset -d +qp set determinants read_wf true +declare -i NDET +NDET=1 +while [[ ${NDET} -lt ${NDETMAX} ]] +do + NDET=$(($NDET + $NDET)) + qp set determinants n_det_max $NDET + qp run fci > ${EZ}.out + NDET=$(qp get determinants n_det) + mv ${EZ}.out ${EZ}.${NDET}.out + cp -r ${EZ} ${EZ}.${NDET} +done + From 82409d3e737ba3481523051248065c3fd9d1fab1 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 12 Apr 2022 15:49:20 +0200 Subject: [PATCH 08/68] Added drone CI config --- .drone.yml | 36 ++++++++++++++++++++++++++++++ drone/Docker/README.md | 8 +++++++ drone/Docker/Ubuntu/Dockerfile | 27 ++++++++++++++++++++++ {travis => drone}/compilation.sh | 0 {travis => drone}/configuration.sh | 0 {travis => drone}/testing.sh | 0 6 files changed, 71 insertions(+) create mode 100644 .drone.yml create mode 100644 drone/Docker/README.md create mode 100644 drone/Docker/Ubuntu/Dockerfile rename {travis => drone}/compilation.sh (100%) rename {travis => drone}/configuration.sh (100%) rename {travis => drone}/testing.sh (100%) diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 00000000..39d035db --- /dev/null +++ b/.drone.yml @@ -0,0 +1,36 @@ +--- +kind: pipeline +type: ssh +name: default + +clone: + depth: 10 + +server: + host: 130.120.229.139 + user: test + password: + from_secret: ssh_pass + +steps: +- name: configure + pull: never + image: ubuntu/qp2_env + commands: + - ./configure -i all -c ./config/gfortran_debug.cfg + - source quantum_package.rc ; qp plugins download https://gitlab.com/scemama/qp_plugins_scemama + - source quantum_package.rc ; qp plugins install champ + +- name: compile + pull: never + image: ubuntu/qp2_env + commands: + - ninja + +- name: testing + pull: never + image: ubuntu/qp2_env + commands: + - qp test + + diff --git a/drone/Docker/README.md b/drone/Docker/README.md new file mode 100644 index 00000000..eb569777 --- /dev/null +++ b/drone/Docker/README.md @@ -0,0 +1,8 @@ +Docker files to build the containers used with DroneCI. + +Example: +``` +docker build -t ubuntu/qp2_env . + +``` + diff --git a/drone/Docker/Ubuntu/Dockerfile b/drone/Docker/Ubuntu/Dockerfile new file mode 100644 index 00000000..05d87ad8 --- /dev/null +++ b/drone/Docker/Ubuntu/Dockerfile @@ -0,0 +1,27 @@ +ARG UBUNTU_VERSION=20.04 +FROM ubuntu:${UBUNTU_VERSION} AS builder + +# Timezone for tzdata +ARG tz=Etc/UTC +RUN echo $tz > /etc/timezone && rm -rf /etc/localtime + +# Install +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ + git \ + curl \ + wget \ + python3 \ + gfortran \ + gcc \ + g++ \ + make \ + build-essential \ + rsync \ + unzip \ + libopenblas-dev \ + pkg-config \ + m4 + +RUN ln -s /usr/bin/python3 /usr/bin/python + + diff --git a/travis/compilation.sh b/drone/compilation.sh similarity index 100% rename from travis/compilation.sh rename to drone/compilation.sh diff --git a/travis/configuration.sh b/drone/configuration.sh similarity index 100% rename from travis/configuration.sh rename to drone/configuration.sh diff --git a/travis/testing.sh b/drone/testing.sh similarity index 100% rename from travis/testing.sh rename to drone/testing.sh From 554af892ff1568491475033a5d4201e81551d54a Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 12 Apr 2022 15:55:51 +0200 Subject: [PATCH 09/68] Update drone --- .drone.yml | 37 +------------------------------------ drone/drone_docker | 30 ++++++++++++++++++++++++++++++ drone/drone_ssh | 30 ++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 36 deletions(-) mode change 100644 => 120000 .drone.yml create mode 100644 drone/drone_docker create mode 100644 drone/drone_ssh diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 39d035db..00000000 --- a/.drone.yml +++ /dev/null @@ -1,36 +0,0 @@ ---- -kind: pipeline -type: ssh -name: default - -clone: - depth: 10 - -server: - host: 130.120.229.139 - user: test - password: - from_secret: ssh_pass - -steps: -- name: configure - pull: never - image: ubuntu/qp2_env - commands: - - ./configure -i all -c ./config/gfortran_debug.cfg - - source quantum_package.rc ; qp plugins download https://gitlab.com/scemama/qp_plugins_scemama - - source quantum_package.rc ; qp plugins install champ - -- name: compile - pull: never - image: ubuntu/qp2_env - commands: - - ninja - -- name: testing - pull: never - image: ubuntu/qp2_env - commands: - - qp test - - diff --git a/.drone.yml b/.drone.yml new file mode 120000 index 00000000..b44fc76b --- /dev/null +++ b/.drone.yml @@ -0,0 +1 @@ +drone/drone_ssh \ No newline at end of file diff --git a/drone/drone_docker b/drone/drone_docker new file mode 100644 index 00000000..0cbeb613 --- /dev/null +++ b/drone/drone_docker @@ -0,0 +1,30 @@ +--- +kind: pipeline +type: ssh +name: default + +clone: + depth: 10 + +steps: +- name: configure + pull: never + image: ubuntu/qp2_env + commands: + - ./configure -i all -c ./config/gfortran_debug.cfg + - source quantum_package.rc ; qp plugins download https://gitlab.com/scemama/qp_plugins_scemama + - source quantum_package.rc ; qp plugins install champ + +- name: compile + pull: never + image: ubuntu/qp2_env + commands: + - ninja + +- name: testing + pull: never + image: ubuntu/qp2_env + commands: + - qp test + + diff --git a/drone/drone_ssh b/drone/drone_ssh new file mode 100644 index 00000000..e15b3fd5 --- /dev/null +++ b/drone/drone_ssh @@ -0,0 +1,30 @@ +--- +kind: pipeline +type: ssh +name: default + +clone: + depth: 10 + +server: + host: 130.120.229.139 + user: test + password: + from_secret: ssh_pass + +steps: +- name: configure + commands: + - ./configure -i all -c ./config/gfortran_debug.cfg + - source quantum_package.rc ; qp plugins download https://gitlab.com/scemama/qp_plugins_scemama + - source quantum_package.rc ; qp plugins install champ + +- name: compile + commands: + - ninja + +- name: testing + commands: + - qp test + + From c3d95a8562cf128c56d598a644e9900831ced72c Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 12 Apr 2022 16:00:33 +0200 Subject: [PATCH 10/68] Drone --- drone/{drone_docker => drone_docker.yml} | 0 drone/{drone_ssh => drone_ssh.yml} | 1 - 2 files changed, 1 deletion(-) rename drone/{drone_docker => drone_docker.yml} (100%) rename drone/{drone_ssh => drone_ssh.yml} (99%) diff --git a/drone/drone_docker b/drone/drone_docker.yml similarity index 100% rename from drone/drone_docker rename to drone/drone_docker.yml diff --git a/drone/drone_ssh b/drone/drone_ssh.yml similarity index 99% rename from drone/drone_ssh rename to drone/drone_ssh.yml index e15b3fd5..99397f11 100644 --- a/drone/drone_ssh +++ b/drone/drone_ssh.yml @@ -1,4 +1,3 @@ ---- kind: pipeline type: ssh name: default From 57bf2e2739873d83fc93138fa27dfa53cc52d803 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 12 Apr 2022 17:25:48 +0200 Subject: [PATCH 11/68] Drone --- .drone.yml | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) mode change 120000 => 100644 .drone.yml diff --git a/.drone.yml b/.drone.yml deleted file mode 120000 index b44fc76b..00000000 --- a/.drone.yml +++ /dev/null @@ -1 +0,0 @@ -drone/drone_ssh \ No newline at end of file diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 00000000..99397f11 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,29 @@ +kind: pipeline +type: ssh +name: default + +clone: + depth: 10 + +server: + host: 130.120.229.139 + user: test + password: + from_secret: ssh_pass + +steps: +- name: configure + commands: + - ./configure -i all -c ./config/gfortran_debug.cfg + - source quantum_package.rc ; qp plugins download https://gitlab.com/scemama/qp_plugins_scemama + - source quantum_package.rc ; qp plugins install champ + +- name: compile + commands: + - ninja + +- name: testing + commands: + - qp test + + From e813fd04f92d0ceabd39b526db86c68dcfec8b6f Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 12 Apr 2022 17:29:29 +0200 Subject: [PATCH 12/68] Drone --- .drone.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.drone.yml b/.drone.yml index 99397f11..0cbeb613 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,3 +1,4 @@ +--- kind: pipeline type: ssh name: default @@ -5,24 +6,24 @@ name: default clone: depth: 10 -server: - host: 130.120.229.139 - user: test - password: - from_secret: ssh_pass - steps: - name: configure + pull: never + image: ubuntu/qp2_env commands: - ./configure -i all -c ./config/gfortran_debug.cfg - source quantum_package.rc ; qp plugins download https://gitlab.com/scemama/qp_plugins_scemama - source quantum_package.rc ; qp plugins install champ - name: compile + pull: never + image: ubuntu/qp2_env commands: - ninja - name: testing + pull: never + image: ubuntu/qp2_env commands: - qp test From 69138a2d25e5ed6e5924f6b9c28bc5846a86c06e Mon Sep 17 00:00:00 2001 From: kossoski Date: Wed, 13 Apr 2022 13:25:39 +0200 Subject: [PATCH 13/68] Hierarchy CI --- src/cipsi/EZFIO.cfg | 6 ++++++ src/cipsi/selection.irp.f | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/cipsi/EZFIO.cfg b/src/cipsi/EZFIO.cfg index 7fcf19eb..e01359c5 100644 --- a/src/cipsi/EZFIO.cfg +++ b/src/cipsi/EZFIO.cfg @@ -34,3 +34,9 @@ doc: Maximum number of excitation for beta determinants with respect to the Hart interface: ezfio,ocaml,provider default: -1 +[twice_hierarchy_max] +type: integer +doc: Twice the maximum hierarchy parameter (excitation degree plus half the seniority number). Using -1 selects all determinants +interface: ezfio,ocaml,provider +default: -1 + diff --git a/src/cipsi/selection.irp.f b/src/cipsi/selection.irp.f index 1317fcf3..c8bc75d3 100644 --- a/src/cipsi/selection.irp.f +++ b/src/cipsi/selection.irp.f @@ -713,6 +713,25 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d if (do_cycle) cycle endif + if (twice_hierarchy_max >= 0) then + s = 0 + do k=1,N_int + s = s + popcnt(ieor(det(k,1),det(k,2))) + enddo + if ( mod(s,2)>0 ) stop 'For now, hierarchy CI is defined only for an even number of electrons' + if (excitation_ref == 1) then + call get_excitation_degree(HF_bitmask,det(1,1),degree,N_int) + else if (excitation_ref == 2) then + stop 'For now, hierarchy CI is defined only for a single reference determinant' +! do k=1,N_dominant_dets_of_cfgs +! call get_excitation_degree(dominant_dets_of_cfgs(1,1,k),det(1,1),degree,N_int) +! enddo + endif + integer :: twice_hierarchy + twice_hierarchy = degree + s/2 + if (twice_hierarchy_max > twice_hierarchy_max) cycle + endif + Hii = diag_H_mat_elem_fock(psi_det_generators(1,1,i_generator),det,fock_diag_tmp,N_int) w = 0d0 From 62c28db6da5887e3198e4491ce7671f74dc003f0 Mon Sep 17 00:00:00 2001 From: kossoski Date: Wed, 13 Apr 2022 13:32:14 +0200 Subject: [PATCH 14/68] correction --- src/cipsi/selection.irp.f | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cipsi/selection.irp.f b/src/cipsi/selection.irp.f index c8bc75d3..d4f184f3 100644 --- a/src/cipsi/selection.irp.f +++ b/src/cipsi/selection.irp.f @@ -729,7 +729,7 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d endif integer :: twice_hierarchy twice_hierarchy = degree + s/2 - if (twice_hierarchy_max > twice_hierarchy_max) cycle + if (twice_hierarchy > twice_hierarchy_max) cycle endif Hii = diag_H_mat_elem_fock(psi_det_generators(1,1,i_generator),det,fock_diag_tmp,N_int) From 8cbabc64943194c17543bc5c72d61dce3597e655 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 13 Apr 2022 13:40:04 +0200 Subject: [PATCH 15/68] Fixed ref values for tests --- src/fci/40.fci.bats | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fci/40.fci.bats b/src/fci/40.fci.bats index f2c78067..864a9d59 100644 --- a/src/fci/40.fci.bats +++ b/src/fci/40.fci.bats @@ -59,13 +59,13 @@ function run_stoch() { @test "HCO" { # 12.2868s qp set_file hco.ezfio - run -113.389297812482 6.e-4 100000 + run -113.393356604085 6.e-4 100000 } @test "H2O2" { # 12.9214s qp set_file h2o2.ezfio qp set_mo_class --core="[1-2]" --act="[3-24]" --del="[25-38]" - run -151.00467 1.e-4 100000 + run -151.005848404095 1.e-4 100000 } @test "HBO" { # 13.3144s From 3762409767713d1df7f7f99dbc034372d86a599b Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 13 Apr 2022 17:58:24 +0200 Subject: [PATCH 16/68] Fixed ref values for tests --- src/fci/40.fci.bats | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/fci/40.fci.bats b/src/fci/40.fci.bats index 864a9d59..3139ebb8 100644 --- a/src/fci/40.fci.bats +++ b/src/fci/40.fci.bats @@ -59,43 +59,43 @@ function run_stoch() { @test "HCO" { # 12.2868s qp set_file hco.ezfio - run -113.393356604085 6.e-4 100000 + run -113.393356604085 1.e-3 100000 } @test "H2O2" { # 12.9214s qp set_file h2o2.ezfio qp set_mo_class --core="[1-2]" --act="[3-24]" --del="[25-38]" - run -151.005848404095 1.e-4 100000 + run -151.005848404095 1.e-3 100000 } @test "HBO" { # 13.3144s [[ -n $TRAVIS ]] && skip qp set_file hbo.ezfio - run -100.212560384678 1.e-3 100000 + run -100.214099486337 1.e-3 100000 } @test "H2O" { # 11.3727s [[ -n $TRAVIS ]] && skip qp set_file h2o.ezfio - run -76.2361605151999 3.e-4 100000 + run -76.2361605151999 5.e-4 100000 } @test "ClO" { # 13.3755s [[ -n $TRAVIS ]] && skip qp set_file clo.ezfio - run -534.545616787223 3.e-4 100000 + run -534.546453546852 1.e-3 100000 } @test "SO" { # 13.4952s [[ -n $TRAVIS ]] && skip qp set_file so.ezfio - run -26.0096209515081 1.e-3 100000 + run -26.0176563764039 1.e-3 100000 } @test "H2S" { # 13.6745s [[ -n $TRAVIS ]] && skip qp set_file h2s.ezfio - run -398.859168655255 3.e-4 100000 + run -398.859577605891 5.e-4 100000 } @test "OH" { # 13.865s @@ -113,13 +113,13 @@ function run_stoch() { @test "H3COH" { # 14.7299s [[ -n $TRAVIS ]] && skip qp set_file h3coh.ezfio - run -115.205191406072 3.e-4 100000 + run -115.205632960026 1.e-3 100000 } @test "SiH3" { # 15.99s [[ -n $TRAVIS ]] && skip qp set_file sih3.ezfio - run -5.57241217753818 3.e-4 100000 + run -5.57241217753818 5.e-4 100000 } @test "CH4" { # 16.1612s @@ -132,7 +132,7 @@ function run_stoch() { @test "ClF" { # 16.8864s [[ -n $TRAVIS ]] && skip qp set_file clf.ezfio - run -559.169313755572 3.e-4 100000 + run -559.169748890031 1.e-3 100000 } @test "SO2" { # 17.5645s @@ -146,14 +146,14 @@ function run_stoch() { [[ -n $TRAVIS ]] && skip qp set_file c2h2.ezfio qp set_mo_class --act="[1-30]" --del="[31-36]" - run -12.3685464085969 3.e-4 100000 + run -12.3685464085969 1.e-3 100000 } @test "N2" { # 18.0198s [[ -n $TRAVIS ]] && skip qp set_file n2.ezfio qp set_mo_class --core="[1,2]" --act="[3-40]" --del="[41-60]" - run -109.28681540699360 3.e-4 100000 + run -109.287917088107 1.e-3 100000 } @test "N2H4" { # 18.5006s @@ -167,7 +167,7 @@ function run_stoch() { [[ -n $TRAVIS ]] && skip qp set_file co2.ezfio qp set_mo_class --core="[1,2]" --act="[3-30]" --del="[31-42]" - run -187.968547952413 3.e-4 100000 + run -187.970184372047 1.e-3 100000 } @@ -182,6 +182,6 @@ function run_stoch() { [[ -n $TRAVIS ]] && skip qp set_file hcn.ezfio qp set_mo_class --core="[1,2]" --act="[3-40]" --del="[41-55]" - run -93.0771143355433 3.e-4 100000 + run -93.0777619629755 1.e-3 100000 } From a1ed2282faa2e78fee014197f1da167603988c8a Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 13 Apr 2022 19:54:14 +0200 Subject: [PATCH 17/68] Adjust tests --- src/fci/40.fci.bats | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/fci/40.fci.bats b/src/fci/40.fci.bats index 3139ebb8..1a0c5507 100644 --- a/src/fci/40.fci.bats +++ b/src/fci/40.fci.bats @@ -132,28 +132,28 @@ function run_stoch() { @test "ClF" { # 16.8864s [[ -n $TRAVIS ]] && skip qp set_file clf.ezfio - run -559.169748890031 1.e-3 100000 + run -559.169748890031 1.5e-3 100000 } @test "SO2" { # 17.5645s [[ -n $TRAVIS ]] && skip qp set_file so2.ezfio qp set_mo_class --core="[1-8]" --act="[9-87]" - run -41.5746738713298 3.e-4 100000 + run -41.5746738713298 1.5e-3 100000 } @test "C2H2" { # 17.6827s [[ -n $TRAVIS ]] && skip qp set_file c2h2.ezfio qp set_mo_class --act="[1-30]" --del="[31-36]" - run -12.3685464085969 1.e-3 100000 + run -12.3685464085969 2.e-3 100000 } @test "N2" { # 18.0198s [[ -n $TRAVIS ]] && skip qp set_file n2.ezfio qp set_mo_class --core="[1,2]" --act="[3-40]" --del="[41-60]" - run -109.287917088107 1.e-3 100000 + run -109.287917088107 1.5e-3 100000 } @test "N2H4" { # 18.5006s @@ -167,7 +167,7 @@ function run_stoch() { [[ -n $TRAVIS ]] && skip qp set_file co2.ezfio qp set_mo_class --core="[1,2]" --act="[3-30]" --del="[31-42]" - run -187.970184372047 1.e-3 100000 + run -187.970184372047 1.5e-3 100000 } From d692391b6b644dec09f468fc082552b382a02044 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 13 Apr 2022 23:58:55 +0200 Subject: [PATCH 18/68] Drone CI file --- .drone.yml | 38 +++++++++++++++++++++++++++++--------- drone/drone_docker.yml | 2 +- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/.drone.yml b/.drone.yml index 0cbeb613..4d20225b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,30 +1,50 @@ --- kind: pipeline -type: ssh +type: docker name: default clone: depth: 10 steps: +- name: setup + image: ubuntu + commands: + - apt-get update + - DEBIAN_FRONTEND=noninteractive apt-get install -y \ + git \ + curl \ + wget \ + python3 \ + gfortran \ + gcc \ + g++ \ + make \ + build-essential \ + rsync \ + unzip \ + libopenblas-dev \ + pkg-config \ + m4 \ + python3 + - ln -s /usr/bin/python3 /usr/bin/python + + - name: configure - pull: never - image: ubuntu/qp2_env + image: ubuntu commands: - ./configure -i all -c ./config/gfortran_debug.cfg - source quantum_package.rc ; qp plugins download https://gitlab.com/scemama/qp_plugins_scemama - source quantum_package.rc ; qp plugins install champ - name: compile - pull: never - image: ubuntu/qp2_env + image: ubuntu commands: - - ninja + - source quantum_package.rc ; ninja - name: testing - pull: never - image: ubuntu/qp2_env + image: ubuntu commands: - - qp test + - source quantum_package.rc ; qp test -a diff --git a/drone/drone_docker.yml b/drone/drone_docker.yml index 0cbeb613..d1eb7175 100644 --- a/drone/drone_docker.yml +++ b/drone/drone_docker.yml @@ -1,6 +1,6 @@ --- kind: pipeline -type: ssh +type: docker name: default clone: From 75dca5f9b5d79681729f713366a120a5e26d6e3f Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 14 Apr 2022 01:15:21 +0200 Subject: [PATCH 19/68] Update droneCI --- .drone.yml | 36 +++++++----------------------------- 1 file changed, 7 insertions(+), 29 deletions(-) diff --git a/.drone.yml b/.drone.yml index 4d20225b..b213de7b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -7,44 +7,22 @@ clone: depth: 10 steps: -- name: setup - image: ubuntu - commands: - - apt-get update - - DEBIAN_FRONTEND=noninteractive apt-get install -y \ - git \ - curl \ - wget \ - python3 \ - gfortran \ - gcc \ - g++ \ - make \ - build-essential \ - rsync \ - unzip \ - libopenblas-dev \ - pkg-config \ - m4 \ - python3 - - ln -s /usr/bin/python3 /usr/bin/python - - name: configure - image: ubuntu + image: scemama666/qp2_env commands: - ./configure -i all -c ./config/gfortran_debug.cfg - - source quantum_package.rc ; qp plugins download https://gitlab.com/scemama/qp_plugins_scemama - - source quantum_package.rc ; qp plugins install champ + - bash -c "source quantum_package.rc ; qp plugins download https://gitlab.com/scemama/qp_plugins_scemama" + - bash -c "source quantum_package.rc ; qp plugins install champ" - name: compile - image: ubuntu + image: scemama666/qp2_env commands: - - source quantum_package.rc ; ninja + - bash -c "source quantum_package.rc ; exec ninja" - name: testing - image: ubuntu + image: scemama666/qp2_env commands: - - source quantum_package.rc ; qp test -a + - bash -c "source quantum_package.rc ; qp test -a" From 1c4e1e1eeb2958f144f9ac1bc65a66a7393304cd Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 19 Apr 2022 10:04:39 +0200 Subject: [PATCH 20/68] Drone CI --- .drone.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 4d20225b..ad677e3a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -45,6 +45,21 @@ steps: - name: testing image: ubuntu commands: - - source quantum_package.rc ; qp test -a + - source quantum_package.rc ; TRAVIS=1 qp_test -a +- name: re-configure + image: ubuntu + commands: + - ./configure -i all -c ./config/gfortran_avx.cfg + +- name: compile + image: ubuntu + commands: + - source quantum_package.rc ; ninja + +- name: testing + image: ubuntu + commands: + - source quantum_package.rc ; qp_test -a + From 057fe8185b597eeee40ffc9568701246e21b513c Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 19 Apr 2022 10:09:22 +0200 Subject: [PATCH 21/68] Drone CI --- .drone.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.drone.yml b/.drone.yml index 799b6dc2..b4683b73 100644 --- a/.drone.yml +++ b/.drone.yml @@ -12,8 +12,8 @@ steps: image: scemama666/qp2_env commands: - ./configure -i all -c ./config/gfortran_debug.cfg - - bash -c "source quantum_package.rc ; qp plugins download https://gitlab.com/scemama/qp_plugins_scemama" - - bash -c "source quantum_package.rc ; qp plugins install champ" + - bash -c "source quantum_package.rc ; exec qp_plugins download https://gitlab.com/scemama/qp_plugins_scemama" + - bash -c "source quantum_package.rc ; exec qp_plugins install champ" - name: compile image: scemama666/qp2_env @@ -23,7 +23,7 @@ steps: - name: testing image: scemama666/qp2_env commands: - - bash -c "source quantum_package.rc ; TRAVIS=1 qp_test -a" + - bash -c "source quantum_package.rc ; TRAVIS=1 exec qp_test -a" - name: re-configure @@ -34,10 +34,10 @@ steps: - name: compile image: ubuntu commands: - - bash -c "source quantum_package.rc ; ninja" + - bash -c "source quantum_package.rc ; exec ninja" - name: testing image: ubuntu commands: - - bash -c "source quantum_package.rc ; qp_test -a" + - bash -c "source quantum_package.rc ; exec qp_test -a" From 790b2d5f3fd874a33e0c5b6a8caedbe07dab2ebd Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 19 Apr 2022 10:13:38 +0200 Subject: [PATCH 22/68] Drone CI --- .drone.yml | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/.drone.yml b/.drone.yml index b4683b73..256b8e9b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,7 +1,7 @@ --- kind: pipeline type: docker -name: default +name: gfortran-debug clone: depth: 10 @@ -25,19 +25,28 @@ steps: commands: - bash -c "source quantum_package.rc ; TRAVIS=1 exec qp_test -a" +--- +kind: pipeline +type: docker +name: gfortran-avx -- name: re-configure - image: ubuntu +clone: + depth: 10 + +steps: + +- name: configure + image: scemama666/qp2_env commands: - ./configure -i all -c ./config/gfortran_avx.cfg - name: compile - image: ubuntu + image: scemama666/qp2_env commands: - bash -c "source quantum_package.rc ; exec ninja" - name: testing - image: ubuntu + image: scemama666/qp2_env commands: - bash -c "source quantum_package.rc ; exec qp_test -a" From 644aa334dc8557b1796cf395687d63f988fe9ab2 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 21 Apr 2022 13:39:01 +0200 Subject: [PATCH 23/68] Update test values --- src/fci/40.fci.bats | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/fci/40.fci.bats b/src/fci/40.fci.bats index 1a0c5507..b8528e97 100644 --- a/src/fci/40.fci.bats +++ b/src/fci/40.fci.bats @@ -71,7 +71,7 @@ function run_stoch() { @test "HBO" { # 13.3144s [[ -n $TRAVIS ]] && skip qp set_file hbo.ezfio - run -100.214099486337 1.e-3 100000 + run -100.213 1.e-3 100000 } @test "H2O" { # 11.3727s @@ -89,7 +89,7 @@ function run_stoch() { @test "SO" { # 13.4952s [[ -n $TRAVIS ]] && skip qp set_file so.ezfio - run -26.0176563764039 1.e-3 100000 + run -26.014 5.e-3 100000 } @test "H2S" { # 13.6745s @@ -119,7 +119,7 @@ function run_stoch() { @test "SiH3" { # 15.99s [[ -n $TRAVIS ]] && skip qp set_file sih3.ezfio - run -5.57241217753818 5.e-4 100000 + run -5.572 1.e-3 100000 } @test "CH4" { # 16.1612s @@ -153,7 +153,7 @@ function run_stoch() { [[ -n $TRAVIS ]] && skip qp set_file n2.ezfio qp set_mo_class --core="[1,2]" --act="[3-40]" --del="[41-60]" - run -109.287917088107 1.5e-3 100000 + run -109.288 2.e-3 100000 } @test "N2H4" { # 18.5006s From 1d5f8400aa8d7e7bcf89eaca052b63904f78fa54 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 21 Apr 2022 13:42:10 +0200 Subject: [PATCH 24/68] Update test values --- src/fci/40.fci.bats | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/fci/40.fci.bats b/src/fci/40.fci.bats index b8528e97..d890d586 100644 --- a/src/fci/40.fci.bats +++ b/src/fci/40.fci.bats @@ -42,7 +42,7 @@ function run_stoch() { [[ -n $TRAVIS ]] && skip qp set_file f2.ezfio qp set_frozen_core - run_stoch -199.304922384814 3.e-4 100000 + run_stoch -199.304922384814 3.e-3 100000 } @test "NH3" { # 10.6657s @@ -89,7 +89,7 @@ function run_stoch() { @test "SO" { # 13.4952s [[ -n $TRAVIS ]] && skip qp set_file so.ezfio - run -26.014 5.e-3 100000 + run -26.015 3.e-3 100000 } @test "H2S" { # 13.6745s @@ -146,7 +146,7 @@ function run_stoch() { [[ -n $TRAVIS ]] && skip qp set_file c2h2.ezfio qp set_mo_class --act="[1-30]" --del="[31-36]" - run -12.3685464085969 2.e-3 100000 + run -12.367 3.e-3 100000 } @test "N2" { # 18.0198s @@ -182,6 +182,6 @@ function run_stoch() { [[ -n $TRAVIS ]] && skip qp set_file hcn.ezfio qp set_mo_class --core="[1,2]" --act="[3-40]" --del="[41-55]" - run -93.0777619629755 1.e-3 100000 + run -93.078 2.e-3 100000 } From 57b47807fa1b7265345d877ca4902e87f39935ba Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 21 Apr 2022 14:25:29 +0200 Subject: [PATCH 25/68] Added CIS_read --- src/cis_read/EZFIO.cfg | 7 +++ src/cis_read/NEED | 3 ++ src/cis_read/README.rst | 5 +++ src/cis_read/cis_read.irp.f | 88 +++++++++++++++++++++++++++++++++++++ src/cis_read/h_apply.irp.f | 14 ++++++ 5 files changed, 117 insertions(+) create mode 100644 src/cis_read/EZFIO.cfg create mode 100644 src/cis_read/NEED create mode 100644 src/cis_read/README.rst create mode 100644 src/cis_read/cis_read.irp.f create mode 100644 src/cis_read/h_apply.irp.f diff --git a/src/cis_read/EZFIO.cfg b/src/cis_read/EZFIO.cfg new file mode 100644 index 00000000..955d1bef --- /dev/null +++ b/src/cis_read/EZFIO.cfg @@ -0,0 +1,7 @@ +[energy] +type: double precision +doc: Variational |CIS| energy +interface: ezfio +size: (determinants.n_states) + + diff --git a/src/cis_read/NEED b/src/cis_read/NEED new file mode 100644 index 00000000..42992ac6 --- /dev/null +++ b/src/cis_read/NEED @@ -0,0 +1,3 @@ +selectors_full +generators_full +davidson_undressed diff --git a/src/cis_read/README.rst b/src/cis_read/README.rst new file mode 100644 index 00000000..31648636 --- /dev/null +++ b/src/cis_read/README.rst @@ -0,0 +1,5 @@ +=== +cis_read +=== + +Reads the input WF and performs all singles on top of it. diff --git a/src/cis_read/cis_read.irp.f b/src/cis_read/cis_read.irp.f new file mode 100644 index 00000000..055b5e15 --- /dev/null +++ b/src/cis_read/cis_read.irp.f @@ -0,0 +1,88 @@ +program cis + implicit none + BEGIN_DOC +! +! Configuration Interaction with Single excitations. +! +! This program takes a reference Slater determinant of ROHF-like +! occupancy, and performs all single excitations on top of it. +! Disregarding spatial symmetry, it computes the `n_states` lowest +! eigenstates of that CI matrix. (see :option:`determinants n_states`) +! +! This program can be useful in many cases: +! +! +! 1. Ground state calculation +! +! To be sure to have the lowest |SCF| solution, perform an :ref:`scf` +! (see the :ref:`module_hartree_fock` module), then a :ref:`cis`, save the +! natural orbitals (see :ref:`save_natorb`) and re-run an :ref:`scf` +! optimization from this |MO| guess. +! +! +! 2. Excited states calculations +! +! The lowest excited states are much likely to be dominated by +! single-excitations. Therefore, running a :ref:`cis` will save the +! `n_states` lowest states within the |CIS| space in the |EZFIO| +! directory, which can afterwards be used as guess wave functions for +! a further multi-state |FCI| calculation if :option:`determinants +! read_wf` is set to |true| before running the :ref:`fci` executable. +! +! +! If :option:`determinants s2_eig` is set to |true|, the |CIS| +! will only retain states having the expected |S^2| value (see +! :option:`determinants expected_s2`). Otherwise, the |CIS| will take +! the lowest :option:`determinants n_states`, whatever multiplicity +! they are. +! +! .. note:: +! +! To discard some orbitals, use the :ref:`qp_set_mo_class` +! command to specify: +! +! * *core* orbitals which will be always doubly occupied +! +! * *act* orbitals where an electron can be either excited from or to +! +! * *del* orbitals which will be never occupied +! + END_DOC + read_wf = .True. + TOUCH read_wf + call run +end + +subroutine run + implicit none + integer :: i + + + if(pseudo_sym)then + call H_apply_cis_sym + else + call H_apply_cis + endif + print*,'' + print *, 'N_det = ', N_det + print*,'******************************' + print *, 'Energies of the states:' + do i = 1,N_states + print *, i, CI_energy(i) + enddo + if (N_states > 1) then + print*,'' + print*,'******************************************************' + print*,'Excitation energies (au) (eV)' + do i = 2, N_states + print*, i ,CI_energy(i) - CI_energy(1), (CI_energy(i) - CI_energy(1))/0.0367502d0 + enddo + print*,'' + endif + + call ezfio_set_cis_energy(CI_energy) + psi_coef = ci_eigenvectors + SOFT_TOUCH psi_coef + call save_wavefunction_truncated(save_threshold) + +end diff --git a/src/cis_read/h_apply.irp.f b/src/cis_read/h_apply.irp.f new file mode 100644 index 00000000..14389bed --- /dev/null +++ b/src/cis_read/h_apply.irp.f @@ -0,0 +1,14 @@ +! Generates subroutine H_apply_cis +! -------------------------------- + +BEGIN_SHELL [ /usr/bin/env python3 ] +from generate_h_apply import H_apply +H = H_apply("cis",do_double_exc=False) +print(H) + +H = H_apply("cis_sym",do_double_exc=False) +H.filter_only_connected_to_hf() +print(H) + +END_SHELL + From 7cd6b13805b9a9e59bb027181c6176182ad81ccb Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sun, 1 May 2022 14:12:28 +0200 Subject: [PATCH 26/68] C quicksort --- src/utils/map_module.f90 | 6 +- src/utils/qsort.c | 373 ++++++++++++++++++++ src/utils/qsort.org | 169 +++++++++ src/utils/qsort_module.f90 | 347 ++++++++++++++++++ src/utils/sort.irp.f | 695 ------------------------------------- 5 files changed, 892 insertions(+), 698 deletions(-) create mode 100644 src/utils/qsort.c create mode 100644 src/utils/qsort.org create mode 100644 src/utils/qsort_module.f90 diff --git a/src/utils/map_module.f90 b/src/utils/map_module.f90 index 98e73470..ceaec874 100644 --- a/src/utils/map_module.f90 +++ b/src/utils/map_module.f90 @@ -238,11 +238,11 @@ subroutine cache_map_sort(map) iorder(i) = i enddo if (cache_key_kind == 2) then - call i2radix_sort(map%key,iorder,map%n_elements,-1) + call i2sort(map%key,iorder,map%n_elements,-1) else if (cache_key_kind == 4) then - call iradix_sort(map%key,iorder,map%n_elements,-1) + call isort(map%key,iorder,map%n_elements,-1) else if (cache_key_kind == 8) then - call i8radix_sort(map%key,iorder,map%n_elements,-1) + call i8sort(map%key,iorder,map%n_elements,-1) endif if (integral_kind == 4) then call set_order(map%value,iorder,map%n_elements) diff --git a/src/utils/qsort.c b/src/utils/qsort.c new file mode 100644 index 00000000..5d685741 --- /dev/null +++ b/src/utils/qsort.c @@ -0,0 +1,373 @@ +/* [[file:~/qp2/src/utils/qsort.org::*Generated%20C%20file][Generated C file:1]] */ +#include +#include + +struct int16_t_comp { + int16_t x; + int32_t i; +}; + +int compare_int16_t( const void * l, const void * r ) +{ + const struct int16_t_comp * restrict _l= l; + const struct int16_t_comp * restrict _r= r; + if( _l->x > _r->x ) return 1; + if( _l->x < _r->x ) return -1; + return 0; +} + +void qsort_int16_t(int16_t* A_in, int32_t* iorder, int32_t isize) { + struct int16_t_comp* A = malloc(isize * sizeof(struct int16_t_comp)); + if (A == NULL) return; + + for (int i=0 ; ix > _r->x ) return 1; + if( _l->x < _r->x ) return -1; + return 0; +} + +void qsort_int16_t_big(int16_t* A_in, int64_t* iorder, int64_t isize) { + struct int16_t_comp_big* A = malloc(isize * sizeof(struct int16_t_comp_big)); + if (A == NULL) return; + + for (int i=0 ; ix > _r->x ) return 1; + if( _l->x < _r->x ) return -1; + return 0; +} + +void qsort_int32_t(int32_t* A_in, int32_t* iorder, int32_t isize) { + struct int32_t_comp* A = malloc(isize * sizeof(struct int32_t_comp)); + if (A == NULL) return; + + for (int i=0 ; ix > _r->x ) return 1; + if( _l->x < _r->x ) return -1; + return 0; +} + +void qsort_int32_t_big(int32_t* A_in, int64_t* iorder, int64_t isize) { + struct int32_t_comp_big* A = malloc(isize * sizeof(struct int32_t_comp_big)); + if (A == NULL) return; + + for (int i=0 ; ix > _r->x ) return 1; + if( _l->x < _r->x ) return -1; + return 0; +} + +void qsort_int64_t(int64_t* A_in, int32_t* iorder, int32_t isize) { + struct int64_t_comp* A = malloc(isize * sizeof(struct int64_t_comp)); + if (A == NULL) return; + + for (int i=0 ; ix > _r->x ) return 1; + if( _l->x < _r->x ) return -1; + return 0; +} + +void qsort_int64_t_big(int64_t* A_in, int64_t* iorder, int64_t isize) { + struct int64_t_comp_big* A = malloc(isize * sizeof(struct int64_t_comp_big)); + if (A == NULL) return; + + for (int i=0 ; ix > _r->x ) return 1; + if( _l->x < _r->x ) return -1; + return 0; +} + +void qsort_double(double* A_in, int32_t* iorder, int32_t isize) { + struct double_comp* A = malloc(isize * sizeof(struct double_comp)); + if (A == NULL) return; + + for (int i=0 ; ix > _r->x ) return 1; + if( _l->x < _r->x ) return -1; + return 0; +} + +void qsort_double_big(double* A_in, int64_t* iorder, int64_t isize) { + struct double_comp_big* A = malloc(isize * sizeof(struct double_comp_big)); + if (A == NULL) return; + + for (int i=0 ; ix > _r->x ) return 1; + if( _l->x < _r->x ) return -1; + return 0; +} + +void qsort_float(float* A_in, int32_t* iorder, int32_t isize) { + struct float_comp* A = malloc(isize * sizeof(struct float_comp)); + if (A == NULL) return; + + for (int i=0 ; ix > _r->x ) return 1; + if( _l->x < _r->x ) return -1; + return 0; +} + +void qsort_float_big(float* A_in, int64_t* iorder, int64_t isize) { + struct float_comp_big* A = malloc(isize * sizeof(struct float_comp_big)); + if (A == NULL) return; + + for (int i=0 ; ix > _r->x ) return 1; + if( _l->x < _r->x ) return -1; + return 0; +} + +void qsort_TYPE_big(TYPE* A_in, int32_t* iorder, int32_t isize) { + struct TYPE_comp_big* A = malloc(isize * sizeof(struct TYPE_comp_big)); + if (A == NULL) return; + + for (int i=0 ; i> +""" +for typ in ["int16_t", "int32_t", "int64_t", "double", "float"]: + print( data.replace("TYPE", typ).replace("_big", "") ) + print( data.replace("int32_t", "int64_t").replace("TYPE", typ) ) +#+end_src + +#+NAME: replaced_f +#+begin_src python :results output :noweb yes +data = """ +<> +""" +c1 = { + "int16_t": "i2", + "int32_t": "i", + "int64_t": "i8", + "double": "d", + "float": "" +} +c2 = { + "int16_t": "integer", + "int32_t": "integer", + "int64_t": "integer", + "double": "real", + "float": "real" +} + +for typ in ["int16_t", "int32_t", "int64_t", "double", "float"]: + print( data.replace("real",c2[typ]).replace("L",c1[typ]).replace("TYPE", typ).replace("_big", "") ) + print( data.replace("real",c2[typ]).replace("L",c1[typ]).replace("int32_t", "int64_t").replace("TYPE", typ) ) +#+end_src + +#+NAME: replaced_f2 +#+begin_src python :results output :noweb yes +data = """ +<> +""" +c1 = { + "int16_t": "i2", + "int32_t": "i", + "int64_t": "i8", + "double": "d", + "float": "" +} +c2 = { + "int16_t": "integer", + "int32_t": "integer", + "int64_t": "integer", + "double": "real", + "float": "real" +} + +for typ in ["int16_t", "int32_t", "int64_t", "double", "float"]: + print( data.replace("real",c2[typ]).replace("L",c1[typ]).replace("TYPE", typ).replace("_big", "") ) + print( data.replace("real",c2[typ]).replace("L",c1[typ]).replace("int32_t", "int64_t").replace("TYPE", typ) ) +#+end_src + +* Generated C file + +#+BEGIN_SRC c :comments link :tangle qsort.c :noweb yes +#include +#include +<> +#+END_SRC + +* Generated Fortran file + +#+BEGIN_SRC f90 :tangle qsort_module.f90 :noweb yes +module qsort_module + use iso_c_binding + + interface + <> + end interface + +end module qsort_module + +<> + +#+END_SRC + diff --git a/src/utils/qsort_module.f90 b/src/utils/qsort_module.f90 new file mode 100644 index 00000000..a72a4f9e --- /dev/null +++ b/src/utils/qsort_module.f90 @@ -0,0 +1,347 @@ +module qsort_module + use iso_c_binding + + interface + + subroutine i2sort_c(A, iorder, isize) bind(C, name="qsort_int16_t") + use iso_c_binding + integer(c_int32_t), value :: isize + integer(c_int32_t) :: iorder(isize) + integer (c_int16_t) :: A(isize) + end subroutine i2sort_c + + subroutine i2sort_noidx_c(A, isize) bind(C, name="qsort_int16_t_noidx") + use iso_c_binding + integer(c_int32_t), value :: isize + integer (c_int16_t) :: A(isize) + end subroutine i2sort_noidx_c + + + + subroutine i2sort_big_c(A, iorder, isize) bind(C, name="qsort_int16_t_big") + use iso_c_binding + integer(c_int64_t), value :: isize + integer(c_int64_t) :: iorder(isize) + integer (c_int16_t) :: A(isize) + end subroutine i2sort_big_c + + subroutine i2sort_noidx_big_c(A, isize) bind(C, name="qsort_int16_t_noidx_big") + use iso_c_binding + integer(c_int64_t), value :: isize + integer (c_int16_t) :: A(isize) + end subroutine i2sort_noidx_big_c + + + + subroutine isort_c(A, iorder, isize) bind(C, name="qsort_int32_t") + use iso_c_binding + integer(c_int32_t), value :: isize + integer(c_int32_t) :: iorder(isize) + integer (c_int32_t) :: A(isize) + end subroutine isort_c + + subroutine isort_noidx_c(A, isize) bind(C, name="qsort_int32_t_noidx") + use iso_c_binding + integer(c_int32_t), value :: isize + integer (c_int32_t) :: A(isize) + end subroutine isort_noidx_c + + + + subroutine isort_big_c(A, iorder, isize) bind(C, name="qsort_int32_t_big") + use iso_c_binding + integer(c_int64_t), value :: isize + integer(c_int64_t) :: iorder(isize) + integer (c_int32_t) :: A(isize) + end subroutine isort_big_c + + subroutine isort_noidx_big_c(A, isize) bind(C, name="qsort_int32_t_noidx_big") + use iso_c_binding + integer(c_int64_t), value :: isize + integer (c_int32_t) :: A(isize) + end subroutine isort_noidx_big_c + + + + subroutine i8sort_c(A, iorder, isize) bind(C, name="qsort_int64_t") + use iso_c_binding + integer(c_int32_t), value :: isize + integer(c_int32_t) :: iorder(isize) + integer (c_int64_t) :: A(isize) + end subroutine i8sort_c + + subroutine i8sort_noidx_c(A, isize) bind(C, name="qsort_int64_t_noidx") + use iso_c_binding + integer(c_int32_t), value :: isize + integer (c_int64_t) :: A(isize) + end subroutine i8sort_noidx_c + + + + subroutine i8sort_big_c(A, iorder, isize) bind(C, name="qsort_int64_t_big") + use iso_c_binding + integer(c_int64_t), value :: isize + integer(c_int64_t) :: iorder(isize) + integer (c_int64_t) :: A(isize) + end subroutine i8sort_big_c + + subroutine i8sort_noidx_big_c(A, isize) bind(C, name="qsort_int64_t_noidx_big") + use iso_c_binding + integer(c_int64_t), value :: isize + integer (c_int64_t) :: A(isize) + end subroutine i8sort_noidx_big_c + + + + subroutine dsort_c(A, iorder, isize) bind(C, name="qsort_double") + use iso_c_binding + integer(c_int32_t), value :: isize + integer(c_int32_t) :: iorder(isize) + real (c_double) :: A(isize) + end subroutine dsort_c + + subroutine dsort_noidx_c(A, isize) bind(C, name="qsort_double_noidx") + use iso_c_binding + integer(c_int32_t), value :: isize + real (c_double) :: A(isize) + end subroutine dsort_noidx_c + + + + subroutine dsort_big_c(A, iorder, isize) bind(C, name="qsort_double_big") + use iso_c_binding + integer(c_int64_t), value :: isize + integer(c_int64_t) :: iorder(isize) + real (c_double) :: A(isize) + end subroutine dsort_big_c + + subroutine dsort_noidx_big_c(A, isize) bind(C, name="qsort_double_noidx_big") + use iso_c_binding + integer(c_int64_t), value :: isize + real (c_double) :: A(isize) + end subroutine dsort_noidx_big_c + + + + subroutine sort_c(A, iorder, isize) bind(C, name="qsort_float") + use iso_c_binding + integer(c_int32_t), value :: isize + integer(c_int32_t) :: iorder(isize) + real (c_float) :: A(isize) + end subroutine sort_c + + subroutine sort_noidx_c(A, isize) bind(C, name="qsort_float_noidx") + use iso_c_binding + integer(c_int32_t), value :: isize + real (c_float) :: A(isize) + end subroutine sort_noidx_c + + + + subroutine sort_big_c(A, iorder, isize) bind(C, name="qsort_float_big") + use iso_c_binding + integer(c_int64_t), value :: isize + integer(c_int64_t) :: iorder(isize) + real (c_float) :: A(isize) + end subroutine sort_big_c + + subroutine sort_noidx_big_c(A, isize) bind(C, name="qsort_float_noidx_big") + use iso_c_binding + integer(c_int64_t), value :: isize + real (c_float) :: A(isize) + end subroutine sort_noidx_big_c + + + + end interface + +end module qsort_module + + +subroutine i2sort(A, iorder, isize) + use qsort_module + use iso_c_binding + integer(c_int32_t) :: isize + integer(c_int32_t) :: iorder(isize) + integer (c_int16_t) :: A(isize) + call i2sort_c(A, iorder, isize) +end subroutine i2sort + +subroutine i2sort_noidx(A, isize) + use iso_c_binding + use qsort_module + integer(c_int32_t) :: isize + integer (c_int16_t) :: A(isize) + call i2sort_noidx_c(A, isize) +end subroutine i2sort_noidx + + + +subroutine i2sort_big(A, iorder, isize) + use qsort_module + use iso_c_binding + integer(c_int64_t) :: isize + integer(c_int64_t) :: iorder(isize) + integer (c_int16_t) :: A(isize) + call i2sort_big_c(A, iorder, isize) +end subroutine i2sort_big + +subroutine i2sort_noidx_big(A, isize) + use iso_c_binding + use qsort_module + integer(c_int64_t) :: isize + integer (c_int16_t) :: A(isize) + call i2sort_noidx_big_c(A, isize) +end subroutine i2sort_noidx_big + + + +subroutine isort(A, iorder, isize) + use qsort_module + use iso_c_binding + integer(c_int32_t) :: isize + integer(c_int32_t) :: iorder(isize) + integer (c_int32_t) :: A(isize) + call isort_c(A, iorder, isize) +end subroutine isort + +subroutine isort_noidx(A, isize) + use iso_c_binding + use qsort_module + integer(c_int32_t) :: isize + integer (c_int32_t) :: A(isize) + call isort_noidx_c(A, isize) +end subroutine isort_noidx + + + +subroutine isort_big(A, iorder, isize) + use qsort_module + use iso_c_binding + integer(c_int64_t) :: isize + integer(c_int64_t) :: iorder(isize) + integer (c_int32_t) :: A(isize) + call isort_big_c(A, iorder, isize) +end subroutine isort_big + +subroutine isort_noidx_big(A, isize) + use iso_c_binding + use qsort_module + integer(c_int64_t) :: isize + integer (c_int32_t) :: A(isize) + call isort_noidx_big_c(A, isize) +end subroutine isort_noidx_big + + + +subroutine i8sort(A, iorder, isize) + use qsort_module + use iso_c_binding + integer(c_int32_t) :: isize + integer(c_int32_t) :: iorder(isize) + integer (c_int64_t) :: A(isize) + call i8sort_c(A, iorder, isize) +end subroutine i8sort + +subroutine i8sort_noidx(A, isize) + use iso_c_binding + use qsort_module + integer(c_int32_t) :: isize + integer (c_int64_t) :: A(isize) + call i8sort_noidx_c(A, isize) +end subroutine i8sort_noidx + + + +subroutine i8sort_big(A, iorder, isize) + use qsort_module + use iso_c_binding + integer(c_int64_t) :: isize + integer(c_int64_t) :: iorder(isize) + integer (c_int64_t) :: A(isize) + call i8sort_big_c(A, iorder, isize) +end subroutine i8sort_big + +subroutine i8sort_noidx_big(A, isize) + use iso_c_binding + use qsort_module + integer(c_int64_t) :: isize + integer (c_int64_t) :: A(isize) + call i8sort_noidx_big_c(A, isize) +end subroutine i8sort_noidx_big + + + +subroutine dsort(A, iorder, isize) + use qsort_module + use iso_c_binding + integer(c_int32_t) :: isize + integer(c_int32_t) :: iorder(isize) + real (c_double) :: A(isize) + call dsort_c(A, iorder, isize) +end subroutine dsort + +subroutine dsort_noidx(A, isize) + use iso_c_binding + use qsort_module + integer(c_int32_t) :: isize + real (c_double) :: A(isize) + call dsort_noidx_c(A, isize) +end subroutine dsort_noidx + + + +subroutine dsort_big(A, iorder, isize) + use qsort_module + use iso_c_binding + integer(c_int64_t) :: isize + integer(c_int64_t) :: iorder(isize) + real (c_double) :: A(isize) + call dsort_big_c(A, iorder, isize) +end subroutine dsort_big + +subroutine dsort_noidx_big(A, isize) + use iso_c_binding + use qsort_module + integer(c_int64_t) :: isize + real (c_double) :: A(isize) + call dsort_noidx_big_c(A, isize) +end subroutine dsort_noidx_big + + + +subroutine sort(A, iorder, isize) + use qsort_module + use iso_c_binding + integer(c_int32_t) :: isize + integer(c_int32_t) :: iorder(isize) + real (c_float) :: A(isize) + call sort_c(A, iorder, isize) +end subroutine sort + +subroutine sort_noidx(A, isize) + use iso_c_binding + use qsort_module + integer(c_int32_t) :: isize + real (c_float) :: A(isize) + call sort_noidx_c(A, isize) +end subroutine sort_noidx + + + +subroutine sort_big(A, iorder, isize) + use qsort_module + use iso_c_binding + integer(c_int64_t) :: isize + integer(c_int64_t) :: iorder(isize) + real (c_float) :: A(isize) + call sort_big_c(A, iorder, isize) +end subroutine sort_big + +subroutine sort_noidx_big(A, isize) + use iso_c_binding + use qsort_module + integer(c_int64_t) :: isize + real (c_float) :: A(isize) + call sort_noidx_big_c(A, isize) +end subroutine sort_noidx_big diff --git a/src/utils/sort.irp.f b/src/utils/sort.irp.f index ff40263c..089c3871 100644 --- a/src/utils/sort.irp.f +++ b/src/utils/sort.irp.f @@ -1,222 +1,4 @@ BEGIN_TEMPLATE - subroutine insertion_$Xsort (x,iorder,isize) - implicit none - BEGIN_DOC - ! Sort array x(isize) using the insertion sort algorithm. - ! iorder in input should be (1,2,3,...,isize), and in output - ! contains the new order of the elements. - END_DOC - integer,intent(in) :: isize - $type,intent(inout) :: x(isize) - integer,intent(inout) :: iorder(isize) - $type :: xtmp - integer :: i, i0, j, jmax - - do i=2,isize - xtmp = x(i) - i0 = iorder(i) - j=i-1 - do while (j>0) - if ((x(j) <= xtmp)) exit - x(j+1) = x(j) - iorder(j+1) = iorder(j) - j=j-1 - enddo - x(j+1) = xtmp - iorder(j+1) = i0 - enddo - end subroutine insertion_$Xsort - - subroutine quick_$Xsort(x, iorder, isize) - implicit none - BEGIN_DOC - ! Sort array x(isize) using the quicksort algorithm. - ! iorder in input should be (1,2,3,...,isize), and in output - ! contains the new order of the elements. - END_DOC - integer,intent(in) :: isize - $type,intent(inout) :: x(isize) - integer,intent(inout) :: iorder(isize) - integer, external :: omp_get_num_threads - call rec_$X_quicksort(x,iorder,isize,1,isize,nproc) - end - - recursive subroutine rec_$X_quicksort(x, iorder, isize, first, last, level) - implicit none - integer, intent(in) :: isize, first, last, level - integer,intent(inout) :: iorder(isize) - $type, intent(inout) :: x(isize) - $type :: c, tmp - integer :: itmp - integer :: i, j - - if(isize<2)return - - c = x( shiftr(first+last,1) ) - i = first - j = last - do - do while (x(i) < c) - i=i+1 - end do - do while (c < x(j)) - j=j-1 - end do - if (i >= j) exit - tmp = x(i) - x(i) = x(j) - x(j) = tmp - itmp = iorder(i) - iorder(i) = iorder(j) - iorder(j) = itmp - i=i+1 - j=j-1 - enddo - if ( ((i-first <= 10000).and.(last-j <= 10000)).or.(level<=0) ) then - if (first < i-1) then - call rec_$X_quicksort(x, iorder, isize, first, i-1,level/2) - endif - if (j+1 < last) then - call rec_$X_quicksort(x, iorder, isize, j+1, last,level/2) - endif - else - if (first < i-1) then - call rec_$X_quicksort(x, iorder, isize, first, i-1,level/2) - endif - if (j+1 < last) then - call rec_$X_quicksort(x, iorder, isize, j+1, last,level/2) - endif - endif - end - - subroutine heap_$Xsort(x,iorder,isize) - implicit none - BEGIN_DOC - ! Sort array x(isize) using the heap sort algorithm. - ! iorder in input should be (1,2,3,...,isize), and in output - ! contains the new order of the elements. - END_DOC - integer,intent(in) :: isize - $type,intent(inout) :: x(isize) - integer,intent(inout) :: iorder(isize) - - integer :: i, k, j, l, i0 - $type :: xtemp - - l = isize/2+1 - k = isize - do while (.True.) - if (l>1) then - l=l-1 - xtemp = x(l) - i0 = iorder(l) - else - xtemp = x(k) - i0 = iorder(k) - x(k) = x(1) - iorder(k) = iorder(1) - k = k-1 - if (k == 1) then - x(1) = xtemp - iorder(1) = i0 - exit - endif - endif - i=l - j = shiftl(l,1) - do while (j1) then - l=l-1 - xtemp = x(l) - i0 = iorder(l) - else - xtemp = x(k) - i0 = iorder(k) - x(k) = x(1) - iorder(k) = iorder(1) - k = k-1 - if (k == 1) then - x(1) = xtemp - iorder(1) = i0 - exit - endif - endif - i=l - j = shiftl(l,1) - do while (j0_8) - if (x(j)<=xtmp) exit - x(j+1_8) = x(j) - iorder(j+1_8) = iorder(j) - j = j-1_8 - enddo - x(j+1_8) = xtmp - iorder(j+1_8) = i0 - enddo - - end subroutine insertion_$Xsort_big - subroutine $Xset_order_big(x,iorder,isize) implicit none BEGIN_DOC @@ -565,223 +90,3 @@ SUBST [ X, type ] END_TEMPLATE -BEGIN_TEMPLATE - -recursive subroutine $Xradix_sort$big(x,iorder,isize,iradix) - implicit none - - BEGIN_DOC - ! Sort integer array x(isize) using the radix sort algorithm. - ! iorder in input should be (1,2,3,...,isize), and in output - ! contains the new order of the elements. - ! iradix should be -1 in input. - END_DOC - integer*$int_type, intent(in) :: isize - integer*$int_type, intent(inout) :: iorder(isize) - integer*$type, intent(inout) :: x(isize) - integer, intent(in) :: iradix - integer :: iradix_new - integer*$type, allocatable :: x2(:), x1(:) - integer*$type :: i4 ! data type - integer*$int_type, allocatable :: iorder1(:),iorder2(:) - integer*$int_type :: i0, i1, i2, i3, i ! index type - integer*$type :: mask - integer :: err - !DIR$ ATTRIBUTES ALIGN : 128 :: iorder1,iorder2, x2, x1 - - if (isize < 2) then - return - endif - - if (iradix == -1) then ! Sort Positive and negative - - allocate(x1(isize),iorder1(isize), x2(isize),iorder2(isize),stat=err) - if (err /= 0) then - print *, irp_here, ': Unable to allocate arrays' - stop - endif - - i1=1_$int_type - i2=1_$int_type - do i=1_$int_type,isize - if (x(i) < 0_$type) then - iorder1(i1) = iorder(i) - x1(i1) = -x(i) - i1 = i1+1_$int_type - else - iorder2(i2) = iorder(i) - x2(i2) = x(i) - i2 = i2+1_$int_type - endif - enddo - i1=i1-1_$int_type - i2=i2-1_$int_type - - do i=1_$int_type,i2 - iorder(i1+i) = iorder2(i) - x(i1+i) = x2(i) - enddo - deallocate(x2,iorder2,stat=err) - if (err /= 0) then - print *, irp_here, ': Unable to deallocate arrays x2, iorder2' - stop - endif - - - if (i1 > 1_$int_type) then - call $Xradix_sort$big(x1,iorder1,i1,-2) - do i=1_$int_type,i1 - x(i) = -x1(1_$int_type+i1-i) - iorder(i) = iorder1(1_$int_type+i1-i) - enddo - endif - - if (i2>1_$int_type) then - call $Xradix_sort$big(x(i1+1_$int_type),iorder(i1+1_$int_type),i2,-2) - endif - - deallocate(x1,iorder1,stat=err) - if (err /= 0) then - print *, irp_here, ': Unable to deallocate arrays x1, iorder1' - stop - endif - return - - else if (iradix == -2) then ! Positive - - ! Find most significant bit - - i0 = 0_$int_type - i4 = maxval(x) - - iradix_new = max($integer_size-1-leadz(i4),1) - mask = ibset(0_$type,iradix_new) - - allocate(x1(isize),iorder1(isize), x2(isize),iorder2(isize),stat=err) - if (err /= 0) then - print *, irp_here, ': Unable to allocate arrays' - stop - endif - - i1=1_$int_type - i2=1_$int_type - - do i=1_$int_type,isize - if (iand(mask,x(i)) == 0_$type) then - iorder1(i1) = iorder(i) - x1(i1) = x(i) - i1 = i1+1_$int_type - else - iorder2(i2) = iorder(i) - x2(i2) = x(i) - i2 = i2+1_$int_type - endif - enddo - i1=i1-1_$int_type - i2=i2-1_$int_type - - do i=1_$int_type,i1 - iorder(i0+i) = iorder1(i) - x(i0+i) = x1(i) - enddo - i0 = i0+i1 - i3 = i0 - deallocate(x1,iorder1,stat=err) - if (err /= 0) then - print *, irp_here, ': Unable to deallocate arrays x1, iorder1' - stop - endif - - - do i=1_$int_type,i2 - iorder(i0+i) = iorder2(i) - x(i0+i) = x2(i) - enddo - i0 = i0+i2 - deallocate(x2,iorder2,stat=err) - if (err /= 0) then - print *, irp_here, ': Unable to deallocate arrays x2, iorder2' - stop - endif - - - if (i3>1_$int_type) then - call $Xradix_sort$big(x,iorder,i3,iradix_new-1) - endif - - if (isize-i3>1_$int_type) then - call $Xradix_sort$big(x(i3+1_$int_type),iorder(i3+1_$int_type),isize-i3,iradix_new-1) - endif - - return - endif - - ASSERT (iradix >= 0) - - if (isize < 48) then - call insertion_$Xsort$big(x,iorder,isize) - return - endif - - - allocate(x2(isize),iorder2(isize),stat=err) - if (err /= 0) then - print *, irp_here, ': Unable to allocate arrays x1, iorder1' - stop - endif - - - mask = ibset(0_$type,iradix) - i0=1_$int_type - i1=1_$int_type - - do i=1_$int_type,isize - if (iand(mask,x(i)) == 0_$type) then - iorder(i0) = iorder(i) - x(i0) = x(i) - i0 = i0+1_$int_type - else - iorder2(i1) = iorder(i) - x2(i1) = x(i) - i1 = i1+1_$int_type - endif - enddo - i0=i0-1_$int_type - i1=i1-1_$int_type - - do i=1_$int_type,i1 - iorder(i0+i) = iorder2(i) - x(i0+i) = x2(i) - enddo - - deallocate(x2,iorder2,stat=err) - if (err /= 0) then - print *, irp_here, ': Unable to allocate arrays x2, iorder2' - stop - endif - - - if (iradix == 0) then - return - endif - - - if (i1>1_$int_type) then - call $Xradix_sort$big(x(i0+1_$int_type),iorder(i0+1_$int_type),i1,iradix-1) - endif - if (i0>1) then - call $Xradix_sort$big(x,iorder,i0,iradix-1) - endif - - end - -SUBST [ X, type, integer_size, is_big, big, int_type ] - i ; 4 ; 32 ; .False. ; ; 4 ;; - i8 ; 8 ; 64 ; .False. ; ; 4 ;; - i2 ; 2 ; 16 ; .False. ; ; 4 ;; - i ; 4 ; 32 ; .True. ; _big ; 8 ;; - i8 ; 8 ; 64 ; .True. ; _big ; 8 ;; -END_TEMPLATE - - - From f168b885db26c1121486c5f4d219968f4474e0c1 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sun, 1 May 2022 14:32:30 +0200 Subject: [PATCH 27/68] Removed IPP dependency with intel using C quicksort --- config/ifort_2019_avx.cfg | 2 +- config/ifort_2019_avx_mpi.cfg | 2 +- config/ifort_2019_mpi_rome.cfg | 2 +- config/ifort_2019_rome.cfg | 2 +- config/ifort_2019_sse4.cfg | 2 +- config/ifort_2019_sse4_mpi.cfg | 2 +- config/ifort_2019_xHost.cfg | 2 +- config/ifort_2021_avx.cfg | 2 +- config/ifort_2021_avx_mpi.cfg | 2 +- config/ifort_2021_mpi_rome.cfg | 2 +- config/ifort_2021_rome.cfg | 2 +- config/ifort_2021_sse4.cfg | 2 +- config/ifort_2021_sse4_mpi.cfg | 2 +- config/ifort_2021_xHost.cfg | 2 +- src/fci/40.fci.bats | 2 +- src/utils/qsort.c | 100 ++++++++++++++++----------------- src/utils/qsort.org | 10 ++-- 17 files changed, 70 insertions(+), 70 deletions(-) diff --git a/config/ifort_2019_avx.cfg b/config/ifort_2019_avx.cfg index 661a0e8f..c5bed0d8 100644 --- a/config/ifort_2019_avx.cfg +++ b/config/ifort_2019_avx.cfg @@ -7,7 +7,7 @@ # [COMMON] FC : ifort -fpic -LAPACK_LIB : -mkl=parallel -lirc -lsvml -limf -lipps +LAPACK_LIB : -mkl=parallel IRPF90 : irpf90 IRPF90_FLAGS : --ninja --align=32 -DINTEL -DSET_NESTED diff --git a/config/ifort_2019_avx_mpi.cfg b/config/ifort_2019_avx_mpi.cfg index 2d212db5..5b4d2922 100644 --- a/config/ifort_2019_avx_mpi.cfg +++ b/config/ifort_2019_avx_mpi.cfg @@ -7,7 +7,7 @@ # [COMMON] FC : mpiifort -fpic -LAPACK_LIB : -mkl=parallel -lirc -lsvml -limf -lipps +LAPACK_LIB : -mkl=parallel IRPF90 : irpf90 IRPF90_FLAGS : --ninja --align=32 -DMPI -DINTEL -DSET_NESTED diff --git a/config/ifort_2019_mpi_rome.cfg b/config/ifort_2019_mpi_rome.cfg index 171219e6..054d4d7d 100644 --- a/config/ifort_2019_mpi_rome.cfg +++ b/config/ifort_2019_mpi_rome.cfg @@ -7,7 +7,7 @@ # [COMMON] FC : mpiifort -fpic -LAPACK_LIB : -mkl=parallel -lirc -lsvml -limf -lipps +LAPACK_LIB : -mkl=parallel IRPF90 : irpf90 IRPF90_FLAGS : --ninja --align=32 -DINTEL -DSET_NESTED diff --git a/config/ifort_2019_rome.cfg b/config/ifort_2019_rome.cfg index e923a1dd..a18a0acb 100644 --- a/config/ifort_2019_rome.cfg +++ b/config/ifort_2019_rome.cfg @@ -7,7 +7,7 @@ # [COMMON] FC : ifort -fpic -LAPACK_LIB : -mkl=parallel -lirc -lsvml -limf -lipps +LAPACK_LIB : -mkl=parallel IRPF90 : irpf90 IRPF90_FLAGS : --ninja --align=32 -DINTEL -DSET_NESTED diff --git a/config/ifort_2019_sse4.cfg b/config/ifort_2019_sse4.cfg index a3aa7cbd..2cdbc2c5 100644 --- a/config/ifort_2019_sse4.cfg +++ b/config/ifort_2019_sse4.cfg @@ -7,7 +7,7 @@ # [COMMON] FC : ifort -fpic -LAPACK_LIB : -mkl=parallel -lirc -lsvml -limf -lipps +LAPACK_LIB : -mkl=parallel IRPF90 : irpf90 IRPF90_FLAGS : --ninja --align=32 -DINTEL -DSET_NESTED diff --git a/config/ifort_2019_sse4_mpi.cfg b/config/ifort_2019_sse4_mpi.cfg index 6959d176..d20cd2a2 100644 --- a/config/ifort_2019_sse4_mpi.cfg +++ b/config/ifort_2019_sse4_mpi.cfg @@ -7,7 +7,7 @@ # [COMMON] FC : mpiifort -fpic -LAPACK_LIB : -mkl=parallel -lirc -lsvml -limf -lipps +LAPACK_LIB : -mkl=parallel IRPF90 : irpf90 IRPF90_FLAGS : --ninja --align=32 -DMPI -DINTEL -DSET_NESTED diff --git a/config/ifort_2019_xHost.cfg b/config/ifort_2019_xHost.cfg index 22d28803..59c6146b 100644 --- a/config/ifort_2019_xHost.cfg +++ b/config/ifort_2019_xHost.cfg @@ -7,7 +7,7 @@ # [COMMON] FC : ifort -fpic -LAPACK_LIB : -mkl=parallel -lirc -lsvml -limf -lipps +LAPACK_LIB : -mkl=parallel IRPF90 : irpf90 IRPF90_FLAGS : --ninja --align=64 -DINTEL -DSET_NESTED diff --git a/config/ifort_2021_avx.cfg b/config/ifort_2021_avx.cfg index 6f657052..6c34cf47 100644 --- a/config/ifort_2021_avx.cfg +++ b/config/ifort_2021_avx.cfg @@ -7,7 +7,7 @@ # [COMMON] FC : ifort -fpic -LAPACK_LIB : -mkl=parallel -lirc -lsvml -limf -lipps +LAPACK_LIB : -mkl=parallel IRPF90 : irpf90 IRPF90_FLAGS : --ninja --align=32 -DINTEL diff --git a/config/ifort_2021_avx_mpi.cfg b/config/ifort_2021_avx_mpi.cfg index c991a4a9..4c893c73 100644 --- a/config/ifort_2021_avx_mpi.cfg +++ b/config/ifort_2021_avx_mpi.cfg @@ -7,7 +7,7 @@ # [COMMON] FC : mpiifort -fpic -LAPACK_LIB : -mkl=parallel -lirc -lsvml -limf -lipps +LAPACK_LIB : -mkl=parallel IRPF90 : irpf90 IRPF90_FLAGS : --ninja --align=32 -DMPI -DINTEL diff --git a/config/ifort_2021_mpi_rome.cfg b/config/ifort_2021_mpi_rome.cfg index 8413d23d..e47a466e 100644 --- a/config/ifort_2021_mpi_rome.cfg +++ b/config/ifort_2021_mpi_rome.cfg @@ -7,7 +7,7 @@ # [COMMON] FC : mpiifort -fpic -LAPACK_LIB : -mkl=parallel -lirc -lsvml -limf -lipps +LAPACK_LIB : -mkl=parallel IRPF90 : irpf90 IRPF90_FLAGS : --ninja --align=32 -DINTEL diff --git a/config/ifort_2021_rome.cfg b/config/ifort_2021_rome.cfg index b3023186..504438c9 100644 --- a/config/ifort_2021_rome.cfg +++ b/config/ifort_2021_rome.cfg @@ -7,7 +7,7 @@ # [COMMON] FC : ifort -fpic -LAPACK_LIB : -mkl=parallel -lirc -lsvml -limf -lipps +LAPACK_LIB : -mkl=parallel IRPF90 : irpf90 IRPF90_FLAGS : --ninja --align=32 -DINTEL diff --git a/config/ifort_2021_sse4.cfg b/config/ifort_2021_sse4.cfg index a6299665..07c3ebb8 100644 --- a/config/ifort_2021_sse4.cfg +++ b/config/ifort_2021_sse4.cfg @@ -7,7 +7,7 @@ # [COMMON] FC : ifort -fpic -LAPACK_LIB : -mkl=parallel -lirc -lsvml -limf -lipps +LAPACK_LIB : -mkl=parallel IRPF90 : irpf90 IRPF90_FLAGS : --ninja --align=32 -DINTEL diff --git a/config/ifort_2021_sse4_mpi.cfg b/config/ifort_2021_sse4_mpi.cfg index 6ae56d2a..f3fa0eaa 100644 --- a/config/ifort_2021_sse4_mpi.cfg +++ b/config/ifort_2021_sse4_mpi.cfg @@ -7,7 +7,7 @@ # [COMMON] FC : mpiifort -fpic -LAPACK_LIB : -mkl=parallel -lirc -lsvml -limf -lipps +LAPACK_LIB : -mkl=parallel IRPF90 : irpf90 IRPF90_FLAGS : --ninja --align=32 -DMPI -DINTEL diff --git a/config/ifort_2021_xHost.cfg b/config/ifort_2021_xHost.cfg index 1e76a69d..1161833b 100644 --- a/config/ifort_2021_xHost.cfg +++ b/config/ifort_2021_xHost.cfg @@ -7,7 +7,7 @@ # [COMMON] FC : ifort -fpic -LAPACK_LIB : -mkl=parallel -lirc -lsvml -limf -lipps +LAPACK_LIB : -mkl=parallel IRPF90 : irpf90 IRPF90_FLAGS : --ninja --align=64 -DINTEL diff --git a/src/fci/40.fci.bats b/src/fci/40.fci.bats index 1a0c5507..23818f44 100644 --- a/src/fci/40.fci.bats +++ b/src/fci/40.fci.bats @@ -65,7 +65,7 @@ function run_stoch() { @test "H2O2" { # 12.9214s qp set_file h2o2.ezfio qp set_mo_class --core="[1-2]" --act="[3-24]" --del="[25-38]" - run -151.005848404095 1.e-3 100000 + run -151.005848404095 2.e-3 100000 } @test "HBO" { # 13.3144s diff --git a/src/utils/qsort.c b/src/utils/qsort.c index 5d685741..c011b35a 100644 --- a/src/utils/qsort.c +++ b/src/utils/qsort.c @@ -9,14 +9,14 @@ struct int16_t_comp { int compare_int16_t( const void * l, const void * r ) { - const struct int16_t_comp * restrict _l= l; - const struct int16_t_comp * restrict _r= r; - if( _l->x > _r->x ) return 1; - if( _l->x < _r->x ) return -1; + const int16_t * restrict _l= l; + const int16_t * restrict _r= r; + if( *_l > *_r ) return 1; + if( *_l < *_r ) return -1; return 0; } -void qsort_int16_t(int16_t* A_in, int32_t* iorder, int32_t isize) { +void qsort_int16_t(int16_t* restrict A_in, int32_t* restrict iorder, int32_t isize) { struct int16_t_comp* A = malloc(isize * sizeof(struct int16_t_comp)); if (A == NULL) return; @@ -46,14 +46,14 @@ struct int16_t_comp_big { int compare_int16_t_big( const void * l, const void * r ) { - const struct int16_t_comp_big * restrict _l= l; - const struct int16_t_comp_big * restrict _r= r; - if( _l->x > _r->x ) return 1; - if( _l->x < _r->x ) return -1; + const int16_t * restrict _l= l; + const int16_t * restrict _r= r; + if( *_l > *_r ) return 1; + if( *_l < *_r ) return -1; return 0; } -void qsort_int16_t_big(int16_t* A_in, int64_t* iorder, int64_t isize) { +void qsort_int16_t_big(int16_t* restrict A_in, int64_t* restrict iorder, int64_t isize) { struct int16_t_comp_big* A = malloc(isize * sizeof(struct int16_t_comp_big)); if (A == NULL) return; @@ -83,14 +83,14 @@ struct int32_t_comp { int compare_int32_t( const void * l, const void * r ) { - const struct int32_t_comp * restrict _l= l; - const struct int32_t_comp * restrict _r= r; - if( _l->x > _r->x ) return 1; - if( _l->x < _r->x ) return -1; + const int32_t * restrict _l= l; + const int32_t * restrict _r= r; + if( *_l > *_r ) return 1; + if( *_l < *_r ) return -1; return 0; } -void qsort_int32_t(int32_t* A_in, int32_t* iorder, int32_t isize) { +void qsort_int32_t(int32_t* restrict A_in, int32_t* restrict iorder, int32_t isize) { struct int32_t_comp* A = malloc(isize * sizeof(struct int32_t_comp)); if (A == NULL) return; @@ -120,14 +120,14 @@ struct int32_t_comp_big { int compare_int32_t_big( const void * l, const void * r ) { - const struct int32_t_comp_big * restrict _l= l; - const struct int32_t_comp_big * restrict _r= r; - if( _l->x > _r->x ) return 1; - if( _l->x < _r->x ) return -1; + const int32_t * restrict _l= l; + const int32_t * restrict _r= r; + if( *_l > *_r ) return 1; + if( *_l < *_r ) return -1; return 0; } -void qsort_int32_t_big(int32_t* A_in, int64_t* iorder, int64_t isize) { +void qsort_int32_t_big(int32_t* restrict A_in, int64_t* restrict iorder, int64_t isize) { struct int32_t_comp_big* A = malloc(isize * sizeof(struct int32_t_comp_big)); if (A == NULL) return; @@ -157,14 +157,14 @@ struct int64_t_comp { int compare_int64_t( const void * l, const void * r ) { - const struct int64_t_comp * restrict _l= l; - const struct int64_t_comp * restrict _r= r; - if( _l->x > _r->x ) return 1; - if( _l->x < _r->x ) return -1; + const int64_t * restrict _l= l; + const int64_t * restrict _r= r; + if( *_l > *_r ) return 1; + if( *_l < *_r ) return -1; return 0; } -void qsort_int64_t(int64_t* A_in, int32_t* iorder, int32_t isize) { +void qsort_int64_t(int64_t* restrict A_in, int32_t* restrict iorder, int32_t isize) { struct int64_t_comp* A = malloc(isize * sizeof(struct int64_t_comp)); if (A == NULL) return; @@ -194,14 +194,14 @@ struct int64_t_comp_big { int compare_int64_t_big( const void * l, const void * r ) { - const struct int64_t_comp_big * restrict _l= l; - const struct int64_t_comp_big * restrict _r= r; - if( _l->x > _r->x ) return 1; - if( _l->x < _r->x ) return -1; + const int64_t * restrict _l= l; + const int64_t * restrict _r= r; + if( *_l > *_r ) return 1; + if( *_l < *_r ) return -1; return 0; } -void qsort_int64_t_big(int64_t* A_in, int64_t* iorder, int64_t isize) { +void qsort_int64_t_big(int64_t* restrict A_in, int64_t* restrict iorder, int64_t isize) { struct int64_t_comp_big* A = malloc(isize * sizeof(struct int64_t_comp_big)); if (A == NULL) return; @@ -231,14 +231,14 @@ struct double_comp { int compare_double( const void * l, const void * r ) { - const struct double_comp * restrict _l= l; - const struct double_comp * restrict _r= r; - if( _l->x > _r->x ) return 1; - if( _l->x < _r->x ) return -1; + const double * restrict _l= l; + const double * restrict _r= r; + if( *_l > *_r ) return 1; + if( *_l < *_r ) return -1; return 0; } -void qsort_double(double* A_in, int32_t* iorder, int32_t isize) { +void qsort_double(double* restrict A_in, int32_t* restrict iorder, int32_t isize) { struct double_comp* A = malloc(isize * sizeof(struct double_comp)); if (A == NULL) return; @@ -268,14 +268,14 @@ struct double_comp_big { int compare_double_big( const void * l, const void * r ) { - const struct double_comp_big * restrict _l= l; - const struct double_comp_big * restrict _r= r; - if( _l->x > _r->x ) return 1; - if( _l->x < _r->x ) return -1; + const double * restrict _l= l; + const double * restrict _r= r; + if( *_l > *_r ) return 1; + if( *_l < *_r ) return -1; return 0; } -void qsort_double_big(double* A_in, int64_t* iorder, int64_t isize) { +void qsort_double_big(double* restrict A_in, int64_t* restrict iorder, int64_t isize) { struct double_comp_big* A = malloc(isize * sizeof(struct double_comp_big)); if (A == NULL) return; @@ -305,14 +305,14 @@ struct float_comp { int compare_float( const void * l, const void * r ) { - const struct float_comp * restrict _l= l; - const struct float_comp * restrict _r= r; - if( _l->x > _r->x ) return 1; - if( _l->x < _r->x ) return -1; + const float * restrict _l= l; + const float * restrict _r= r; + if( *_l > *_r ) return 1; + if( *_l < *_r ) return -1; return 0; } -void qsort_float(float* A_in, int32_t* iorder, int32_t isize) { +void qsort_float(float* restrict A_in, int32_t* restrict iorder, int32_t isize) { struct float_comp* A = malloc(isize * sizeof(struct float_comp)); if (A == NULL) return; @@ -342,14 +342,14 @@ struct float_comp_big { int compare_float_big( const void * l, const void * r ) { - const struct float_comp_big * restrict _l= l; - const struct float_comp_big * restrict _r= r; - if( _l->x > _r->x ) return 1; - if( _l->x < _r->x ) return -1; + const float * restrict _l= l; + const float * restrict _r= r; + if( *_l > *_r ) return 1; + if( *_l < *_r ) return -1; return 0; } -void qsort_float_big(float* A_in, int64_t* iorder, int64_t isize) { +void qsort_float_big(float* restrict A_in, int64_t* restrict iorder, int64_t isize) { struct float_comp_big* A = malloc(isize * sizeof(struct float_comp_big)); if (A == NULL) return; diff --git a/src/utils/qsort.org b/src/utils/qsort.org index 0c344207..abf0d54a 100644 --- a/src/utils/qsort.org +++ b/src/utils/qsort.org @@ -11,14 +11,14 @@ struct TYPE_comp_big { int compare_TYPE_big( const void * l, const void * r ) { - const struct TYPE_comp_big * restrict _l= l; - const struct TYPE_comp_big * restrict _r= r; - if( _l->x > _r->x ) return 1; - if( _l->x < _r->x ) return -1; + const TYPE * restrict _l= l; + const TYPE * restrict _r= r; + if( *_l > *_r ) return 1; + if( *_l < *_r ) return -1; return 0; } -void qsort_TYPE_big(TYPE* A_in, int32_t* iorder, int32_t isize) { +void qsort_TYPE_big(TYPE* restrict A_in, int32_t* restrict iorder, int32_t isize) { struct TYPE_comp_big* A = malloc(isize * sizeof(struct TYPE_comp_big)); if (A == NULL) return; From be6c230f52641631f26ad15f6793efb8feaaab89 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sun, 1 May 2022 15:01:37 +0200 Subject: [PATCH 28/68] Accelerated PT2 by removing sort --- src/cipsi/selection.irp.f | 2 -- src/fci/40.fci.bats | 2 +- src/mo_two_e_erf_ints/map_integrals_erf.irp.f | 12 ++++++------ 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/cipsi/selection.irp.f b/src/cipsi/selection.irp.f index 7417dd05..ec60c606 100644 --- a/src/cipsi/selection.irp.f +++ b/src/cipsi/selection.irp.f @@ -258,8 +258,6 @@ subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_d deallocate(exc_degree) nmax=k-1 - call isort_noidx(indices,nmax) - ! Start with 32 elements. Size will double along with the filtering. allocate(preinteresting(0:32), prefullinteresting(0:32), & interesting(0:32), fullinteresting(0:32)) diff --git a/src/fci/40.fci.bats b/src/fci/40.fci.bats index 23818f44..89c65c94 100644 --- a/src/fci/40.fci.bats +++ b/src/fci/40.fci.bats @@ -77,7 +77,7 @@ function run_stoch() { @test "H2O" { # 11.3727s [[ -n $TRAVIS ]] && skip qp set_file h2o.ezfio - run -76.2361605151999 5.e-4 100000 + run -76.2361605151999 2.e-3 100000 } @test "ClO" { # 13.3755s diff --git a/src/mo_two_e_erf_ints/map_integrals_erf.irp.f b/src/mo_two_e_erf_ints/map_integrals_erf.irp.f index 73050ec5..3405ec2b 100644 --- a/src/mo_two_e_erf_ints/map_integrals_erf.irp.f +++ b/src/mo_two_e_erf_ints/map_integrals_erf.irp.f @@ -235,11 +235,11 @@ subroutine get_mo_two_e_integrals_erf_ij(k,l,sze,out_array,map) logical :: integral_is_in_map if (key_kind == 8) then - call i8radix_sort(hash,iorder,kk,-1) + call i8sort(hash,iorder,kk) else if (key_kind == 4) then - call iradix_sort(hash,iorder,kk,-1) + call isort(hash,iorder,kk) else if (key_kind == 2) then - call i2radix_sort(hash,iorder,kk,-1) + call i2sort(hash,iorder,kk) endif call map_get_many(mo_integrals_erf_map, hash, tmp_val, kk) @@ -290,11 +290,11 @@ subroutine get_mo_two_e_integrals_erf_i1j1(k,l,sze,out_array,map) logical :: integral_is_in_map if (key_kind == 8) then - call i8radix_sort(hash,iorder,kk,-1) + call i8sort(hash,iorder,kk) else if (key_kind == 4) then - call iradix_sort(hash,iorder,kk,-1) + call isort(hash,iorder,kk) else if (key_kind == 2) then - call i2radix_sort(hash,iorder,kk,-1) + call i2sort(hash,iorder,kk) endif call map_get_many(mo_integrals_erf_map, hash, tmp_val, kk) From abac06299cd965d304b1aad4b4fc4b8de4f7d136 Mon Sep 17 00:00:00 2001 From: ydamour Date: Thu, 5 May 2022 16:22:44 +0200 Subject: [PATCH 29/68] update i_H_j --- src/determinants/slater_rules.irp.f | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/determinants/slater_rules.irp.f b/src/determinants/slater_rules.irp.f index 3a33a37d..897607a9 100644 --- a/src/determinants/slater_rules.irp.f +++ b/src/determinants/slater_rules.irp.f @@ -623,7 +623,8 @@ subroutine i_H_j(key_i,key_j,Nint,hij) integer :: occ(Nint*bit_kind_size,2) double precision :: diag_H_mat_elem, phase integer :: n_occ_ab(2) - PROVIDE mo_two_e_integrals_in_map mo_integrals_map big_array_exchange_integrals + PROVIDE mo_two_e_integrals_in_map mo_integrals_map big_array_exchange_integrals + PROVIDE ao_one_e_integrals mo_one_e_integrals ASSERT (Nint > 0) ASSERT (Nint == N_int) @@ -681,7 +682,6 @@ subroutine i_H_j(key_i,key_j,Nint,hij) case (1) call get_single_excitation(key_i,key_j,exc,phase,Nint) !DIR$ FORCEINLINE - call bitstring_to_list_ab(key_i, occ, n_occ_ab, Nint) if (exc(0,1,1) == 1) then ! Single alpha m = exc(1,1,1) @@ -700,10 +700,6 @@ subroutine i_H_j(key_i,key_j,Nint,hij) end select end - - - - subroutine i_H_j_verbose(key_i,key_j,Nint,hij,hmono,hdouble,phase) use bitmasks implicit none @@ -1038,7 +1034,6 @@ subroutine i_H_psi(key,keys,coef,Nint,Ndet,Ndet_max,Nstate,i_H_psi_array) end - subroutine i_H_psi_minilist(key,keys,idx_key,N_minilist,coef,Nint,Ndet,Ndet_max,Nstate,i_H_psi_array) use bitmasks implicit none From 57527c94a27491107e49d9623c0124c516976d34 Mon Sep 17 00:00:00 2001 From: ydamour Date: Thu, 5 May 2022 17:26:41 +0200 Subject: [PATCH 30/68] update binom_func to avoid .999... --- src/utils/util.irp.f | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/utils/util.irp.f b/src/utils/util.irp.f index ef846bdb..127d5433 100644 --- a/src/utils/util.irp.f +++ b/src/utils/util.irp.f @@ -37,6 +37,10 @@ double precision function binom_func(i,j) else binom_func = dexp( logfact(i)-logfact(j)-logfact(i-j) ) endif + + ! To avoid .999999 numbers + binom_func = binom_func + 0.5d0 + end From e15dceaa10c0abbfdda434b89429c6be87214815 Mon Sep 17 00:00:00 2001 From: ydamour Date: Wed, 11 May 2022 12:59:58 +0200 Subject: [PATCH 31/68] new format for pt2 --- src/cipsi/pt2_stoch_routines.irp.f | 88 ++++++++++++++++++++++++++---- src/utils/format_w_error.irp.f | 71 ++++++++++++++++++++++++ 2 files changed, 147 insertions(+), 12 deletions(-) create mode 100644 src/utils/format_w_error.irp.f diff --git a/src/cipsi/pt2_stoch_routines.irp.f b/src/cipsi/pt2_stoch_routines.irp.f index c7cee1ac..1328e7a0 100644 --- a/src/cipsi/pt2_stoch_routines.irp.f +++ b/src/cipsi/pt2_stoch_routines.irp.f @@ -290,9 +290,13 @@ subroutine ZMQ_pt2(E, pt2_data, pt2_data_err, relative_error, N_in) call set_multiple_levels_omp(.False.) - print '(A)', '========== ======================= ===================== ===================== ===========' - print '(A)', ' Samples Energy Variance Norm^2 Seconds' - print '(A)', '========== ======================= ===================== ===================== ===========' + ! old + !print '(A)', '========== ======================= ===================== ===================== ===========' + !print '(A)', ' Samples Energy Variance Norm^2 Seconds' + !print '(A)', '========== ======================= ===================== ===================== ===========' + print '(A)', '========== ==================== ================ ================ ================ ============= ===========' + print '(A)', ' Samples Energy PT2 Variance Norm^2 Convergence Seconds' + print '(A)', '========== ==================== ================ ================ ================ ============= ===========' PROVIDE global_selection_buffer @@ -316,7 +320,10 @@ subroutine ZMQ_pt2(E, pt2_data, pt2_data_err, relative_error, N_in) call end_parallel_job(zmq_to_qp_run_socket, zmq_socket_pull, 'pt2') call set_multiple_levels_omp(.True.) - print '(A)', '========== ======================= ===================== ===================== ===========' + ! old + !print '(A)', '========== ======================= ===================== ===================== ===========' + print '(A)', '========== ==================== ================ ================ ================ ============= ===========' + do k=1,N_states pt2_overlap(pt2_stoch_istate,k) = pt2_data % overlap(k,pt2_stoch_istate) @@ -414,6 +421,17 @@ subroutine pt2_collector(zmq_socket_pull, E, relative_error, pt2_data, pt2_data_ double precision :: rss double precision, external :: memory_of_double, memory_of_int + character(len=20) :: format_str1, str_error1, format_str2, str_error2 + character(len=20) :: format_str3, str_error3, format_str4, str_error4 + character(len=20) :: format_value1, format_value2, format_value3, format_value4 + character(len=20) :: str_value1, str_value2, str_value3, str_value4 + character(len=20) :: str_conv + double precision :: value1, value2, value3, value4 + double precision :: error1, error2, error3, error4 + integer :: size1,size2,size3,size4 + + double precision :: conv_crit + sending =.False. rss = memory_of_int(pt2_n_tasks_max*2+N_det_generators*2) @@ -537,14 +555,60 @@ subroutine pt2_collector(zmq_socket_pull, E, relative_error, pt2_data, pt2_data_ if ((time - time1 > 1.d0) .or. (n==N_det_generators)) then time1 = time - print '(I10, X, F12.6, X, G10.3, X, F10.6, X, G10.3, X, F10.6, X, G10.3, X, F10.1)', c, & - pt2_data % pt2(pt2_stoch_istate) +E, & - pt2_data_err % pt2(pt2_stoch_istate), & - pt2_data % variance(pt2_stoch_istate), & - pt2_data_err % variance(pt2_stoch_istate), & - pt2_data % overlap(pt2_stoch_istate,pt2_stoch_istate), & - pt2_data_err % overlap(pt2_stoch_istate,pt2_stoch_istate), & - time-time0 + + value1 = pt2_data % pt2(pt2_stoch_istate) + E + error1 = pt2_data_err % pt2(pt2_stoch_istate) + value2 = pt2_data % pt2(pt2_stoch_istate) + error2 = pt2_data_err % pt2(pt2_stoch_istate) + value3 = pt2_data % variance(pt2_stoch_istate) + error3 = pt2_data_err % variance(pt2_stoch_istate) + value4 = pt2_data % overlap(pt2_stoch_istate,pt2_stoch_istate) + error4 = pt2_data_err % overlap(pt2_stoch_istate,pt2_stoch_istate) + + ! Max size of the values (FX.Y) with X=size + size1 = 15 + size2 = 12 + size3 = 12 + size4 = 12 + + ! To generate the format: number(error) + call format_w_error(value1,error1,size1,8,format_value1,str_error1) + call format_w_error(value2,error2,size2,8,format_value2,str_error2) + call format_w_error(value3,error3,size3,8,format_value3,str_error3) + call format_w_error(value4,error4,size4,8,format_value4,str_error4) + + ! value > string with the right format + write(str_value1,'('//format_value1//')') value1 + write(str_value2,'('//format_value2//')') value2 + write(str_value3,'('//format_value3//')') value3 + write(str_value4,'('//format_value4//')') value4 + + ! Convergence criterion + conv_crit = dabs(pt2_data_err % pt2(pt2_stoch_istate)) / & + (1.d-20 + dabs(pt2_data % pt2(pt2_stoch_istate)) ) + write(str_conv,'(G10.3)') conv_crit + + write(*,'(I10,X,X,A20,X,A16,X,A16,X,A16,X,A12,X,F10.1)') c,& + adjustl(adjustr(str_value1)//'('//str_error1(1:1)//')'),& + adjustl(adjustr(str_value2)//'('//str_error2(1:1)//')'),& + adjustl(adjustr(str_value3)//'('//str_error3(1:1)//')'),& + adjustl(adjustr(str_value4)//'('//str_error4(1:1)//')'),& + adjustl(str_conv),& + time-time0 + + ! Old print + !print '(I10, X, F12.6, X, G10.3, X, F10.6, X, G10.3, X, F10.6, X, G10.3, X, F10.1,1pE16.6,1pE16.6)', c, & + ! pt2_data % pt2(pt2_stoch_istate) +E, & + ! pt2_data_err % pt2(pt2_stoch_istate), & + ! pt2_data % variance(pt2_stoch_istate), & + ! pt2_data_err % variance(pt2_stoch_istate), & + ! pt2_data % overlap(pt2_stoch_istate,pt2_stoch_istate), & + ! pt2_data_err % overlap(pt2_stoch_istate,pt2_stoch_istate), & + ! time-time0, & + ! pt2_data % pt2(pt2_stoch_istate), & + ! dabs(pt2_data_err % pt2(pt2_stoch_istate)) / & + ! (1.d-20 + dabs(pt2_data % pt2(pt2_stoch_istate)) ) + if (stop_now .or. ( & (do_exit .and. (dabs(pt2_data_err % pt2(pt2_stoch_istate)) / & (1.d-20 + dabs(pt2_data % pt2(pt2_stoch_istate)) ) <= relative_error))) ) then diff --git a/src/utils/format_w_error.irp.f b/src/utils/format_w_error.irp.f new file mode 100644 index 00000000..1378d367 --- /dev/null +++ b/src/utils/format_w_error.irp.f @@ -0,0 +1,71 @@ +subroutine format_w_error(value,error,size_nb,max_nb_digits,format_value,str_error) + + implicit none + + BEGIN_DOC + ! Format for double precision, value(error) + END_DOC + + ! in + ! | value | double precision | value... | + ! | error | double precision | error... | + ! | size_nb | integer | X in FX.Y | + ! | max_nb_digits | integer | Max Y in FX.Y | + + ! out + ! | format_value | character | string FX.Y for the format | + ! | str_error | character | string of the error | + + ! internal + ! | str_size | character | size in string format | + ! | nb_digits | integer | number of digits Y in FX.Y depending of the error | + ! | str_nb_digits | character | nb_digits in string format | + ! | str_exp | character | string of the value in exponential format | + + ! in + double precision, intent(in) :: error, value + integer, intent(in) :: size_nb, max_nb_digits + + ! out + character(len=20), intent(out) :: str_error, format_value + + ! internal + character(len=20) :: str_size, str_nb_digits, str_exp + integer :: nb_digits + + ! max_nb_digit: Y max + ! size_nb = Size of the double: X (FX.Y) + write(str_size,'(I3)') size_nb + + ! Error + write(str_exp,'(1pE20.0)') error + str_error = trim(adjustl(str_exp)) + + ! Number of digit: Y (FX.Y) from the exponent + str_nb_digits = str_exp(19:20) + read(str_nb_digits,*) nb_digits + + ! If the error is 0d0 + if (error <= 1d-16) then + write(str_nb_digits,*) max_nb_digits + endif + + ! If the error is too small + if (nb_digits > max_nb_digits) then + write(str_nb_digits,*) max_nb_digits + str_error(1:1) = '0' + endif + + ! If the error is too big (>= 0.5) + if (error >= 0.5d0) then + str_nb_digits = '1' + str_error(1:1) = '*' + endif + + ! FX.Y,A1,A1,A1 for value(str_error) + !string = 'F'//trim(adjustl(str_size))//'.'//trim(adjustl(str_nb_digits))//',A1,A1,A1' + + ! FX.Y just for the value + format_value = 'F'//trim(adjustl(str_size))//'.'//trim(adjustl(str_nb_digits)) + +end From 7df328724152480842fde2a183b08cb0a81c116b Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 12 May 2022 10:12:36 +0200 Subject: [PATCH 32/68] Fix bug introduced by 57527c94a27491107e --- src/utils/util.irp.f | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/util.irp.f b/src/utils/util.irp.f index 127d5433..84593031 100644 --- a/src/utils/util.irp.f +++ b/src/utils/util.irp.f @@ -39,7 +39,7 @@ double precision function binom_func(i,j) endif ! To avoid .999999 numbers - binom_func = binom_func + 0.5d0 + binom_func = floor(binom_func + 0.5d0) end From 185f3a500ca8d3bdb49d59902266caa2910190af Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 12 May 2022 11:48:40 +0200 Subject: [PATCH 33/68] Fixed tests for Drone CI --- src/fci/40.fci.bats | 105 ++++++++++++----------- src/fci/EZFIO.cfg | 6 ++ src/iterations/print_extrapolation.irp.f | 1 + 3 files changed, 60 insertions(+), 52 deletions(-) diff --git a/src/fci/40.fci.bats b/src/fci/40.fci.bats index 89c65c94..9b99d865 100644 --- a/src/fci/40.fci.bats +++ b/src/fci/40.fci.bats @@ -8,12 +8,12 @@ function run() { test_exe fci || skip qp edit --check qp set perturbation do_pt2 False - qp set determinants n_det_max 8000 + qp set determinants n_det_max $3 qp set determinants n_states 1 qp set davidson threshold_davidson 1.e-10 qp set davidson n_states_diag 8 qp run fci - energy1="$(ezfio get fci energy | tr '[]' ' ' | cut -d ',' -f 1)" + energy1="$(qp get fci energy | tr '[]' ' ' | cut -d ',' -f 1)" eq $energy1 $1 $thresh } @@ -22,166 +22,167 @@ function run_stoch() { thresh=$2 test_exe fci || skip qp set perturbation do_pt2 True + qp set perturbation pt2_relative_error 0.005 qp set determinants n_det_max $3 qp set determinants n_states 1 qp set davidson threshold_davidson 1.e-10 qp set davidson n_states_diag 1 qp run fci - energy1="$(ezfio get fci energy_pt2 | tr '[]' ' ' | cut -d ',' -f 1)" + energy1="$(qp get fci energy_extrapolated | tr '[]' ' ' | cut -d ',' -f 1)" eq $energy1 $1 $thresh } -@test "B-B" { + +@test "B-B" { # 0:00:10 qp set_file b2_stretched.ezfio qp set determinants n_det_max 10000 qp set_frozen_core - run_stoch -49.14103054419 3.e-4 10000 + run_stoch -49.14104086 0.0001 10000 } -@test "F2" { # 4.07m +@test "F2" { # 0:03:34 [[ -n $TRAVIS ]] && skip qp set_file f2.ezfio qp set_frozen_core - run_stoch -199.304922384814 3.e-4 100000 + run_stoch -199.30821487 0.002 100000 } -@test "NH3" { # 10.6657s +@test "NH3" { # 0:00:11 qp set_file nh3.ezfio qp set_mo_class --core="[1-4]" --act="[5-72]" - run -56.244753429144986 3.e-4 100000 + run -56.24474790 1.e-5 10000 } -@test "DHNO" { # 11.4721s +@test "DHNO" { # 0:00:10 qp set_file dhno.ezfio qp set_mo_class --core="[1-7]" --act="[8-64]" - run -130.459020029816 3.e-4 100000 + run -130.45901042 1.e-4 10000 } -@test "HCO" { # 12.2868s +@test "HCO" { # 0:01:16 qp set_file hco.ezfio - run -113.393356604085 1.e-3 100000 + run_stoch -113.41658256 1.e-3 50000 } -@test "H2O2" { # 12.9214s +@test "H2O2" { # 0:01:48 qp set_file h2o2.ezfio qp set_mo_class --core="[1-2]" --act="[3-24]" --del="[25-38]" - run -151.005848404095 2.e-3 100000 + run_stoch -151.02317880 2.e-3 100000 } -@test "HBO" { # 13.3144s +@test "HBO" { # 0:00:46 [[ -n $TRAVIS ]] && skip qp set_file hbo.ezfio - run -100.214099486337 1.e-3 100000 + run_stoch -100.22361288 1.e-4 50000 } -@test "H2O" { # 11.3727s +@test "H2O" { # 0:01:05 [[ -n $TRAVIS ]] && skip qp set_file h2o.ezfio - run -76.2361605151999 2.e-3 100000 + run_stoch -76.24347962 1.e-4 100000 } -@test "ClO" { # 13.3755s +@test "ClO" { # 0:03:07 [[ -n $TRAVIS ]] && skip qp set_file clo.ezfio - run -534.546453546852 1.e-3 100000 + run_stoch -534.58202840 1.e-3 100000 } -@test "SO" { # 13.4952s +@test "SO" { # 0:01:49 [[ -n $TRAVIS ]] && skip qp set_file so.ezfio - run -26.0176563764039 1.e-3 100000 + run_stoch -26.04335528 5.e-3 100000 } -@test "H2S" { # 13.6745s +@test "H2S" { # 0:01:12 [[ -n $TRAVIS ]] && skip qp set_file h2s.ezfio - run -398.859577605891 5.e-4 100000 + run_stoch -398.87187312 1.e-3 50000 } -@test "OH" { # 13.865s +@test "OH" { # 0:00:41 [[ -n $TRAVIS ]] && skip qp set_file oh.ezfio - run -75.6121856748294 3.e-4 100000 + run_stoch -75.62393829 1.e-3 50000 } -@test "SiH2_3B1" { # 13.938ss +@test "SiH2_3B1" { # 0:00:50 [[ -n $TRAVIS ]] && skip qp set_file sih2_3b1.ezfio - run -290.0175411299477 3.e-4 100000 + run_stoch -290.02083172 3.e-5 50000 } -@test "H3COH" { # 14.7299s +@test "H3COH" { # 0:01:05 [[ -n $TRAVIS ]] && skip qp set_file h3coh.ezfio - run -115.205632960026 1.e-3 100000 + run_stoch -115.22625460 2.e-3 50000 } -@test "SiH3" { # 15.99s +@test "SiH3" { # 0:01:09 [[ -n $TRAVIS ]] && skip qp set_file sih3.ezfio - run -5.57241217753818 5.e-4 100000 + run_stoch -5.57818759 1.e-3 50000 } -@test "CH4" { # 16.1612s +@test "CH4" { # 0:02:06 [[ -n $TRAVIS ]] && skip qp set_file ch4.ezfio qp set_mo_class --core="[1]" --act="[2-30]" --del="[31-59]" - run -40.2409678239136 3.e-4 100000 + run_stoch -40.24195947 1.e-4 100000 } -@test "ClF" { # 16.8864s +@test "ClF" { # 0:01:55 [[ -n $TRAVIS ]] && skip qp set_file clf.ezfio - run -559.169748890031 1.5e-3 100000 + run_stoch -559.20157348 1.e-3 50000 } -@test "SO2" { # 17.5645s +@test "SO2" { # 0:00:24 [[ -n $TRAVIS ]] && skip qp set_file so2.ezfio qp set_mo_class --core="[1-8]" --act="[9-87]" - run -41.5746738713298 1.5e-3 100000 + run_stoch -41.57468087 1.e-4 50000 } -@test "C2H2" { # 17.6827s +@test "C2H2" { # 0:00:57 [[ -n $TRAVIS ]] && skip qp set_file c2h2.ezfio qp set_mo_class --act="[1-30]" --del="[31-36]" - run -12.3685464085969 2.e-3 100000 + run_stoch -12.38655876 1.e-3 50000 } -@test "N2" { # 18.0198s +@test "N2" { # 0:01:15 [[ -n $TRAVIS ]] && skip qp set_file n2.ezfio qp set_mo_class --core="[1,2]" --act="[3-40]" --del="[41-60]" - run -109.287917088107 1.5e-3 100000 + run_stoch -109.31133266 2.e-3 50000 } -@test "N2H4" { # 18.5006s +@test "N2H4" { # 0:00:51 [[ -n $TRAVIS ]] && skip qp set_file n2h4.ezfio qp set_mo_class --core="[1-2]" --act="[3-24]" --del="[25-48]" - run -111.367332681559 3.e-4 100000 + run_stoch -111.38161063 1.e-3 50000 } -@test "CO2" { # 21.1748s +@test "CO2" { # 0:01:00 [[ -n $TRAVIS ]] && skip qp set_file co2.ezfio qp set_mo_class --core="[1,2]" --act="[3-30]" --del="[31-42]" - run -187.970184372047 1.5e-3 100000 + run_stoch -188.00154729 2.e-3 50000 } - -@test "[Cu(NH3)4]2+" { # 25.0417s +@test "[Cu(NH3)4]2+" { # 0:01:53 [[ -n $TRAVIS ]] && skip qp set_file cu_nh3_4_2plus.ezfio qp set_mo_class --core="[1-24]" --act="[25-45]" --del="[46-87]" - run -1862.9869374387192 3.e-04 100000 + run_stoch -1862.98705091 1.e-05 50000 } -@test "HCN" { # 20.3273s +@test "HCN" { # 0:01:26 [[ -n $TRAVIS ]] && skip qp set_file hcn.ezfio qp set_mo_class --core="[1,2]" --act="[3-40]" --del="[41-55]" - run -93.0777619629755 1.e-3 100000 + run_stoch -93.09855896 5.e-4 50000 } diff --git a/src/fci/EZFIO.cfg b/src/fci/EZFIO.cfg index d897428a..6b46a85f 100644 --- a/src/fci/EZFIO.cfg +++ b/src/fci/EZFIO.cfg @@ -10,3 +10,9 @@ doc: Calculated |FCI| energy + |PT2| interface: ezfio size: (determinants.n_states) +[energy_extrapolated] +type: double precision +doc: Calculated |FCI| energy + |PT2| +interface: ezfio +size: (determinants.n_states) + diff --git a/src/iterations/print_extrapolation.irp.f b/src/iterations/print_extrapolation.irp.f index cb46fb67..e07cc1ed 100644 --- a/src/iterations/print_extrapolation.irp.f +++ b/src/iterations/print_extrapolation.irp.f @@ -41,6 +41,7 @@ subroutine print_extrapolated_energy enddo print *, '' + call ezfio_set_fci_energy_extrapolated(extrapolated_energy(2,1:N_states)) end subroutine From 687fa9472a707157ae4f4d58d9cc65c2ab803bba Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 12 May 2022 12:03:22 +0200 Subject: [PATCH 34/68] Update drone config --- .drone.yml | 74 ++++++++++++++--------------- bin/qp_convert_output_to_ezfio | 2 +- src/determinants/determinants.irp.f | 3 +- 3 files changed, 39 insertions(+), 40 deletions(-) diff --git a/.drone.yml b/.drone.yml index 256b8e9b..52b48829 100644 --- a/.drone.yml +++ b/.drone.yml @@ -7,46 +7,46 @@ clone: depth: 10 steps: + - name: configure debug + image: scemama666/qp2_env + commands: + - ./configure -i all -c ./config/gfortran_debug.cfg + - bash -c "source quantum_package.rc ; exec qp_plugins download https://gitlab.com/scemama/qp_plugins_scemama" + - bash -c "source quantum_package.rc ; exec qp_plugins install champ" -- name: configure - image: scemama666/qp2_env - commands: - - ./configure -i all -c ./config/gfortran_debug.cfg - - bash -c "source quantum_package.rc ; exec qp_plugins download https://gitlab.com/scemama/qp_plugins_scemama" - - bash -c "source quantum_package.rc ; exec qp_plugins install champ" + - name: compile debug + image: scemama666/qp2_env + commands: + - bash -c "source quantum_package.rc ; exec ninja" -- name: compile - image: scemama666/qp2_env - commands: - - bash -c "source quantum_package.rc ; exec ninja" + - name: testing debug + image: scemama666/qp2_env + commands: + - bash -c "source quantum_package.rc ; TRAVIS=1 exec qp_test -a" -- name: testing - image: scemama666/qp2_env - commands: - - bash -c "source quantum_package.rc ; TRAVIS=1 exec qp_test -a" + - name: configure fast + image: scemama666/qp2_env + commands: + - ./configure -i all -c ./config/gfortran_avx.cfg ---- -kind: pipeline -type: docker -name: gfortran-avx + - name: compile fast + image: scemama666/qp2_env + commands: + - bash -c "source quantum_package.rc ; exec ninja" -clone: - depth: 10 - -steps: - -- name: configure - image: scemama666/qp2_env - commands: - - ./configure -i all -c ./config/gfortran_avx.cfg - -- name: compile - image: scemama666/qp2_env - commands: - - bash -c "source quantum_package.rc ; exec ninja" - -- name: testing - image: scemama666/qp2_env - commands: - - bash -c "source quantum_package.rc ; exec qp_test -a" + - name: testing fast + image: scemama666/qp2_env + commands: + - bash -c "source quantum_package.rc ; exec qp_test -a" + - name: notify + image: drillster/drone-email + settings: + host: + from_secret: hostname # irsamc.ups-tlse.fr + from: + from_secret: from # drone@irssv7.ups-tlse.fr + recipients: + from_secret: recipients # scemama@irsamc.ups-tlse.fr + when: + status: [changed, failure] diff --git a/bin/qp_convert_output_to_ezfio b/bin/qp_convert_output_to_ezfio index 091423e4..07ad2236 100755 --- a/bin/qp_convert_output_to_ezfio +++ b/bin/qp_convert_output_to_ezfio @@ -224,7 +224,7 @@ def write_ezfio(res, filename): exponent += [p.expo for p in b.prim] ang_mom.append(str.count(s, "z")) shell_prim_num.append(len(b.prim)) - shell_index += [nshell_tot+1] * len(b.prim) + shell_index += [nshell_tot] * len(b.prim) # ~#~#~#~#~ # # W r i t e # diff --git a/src/determinants/determinants.irp.f b/src/determinants/determinants.irp.f index eeadf779..12ad912f 100644 --- a/src/determinants/determinants.irp.f +++ b/src/determinants/determinants.irp.f @@ -542,12 +542,11 @@ subroutine save_wavefunction_general(ndet,nstates,psidet,dim_psicoef,psicoef) integer :: i,j,k, ndet_qp_edit if (mpi_master) then - ndet_qp_edit = min(ndet,N_det_qp_edit) call ezfio_set_determinants_N_int(N_int) call ezfio_set_determinants_bit_kind(bit_kind) call ezfio_set_determinants_N_det(ndet) - call ezfio_set_determinants_N_det_qp_edit(ndet_qp_edit) + call ezfio_set_determinants_N_det_qp_edit(min(ndet,10000)) call ezfio_set_determinants_n_states(nstates) call ezfio_set_determinants_mo_label(mo_label) From 8a7854de574ebb0679f849ba14f5b3d42651b2f4 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 12 May 2022 12:08:18 +0200 Subject: [PATCH 35/68] Update drone.yml --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 52b48829..d3d3ef92 100644 --- a/.drone.yml +++ b/.drone.yml @@ -27,7 +27,7 @@ steps: - name: configure fast image: scemama666/qp2_env commands: - - ./configure -i all -c ./config/gfortran_avx.cfg + - ./configure -c ./config/gfortran_avx.cfg - name: compile fast image: scemama666/qp2_env From 6224e449ca2f1850152e2fdc46f838806e1b5907 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 12 May 2022 14:28:25 +0200 Subject: [PATCH 36/68] Replaces psi_det_size by N_det --- src/csf/configurations.irp.f | 2 +- src/davidson/davidson_parallel.irp.f | 2 +- src/davidson/davidson_parallel_csf.irp.f | 2 +- src/davidson/davidson_parallel_nos2.irp.f | 2 +- src/davidson/u0_hs2_u0.irp.f | 2 +- src/davidson/u0_wee_u0.irp.f | 2 +- src/determinants/determinants.irp.f | 69 +++++------------------ src/determinants/h_apply.irp.f | 7 +-- src/determinants/psi_cas.irp.f | 20 +++---- src/determinants/s2.irp.f | 2 +- src/determinants/spindeterminants.irp.f | 6 +- src/determinants/zmq.irp.f | 23 ++------ src/generators_cas/generators.irp.f | 10 ++-- src/generators_full/generators.irp.f | 10 ++-- src/perturbation/selection.irp.f | 4 +- src/psiref_cas/psi_ref.irp.f | 12 ++-- src/psiref_utils/psi_ref_utils.irp.f | 26 ++++----- src/selectors_utils/selectors.irp.f | 2 +- src/single_ref_method/generators.irp.f | 4 +- 19 files changed, 77 insertions(+), 130 deletions(-) diff --git a/src/csf/configurations.irp.f b/src/csf/configurations.irp.f index ce5d48ab..3ecaa517 100644 --- a/src/csf/configurations.irp.f +++ b/src/csf/configurations.irp.f @@ -332,7 +332,7 @@ subroutine configuration_to_dets_tree_addressing(o,d,sze,n_alpha,Nint) end - BEGIN_PROVIDER [ integer(bit_kind), psi_configuration, (N_int,2,psi_det_size) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_configuration, (N_int,2,N_det) ] &BEGIN_PROVIDER [ integer, N_configuration ] implicit none BEGIN_DOC diff --git a/src/davidson/davidson_parallel.irp.f b/src/davidson/davidson_parallel.irp.f index e627dfc9..b642d7a4 100644 --- a/src/davidson/davidson_parallel.irp.f +++ b/src/davidson/davidson_parallel.irp.f @@ -99,7 +99,7 @@ subroutine davidson_slave_work(zmq_to_qp_run_socket, zmq_socket_push, N_st, sze, integer :: rc, ni, nj integer*8 :: rc8 - integer :: N_states_read, N_det_read, psi_det_size_read + integer :: N_states_read, N_det_read integer :: N_det_selectors_read, N_det_generators_read integer, external :: zmq_get_dvector diff --git a/src/davidson/davidson_parallel_csf.irp.f b/src/davidson/davidson_parallel_csf.irp.f index d8e9bffa..8a8fcc4a 100644 --- a/src/davidson/davidson_parallel_csf.irp.f +++ b/src/davidson/davidson_parallel_csf.irp.f @@ -99,7 +99,7 @@ subroutine davidson_csf_slave_work(zmq_to_qp_run_socket, zmq_socket_push, N_st, integer :: rc, ni, nj integer*8 :: rc8 - integer :: N_states_read, N_det_read, psi_det_size_read + integer :: N_states_read, N_det_read integer :: N_det_selectors_read, N_det_generators_read integer, external :: zmq_get_dvector diff --git a/src/davidson/davidson_parallel_nos2.irp.f b/src/davidson/davidson_parallel_nos2.irp.f index 597b001f..dcc9687d 100644 --- a/src/davidson/davidson_parallel_nos2.irp.f +++ b/src/davidson/davidson_parallel_nos2.irp.f @@ -99,7 +99,7 @@ subroutine davidson_nos2_slave_work(zmq_to_qp_run_socket, zmq_socket_push, N_st, integer :: rc, ni, nj integer*8 :: rc8 - integer :: N_states_read, N_det_read, psi_det_size_read + integer :: N_states_read, N_det_read integer :: N_det_selectors_read, N_det_generators_read integer, external :: zmq_get_dvector diff --git a/src/davidson/u0_hs2_u0.irp.f b/src/davidson/u0_hs2_u0.irp.f index 38fb56bd..e67777e7 100644 --- a/src/davidson/u0_hs2_u0.irp.f +++ b/src/davidson/u0_hs2_u0.irp.f @@ -6,7 +6,7 @@ ! ! psi_s2(i) = $\langle \Psi_i | S^2 | \Psi_i \rangle$ END_DOC - call u_0_HS2_u_0(psi_energy,psi_s2,psi_coef,N_det,psi_det,N_int,N_states,psi_det_size) + call u_0_HS2_u_0(psi_energy,psi_s2,psi_coef,N_det,psi_det,N_int,N_states,N_det) integer :: i do i=N_det+1,N_states psi_energy(i) = 0.d0 diff --git a/src/davidson/u0_wee_u0.irp.f b/src/davidson/u0_wee_u0.irp.f index 0c543aca..e53d76ea 100644 --- a/src/davidson/u0_wee_u0.irp.f +++ b/src/davidson/u0_wee_u0.irp.f @@ -4,7 +4,7 @@ BEGIN_PROVIDER [ double precision, psi_energy_two_e, (N_states) ] ! Energy of the current wave function END_DOC integer :: i,j - call u_0_H_u_0_two_e(psi_energy_two_e,psi_coef,N_det,psi_det,N_int,N_states,psi_det_size) + call u_0_H_u_0_two_e(psi_energy_two_e,psi_coef,N_det,psi_det,N_int,N_states,N_det) do i=N_det+1,N_states psi_energy_two_e(i) = 0.d0 enddo diff --git a/src/determinants/determinants.irp.f b/src/determinants/determinants.irp.f index eeadf779..16f3bedb 100644 --- a/src/determinants/determinants.irp.f +++ b/src/determinants/determinants.irp.f @@ -70,42 +70,7 @@ BEGIN_PROVIDER [integer, max_degree_exc] enddo END_PROVIDER -BEGIN_PROVIDER [ integer, psi_det_size ] - implicit none - BEGIN_DOC - ! Size of the psi_det and psi_coef arrays - END_DOC - PROVIDE ezfio_filename - logical :: exists - psi_det_size = 1 - PROVIDE mpi_master - if (read_wf) then - if (mpi_master) then - call ezfio_has_determinants_n_det(exists) - if (exists) then - call ezfio_get_determinants_n_det(psi_det_size) - else - psi_det_size = 1 - endif - call write_int(6,psi_det_size,'Dimension of the psi arrays') - endif - IRP_IF MPI_DEBUG - print *, irp_here, mpi_rank - call MPI_BARRIER(MPI_COMM_WORLD, ierr) - IRP_ENDIF - IRP_IF MPI - include 'mpif.h' - integer :: ierr - call MPI_BCAST( psi_det_size, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr) - if (ierr /= MPI_SUCCESS) then - stop 'Unable to read psi_det_size with MPI' - endif - IRP_ENDIF - endif - -END_PROVIDER - -BEGIN_PROVIDER [ integer(bit_kind), psi_det, (N_int,2,psi_det_size) ] +BEGIN_PROVIDER [ integer(bit_kind), psi_det, (N_int,2,N_det) ] implicit none BEGIN_DOC ! The determinants of the wave function. Initialized with Hartree-Fock if the |EZFIO| file @@ -176,7 +141,7 @@ END_PROVIDER -BEGIN_PROVIDER [ double precision, psi_coef, (psi_det_size,N_states) ] +BEGIN_PROVIDER [ double precision, psi_coef, (N_det,N_states) ] implicit none BEGIN_DOC ! The wave function coefficients. Initialized with Hartree-Fock if the |EZFIO| file @@ -189,7 +154,7 @@ BEGIN_PROVIDER [ double precision, psi_coef, (psi_det_size,N_states) ] PROVIDE read_wf N_det mo_label ezfio_filename psi_coef = 0.d0 - do i=1,min(N_states,psi_det_size) + do i=1,min(N_states,N_det) psi_coef(i,i) = 1.d0 enddo @@ -237,7 +202,7 @@ BEGIN_PROVIDER [ double precision, psi_coef, (psi_det_size,N_states) ] END_PROVIDER -BEGIN_PROVIDER [ double precision, psi_average_norm_contrib, (psi_det_size) ] +BEGIN_PROVIDER [ double precision, psi_average_norm_contrib, (N_det) ] implicit none BEGIN_DOC ! Contribution of determinants to the state-averaged density. @@ -287,10 +252,10 @@ END_PROVIDER !==============================================================================! - BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_coef_sorted, (psi_det_size,N_states) ] -&BEGIN_PROVIDER [ double precision, psi_average_norm_contrib_sorted, (psi_det_size) ] -&BEGIN_PROVIDER [ integer, psi_det_sorted_order, (psi_det_size) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_coef_sorted, (N_det,N_states) ] +&BEGIN_PROVIDER [ double precision, psi_average_norm_contrib_sorted, (N_det) ] +&BEGIN_PROVIDER [ integer, psi_det_sorted_order, (N_det) ] implicit none BEGIN_DOC ! Wave function sorted by determinants contribution to the norm (state-averaged) @@ -319,17 +284,12 @@ END_PROVIDER psi_det_sorted_order(iorder(i)) = i enddo - psi_det_sorted(:,:,N_det+1:psi_det_size) = 0_bit_kind - psi_coef_sorted(N_det+1:psi_det_size,:) = 0.d0 - psi_average_norm_contrib_sorted(N_det+1:psi_det_size) = 0.d0 - psi_det_sorted_order(N_det+1:psi_det_size) = 0 - deallocate(iorder) END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted_bit, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_coef_sorted_bit, (psi_det_size,N_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted_bit, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_coef_sorted_bit, (N_det,N_states) ] implicit none BEGIN_DOC ! Determinants on which we apply $\langle i|H|psi \rangle$ for perturbation. @@ -355,9 +315,6 @@ subroutine sort_dets_by_det_search_key(Ndet, det_in, coef_in, sze, det_out, coef ! Determinants are sorted according to their :c:func:`det_search_key`. ! Useful to accelerate the search of a random determinant in the wave ! function. - ! - ! /!\ The first dimension of coef_out and coef_in need to be psi_det_size - ! END_DOC integer :: i,j,k integer, allocatable :: iorder(:) @@ -491,7 +448,11 @@ subroutine save_wavefunction_truncated(thr) endif enddo if (mpi_master) then - call save_wavefunction_general(N_det_save,min(N_states,N_det_save),psi_det_sorted,size(psi_coef_sorted,1),psi_coef_sorted) + call save_wavefunction_general(N_det_save, & + min(N_states,N_det_save), & + psi_det_sorted, & + size(psi_coef_sorted,1), & + psi_coef_sorted) endif end diff --git a/src/determinants/h_apply.irp.f b/src/determinants/h_apply.irp.f index d01ad1c7..246ff209 100644 --- a/src/determinants/h_apply.irp.f +++ b/src/determinants/h_apply.irp.f @@ -159,10 +159,7 @@ subroutine copy_H_apply_buffer_to_wf enddo ! Update array sizes - if (psi_det_size < N_det) then - psi_det_size = N_det - TOUCH psi_det_size - endif + TOUCH N_det ! Restore backup in resized array do i=1,N_det_old @@ -180,7 +177,7 @@ subroutine copy_H_apply_buffer_to_wf !$OMP PARALLEL DEFAULT(SHARED) & !$OMP PRIVATE(j,k,i) FIRSTPRIVATE(N_det_old) & - !$OMP SHARED(N_int,H_apply_buffer,psi_det,psi_coef,N_states,psi_det_size) + !$OMP SHARED(N_int,H_apply_buffer,psi_det,psi_coef,N_states,N_det) j=0 !$ j=omp_get_thread_num() do k=0,j-1 diff --git a/src/determinants/psi_cas.irp.f b/src/determinants/psi_cas.irp.f index 19a1c260..125ec1e1 100644 --- a/src/determinants/psi_cas.irp.f +++ b/src/determinants/psi_cas.irp.f @@ -1,8 +1,8 @@ use bitmasks - BEGIN_PROVIDER [ integer(bit_kind), psi_cas, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_cas_coef, (psi_det_size,n_states) ] -&BEGIN_PROVIDER [ integer, idx_cas, (psi_det_size) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_cas, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_cas_coef, (N_det,n_states) ] +&BEGIN_PROVIDER [ integer, idx_cas, (N_det) ] &BEGIN_PROVIDER [ integer, N_det_cas ] implicit none BEGIN_DOC @@ -44,8 +44,8 @@ use bitmasks END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_cas_sorted_bit, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_cas_coef_sorted_bit, (psi_det_size,N_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_cas_sorted_bit, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_cas_coef_sorted_bit, (N_det,N_states) ] implicit none BEGIN_DOC ! |CAS| determinants sorted to accelerate the search of a random determinant in the wave @@ -58,9 +58,9 @@ END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_non_cas, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_non_cas_coef, (psi_det_size,n_states) ] -&BEGIN_PROVIDER [ integer, idx_non_cas, (psi_det_size) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_non_cas, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_non_cas_coef, (N_det,n_states) ] +&BEGIN_PROVIDER [ integer, idx_non_cas, (N_det) ] &BEGIN_PROVIDER [ integer, N_det_non_cas ] implicit none BEGIN_DOC @@ -97,8 +97,8 @@ END_PROVIDER N_det_non_cas = i_non_cas END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_non_cas_sorted_bit, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_non_cas_coef_sorted_bit, (psi_det_size,N_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_non_cas_sorted_bit, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_non_cas_coef_sorted_bit, (N_det,N_states) ] implicit none BEGIN_DOC ! |CAS| determinants sorted to accelerate the search of a random determinant in the wave diff --git a/src/determinants/s2.irp.f b/src/determinants/s2.irp.f index 2c1a8757..abae212f 100644 --- a/src/determinants/s2.irp.f +++ b/src/determinants/s2.irp.f @@ -110,7 +110,7 @@ END_PROVIDER ! array of the averaged values of the S^2 operator on the various states END_DOC integer :: i - call u_0_S2_u_0(s2_values,psi_coef,n_det,psi_det,N_int,N_states,psi_det_size) + call u_0_S2_u_0(s2_values,psi_coef,n_det,psi_det,N_int,N_states,N_det) do i = 1, N_states s_values(i) = 0.5d0 *(-1.d0 + dsqrt(1.d0 + 4 * s2_values(i))) enddo diff --git a/src/determinants/spindeterminants.irp.f b/src/determinants/spindeterminants.irp.f index dd55e112..e4a857a9 100644 --- a/src/determinants/spindeterminants.irp.f +++ b/src/determinants/spindeterminants.irp.f @@ -24,7 +24,7 @@ integer*8 function spin_det_search_key(det,Nint) end -BEGIN_PROVIDER [ integer(bit_kind), psi_det_alpha, (N_int,psi_det_size) ] +BEGIN_PROVIDER [ integer(bit_kind), psi_det_alpha, (N_int,N_det) ] implicit none BEGIN_DOC ! List of $\alpha$ determinants of psi_det @@ -39,7 +39,7 @@ BEGIN_PROVIDER [ integer(bit_kind), psi_det_alpha, (N_int,psi_det_size) ] END_PROVIDER -BEGIN_PROVIDER [ integer(bit_kind), psi_det_beta, (N_int,psi_det_size) ] +BEGIN_PROVIDER [ integer(bit_kind), psi_det_beta, (N_int,N_det) ] implicit none BEGIN_DOC ! List of $\beta$ determinants of psi_det @@ -56,7 +56,7 @@ END_PROVIDER BEGIN_TEMPLATE - BEGIN_PROVIDER [ integer(bit_kind), psi_det_$alpha_unique, (N_int,psi_det_size) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_det_$alpha_unique, (N_int,N_det) ] &BEGIN_PROVIDER [ integer, N_det_$alpha_unique ] implicit none BEGIN_DOC diff --git a/src/determinants/zmq.irp.f b/src/determinants/zmq.irp.f index 5a114533..7288de05 100644 --- a/src/determinants/zmq.irp.f +++ b/src/determinants/zmq.irp.f @@ -10,7 +10,6 @@ integer function zmq_put_psi(zmq_to_qp_run_socket,worker_id) integer, external :: zmq_put_N_states integer, external :: zmq_put_N_det - integer, external :: zmq_put_psi_det_size integer*8, external :: zmq_put_psi_det integer*8, external :: zmq_put_psi_coef @@ -23,10 +22,6 @@ integer function zmq_put_psi(zmq_to_qp_run_socket,worker_id) zmq_put_psi = -1 return endif - if (zmq_put_psi_det_size(zmq_to_qp_run_socket, worker_id) == -1) then - zmq_put_psi = -1 - return - endif if (zmq_put_psi_det(zmq_to_qp_run_socket, worker_id) == -1) then zmq_put_psi = -1 return @@ -51,7 +46,6 @@ integer function zmq_get_psi_notouch(zmq_to_qp_run_socket, worker_id) integer, external :: zmq_get_N_states integer, external :: zmq_get_N_det - integer, external :: zmq_get_psi_det_size integer*8, external :: zmq_get_psi_det integer*8, external :: zmq_get_psi_coef @@ -65,19 +59,15 @@ integer function zmq_get_psi_notouch(zmq_to_qp_run_socket, worker_id) zmq_get_psi_notouch = -1 return endif - if (zmq_get_psi_det_size(zmq_to_qp_run_socket, worker_id) == -1) then - zmq_get_psi_notouch = -1 - return - endif - if (size(psi_det,kind=8) /= N_int*2_8*psi_det_size*bit_kind) then + if (size(psi_det,kind=8) /= N_int*2_8*N_det*bit_kind) then deallocate(psi_det) - allocate(psi_det(N_int,2,psi_det_size)) + allocate(psi_det(N_int,2,N_det)) endif - if (size(psi_coef,kind=8) /= psi_det_size*N_states) then + if (size(psi_coef,kind=8) /= N_det*N_states) then deallocate(psi_coef) - allocate(psi_coef(psi_det_size,N_states)) + allocate(psi_coef(N_det,N_states)) endif if (zmq_get_psi_det(zmq_to_qp_run_socket, worker_id) == -1_8) then @@ -102,7 +92,7 @@ integer function zmq_get_psi(zmq_to_qp_run_socket, worker_id) integer, intent(in) :: worker_id integer, external :: zmq_get_psi_notouch zmq_get_psi = zmq_get_psi_notouch(zmq_to_qp_run_socket, worker_id) - SOFT_TOUCH psi_det psi_coef psi_det_size N_det N_states + SOFT_TOUCH psi_det psi_coef N_det N_states end @@ -266,7 +256,7 @@ integer function zmq_get_psi_bilinear(zmq_to_qp_run_socket, worker_id) return endif - SOFT_TOUCH psi_bilinear_matrix_values psi_bilinear_matrix_rows psi_bilinear_matrix_columns psi_bilinear_matrix_order psi_det psi_coef psi_det_size N_det N_states psi_det_beta_unique psi_det_alpha_unique N_det_beta_unique N_det_alpha_unique + SOFT_TOUCH psi_bilinear_matrix_values psi_bilinear_matrix_rows psi_bilinear_matrix_columns psi_bilinear_matrix_order psi_det psi_coef N_det N_states psi_det_beta_unique psi_det_alpha_unique N_det_beta_unique N_det_alpha_unique end @@ -374,7 +364,6 @@ N_states ;; N_det ;; N_det_alpha_unique ;; N_det_beta_unique ;; -psi_det_size ;; END_TEMPLATE diff --git a/src/generators_cas/generators.irp.f b/src/generators_cas/generators.irp.f index b2f58202..e499f703 100644 --- a/src/generators_cas/generators.irp.f +++ b/src/generators_cas/generators.irp.f @@ -20,11 +20,11 @@ BEGIN_PROVIDER [ integer, N_det_generators ] call write_int(6,N_det_generators,'Number of generators') END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_det_generators, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_coef_generators, (psi_det_size,N_states) ] -&BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted_gen, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_coef_sorted_gen, (psi_det_size,N_states) ] -&BEGIN_PROVIDER [ integer, psi_det_sorted_gen_order, (psi_det_size) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_det_generators, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_coef_generators, (N_det,N_states) ] +&BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted_gen, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_coef_sorted_gen, (N_det,N_states) ] +&BEGIN_PROVIDER [ integer, psi_det_sorted_gen_order, (N_det) ] implicit none BEGIN_DOC ! For Single reference wave functions, the generator is the diff --git a/src/generators_full/generators.irp.f b/src/generators_full/generators.irp.f index 7f18947f..376e5e3e 100644 --- a/src/generators_full/generators.irp.f +++ b/src/generators_full/generators.irp.f @@ -22,8 +22,8 @@ BEGIN_PROVIDER [ integer, N_det_generators ] call write_int(6,N_det_generators,'Number of generators') END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_det_generators, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_coef_generators, (psi_det_size,N_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_det_generators, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_coef_generators, (N_det,N_states) ] implicit none BEGIN_DOC ! For Single reference wave functions, the generator is the @@ -34,9 +34,9 @@ END_PROVIDER END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted_gen, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_coef_sorted_gen, (psi_det_size,N_states) ] -&BEGIN_PROVIDER [ integer, psi_det_sorted_gen_order, (psi_det_size) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted_gen, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_coef_sorted_gen, (N_det,N_states) ] +&BEGIN_PROVIDER [ integer, psi_det_sorted_gen_order, (N_det) ] implicit none BEGIN_DOC diff --git a/src/perturbation/selection.irp.f b/src/perturbation/selection.irp.f index f3f03673..67422226 100644 --- a/src/perturbation/selection.irp.f +++ b/src/perturbation/selection.irp.f @@ -90,12 +90,12 @@ subroutine remove_small_contributions enddo !$OMP PARALLEL DEFAULT(NONE) & !$OMP PRIVATE(i,j,i_H_psi_array) & - !$OMP SHARED(k,psi_det_sorted,psi_coef_sorted,N_int,N_det,psi_det_size,N_states, & + !$OMP SHARED(k,psi_det_sorted,psi_coef_sorted,N_int,N_det,N_det,N_states, & !$OMP selection_criterion_min,keep,N_det_generators) & !$OMP REDUCTION(+:N_removed) !$OMP DO do i=2*N_det_generators+1, N_det - call i_H_psi(psi_det_sorted(1,1,i),psi_det_sorted,psi_coef_sorted,N_int,min(N_det,2*N_det_generators),psi_det_size,N_states,i_H_psi_array) + call i_H_psi(psi_det_sorted(1,1,i),psi_det_sorted,psi_coef_sorted,N_int,min(N_det,2*N_det_generators),N_det,N_states,i_H_psi_array) keep(i) = .False. do j=1,N_states keep(i) = keep(i) .or. (-(psi_coef_sorted(i,j)*i_H_psi_array(j)) > selection_criterion_min) diff --git a/src/psiref_cas/psi_ref.irp.f b/src/psiref_cas/psi_ref.irp.f index 78dd2239..0e1df986 100644 --- a/src/psiref_cas/psi_ref.irp.f +++ b/src/psiref_cas/psi_ref.irp.f @@ -1,8 +1,8 @@ use bitmasks - BEGIN_PROVIDER [ integer(bit_kind), psi_ref, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_ref_coef, (psi_det_size,n_states) ] -&BEGIN_PROVIDER [ integer, idx_ref, (psi_det_size) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_ref, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_ref_coef, (N_det,n_states) ] +&BEGIN_PROVIDER [ integer, idx_ref, (N_det) ] &BEGIN_PROVIDER [ integer, N_det_ref ] implicit none BEGIN_DOC @@ -26,7 +26,7 @@ use bitmasks END_PROVIDER -BEGIN_PROVIDER [ double precision, psi_ref_coef_inv, (psi_det_size,n_states) ] +BEGIN_PROVIDER [ double precision, psi_ref_coef_inv, (N_det,n_states) ] implicit none BEGIN_DOC ! 1/psi_ref_coef @@ -41,8 +41,8 @@ BEGIN_PROVIDER [ double precision, psi_ref_coef_inv, (psi_det_size,n_states) ] END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_ref_restart, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_ref_coef_restart, (psi_det_size,n_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_ref_restart, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_ref_coef_restart, (N_det,n_states) ] implicit none BEGIN_DOC ! Projection of the CAS wave function on the restart wave function. diff --git a/src/psiref_utils/psi_ref_utils.irp.f b/src/psiref_utils/psi_ref_utils.irp.f index 19e42283..185d9778 100644 --- a/src/psiref_utils/psi_ref_utils.irp.f +++ b/src/psiref_utils/psi_ref_utils.irp.f @@ -1,8 +1,8 @@ use bitmasks - BEGIN_PROVIDER [ integer(bit_kind), psi_ref_sorted_bit, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_ref_coef_sorted_bit, (psi_det_size,N_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_ref_sorted_bit, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_ref_coef_sorted_bit, (N_det,N_states) ] implicit none BEGIN_DOC ! Reference determinants sorted to accelerate the search of a random determinant in the wave @@ -14,7 +14,7 @@ use bitmasks END_PROVIDER -BEGIN_PROVIDER [ double precision, psi_ref_coef_transp, (n_states,psi_det_size) ] +BEGIN_PROVIDER [ double precision, psi_ref_coef_transp, (n_states,N_det) ] implicit none BEGIN_DOC ! Transposed psi_ref_coef @@ -27,7 +27,7 @@ BEGIN_PROVIDER [ double precision, psi_ref_coef_transp, (n_states,psi_det_size) enddo END_PROVIDER -BEGIN_PROVIDER [ double precision, psi_ref_coef_normalized, (psi_det_size,n_states) ] +BEGIN_PROVIDER [ double precision, psi_ref_coef_normalized, (N_det,n_states) ] implicit none BEGIN_DOC ! Normalized coefficients of the reference @@ -43,7 +43,7 @@ BEGIN_PROVIDER [ double precision, psi_ref_coef_normalized, (psi_det_size,n_sta END_PROVIDER -BEGIN_PROVIDER [ double precision, psi_non_ref_coef_transp, (n_states,psi_det_size) ] +BEGIN_PROVIDER [ double precision, psi_non_ref_coef_transp, (n_states,N_det) ] implicit none BEGIN_DOC ! Transposed psi_non_ref_coef @@ -56,10 +56,10 @@ BEGIN_PROVIDER [ double precision, psi_non_ref_coef_transp, (n_states,psi_det_si enddo END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_non_ref, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_non_ref_coef, (psi_det_size,n_states) ] -&BEGIN_PROVIDER [ integer, idx_non_ref, (psi_det_size) ] -&BEGIN_PROVIDER [ integer, idx_non_ref_rev, (psi_det_size) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_non_ref, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_non_ref_coef, (N_det,n_states) ] +&BEGIN_PROVIDER [ integer, idx_non_ref, (N_det) ] +&BEGIN_PROVIDER [ integer, idx_non_ref_rev, (N_det) ] &BEGIN_PROVIDER [ integer, N_det_non_ref ] implicit none BEGIN_DOC @@ -102,8 +102,8 @@ END_PROVIDER endif END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_non_ref_restart, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_non_ref_coef_restart, (psi_det_size,n_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_non_ref_restart, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_non_ref_coef_restart, (N_det,n_states) ] implicit none BEGIN_DOC ! Set of determinants which are not part of the reference, defined from the application @@ -144,8 +144,8 @@ END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_non_ref_sorted_bit, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_non_ref_coef_sorted_bit, (psi_det_size,N_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_non_ref_sorted_bit, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_non_ref_coef_sorted_bit, (N_det,N_states) ] implicit none BEGIN_DOC ! Reference determinants sorted to accelerate the search of a random determinant in the wave diff --git a/src/selectors_utils/selectors.irp.f b/src/selectors_utils/selectors.irp.f index 92366d1d..765bd5e8 100644 --- a/src/selectors_utils/selectors.irp.f +++ b/src/selectors_utils/selectors.irp.f @@ -2,7 +2,7 @@ use bitmasks BEGIN_PROVIDER [ integer, psi_selectors_size ] implicit none - psi_selectors_size = psi_det_size + psi_selectors_size = N_det END_PROVIDER BEGIN_PROVIDER [ double precision, psi_selectors_coef_transp, (N_states,psi_selectors_size) ] diff --git a/src/single_ref_method/generators.irp.f b/src/single_ref_method/generators.irp.f index ce71f996..dd6985a5 100644 --- a/src/single_ref_method/generators.irp.f +++ b/src/single_ref_method/generators.irp.f @@ -9,8 +9,8 @@ BEGIN_PROVIDER [ integer, N_det_generators ] N_det_generators = 1 END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_det_generators, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_coef_generators, (psi_det_size,N_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_det_generators, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_coef_generators, (N_det,N_states) ] implicit none BEGIN_DOC ! For Single reference wave functions, the generator is the From eaf34675c2336151b124e61bac738712f13e0048 Mon Sep 17 00:00:00 2001 From: ydamour Date: Thu, 12 May 2022 19:58:23 +0200 Subject: [PATCH 37/68] another useless bitstring_to_list --- src/determinants/slater_rules_wee_mono.irp.f | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/determinants/slater_rules_wee_mono.irp.f b/src/determinants/slater_rules_wee_mono.irp.f index 4c1c9330..7c2ad148 100644 --- a/src/determinants/slater_rules_wee_mono.irp.f +++ b/src/determinants/slater_rules_wee_mono.irp.f @@ -282,9 +282,7 @@ subroutine i_H_j_two_e(key_i,key_j,Nint,hij) double precision :: get_two_e_integral integer :: m,n,p,q integer :: i,j,k - integer :: occ(Nint*bit_kind_size,2) double precision :: diag_H_mat_elem, phase,phase_2 - integer :: n_occ_ab(2) PROVIDE mo_two_e_integrals_in_map mo_integrals_map big_array_exchange_integrals ref_bitmask_two_e_energy ASSERT (Nint > 0) @@ -342,7 +340,6 @@ subroutine i_H_j_two_e(key_i,key_j,Nint,hij) case (1) call get_single_excitation(key_i,key_j,exc,phase,Nint) !DIR$ FORCEINLINE - call bitstring_to_list_ab(key_i, occ, n_occ_ab, Nint) if (exc(0,1,1) == 1) then ! Mono alpha m = exc(1,1,1) From bcb334afd295aea112ab46b3e17247df7c929d2c Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 12 May 2022 12:32:28 +0200 Subject: [PATCH 38/68] Changed order of tests --- src/fci/40.fci.bats | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/fci/40.fci.bats b/src/fci/40.fci.bats index 9b99d865..c303ea87 100644 --- a/src/fci/40.fci.bats +++ b/src/fci/40.fci.bats @@ -40,13 +40,6 @@ function run_stoch() { run_stoch -49.14104086 0.0001 10000 } -@test "F2" { # 0:03:34 - [[ -n $TRAVIS ]] && skip - qp set_file f2.ezfio - qp set_frozen_core - run_stoch -199.30821487 0.002 100000 -} - @test "NH3" { # 0:00:11 qp set_file nh3.ezfio qp set_mo_class --core="[1-4]" --act="[5-72]" @@ -186,3 +179,10 @@ function run_stoch() { run_stoch -93.09855896 5.e-4 50000 } +@test "F2" { # 0:03:34 + [[ -n $TRAVIS ]] && skip + qp set_file f2.ezfio + qp set_frozen_core + run_stoch -199.30821487 0.002 100000 +} + From 1f81de5bd4c2788dfdec8193feb3c9fa8631fdd5 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 13 May 2022 10:11:17 +0200 Subject: [PATCH 39/68] Additional check in run_selection_slave --- src/cipsi/run_selection_slave.irp.f | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cipsi/run_selection_slave.irp.f b/src/cipsi/run_selection_slave.irp.f index 91bd3a38..de7c209c 100644 --- a/src/cipsi/run_selection_slave.irp.f +++ b/src/cipsi/run_selection_slave.irp.f @@ -61,10 +61,14 @@ subroutine run_selection_slave(thread,iproc,energy) if (N /= buf%N) then print *, 'N=', N print *, 'buf%N=', buf%N - print *, 'bug in ', irp_here - stop '-1' + print *, 'In ', irp_here, ': N /= buf%N' + stop -1 end if end if + if (i_generator > N_det_generators) then + print *, 'In ', irp_here, ': i_generator > N_det_generators' + stop -1 + endif call select_connected(i_generator,energy,pt2_data,buf,subset,pt2_F(i_generator)) endif From 135082dd7d72d44c4724ac121f090ee3b2e7661d Mon Sep 17 00:00:00 2001 From: ydamour Date: Fri, 13 May 2022 18:07:40 +0200 Subject: [PATCH 40/68] duplication if N_det in OMP section --- src/perturbation/selection.irp.f | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/perturbation/selection.irp.f b/src/perturbation/selection.irp.f index 67422226..d5947d25 100644 --- a/src/perturbation/selection.irp.f +++ b/src/perturbation/selection.irp.f @@ -90,7 +90,7 @@ subroutine remove_small_contributions enddo !$OMP PARALLEL DEFAULT(NONE) & !$OMP PRIVATE(i,j,i_H_psi_array) & - !$OMP SHARED(k,psi_det_sorted,psi_coef_sorted,N_int,N_det,N_det,N_states, & + !$OMP SHARED(k,psi_det_sorted,psi_coef_sorted,N_int,N_det,N_states, & !$OMP selection_criterion_min,keep,N_det_generators) & !$OMP REDUCTION(+:N_removed) !$OMP DO From 29c0dc2e2fdcb029dd6e04f2cc3288d46db162aa Mon Sep 17 00:00:00 2001 From: ydamour Date: Fri, 13 May 2022 18:50:54 +0200 Subject: [PATCH 41/68] fix bug save_wavefunction_general --- src/determinants/determinants.irp.f | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/determinants/determinants.irp.f b/src/determinants/determinants.irp.f index d9e1303e..36da8c07 100644 --- a/src/determinants/determinants.irp.f +++ b/src/determinants/determinants.irp.f @@ -503,11 +503,12 @@ subroutine save_wavefunction_general(ndet,nstates,psidet,dim_psicoef,psicoef) integer :: i,j,k, ndet_qp_edit if (mpi_master) then + ndet_qp_edit = min(ndet,10000) call ezfio_set_determinants_N_int(N_int) call ezfio_set_determinants_bit_kind(bit_kind) call ezfio_set_determinants_N_det(ndet) - call ezfio_set_determinants_N_det_qp_edit(min(ndet,10000)) + call ezfio_set_determinants_N_det_qp_edit(ndet_qp_edit) call ezfio_set_determinants_n_states(nstates) call ezfio_set_determinants_mo_label(mo_label) From eda7ea74407cb600e033c289ecd285a5b60b73aa Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 16 May 2022 13:47:55 +0200 Subject: [PATCH 42/68] Removed docker files --- drone/Docker/README.md | 8 -------- drone/Docker/Ubuntu/Dockerfile | 27 --------------------------- drone/compilation.sh | 16 ---------------- drone/configuration.sh | 10 ---------- drone/drone_docker.yml | 30 ------------------------------ drone/drone_ssh.yml | 29 ----------------------------- drone/testing.sh | 16 ---------------- src/cisd/30.cisd.bats | 2 +- 8 files changed, 1 insertion(+), 137 deletions(-) delete mode 100644 drone/Docker/README.md delete mode 100644 drone/Docker/Ubuntu/Dockerfile delete mode 100755 drone/compilation.sh delete mode 100755 drone/configuration.sh delete mode 100644 drone/drone_docker.yml delete mode 100644 drone/drone_ssh.yml delete mode 100755 drone/testing.sh diff --git a/drone/Docker/README.md b/drone/Docker/README.md deleted file mode 100644 index eb569777..00000000 --- a/drone/Docker/README.md +++ /dev/null @@ -1,8 +0,0 @@ -Docker files to build the containers used with DroneCI. - -Example: -``` -docker build -t ubuntu/qp2_env . - -``` - diff --git a/drone/Docker/Ubuntu/Dockerfile b/drone/Docker/Ubuntu/Dockerfile deleted file mode 100644 index 05d87ad8..00000000 --- a/drone/Docker/Ubuntu/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ -ARG UBUNTU_VERSION=20.04 -FROM ubuntu:${UBUNTU_VERSION} AS builder - -# Timezone for tzdata -ARG tz=Etc/UTC -RUN echo $tz > /etc/timezone && rm -rf /etc/localtime - -# Install -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ - git \ - curl \ - wget \ - python3 \ - gfortran \ - gcc \ - g++ \ - make \ - build-essential \ - rsync \ - unzip \ - libopenblas-dev \ - pkg-config \ - m4 - -RUN ln -s /usr/bin/python3 /usr/bin/python - - diff --git a/drone/compilation.sh b/drone/compilation.sh deleted file mode 100755 index 071b4872..00000000 --- a/drone/compilation.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -# Stage 2 - -# Extract cache from config stage -cd ../ -tar -zxf $HOME/cache/config.tgz - -# Configure QP2 -cd qp2 -source ./quantum_package.rc -ninja -j 1 -v || exit -1 - -# Create cache -cd .. -tar -zcf $HOME/cache/compil.tgz qp2 && rm $HOME/cache/config.tgz - diff --git a/drone/configuration.sh b/drone/configuration.sh deleted file mode 100755 index f925107d..00000000 --- a/drone/configuration.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -# Stage 1 - -# Configure QP2 -./configure --download all --install all --config ./config/travis.cfg || exit -1 - -# Create cache -cd ../ -tar -zcf $HOME/cache/config.tgz qp2 - diff --git a/drone/drone_docker.yml b/drone/drone_docker.yml deleted file mode 100644 index d1eb7175..00000000 --- a/drone/drone_docker.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -kind: pipeline -type: docker -name: default - -clone: - depth: 10 - -steps: -- name: configure - pull: never - image: ubuntu/qp2_env - commands: - - ./configure -i all -c ./config/gfortran_debug.cfg - - source quantum_package.rc ; qp plugins download https://gitlab.com/scemama/qp_plugins_scemama - - source quantum_package.rc ; qp plugins install champ - -- name: compile - pull: never - image: ubuntu/qp2_env - commands: - - ninja - -- name: testing - pull: never - image: ubuntu/qp2_env - commands: - - qp test - - diff --git a/drone/drone_ssh.yml b/drone/drone_ssh.yml deleted file mode 100644 index 99397f11..00000000 --- a/drone/drone_ssh.yml +++ /dev/null @@ -1,29 +0,0 @@ -kind: pipeline -type: ssh -name: default - -clone: - depth: 10 - -server: - host: 130.120.229.139 - user: test - password: - from_secret: ssh_pass - -steps: -- name: configure - commands: - - ./configure -i all -c ./config/gfortran_debug.cfg - - source quantum_package.rc ; qp plugins download https://gitlab.com/scemama/qp_plugins_scemama - - source quantum_package.rc ; qp plugins install champ - -- name: compile - commands: - - ninja - -- name: testing - commands: - - qp test - - diff --git a/drone/testing.sh b/drone/testing.sh deleted file mode 100755 index f67bd106..00000000 --- a/drone/testing.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -# Stage 3 - -# Extract cache from compile stage -cd ../ -tar -zxf $HOME/cache/compil.tgz - -# Configure QP2 -cd qp2 -source ./quantum_package.rc -exec qp_test -a && rm $HOME/cache/compil.tgz - - - - - diff --git a/src/cisd/30.cisd.bats b/src/cisd/30.cisd.bats index 58d996f8..6e110aa3 100644 --- a/src/cisd/30.cisd.bats +++ b/src/cisd/30.cisd.bats @@ -77,7 +77,7 @@ function run() { [[ -n $TRAVIS ]] && skip qp set_file ch4.ezfio qp set_mo_class --core="[1]" --act="[2-30]" --del="[31-59]" - run -40.2403962667047 -39.8433221754964 + run -40.2403962667047 -39.843315 } @test "SiH3" { # 20.2202s 1.38648m From 62dbf1194249cde77526aea436d83897299c408c Mon Sep 17 00:00:00 2001 From: ydamour Date: Thu, 19 May 2022 10:28:05 +0200 Subject: [PATCH 43/68] update au to eV --- src/cis/cis.irp.f | 2 +- src/cisd/cisd.irp.f | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cis/cis.irp.f b/src/cis/cis.irp.f index f72197c2..57bf7789 100644 --- a/src/cis/cis.irp.f +++ b/src/cis/cis.irp.f @@ -74,7 +74,7 @@ subroutine run print*,'******************************************************' print*,'Excitation energies (au) (eV)' do i = 2, N_states - print*, i ,CI_energy(i) - CI_energy(1), (CI_energy(i) - CI_energy(1))/0.0367502d0 + print*, i ,CI_energy(i) - CI_energy(1), (CI_energy(i) - CI_energy(1)) * 27.211396641308d0 enddo print*,'' endif diff --git a/src/cisd/cisd.irp.f b/src/cisd/cisd.irp.f index fca3b10e..a6211d20 100644 --- a/src/cisd/cisd.irp.f +++ b/src/cisd/cisd.irp.f @@ -95,8 +95,8 @@ subroutine run print*,'******************************' print*,'Excitation energies (eV) (CISD+Q)' do i = 2, N_states - print*, i ,(CI_energy(i) - CI_energy(1))/0.0367502d0, & - (cisdq(i) - cisdq(1)) / 0.0367502d0 + print*, i ,(CI_energy(i) - CI_energy(1))*27.211396641308d0, & + (cisdq(i) - cisdq(1)) * 27.211396641308d0 enddo endif From f4512851bfc354144ad696e677cbf5d8fe135396 Mon Sep 17 00:00:00 2001 From: ydamour Date: Thu, 19 May 2022 10:42:29 +0200 Subject: [PATCH 44/68] provder for Ha to eV --- src/cis/cis.irp.f | 2 +- src/cisd/cisd.irp.f | 4 ++-- src/iterations/print_extrapolation.irp.f | 2 +- src/iterations/print_summary.irp.f | 12 ++++++------ src/utils/units.irp.f | 10 ++++++++++ 5 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 src/utils/units.irp.f diff --git a/src/cis/cis.irp.f b/src/cis/cis.irp.f index 57bf7789..2b16a5f7 100644 --- a/src/cis/cis.irp.f +++ b/src/cis/cis.irp.f @@ -74,7 +74,7 @@ subroutine run print*,'******************************************************' print*,'Excitation energies (au) (eV)' do i = 2, N_states - print*, i ,CI_energy(i) - CI_energy(1), (CI_energy(i) - CI_energy(1)) * 27.211396641308d0 + print*, i ,CI_energy(i) - CI_energy(1), (CI_energy(i) - CI_energy(1)) * ha_to_ev enddo print*,'' endif diff --git a/src/cisd/cisd.irp.f b/src/cisd/cisd.irp.f index a6211d20..6137643c 100644 --- a/src/cisd/cisd.irp.f +++ b/src/cisd/cisd.irp.f @@ -95,8 +95,8 @@ subroutine run print*,'******************************' print*,'Excitation energies (eV) (CISD+Q)' do i = 2, N_states - print*, i ,(CI_energy(i) - CI_energy(1))*27.211396641308d0, & - (cisdq(i) - cisdq(1)) * 27.211396641308d0 + print*, i ,(CI_energy(i) - CI_energy(1)) * ha_to_ev, & + (cisdq(i) - cisdq(1)) * ha_to_ev enddo endif diff --git a/src/iterations/print_extrapolation.irp.f b/src/iterations/print_extrapolation.irp.f index e07cc1ed..7f602ffb 100644 --- a/src/iterations/print_extrapolation.irp.f +++ b/src/iterations/print_extrapolation.irp.f @@ -35,7 +35,7 @@ subroutine print_extrapolated_energy do k=2,min(N_iter,8) write(*,'(F11.4,X,3(X,F18.8))') pt2_iterations(i,N_iter+1-k), extrapolated_energy(k,i), & extrapolated_energy(k,i) - extrapolated_energy(k,1), & - (extrapolated_energy(k,i) - extrapolated_energy(k,1) ) * 27.211396641308d0 + (extrapolated_energy(k,i) - extrapolated_energy(k,1) ) * ha_to_ev enddo write(*,*) '=========== ', '=================== ', '=================== ', '===================' enddo diff --git a/src/iterations/print_summary.irp.f b/src/iterations/print_summary.irp.f index 8e6285e2..a0db3534 100644 --- a/src/iterations/print_summary.irp.f +++ b/src/iterations/print_summary.irp.f @@ -36,7 +36,7 @@ subroutine print_summary(e_,pt2_data,pt2_data_err,n_det_,n_configuration_,n_st,s write(*,fmt) '# E ', e_(1:N_states_p) if (N_states_p > 1) then write(*,fmt) '# Excit. (au)', e_(1:N_states_p)-e_(1) - write(*,fmt) '# Excit. (eV)', (e_(1:N_states_p)-e_(1))*27.211396641308d0 + write(*,fmt) '# Excit. (eV)', (e_(1:N_states_p)-e_(1))*ha_to_ev endif write(fmt,*) '(A13,', 2*N_states_p, '(1X,F14.8))' write(*,fmt) '# PT2 '//pt2_string, (pt2_data % pt2(k), pt2_data_err % pt2(k), k=1,N_states_p) @@ -47,8 +47,8 @@ subroutine print_summary(e_,pt2_data,pt2_data_err,n_det_,n_configuration_,n_st,s if (N_states_p > 1) then write(*,fmt) '# Excit. (au)', ( (e_(k)+pt2_data % pt2(k)-e_(1)-pt2_data % pt2(1)), & dsqrt(pt2_data_err % pt2(k)*pt2_data_err % pt2(k)+pt2_data_err % pt2(1)*pt2_data_err % pt2(1)), k=1,N_states_p) - write(*,fmt) '# Excit. (eV)', ( (e_(k)+pt2_data % pt2(k)-e_(1)-pt2_data % pt2(1))*27.211396641308d0, & - dsqrt(pt2_data_err % pt2(k)*pt2_data_err % pt2(k)+pt2_data_err % pt2(1)*pt2_data_err % pt2(1))*27.211396641308d0, k=1,N_states_p) + write(*,fmt) '# Excit. (eV)', ( (e_(k)+pt2_data % pt2(k)-e_(1)-pt2_data % pt2(1))*ha_to_ev, & + dsqrt(pt2_data_err % pt2(k)*pt2_data_err % pt2(k)+pt2_data_err % pt2(1)*pt2_data_err % pt2(1))*ha_to_ev, k=1,N_states_p) endif write(fmt,*) '(''# ============'',', N_states_p, '(1X,''=============================''))' write(*,fmt) @@ -82,19 +82,19 @@ subroutine print_summary(e_,pt2_data,pt2_data_err,n_det_,n_configuration_,n_st,s print *, 'Variational Energy difference (au | eV)' do i=2, N_states_p print*,'Delta E = ', (e_(i) - e_(1)), & - (e_(i) - e_(1)) * 27.211396641308d0 + (e_(i) - e_(1)) * ha_to_ev enddo print *, '-----' print*, 'Variational + perturbative Energy difference (au | eV)' do i=2, N_states_p print*,'Delta E = ', (e_(i)+ pt2_data % pt2(i) - (e_(1) + pt2_data % pt2(1))), & - (e_(i)+ pt2_data % pt2(i) - (e_(1) + pt2_data % pt2(1))) * 27.211396641308d0 + (e_(i)+ pt2_data % pt2(i) - (e_(1) + pt2_data % pt2(1))) * ha_to_ev enddo print *, '-----' print*, 'Variational + renormalized perturbative Energy difference (au | eV)' do i=2, N_states_p print*,'Delta E = ', (e_(i)+ pt2_data % rpt2(i) - (e_(1) + pt2_data % rpt2(1))), & - (e_(i)+ pt2_data % rpt2(i) - (e_(1) + pt2_data % rpt2(1))) * 27.211396641308d0 + (e_(i)+ pt2_data % rpt2(i) - (e_(1) + pt2_data % rpt2(1))) * ha_to_ev enddo endif diff --git a/src/utils/units.irp.f b/src/utils/units.irp.f new file mode 100644 index 00000000..914fd041 --- /dev/null +++ b/src/utils/units.irp.f @@ -0,0 +1,10 @@ +BEGIN_PROVIDER [double precision, ha_to_ev] + + implicit none + BEGIN_DOC + ! Converstion from Hartree to eV + END_DOC + + ha_to_ev = 27.211396641308d0 + +END_PROVIDER From 7a67d69c0a794bbb0e6cbe24a5b9a62142479f44 Mon Sep 17 00:00:00 2001 From: ydamour Date: Thu, 19 May 2022 11:12:20 +0200 Subject: [PATCH 45/68] au to Debye --- src/determinants/dipole_moments.irp.f | 10 +++++++--- src/utils/units.irp.f | 12 ++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/determinants/dipole_moments.irp.f b/src/determinants/dipole_moments.irp.f index 06fca0cd..b411dda4 100644 --- a/src/determinants/dipole_moments.irp.f +++ b/src/determinants/dipole_moments.irp.f @@ -66,9 +66,13 @@ END_PROVIDER write(*,'(i16)',advance='no') i end do write(*,*) '' - write(*,'(A17,100(1pE16.8))') 'x_dipole_moment = ',x_dipole_moment - write(*,'(A17,100(1pE16.8))') 'y_dipole_moment = ',y_dipole_moment - write(*,'(A17,100(1pE16.8))') 'z_dipole_moment = ',z_dipole_moment + write(*,'(A23,100(1pE16.8))') 'x_dipole_moment (au) = ',x_dipole_moment + write(*,'(A23,100(1pE16.8))') 'y_dipole_moment (au) = ',y_dipole_moment + write(*,'(A23,100(1pE16.8))') 'z_dipole_moment (au) = ',z_dipole_moment + write(*,*) '' + write(*,'(A23,100(1pE16.8))') 'x_dipole_moment (D) = ',x_dipole_moment * au_to_D + write(*,'(A23,100(1pE16.8))') 'y_dipole_moment (D) = ',y_dipole_moment * au_to_D + write(*,'(A23,100(1pE16.8))') 'z_dipole_moment (D) = ',z_dipole_moment * au_to_D !print*, 'x_dipole_moment = ',x_dipole_moment !print*, 'y_dipole_moment = ',y_dipole_moment !print*, 'z_dipole_moment = ',z_dipole_moment diff --git a/src/utils/units.irp.f b/src/utils/units.irp.f index 914fd041..1850b28b 100644 --- a/src/utils/units.irp.f +++ b/src/utils/units.irp.f @@ -8,3 +8,15 @@ BEGIN_PROVIDER [double precision, ha_to_ev] ha_to_ev = 27.211396641308d0 END_PROVIDER + +BEGIN_PROVIDER [double precision, au_to_D] + + implicit none + BEGIN_DOC + ! Converstion from au to Debye + END_DOC + + au_to_D = 2.5415802529d0 + +END_PROVIDER + From ec39cad837eb5deea739b96ad63e63a11b2aba7b Mon Sep 17 00:00:00 2001 From: ydamour Date: Thu, 19 May 2022 11:12:39 +0200 Subject: [PATCH 46/68] cisd(q) only if n_elec >= 4 --- src/cisd/cisd.irp.f | 59 ++++++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/src/cisd/cisd.irp.f b/src/cisd/cisd.irp.f index 6137643c..5f167686 100644 --- a/src/cisd/cisd.irp.f +++ b/src/cisd/cisd.irp.f @@ -69,7 +69,9 @@ subroutine run do i = 1,N_states k = maxloc(dabs(psi_coef_sorted(1:N_det,i)),dim=1) delta_E = CI_electronic_energy(i) - diag_h_mat_elem(psi_det_sorted(1,1,k),N_int) - cisdq(i) = CI_energy(i) + delta_E * (1.d0 - psi_coef_sorted(k,i)**2) + if (elec_alpha_num + elec_beta_num >= 4) then + cisdq(i) = CI_energy(i) + delta_E * (1.d0 - psi_coef_sorted(k,i)**2) + endif enddo print *, 'N_det = ', N_det print*,'' @@ -78,26 +80,43 @@ subroutine run do i = 1,N_states print *, i, CI_energy(i) enddo - print*,'' - print*,'******************************' - print *, 'CISD+Q Energies' - do i = 1,N_states - print *, i, cisdq(i) - enddo + if (elec_alpha_num + elec_beta_num >= 4) then + print*,'' + print*,'******************************' + print *, 'CISD+Q Energies' + do i = 1,N_states + print *, i, cisdq(i) + enddo + endif if (N_states > 1) then - print*,'' - print*,'******************************' - print*,'Excitation energies (au) (CISD+Q)' - do i = 2, N_states - print*, i ,CI_energy(i) - CI_energy(1), cisdq(i) - cisdq(1) - enddo - print*,'' - print*,'******************************' - print*,'Excitation energies (eV) (CISD+Q)' - do i = 2, N_states - print*, i ,(CI_energy(i) - CI_energy(1)) * ha_to_ev, & - (cisdq(i) - cisdq(1)) * ha_to_ev - enddo + if (elec_alpha_num + elec_beta_num >= 4) then + print*,'' + print*,'******************************' + print*,'Excitation energies (au) (CISD+Q)' + do i = 2, N_states + print*, i ,CI_energy(i) - CI_energy(1), cisdq(i) - cisdq(1) + enddo + print*,'' + print*,'******************************' + print*,'Excitation energies (eV) (CISD+Q)' + do i = 2, N_states + print*, i ,(CI_energy(i) - CI_energy(1)) * ha_to_ev, & + (cisdq(i) - cisdq(1)) * ha_to_ev + enddo + else + print*,'' + print*,'******************************' + print*,'Excitation energies (au) (CISD)' + do i = 2, N_states + print*, i ,CI_energy(i) - CI_energy(1) + enddo + print*,'' + print*,'******************************' + print*,'Excitation energies (eV) (CISD)' + do i = 2, N_states + print*, i ,(CI_energy(i) - CI_energy(1)) * ha_to_ev + enddo + endif endif end From a52a084f583a7bad79394aa279df421a00cd80de Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 25 May 2022 13:34:56 +0200 Subject: [PATCH 47/68] Revert "Replaces psi_det_size by N_det" This reverts commit 6224e449ca2f1850152e2fdc46f838806e1b5907. --- src/csf/configurations.irp.f | 2 +- src/davidson/davidson_parallel.irp.f | 2 +- src/davidson/davidson_parallel_csf.irp.f | 2 +- src/davidson/davidson_parallel_nos2.irp.f | 2 +- src/davidson/u0_hs2_u0.irp.f | 2 +- src/davidson/u0_wee_u0.irp.f | 2 +- src/determinants/determinants.irp.f | 69 ++++++++++++++++++----- src/determinants/h_apply.irp.f | 7 ++- src/determinants/psi_cas.irp.f | 20 +++---- src/determinants/s2.irp.f | 2 +- src/determinants/spindeterminants.irp.f | 6 +- src/determinants/zmq.irp.f | 27 ++++++--- src/generators_cas/generators.irp.f | 10 ++-- src/generators_full/generators.irp.f | 10 ++-- src/perturbation/selection.irp.f | 4 +- src/psiref_cas/psi_ref.irp.f | 12 ++-- src/psiref_utils/psi_ref_utils.irp.f | 26 ++++----- src/selectors_utils/selectors.irp.f | 2 +- src/single_ref_method/generators.irp.f | 4 +- 19 files changed, 132 insertions(+), 79 deletions(-) diff --git a/src/csf/configurations.irp.f b/src/csf/configurations.irp.f index 3ecaa517..ce5d48ab 100644 --- a/src/csf/configurations.irp.f +++ b/src/csf/configurations.irp.f @@ -332,7 +332,7 @@ subroutine configuration_to_dets_tree_addressing(o,d,sze,n_alpha,Nint) end - BEGIN_PROVIDER [ integer(bit_kind), psi_configuration, (N_int,2,N_det) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_configuration, (N_int,2,psi_det_size) ] &BEGIN_PROVIDER [ integer, N_configuration ] implicit none BEGIN_DOC diff --git a/src/davidson/davidson_parallel.irp.f b/src/davidson/davidson_parallel.irp.f index b642d7a4..e627dfc9 100644 --- a/src/davidson/davidson_parallel.irp.f +++ b/src/davidson/davidson_parallel.irp.f @@ -99,7 +99,7 @@ subroutine davidson_slave_work(zmq_to_qp_run_socket, zmq_socket_push, N_st, sze, integer :: rc, ni, nj integer*8 :: rc8 - integer :: N_states_read, N_det_read + integer :: N_states_read, N_det_read, psi_det_size_read integer :: N_det_selectors_read, N_det_generators_read integer, external :: zmq_get_dvector diff --git a/src/davidson/davidson_parallel_csf.irp.f b/src/davidson/davidson_parallel_csf.irp.f index 8a8fcc4a..d8e9bffa 100644 --- a/src/davidson/davidson_parallel_csf.irp.f +++ b/src/davidson/davidson_parallel_csf.irp.f @@ -99,7 +99,7 @@ subroutine davidson_csf_slave_work(zmq_to_qp_run_socket, zmq_socket_push, N_st, integer :: rc, ni, nj integer*8 :: rc8 - integer :: N_states_read, N_det_read + integer :: N_states_read, N_det_read, psi_det_size_read integer :: N_det_selectors_read, N_det_generators_read integer, external :: zmq_get_dvector diff --git a/src/davidson/davidson_parallel_nos2.irp.f b/src/davidson/davidson_parallel_nos2.irp.f index dcc9687d..597b001f 100644 --- a/src/davidson/davidson_parallel_nos2.irp.f +++ b/src/davidson/davidson_parallel_nos2.irp.f @@ -99,7 +99,7 @@ subroutine davidson_nos2_slave_work(zmq_to_qp_run_socket, zmq_socket_push, N_st, integer :: rc, ni, nj integer*8 :: rc8 - integer :: N_states_read, N_det_read + integer :: N_states_read, N_det_read, psi_det_size_read integer :: N_det_selectors_read, N_det_generators_read integer, external :: zmq_get_dvector diff --git a/src/davidson/u0_hs2_u0.irp.f b/src/davidson/u0_hs2_u0.irp.f index e67777e7..38fb56bd 100644 --- a/src/davidson/u0_hs2_u0.irp.f +++ b/src/davidson/u0_hs2_u0.irp.f @@ -6,7 +6,7 @@ ! ! psi_s2(i) = $\langle \Psi_i | S^2 | \Psi_i \rangle$ END_DOC - call u_0_HS2_u_0(psi_energy,psi_s2,psi_coef,N_det,psi_det,N_int,N_states,N_det) + call u_0_HS2_u_0(psi_energy,psi_s2,psi_coef,N_det,psi_det,N_int,N_states,psi_det_size) integer :: i do i=N_det+1,N_states psi_energy(i) = 0.d0 diff --git a/src/davidson/u0_wee_u0.irp.f b/src/davidson/u0_wee_u0.irp.f index e53d76ea..0c543aca 100644 --- a/src/davidson/u0_wee_u0.irp.f +++ b/src/davidson/u0_wee_u0.irp.f @@ -4,7 +4,7 @@ BEGIN_PROVIDER [ double precision, psi_energy_two_e, (N_states) ] ! Energy of the current wave function END_DOC integer :: i,j - call u_0_H_u_0_two_e(psi_energy_two_e,psi_coef,N_det,psi_det,N_int,N_states,N_det) + call u_0_H_u_0_two_e(psi_energy_two_e,psi_coef,N_det,psi_det,N_int,N_states,psi_det_size) do i=N_det+1,N_states psi_energy_two_e(i) = 0.d0 enddo diff --git a/src/determinants/determinants.irp.f b/src/determinants/determinants.irp.f index 36da8c07..4b317025 100644 --- a/src/determinants/determinants.irp.f +++ b/src/determinants/determinants.irp.f @@ -70,7 +70,42 @@ BEGIN_PROVIDER [integer, max_degree_exc] enddo END_PROVIDER -BEGIN_PROVIDER [ integer(bit_kind), psi_det, (N_int,2,N_det) ] +BEGIN_PROVIDER [ integer, psi_det_size ] + implicit none + BEGIN_DOC + ! Size of the psi_det and psi_coef arrays + END_DOC + PROVIDE ezfio_filename + logical :: exists + psi_det_size = 1 + PROVIDE mpi_master + if (read_wf) then + if (mpi_master) then + call ezfio_has_determinants_n_det(exists) + if (exists) then + call ezfio_get_determinants_n_det(psi_det_size) + else + psi_det_size = 1 + endif + call write_int(6,psi_det_size,'Dimension of the psi arrays') + endif + IRP_IF MPI_DEBUG + print *, irp_here, mpi_rank + call MPI_BARRIER(MPI_COMM_WORLD, ierr) + IRP_ENDIF + IRP_IF MPI + include 'mpif.h' + integer :: ierr + call MPI_BCAST( psi_det_size, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr) + if (ierr /= MPI_SUCCESS) then + stop 'Unable to read psi_det_size with MPI' + endif + IRP_ENDIF + endif + +END_PROVIDER + +BEGIN_PROVIDER [ integer(bit_kind), psi_det, (N_int,2,psi_det_size) ] implicit none BEGIN_DOC ! The determinants of the wave function. Initialized with Hartree-Fock if the |EZFIO| file @@ -141,7 +176,7 @@ END_PROVIDER -BEGIN_PROVIDER [ double precision, psi_coef, (N_det,N_states) ] +BEGIN_PROVIDER [ double precision, psi_coef, (psi_det_size,N_states) ] implicit none BEGIN_DOC ! The wave function coefficients. Initialized with Hartree-Fock if the |EZFIO| file @@ -154,7 +189,7 @@ BEGIN_PROVIDER [ double precision, psi_coef, (N_det,N_states) ] PROVIDE read_wf N_det mo_label ezfio_filename psi_coef = 0.d0 - do i=1,min(N_states,N_det) + do i=1,min(N_states,psi_det_size) psi_coef(i,i) = 1.d0 enddo @@ -202,7 +237,7 @@ BEGIN_PROVIDER [ double precision, psi_coef, (N_det,N_states) ] END_PROVIDER -BEGIN_PROVIDER [ double precision, psi_average_norm_contrib, (N_det) ] +BEGIN_PROVIDER [ double precision, psi_average_norm_contrib, (psi_det_size) ] implicit none BEGIN_DOC ! Contribution of determinants to the state-averaged density. @@ -252,10 +287,10 @@ END_PROVIDER !==============================================================================! - BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_coef_sorted, (N_det,N_states) ] -&BEGIN_PROVIDER [ double precision, psi_average_norm_contrib_sorted, (N_det) ] -&BEGIN_PROVIDER [ integer, psi_det_sorted_order, (N_det) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_coef_sorted, (psi_det_size,N_states) ] +&BEGIN_PROVIDER [ double precision, psi_average_norm_contrib_sorted, (psi_det_size) ] +&BEGIN_PROVIDER [ integer, psi_det_sorted_order, (psi_det_size) ] implicit none BEGIN_DOC ! Wave function sorted by determinants contribution to the norm (state-averaged) @@ -284,12 +319,17 @@ END_PROVIDER psi_det_sorted_order(iorder(i)) = i enddo + psi_det_sorted(:,:,N_det+1:psi_det_size) = 0_bit_kind + psi_coef_sorted(N_det+1:psi_det_size,:) = 0.d0 + psi_average_norm_contrib_sorted(N_det+1:psi_det_size) = 0.d0 + psi_det_sorted_order(N_det+1:psi_det_size) = 0 + deallocate(iorder) END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted_bit, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_coef_sorted_bit, (N_det,N_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted_bit, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_coef_sorted_bit, (psi_det_size,N_states) ] implicit none BEGIN_DOC ! Determinants on which we apply $\langle i|H|psi \rangle$ for perturbation. @@ -315,6 +355,9 @@ subroutine sort_dets_by_det_search_key(Ndet, det_in, coef_in, sze, det_out, coef ! Determinants are sorted according to their :c:func:`det_search_key`. ! Useful to accelerate the search of a random determinant in the wave ! function. + ! + ! /!\ The first dimension of coef_out and coef_in need to be psi_det_size + ! END_DOC integer :: i,j,k integer, allocatable :: iorder(:) @@ -448,11 +491,7 @@ subroutine save_wavefunction_truncated(thr) endif enddo if (mpi_master) then - call save_wavefunction_general(N_det_save, & - min(N_states,N_det_save), & - psi_det_sorted, & - size(psi_coef_sorted,1), & - psi_coef_sorted) + call save_wavefunction_general(N_det_save,min(N_states,N_det_save),psi_det_sorted,size(psi_coef_sorted,1),psi_coef_sorted) endif end diff --git a/src/determinants/h_apply.irp.f b/src/determinants/h_apply.irp.f index 246ff209..d01ad1c7 100644 --- a/src/determinants/h_apply.irp.f +++ b/src/determinants/h_apply.irp.f @@ -159,7 +159,10 @@ subroutine copy_H_apply_buffer_to_wf enddo ! Update array sizes - TOUCH N_det + if (psi_det_size < N_det) then + psi_det_size = N_det + TOUCH psi_det_size + endif ! Restore backup in resized array do i=1,N_det_old @@ -177,7 +180,7 @@ subroutine copy_H_apply_buffer_to_wf !$OMP PARALLEL DEFAULT(SHARED) & !$OMP PRIVATE(j,k,i) FIRSTPRIVATE(N_det_old) & - !$OMP SHARED(N_int,H_apply_buffer,psi_det,psi_coef,N_states,N_det) + !$OMP SHARED(N_int,H_apply_buffer,psi_det,psi_coef,N_states,psi_det_size) j=0 !$ j=omp_get_thread_num() do k=0,j-1 diff --git a/src/determinants/psi_cas.irp.f b/src/determinants/psi_cas.irp.f index 125ec1e1..19a1c260 100644 --- a/src/determinants/psi_cas.irp.f +++ b/src/determinants/psi_cas.irp.f @@ -1,8 +1,8 @@ use bitmasks - BEGIN_PROVIDER [ integer(bit_kind), psi_cas, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_cas_coef, (N_det,n_states) ] -&BEGIN_PROVIDER [ integer, idx_cas, (N_det) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_cas, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_cas_coef, (psi_det_size,n_states) ] +&BEGIN_PROVIDER [ integer, idx_cas, (psi_det_size) ] &BEGIN_PROVIDER [ integer, N_det_cas ] implicit none BEGIN_DOC @@ -44,8 +44,8 @@ use bitmasks END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_cas_sorted_bit, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_cas_coef_sorted_bit, (N_det,N_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_cas_sorted_bit, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_cas_coef_sorted_bit, (psi_det_size,N_states) ] implicit none BEGIN_DOC ! |CAS| determinants sorted to accelerate the search of a random determinant in the wave @@ -58,9 +58,9 @@ END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_non_cas, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_non_cas_coef, (N_det,n_states) ] -&BEGIN_PROVIDER [ integer, idx_non_cas, (N_det) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_non_cas, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_non_cas_coef, (psi_det_size,n_states) ] +&BEGIN_PROVIDER [ integer, idx_non_cas, (psi_det_size) ] &BEGIN_PROVIDER [ integer, N_det_non_cas ] implicit none BEGIN_DOC @@ -97,8 +97,8 @@ END_PROVIDER N_det_non_cas = i_non_cas END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_non_cas_sorted_bit, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_non_cas_coef_sorted_bit, (N_det,N_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_non_cas_sorted_bit, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_non_cas_coef_sorted_bit, (psi_det_size,N_states) ] implicit none BEGIN_DOC ! |CAS| determinants sorted to accelerate the search of a random determinant in the wave diff --git a/src/determinants/s2.irp.f b/src/determinants/s2.irp.f index abae212f..2c1a8757 100644 --- a/src/determinants/s2.irp.f +++ b/src/determinants/s2.irp.f @@ -110,7 +110,7 @@ END_PROVIDER ! array of the averaged values of the S^2 operator on the various states END_DOC integer :: i - call u_0_S2_u_0(s2_values,psi_coef,n_det,psi_det,N_int,N_states,N_det) + call u_0_S2_u_0(s2_values,psi_coef,n_det,psi_det,N_int,N_states,psi_det_size) do i = 1, N_states s_values(i) = 0.5d0 *(-1.d0 + dsqrt(1.d0 + 4 * s2_values(i))) enddo diff --git a/src/determinants/spindeterminants.irp.f b/src/determinants/spindeterminants.irp.f index e4a857a9..dd55e112 100644 --- a/src/determinants/spindeterminants.irp.f +++ b/src/determinants/spindeterminants.irp.f @@ -24,7 +24,7 @@ integer*8 function spin_det_search_key(det,Nint) end -BEGIN_PROVIDER [ integer(bit_kind), psi_det_alpha, (N_int,N_det) ] +BEGIN_PROVIDER [ integer(bit_kind), psi_det_alpha, (N_int,psi_det_size) ] implicit none BEGIN_DOC ! List of $\alpha$ determinants of psi_det @@ -39,7 +39,7 @@ BEGIN_PROVIDER [ integer(bit_kind), psi_det_alpha, (N_int,N_det) ] END_PROVIDER -BEGIN_PROVIDER [ integer(bit_kind), psi_det_beta, (N_int,N_det) ] +BEGIN_PROVIDER [ integer(bit_kind), psi_det_beta, (N_int,psi_det_size) ] implicit none BEGIN_DOC ! List of $\beta$ determinants of psi_det @@ -56,7 +56,7 @@ END_PROVIDER BEGIN_TEMPLATE - BEGIN_PROVIDER [ integer(bit_kind), psi_det_$alpha_unique, (N_int,N_det) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_det_$alpha_unique, (N_int,psi_det_size) ] &BEGIN_PROVIDER [ integer, N_det_$alpha_unique ] implicit none BEGIN_DOC diff --git a/src/determinants/zmq.irp.f b/src/determinants/zmq.irp.f index 7288de05..5a114533 100644 --- a/src/determinants/zmq.irp.f +++ b/src/determinants/zmq.irp.f @@ -10,6 +10,7 @@ integer function zmq_put_psi(zmq_to_qp_run_socket,worker_id) integer, external :: zmq_put_N_states integer, external :: zmq_put_N_det + integer, external :: zmq_put_psi_det_size integer*8, external :: zmq_put_psi_det integer*8, external :: zmq_put_psi_coef @@ -22,6 +23,10 @@ integer function zmq_put_psi(zmq_to_qp_run_socket,worker_id) zmq_put_psi = -1 return endif + if (zmq_put_psi_det_size(zmq_to_qp_run_socket, worker_id) == -1) then + zmq_put_psi = -1 + return + endif if (zmq_put_psi_det(zmq_to_qp_run_socket, worker_id) == -1) then zmq_put_psi = -1 return @@ -46,6 +51,7 @@ integer function zmq_get_psi_notouch(zmq_to_qp_run_socket, worker_id) integer, external :: zmq_get_N_states integer, external :: zmq_get_N_det + integer, external :: zmq_get_psi_det_size integer*8, external :: zmq_get_psi_det integer*8, external :: zmq_get_psi_coef @@ -59,15 +65,19 @@ integer function zmq_get_psi_notouch(zmq_to_qp_run_socket, worker_id) zmq_get_psi_notouch = -1 return endif - - if (size(psi_det,kind=8) /= N_int*2_8*N_det*bit_kind) then - deallocate(psi_det) - allocate(psi_det(N_int,2,N_det)) + if (zmq_get_psi_det_size(zmq_to_qp_run_socket, worker_id) == -1) then + zmq_get_psi_notouch = -1 + return endif - if (size(psi_coef,kind=8) /= N_det*N_states) then + if (size(psi_det,kind=8) /= N_int*2_8*psi_det_size*bit_kind) then + deallocate(psi_det) + allocate(psi_det(N_int,2,psi_det_size)) + endif + + if (size(psi_coef,kind=8) /= psi_det_size*N_states) then deallocate(psi_coef) - allocate(psi_coef(N_det,N_states)) + allocate(psi_coef(psi_det_size,N_states)) endif if (zmq_get_psi_det(zmq_to_qp_run_socket, worker_id) == -1_8) then @@ -92,7 +102,7 @@ integer function zmq_get_psi(zmq_to_qp_run_socket, worker_id) integer, intent(in) :: worker_id integer, external :: zmq_get_psi_notouch zmq_get_psi = zmq_get_psi_notouch(zmq_to_qp_run_socket, worker_id) - SOFT_TOUCH psi_det psi_coef N_det N_states + SOFT_TOUCH psi_det psi_coef psi_det_size N_det N_states end @@ -256,7 +266,7 @@ integer function zmq_get_psi_bilinear(zmq_to_qp_run_socket, worker_id) return endif - SOFT_TOUCH psi_bilinear_matrix_values psi_bilinear_matrix_rows psi_bilinear_matrix_columns psi_bilinear_matrix_order psi_det psi_coef N_det N_states psi_det_beta_unique psi_det_alpha_unique N_det_beta_unique N_det_alpha_unique + SOFT_TOUCH psi_bilinear_matrix_values psi_bilinear_matrix_rows psi_bilinear_matrix_columns psi_bilinear_matrix_order psi_det psi_coef psi_det_size N_det N_states psi_det_beta_unique psi_det_alpha_unique N_det_beta_unique N_det_alpha_unique end @@ -364,6 +374,7 @@ N_states ;; N_det ;; N_det_alpha_unique ;; N_det_beta_unique ;; +psi_det_size ;; END_TEMPLATE diff --git a/src/generators_cas/generators.irp.f b/src/generators_cas/generators.irp.f index e499f703..b2f58202 100644 --- a/src/generators_cas/generators.irp.f +++ b/src/generators_cas/generators.irp.f @@ -20,11 +20,11 @@ BEGIN_PROVIDER [ integer, N_det_generators ] call write_int(6,N_det_generators,'Number of generators') END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_det_generators, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_coef_generators, (N_det,N_states) ] -&BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted_gen, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_coef_sorted_gen, (N_det,N_states) ] -&BEGIN_PROVIDER [ integer, psi_det_sorted_gen_order, (N_det) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_det_generators, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_coef_generators, (psi_det_size,N_states) ] +&BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted_gen, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_coef_sorted_gen, (psi_det_size,N_states) ] +&BEGIN_PROVIDER [ integer, psi_det_sorted_gen_order, (psi_det_size) ] implicit none BEGIN_DOC ! For Single reference wave functions, the generator is the diff --git a/src/generators_full/generators.irp.f b/src/generators_full/generators.irp.f index 376e5e3e..7f18947f 100644 --- a/src/generators_full/generators.irp.f +++ b/src/generators_full/generators.irp.f @@ -22,8 +22,8 @@ BEGIN_PROVIDER [ integer, N_det_generators ] call write_int(6,N_det_generators,'Number of generators') END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_det_generators, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_coef_generators, (N_det,N_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_det_generators, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_coef_generators, (psi_det_size,N_states) ] implicit none BEGIN_DOC ! For Single reference wave functions, the generator is the @@ -34,9 +34,9 @@ END_PROVIDER END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted_gen, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_coef_sorted_gen, (N_det,N_states) ] -&BEGIN_PROVIDER [ integer, psi_det_sorted_gen_order, (N_det) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted_gen, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_coef_sorted_gen, (psi_det_size,N_states) ] +&BEGIN_PROVIDER [ integer, psi_det_sorted_gen_order, (psi_det_size) ] implicit none BEGIN_DOC diff --git a/src/perturbation/selection.irp.f b/src/perturbation/selection.irp.f index d5947d25..f3f03673 100644 --- a/src/perturbation/selection.irp.f +++ b/src/perturbation/selection.irp.f @@ -90,12 +90,12 @@ subroutine remove_small_contributions enddo !$OMP PARALLEL DEFAULT(NONE) & !$OMP PRIVATE(i,j,i_H_psi_array) & - !$OMP SHARED(k,psi_det_sorted,psi_coef_sorted,N_int,N_det,N_states, & + !$OMP SHARED(k,psi_det_sorted,psi_coef_sorted,N_int,N_det,psi_det_size,N_states, & !$OMP selection_criterion_min,keep,N_det_generators) & !$OMP REDUCTION(+:N_removed) !$OMP DO do i=2*N_det_generators+1, N_det - call i_H_psi(psi_det_sorted(1,1,i),psi_det_sorted,psi_coef_sorted,N_int,min(N_det,2*N_det_generators),N_det,N_states,i_H_psi_array) + call i_H_psi(psi_det_sorted(1,1,i),psi_det_sorted,psi_coef_sorted,N_int,min(N_det,2*N_det_generators),psi_det_size,N_states,i_H_psi_array) keep(i) = .False. do j=1,N_states keep(i) = keep(i) .or. (-(psi_coef_sorted(i,j)*i_H_psi_array(j)) > selection_criterion_min) diff --git a/src/psiref_cas/psi_ref.irp.f b/src/psiref_cas/psi_ref.irp.f index 0e1df986..78dd2239 100644 --- a/src/psiref_cas/psi_ref.irp.f +++ b/src/psiref_cas/psi_ref.irp.f @@ -1,8 +1,8 @@ use bitmasks - BEGIN_PROVIDER [ integer(bit_kind), psi_ref, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_ref_coef, (N_det,n_states) ] -&BEGIN_PROVIDER [ integer, idx_ref, (N_det) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_ref, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_ref_coef, (psi_det_size,n_states) ] +&BEGIN_PROVIDER [ integer, idx_ref, (psi_det_size) ] &BEGIN_PROVIDER [ integer, N_det_ref ] implicit none BEGIN_DOC @@ -26,7 +26,7 @@ use bitmasks END_PROVIDER -BEGIN_PROVIDER [ double precision, psi_ref_coef_inv, (N_det,n_states) ] +BEGIN_PROVIDER [ double precision, psi_ref_coef_inv, (psi_det_size,n_states) ] implicit none BEGIN_DOC ! 1/psi_ref_coef @@ -41,8 +41,8 @@ BEGIN_PROVIDER [ double precision, psi_ref_coef_inv, (N_det,n_states) ] END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_ref_restart, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_ref_coef_restart, (N_det,n_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_ref_restart, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_ref_coef_restart, (psi_det_size,n_states) ] implicit none BEGIN_DOC ! Projection of the CAS wave function on the restart wave function. diff --git a/src/psiref_utils/psi_ref_utils.irp.f b/src/psiref_utils/psi_ref_utils.irp.f index 185d9778..19e42283 100644 --- a/src/psiref_utils/psi_ref_utils.irp.f +++ b/src/psiref_utils/psi_ref_utils.irp.f @@ -1,8 +1,8 @@ use bitmasks - BEGIN_PROVIDER [ integer(bit_kind), psi_ref_sorted_bit, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_ref_coef_sorted_bit, (N_det,N_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_ref_sorted_bit, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_ref_coef_sorted_bit, (psi_det_size,N_states) ] implicit none BEGIN_DOC ! Reference determinants sorted to accelerate the search of a random determinant in the wave @@ -14,7 +14,7 @@ use bitmasks END_PROVIDER -BEGIN_PROVIDER [ double precision, psi_ref_coef_transp, (n_states,N_det) ] +BEGIN_PROVIDER [ double precision, psi_ref_coef_transp, (n_states,psi_det_size) ] implicit none BEGIN_DOC ! Transposed psi_ref_coef @@ -27,7 +27,7 @@ BEGIN_PROVIDER [ double precision, psi_ref_coef_transp, (n_states,N_det) ] enddo END_PROVIDER -BEGIN_PROVIDER [ double precision, psi_ref_coef_normalized, (N_det,n_states) ] +BEGIN_PROVIDER [ double precision, psi_ref_coef_normalized, (psi_det_size,n_states) ] implicit none BEGIN_DOC ! Normalized coefficients of the reference @@ -43,7 +43,7 @@ BEGIN_PROVIDER [ double precision, psi_ref_coef_normalized, (N_det,n_states) ] END_PROVIDER -BEGIN_PROVIDER [ double precision, psi_non_ref_coef_transp, (n_states,N_det) ] +BEGIN_PROVIDER [ double precision, psi_non_ref_coef_transp, (n_states,psi_det_size) ] implicit none BEGIN_DOC ! Transposed psi_non_ref_coef @@ -56,10 +56,10 @@ BEGIN_PROVIDER [ double precision, psi_non_ref_coef_transp, (n_states,N_det) ] enddo END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_non_ref, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_non_ref_coef, (N_det,n_states) ] -&BEGIN_PROVIDER [ integer, idx_non_ref, (N_det) ] -&BEGIN_PROVIDER [ integer, idx_non_ref_rev, (N_det) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_non_ref, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_non_ref_coef, (psi_det_size,n_states) ] +&BEGIN_PROVIDER [ integer, idx_non_ref, (psi_det_size) ] +&BEGIN_PROVIDER [ integer, idx_non_ref_rev, (psi_det_size) ] &BEGIN_PROVIDER [ integer, N_det_non_ref ] implicit none BEGIN_DOC @@ -102,8 +102,8 @@ END_PROVIDER endif END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_non_ref_restart, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_non_ref_coef_restart, (N_det,n_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_non_ref_restart, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_non_ref_coef_restart, (psi_det_size,n_states) ] implicit none BEGIN_DOC ! Set of determinants which are not part of the reference, defined from the application @@ -144,8 +144,8 @@ END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_non_ref_sorted_bit, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_non_ref_coef_sorted_bit, (N_det,N_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_non_ref_sorted_bit, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_non_ref_coef_sorted_bit, (psi_det_size,N_states) ] implicit none BEGIN_DOC ! Reference determinants sorted to accelerate the search of a random determinant in the wave diff --git a/src/selectors_utils/selectors.irp.f b/src/selectors_utils/selectors.irp.f index 765bd5e8..92366d1d 100644 --- a/src/selectors_utils/selectors.irp.f +++ b/src/selectors_utils/selectors.irp.f @@ -2,7 +2,7 @@ use bitmasks BEGIN_PROVIDER [ integer, psi_selectors_size ] implicit none - psi_selectors_size = N_det + psi_selectors_size = psi_det_size END_PROVIDER BEGIN_PROVIDER [ double precision, psi_selectors_coef_transp, (N_states,psi_selectors_size) ] diff --git a/src/single_ref_method/generators.irp.f b/src/single_ref_method/generators.irp.f index dd6985a5..ce71f996 100644 --- a/src/single_ref_method/generators.irp.f +++ b/src/single_ref_method/generators.irp.f @@ -9,8 +9,8 @@ BEGIN_PROVIDER [ integer, N_det_generators ] N_det_generators = 1 END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_det_generators, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_coef_generators, (N_det,N_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_det_generators, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_coef_generators, (psi_det_size,N_states) ] implicit none BEGIN_DOC ! For Single reference wave functions, the generator is the From 727815751cdcadc8affbdd87897150dbb06e6e76 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 25 May 2022 19:35:44 +0200 Subject: [PATCH 48/68] DGEMM four-index transformation --- src/mo_two_e_ints/mo_bi_integrals.irp.f | 96 ++++++++++++++++++++++++- 1 file changed, 95 insertions(+), 1 deletion(-) diff --git a/src/mo_two_e_ints/mo_bi_integrals.irp.f b/src/mo_two_e_ints/mo_bi_integrals.irp.f index d58932ce..c03b363d 100644 --- a/src/mo_two_e_ints/mo_bi_integrals.irp.f +++ b/src/mo_two_e_ints/mo_bi_integrals.irp.f @@ -53,7 +53,11 @@ BEGIN_PROVIDER [ logical, mo_two_e_integrals_in_map ] ! call four_idx_novvvv call four_idx_novvvv_old else - call add_integrals_to_map(full_ijkl_bitmask_4) + if (ao_num*ao_num*ao_num*ao_num*32.d-9 < dble(qp_max_mem)) then + call four_idx_dgemm + else + call add_integrals_to_map(full_ijkl_bitmask_4) + endif endif call wall_time(wall_2) @@ -77,6 +81,96 @@ BEGIN_PROVIDER [ logical, mo_two_e_integrals_in_map ] END_PROVIDER +subroutine four_idx_dgemm + implicit none + integer :: p,q,r,s,i,j,k,l + double precision, allocatable :: a1(:,:,:,:) + double precision, allocatable :: a2(:,:,:,:) + + allocate (a1(ao_num,ao_num,ao_num,ao_num)) + + print *, 'Getting AOs' + !$OMP PARALLEL DO DEFAULT(SHARED) PRIVATE(q,r,s) + do s=1,ao_num + do r=1,ao_num + do q=1,ao_num + call get_ao_two_e_integrals(q,r,s,ao_num,a1(1,q,r,s)) + enddo + enddo + enddo + !$OMP END PARALLEL DO + + print *, '1st transformation' + ! 1st transformation + allocate (a2(ao_num,ao_num,ao_num,mo_num)) + call dgemm('T','N', (ao_num*ao_num*ao_num), mo_num, ao_num, 1.d0, a1, ao_num, mo_coef, ao_num, 0.d0, a2, (ao_num*ao_num*ao_num)) + + ! 2nd transformation + print *, '2nd transformation' + deallocate (a1) + allocate (a1(ao_num,ao_num,mo_num,mo_num)) + call dgemm('T','N', (ao_num*ao_num*mo_num), mo_num, ao_num, 1.d0, a2, ao_num, mo_coef, ao_num, 0.d0, a1, (ao_num*ao_num*mo_num)) + + ! 3rd transformation + print *, '3rd transformation' + deallocate (a2) + allocate (a2(ao_num,mo_num,mo_num,mo_num)) + call dgemm('T','N', (ao_num*mo_num*mo_num), mo_num, ao_num, 1.d0, a1, ao_num, mo_coef, ao_num, 0.d0, a2, (ao_num*mo_num*mo_num)) + + ! 4th transformation + print *, '4th transformation' + deallocate (a1) + allocate (a1(mo_num,mo_num,mo_num,mo_num)) + call dgemm('T','N', (mo_num*mo_num*mo_num), mo_num, ao_num, 1.d0, a2, ao_num, mo_coef, ao_num, 0.d0, a1, (mo_num*mo_num*mo_num)) + + deallocate (a2) + + integer :: n_integrals, size_buffer + integer(key_kind) , allocatable :: buffer_i(:) + real(integral_kind), allocatable :: buffer_value(:) + size_buffer = min(ao_num*ao_num*ao_num,16000000) + + print *, 'Storing' + !$OMP PARALLEL DEFAULT(SHARED) PRIVATE(i,j,k,l,buffer_value,buffer_i,n_integrals) + allocate ( buffer_i(size_buffer), buffer_value(size_buffer) ) + + n_integrals = 0 + !$OMP DO + do l=1,mo_num + do k=1,mo_num + do j=1,l + do i=1,k + if (abs(a1(i,j,k,l)) < mo_integrals_threshold) then + cycle + endif + n_integrals += 1 + buffer_value(n_integrals) = a1(i,j,k,l) + !DIR$ FORCEINLINE + call mo_two_e_integrals_index(i,j,k,l,buffer_i(n_integrals)) + if (n_integrals == size_buffer) then + call map_append(mo_integrals_map, buffer_i, buffer_value, n_integrals) + n_integrals = 0 + endif + enddo + enddo + enddo + enddo + !$OMP END DO + + call map_append(mo_integrals_map, buffer_i, buffer_value, n_integrals) + + deallocate(buffer_i, buffer_value) + !$OMP END PARALLEL + + deallocate (a1) + + print *, 'Unique' + call map_unique(mo_integrals_map) + + integer*8 :: get_mo_map_size, mo_map_size + mo_map_size = get_mo_map_size() + +end subroutine subroutine add_integrals_to_map(mask_ijkl) use bitmasks From 4ccaa8f695a4928be80bb214dd063a7b7e9d28a9 Mon Sep 17 00:00:00 2001 From: v1j4y Date: Mon, 6 Jun 2022 13:41:29 +0200 Subject: [PATCH 49/68] Open-Shell CSF: Fix bug in getbftodetfunction. --- src/csf/cfgCI_utils.c | 50 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/src/csf/cfgCI_utils.c b/src/csf/cfgCI_utils.c index 23b984a0..63172d14 100644 --- a/src/csf/cfgCI_utils.c +++ b/src/csf/cfgCI_utils.c @@ -68,10 +68,16 @@ void getBFIndexList(int NSOMO, int *BF1, int *IdxListBF1){ break; } } - BFcopy[Iidx] = -1; - BFcopy[Jidx] = -1; - IdxListBF1[Jidx] = Iidx; - IdxListBF1[Iidx] = Jidx; + if(countN1 <= 0){ + BFcopy[Iidx] = -1; + IdxListBF1[Iidx] = Iidx; + } + else{ + BFcopy[Iidx] = -1; + BFcopy[Jidx] = -1; + IdxListBF1[Jidx] = Iidx; + IdxListBF1[Iidx] = Jidx; + } } } @@ -1297,16 +1303,21 @@ void getbftodetfunction(Tree *dettree, int NSOMO, int MS, int *BF1, double *rowv double fac = 1.0; for(int i = 0; i < NSOMO; i++) donepq[i] = 0.0; + for(int i=0;i 0.0 || donepq[idxq] > 0.0) continue; + if(donepq[idxp] > 0.0 || donepq[idxq] > 0.0 || idxp == idxq) continue; fac *= 2.0; donepq[idxp] = 1.0; donepq[idxq] = 1.0; for(int j = 0; j < npairs; j = j + shft){ + printf("i=%d j=%d (%d,%d)\n",i,j,idxp,idxq); for(int k = 0; k < shft/2; k++){ detslist[(k+j)*NSOMO + idxp] = 1; detslist[(k+j)*NSOMO + idxq] = 0; @@ -1319,15 +1330,26 @@ void getbftodetfunction(Tree *dettree, int NSOMO, int MS, int *BF1, double *rowv } shft /= 2; } + for(int i=0;i Date: Mon, 6 Jun 2022 14:08:34 +0200 Subject: [PATCH 50/68] Open-Shell CSF: Fix bug in build csftree. --- src/csf/cfgCI_utils.c | 34 +++++----------------------------- src/csf/tree_utils.c | 26 +++++++++++++++----------- 2 files changed, 20 insertions(+), 40 deletions(-) diff --git a/src/csf/cfgCI_utils.c b/src/csf/cfgCI_utils.c index 63172d14..91e7360a 100644 --- a/src/csf/cfgCI_utils.c +++ b/src/csf/cfgCI_utils.c @@ -1317,7 +1317,6 @@ void getbftodetfunction(Tree *dettree, int NSOMO, int MS, int *BF1, double *rowv donepq[idxp] = 1.0; donepq[idxq] = 1.0; for(int j = 0; j < npairs; j = j + shft){ - printf("i=%d j=%d (%d,%d)\n",i,j,idxp,idxq); for(int k = 0; k < shft/2; k++){ detslist[(k+j)*NSOMO + idxp] = 1; detslist[(k+j)*NSOMO + idxq] = 0; @@ -1330,14 +1329,7 @@ void getbftodetfunction(Tree *dettree, int NSOMO, int MS, int *BF1, double *rowv } shft /= 2; } - for(int i=0;i NSOMOMax || icpl < 0 || izeros > zeromax ) return; // If we find a valid BF assign its address - if(isomo == NSOMOMax){ + if(isomo == NSOMOMax && icpl == MSmax){ (*inode)->addr = bftree->rootNode->addr; bftree->rootNode->addr += 1; return; } // Call 0 branch - if(((*inode)->C0) == NULL && izeros+1 <= zeromax){ - ((*inode)->C0) = malloc(sizeof(Node)); - (*(*inode)->C0) = (Node){ .C0 = NULL, .C1 = NULL, .PREV = *inode, .addr = -1, .cpl = 0, .iSOMO = isomo }; - buildTree(bftree, &(*inode)->C0, isomo+1, izeros+1, icpl+1, NSOMOMax, MSmax); + if(izeros+1 <= zeromax){ + if(((*inode)->C0) == NULL){ + ((*inode)->C0) = malloc(sizeof(Node)); + (*(*inode)->C0) = (Node){ .C0 = NULL, .C1 = NULL, .PREV = *inode, .addr = -1, .cpl = 0, .iSOMO = isomo }; + buildTree(bftree, &(*inode)->C0, isomo+1, izeros+1, icpl+1, NSOMOMax, MSmax); + } + else buildTree(bftree, &(*inode)->C0, isomo+1, izeros+1, icpl+1, NSOMOMax, MSmax); } - else buildTree(bftree, &(*inode)->C0, isomo+1, izeros+1, icpl+1, NSOMOMax, MSmax); // Call 1 branch - if(((*inode)->C1) == NULL && icpl-1 >= 0){ - ((*inode)->C1) = malloc(sizeof(Node)); - (*(*inode)->C1) = (Node){ .C0 = NULL, .C1 = NULL, .PREV = *inode, .addr = -1, .cpl = 1, .iSOMO = isomo }; - buildTree(bftree, &(*inode)->C1, isomo+1, izeros+0, icpl-1, NSOMOMax, MSmax); + if(icpl-1 >=0){ + if(((*inode)->C1) == NULL){ + ((*inode)->C1) = malloc(sizeof(Node)); + (*(*inode)->C1) = (Node){ .C0 = NULL, .C1 = NULL, .PREV = *inode, .addr = -1, .cpl = 1, .iSOMO = isomo }; + buildTree(bftree, &(*inode)->C1, isomo+1, izeros+0, icpl-1, NSOMOMax, MSmax); + } + else buildTree(bftree, &(*inode)->C1, isomo+1, izeros+0, icpl-1, NSOMOMax, MSmax); } - else buildTree(bftree, &(*inode)->C1, isomo+1, izeros+0, icpl-1, NSOMOMax, MSmax); return; } From e06ab2fd05d46a8f8be6c86f23e3870615287b8d Mon Sep 17 00:00:00 2001 From: v1j4y Date: Mon, 6 Jun 2022 15:23:25 +0200 Subject: [PATCH 51/68] Open-Shell CSF: Fix bug in convertCSFtoDetBasis. --- src/csf/cfgCI_utils.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/csf/cfgCI_utils.c b/src/csf/cfgCI_utils.c index 91e7360a..746de04e 100644 --- a/src/csf/cfgCI_utils.c +++ b/src/csf/cfgCI_utils.c @@ -334,10 +334,21 @@ void convertCSFtoDetBasis(int64_t Isomo, int MS, int rowsmax, int colsmax, doubl Get Overlap ************************************/ // Fill matrix + + int rowsbftodetI, colsbftodetI; + + /*********************************** + Get BFtoDeterminant Matrix + ************************************/ + + printf("In convertcsftodet\n"); + convertBFtoDetBasis(Isomo, MS, &bftodetmatrixI, &rowsbftodetI, &colsbftodetI); + int rowsI = 0; int colsI = 0; - getOverlapMatrix(Isomo, MS, &overlapMatrixI, &rowsI, &colsI, &NSOMO); + //getOverlapMatrix(Isomo, MS, &overlapMatrixI, &rowsI, &colsI, &NSOMO); + getOverlapMatrix_withDet(bftodetmatrixI, rowsbftodetI, colsbftodetI, Isomo, MS, &overlapMatrixI, &rowsI, &colsI, &NSOMO); /*********************************** @@ -348,14 +359,6 @@ void convertCSFtoDetBasis(int64_t Isomo, int MS, int rowsmax, int colsmax, doubl gramSchmidt(overlapMatrixI, rowsI, colsI, orthoMatrixI); - /*********************************** - Get BFtoDeterminant Matrix - ************************************/ - - int rowsbftodetI, colsbftodetI; - - convertBFtoDetBasis(Isomo, MS, &bftodetmatrixI, &rowsbftodetI, &colsbftodetI); - /*********************************** Get Final CSF to Det Matrix ************************************/ @@ -1305,7 +1308,7 @@ void getbftodetfunction(Tree *dettree, int NSOMO, int MS, int *BF1, double *rowv donepq[i] = 0.0; for(int i=0;i Date: Wed, 8 Jun 2022 07:48:58 +0200 Subject: [PATCH 52/68] Update tests --- src/fci/40.fci.bats | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fci/40.fci.bats b/src/fci/40.fci.bats index c303ea87..871de780 100644 --- a/src/fci/40.fci.bats +++ b/src/fci/40.fci.bats @@ -54,7 +54,7 @@ function run_stoch() { @test "HCO" { # 0:01:16 qp set_file hco.ezfio - run_stoch -113.41658256 1.e-3 50000 + run_stoch -113.41658256 2.e-3 50000 } @test "H2O2" { # 0:01:48 @@ -66,7 +66,7 @@ function run_stoch() { @test "HBO" { # 0:00:46 [[ -n $TRAVIS ]] && skip qp set_file hbo.ezfio - run_stoch -100.22361288 1.e-4 50000 + run_stoch -100.22361288 2.e-3 50000 } @test "H2O" { # 0:01:05 From 6861cea2ac2bd5cbd40c9bd3f4b076602da830a0 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 8 Jun 2022 11:08:53 +0200 Subject: [PATCH 53/68] Compiles with OCaml 4.13.1 --- bin/qp_test | 9 +- configure | 4 +- external/qp2-dependencies | 2 +- ocaml/Qputils.ml | 4 + ocaml/qp_tunnel.ml | 139 ++++++++++++++--------- src/fci/40.fci.bats | 16 +-- src/iterations/print_extrapolation.irp.f | 2 +- tests/bats/common.bats.sh | 2 +- 8 files changed, 102 insertions(+), 76 deletions(-) diff --git a/bin/qp_test b/bin/qp_test index 67b3ea02..288b7291 100755 --- a/bin/qp_test +++ b/bin/qp_test @@ -60,19 +60,14 @@ def main(arguments): print("Running tests for %s"%(bats_file)) print("") if arguments["-v"]: - p = None if arguments["TEST"]: test = "export TEST=%s ; "%arguments["TEST"] else: test = "" - try: - os.system(test+" python3 bats_to_sh.py "+bats_file+ + os.system(test+" python3 bats_to_sh.py "+bats_file+ "| bash") - except: - if p: - p.terminate() else: - subprocess.check_call(["bats", bats_file], env=os.environ) + subprocess.check_call(["bats", "--verbose-run", "--trace", bats_file], env=os.environ) diff --git a/configure b/configure index e70820fe..5c38b9f2 100755 --- a/configure +++ b/configure @@ -281,8 +281,8 @@ EOF execute << EOF cd "\${QP_ROOT}"/external - tar -zxf qp2-dependencies/bats-v1.1.0.tar.gz - ( cd bats-core-1.1.0/ ; ./install.sh \${QP_ROOT}) + tar -zxf qp2-dependencies/bats-v1.7.0.tar.gz + ( cd bats-core-1.7.0/ ; ./install.sh \${QP_ROOT}) EOF else diff --git a/external/qp2-dependencies b/external/qp2-dependencies index 90ee61f5..242151e0 160000 --- a/external/qp2-dependencies +++ b/external/qp2-dependencies @@ -1 +1 @@ -Subproject commit 90ee61f5041c7c94a0c605625a264860292813a0 +Subproject commit 242151e03d1d6bf042387226431d82d35845686a diff --git a/ocaml/Qputils.ml b/ocaml/Qputils.ml index 270e069f..752a65a0 100644 --- a/ocaml/Qputils.ml +++ b/ocaml/Qputils.ml @@ -56,3 +56,7 @@ let string_of_string s = s let list_map f l = List.rev_map f l |> List.rev + +let socket_convert socket = + ((Obj.magic (Obj.repr socket)) : [ `Xsub ] Zmq.Socket.t ) + diff --git a/ocaml/qp_tunnel.ml b/ocaml/qp_tunnel.ml index 84e50eb5..6885db73 100644 --- a/ocaml/qp_tunnel.ml +++ b/ocaml/qp_tunnel.ml @@ -2,7 +2,7 @@ open Qputils open Qptypes type ezfio_or_address = EZFIO of string | ADDRESS of string -type req_or_sub = REQ | SUB +type req_or_sub = REQ | SUB let localport = 42379 @@ -29,7 +29,7 @@ let () = end; let arg = - let x = + let x = match Command_line.anon_args () with | [x] -> x | _ -> begin @@ -44,7 +44,7 @@ let () = in - let localhost = + let localhost = Lazy.force TaskServer.ip_address in @@ -52,28 +52,28 @@ let () = let long_address = match arg with | ADDRESS x -> x - | EZFIO x -> - let ic = + | EZFIO x -> + let ic = Filename.concat (Qpackage.ezfio_work x) "qp_run_address" |> open_in in - let result = + let result = input_line ic |> String.trim in close_in ic; result in - + let protocol, address, port = match String.split_on_char ':' long_address with | t :: a :: p :: [] -> t, a, int_of_string p - | _ -> failwith @@ + | _ -> failwith @@ Printf.sprintf "%s : Malformed address" long_address in - let zmq_context = + let zmq_context = Zmq.Context.create () in @@ -105,10 +105,10 @@ let () = let create_socket sock_type bind_or_connect addr = - let socket = + let socket = Zmq.Socket.create zmq_context sock_type in - let () = + let () = try bind_or_connect socket addr with @@ -131,37 +131,64 @@ let () = Sys.set_signal Sys.sigint handler; - let new_thread req_or_sub addr_in addr_out = + let new_thread_req addr_in addr_out = let socket_in, socket_out = - match req_or_sub with - | REQ -> create_socket Zmq.Socket.router Zmq.Socket.bind addr_in, create_socket Zmq.Socket.dealer Zmq.Socket.connect addr_out - | SUB -> - create_socket Zmq.Socket.sub Zmq.Socket.connect addr_in, - create_socket Zmq.Socket.pub Zmq.Socket.bind addr_out in - if req_or_sub = SUB then - Zmq.Socket.subscribe socket_in ""; - - - let action_in = - match req_or_sub with - | REQ -> (fun () -> Zmq.Socket.recv_all socket_in |> Zmq.Socket.send_all socket_out) - | SUB -> (fun () -> Zmq.Socket.recv_all socket_in |> Zmq.Socket.send_all socket_out) + let action_in = + fun () -> Zmq.Socket.recv_all socket_in |> Zmq.Socket.send_all socket_out in - let action_out = - match req_or_sub with - | REQ -> (fun () -> Zmq.Socket.recv_all socket_out |> Zmq.Socket.send_all socket_in ) - | SUB -> (fun () -> () ) + let action_out = + fun () -> Zmq.Socket.recv_all socket_out |> Zmq.Socket.send_all socket_in in let pollitem = Zmq.Poll.mask_of - [| (socket_in, Zmq.Poll.In) ; (socket_out, Zmq.Poll.In) |] + [| (socket_convert socket_in, Zmq.Poll.In) ; (socket_convert socket_out, Zmq.Poll.In) |] + in + + while !run_status do + + let polling = + Zmq.Poll.poll ~timeout:1000 pollitem + in + + match polling with + | [| Some Zmq.Poll.In ; Some Zmq.Poll.In |] -> ( action_out () ; action_in () ) + | [| _ ; Some Zmq.Poll.In |] -> action_out () + | [| Some Zmq.Poll.In ; _ |] -> action_in () + | _ -> () + done; + + Zmq.Socket.close socket_in; + Zmq.Socket.close socket_out; + in + + let new_thread_sub addr_in addr_out = + let socket_in, socket_out = + create_socket Zmq.Socket.sub Zmq.Socket.connect addr_in, + create_socket Zmq.Socket.pub Zmq.Socket.bind addr_out + in + + Zmq.Socket.subscribe socket_in ""; + + + + let action_in = + fun () -> Zmq.Socket.recv_all socket_in |> Zmq.Socket.send_all socket_out + in + + let action_out = + fun () -> () + in + + let pollitem = + Zmq.Poll.mask_of + [| (socket_convert socket_in, Zmq.Poll.In) ; (socket_convert socket_out, Zmq.Poll.In) |] in @@ -173,8 +200,8 @@ let () = match polling with | [| Some Zmq.Poll.In ; Some Zmq.Poll.In |] -> ( action_out () ; action_in () ) - | [| _ ; Some Zmq.Poll.In |] -> action_out () - | [| Some Zmq.Poll.In ; _ |] -> action_in () + | [| _ ; Some Zmq.Poll.In |] -> action_out () + | [| Some Zmq.Poll.In ; _ |] -> action_in () | _ -> () done; @@ -193,8 +220,8 @@ let () = Printf.sprintf "tcp://*:%d" localport in - let f () = - new_thread REQ addr_in addr_out + let f () = + new_thread_req addr_in addr_out in (Thread.create f) () @@ -211,8 +238,8 @@ let () = Printf.sprintf "tcp://*:%d" (localport+2) in - let f () = - new_thread REQ addr_in addr_out + let f () = + new_thread_req addr_in addr_out in (Thread.create f) () in @@ -227,8 +254,8 @@ let () = Printf.sprintf "tcp://*:%d" (localport+1) in - let f () = - new_thread SUB addr_in addr_out + let f () = + new_thread_sub addr_in addr_out in (Thread.create f) () in @@ -236,7 +263,7 @@ let () = let input_thread = - let f () = + let f () = let addr_out = match arg with | EZFIO _ -> None @@ -248,22 +275,22 @@ let () = Printf.sprintf "tcp://*:%d" (localport+9) in - let socket_in = + let socket_in = create_socket Zmq.Socket.rep Zmq.Socket.bind addr_in in let socket_out = - match addr_out with + match addr_out with | Some addr_out -> Some ( create_socket Zmq.Socket.req Zmq.Socket.connect addr_out) | None -> None in - let temp_file = + let temp_file = Filename.temp_file "qp_tunnel" ".tar.gz" in - let get_ezfio_filename () = + let get_ezfio_filename () = match arg with | EZFIO x -> x | ADDRESS _ -> @@ -277,9 +304,9 @@ let () = end in - let get_input () = + let get_input () = match arg with - | EZFIO x -> + | EZFIO x -> begin Printf.sprintf "tar --exclude=\"*.gz.*\" -zcf %s %s" temp_file x |> Sys.command |> ignore; @@ -291,11 +318,11 @@ let () = in ignore @@ Unix.lseek fd 0 Unix.SEEK_SET ; let bstr = - Unix.map_file fd Bigarray.char + Unix.map_file fd Bigarray.char Bigarray.c_layout false [| len |] |> Bigarray.array1_of_genarray in - let result = + let result = String.init len (fun i -> bstr.{i}) ; in Unix.close fd; @@ -313,7 +340,7 @@ let () = end in - let () = + let () = match socket_out with | None -> () | Some socket_out -> @@ -329,7 +356,7 @@ let () = | ADDRESS _ -> begin Printf.printf "Getting input... %!"; - let ezfio_filename = + let ezfio_filename = get_ezfio_filename () in Printf.printf "%s%!" ezfio_filename; @@ -343,7 +370,7 @@ let () = |> Sys.command |> ignore ; let oc = Filename.concat (Qpackage.ezfio_work ezfio_filename) "qp_run_address" - |> open_out + |> open_out in Printf.fprintf oc "tcp://%s:%d\n" localhost localport; close_out oc; @@ -359,9 +386,9 @@ let () = let action () = match Zmq.Socket.recv socket_in with | "get_input" -> get_input () - |> Zmq.Socket.send socket_in + |> Zmq.Socket.send socket_in | "get_ezfio_filename" -> get_ezfio_filename () - |> Zmq.Socket.send socket_in + |> Zmq.Socket.send socket_in | "test" -> Zmq.Socket.send socket_in "OK" | x -> Printf.sprintf "Message '%s' not understood" x |> Zmq.Socket.send socket_in @@ -372,7 +399,7 @@ On remote hosts, create ssh tunnel using: ssh -L %d:%s:%d -L %d:%s:%d -L %d:%s:%d -L %d:%s:%d %s & Or from this host connect to clients using: ssh -R %d:localhost:%d -R %d:localhost:%d -R %d:localhost:%d -R %d:localhost:%d & -%!" +%!" (port ) localhost (localport ) (port+1) localhost (localport+1) (port+2) localhost (localport+2) @@ -392,12 +419,12 @@ Or from this host connect to clients using: match polling.(0) with | Some Zmq.Poll.In -> action () | None -> () - | Some Zmq.Poll.In_out + | Some Zmq.Poll.In_out | Some Zmq.Poll.Out -> () done; - let () = + let () = match socket_out with | Some socket_out -> Zmq.Socket.close socket_out | None -> () @@ -415,7 +442,7 @@ Or from this host connect to clients using: Thread.join ocaml_thread; Zmq.Context.terminate zmq_context; Printf.printf "qp_tunnel exited properly.\n" - + diff --git a/src/fci/40.fci.bats b/src/fci/40.fci.bats index 871de780..600217de 100644 --- a/src/fci/40.fci.bats +++ b/src/fci/40.fci.bats @@ -37,48 +37,48 @@ function run_stoch() { qp set_file b2_stretched.ezfio qp set determinants n_det_max 10000 qp set_frozen_core - run_stoch -49.14104086 0.0001 10000 + run_stoch -49.14097596 0.0001 10000 } @test "NH3" { # 0:00:11 qp set_file nh3.ezfio qp set_mo_class --core="[1-4]" --act="[5-72]" - run -56.24474790 1.e-5 10000 + run -56.24474908 1.e-5 10000 } @test "DHNO" { # 0:00:10 qp set_file dhno.ezfio qp set_mo_class --core="[1-7]" --act="[8-64]" - run -130.45901042 1.e-4 10000 + run -130.45904647 1.e-4 10000 } @test "HCO" { # 0:01:16 qp set_file hco.ezfio - run_stoch -113.41658256 2.e-3 50000 + run_stoch -113.41448940 2.e-3 50000 } @test "H2O2" { # 0:01:48 qp set_file h2o2.ezfio qp set_mo_class --core="[1-2]" --act="[3-24]" --del="[25-38]" - run_stoch -151.02317880 2.e-3 100000 + run_stoch -151.02437936 2.e-3 100000 } @test "HBO" { # 0:00:46 [[ -n $TRAVIS ]] && skip qp set_file hbo.ezfio - run_stoch -100.22361288 2.e-3 50000 + run_stoch -100.221198108988 2.e-3 50000 } @test "H2O" { # 0:01:05 [[ -n $TRAVIS ]] && skip qp set_file h2o.ezfio - run_stoch -76.24347962 1.e-4 100000 + run_stoch -76.241332121813 1.e-3 100000 } @test "ClO" { # 0:03:07 [[ -n $TRAVIS ]] && skip qp set_file clo.ezfio - run_stoch -534.58202840 1.e-3 100000 + run_stoch -534.573564655419 1.e-3 100000 } @test "SO" { # 0:01:49 diff --git a/src/iterations/print_extrapolation.irp.f b/src/iterations/print_extrapolation.irp.f index 7f602ffb..7c6dbb9b 100644 --- a/src/iterations/print_extrapolation.irp.f +++ b/src/iterations/print_extrapolation.irp.f @@ -41,7 +41,7 @@ subroutine print_extrapolated_energy enddo print *, '' - call ezfio_set_fci_energy_extrapolated(extrapolated_energy(2,1:N_states)) + call ezfio_set_fci_energy_extrapolated(extrapolated_energy(min(N_iter,3),1:N_states)) end subroutine diff --git a/tests/bats/common.bats.sh b/tests/bats/common.bats.sh index f6ea4023..802c0232 100644 --- a/tests/bats/common.bats.sh +++ b/tests/bats/common.bats.sh @@ -46,7 +46,7 @@ function test_exe() { run_only_test() { if [[ "$BATS_TEST_DESCRIPTION" != "$1" ]] && [[ "$BATS_TEST_NUMBER" != "$1" ]]; then - if [[ -z $BATS_TEST_FILENAME ]] ; then + if [[ -z "$BATS_TEST_FILENAME" ]] ; then exit 0 else skip From cea413b00a775bb08cafd33621a63f839432935e Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 8 Jun 2022 17:44:53 +0200 Subject: [PATCH 54/68] 3-point extrapolation in tests --- src/fci/40.fci.bats | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/fci/40.fci.bats b/src/fci/40.fci.bats index 600217de..ac34251f 100644 --- a/src/fci/40.fci.bats +++ b/src/fci/40.fci.bats @@ -90,99 +90,99 @@ function run_stoch() { @test "H2S" { # 0:01:12 [[ -n $TRAVIS ]] && skip qp set_file h2s.ezfio - run_stoch -398.87187312 1.e-3 50000 + run_stoch -398.865173546866 1.e-3 50000 } @test "OH" { # 0:00:41 [[ -n $TRAVIS ]] && skip qp set_file oh.ezfio - run_stoch -75.62393829 1.e-3 50000 + run_stoch -75.6193013819546 1.e-3 50000 } @test "SiH2_3B1" { # 0:00:50 [[ -n $TRAVIS ]] && skip qp set_file sih2_3b1.ezfio - run_stoch -290.02083172 3.e-5 50000 + run_stoch -290.01754869 3.e-5 50000 } @test "H3COH" { # 0:01:05 [[ -n $TRAVIS ]] && skip qp set_file h3coh.ezfio - run_stoch -115.22625460 2.e-3 50000 + run_stoch -115.224147057725 2.e-3 50000 } @test "SiH3" { # 0:01:09 [[ -n $TRAVIS ]] && skip qp set_file sih3.ezfio - run_stoch -5.57818759 1.e-3 50000 + run_stoch -5.57812512359276 1.e-3 50000 } @test "CH4" { # 0:02:06 [[ -n $TRAVIS ]] && skip qp set_file ch4.ezfio qp set_mo_class --core="[1]" --act="[2-30]" --del="[31-59]" - run_stoch -40.24195947 1.e-4 100000 + run_stoch -40.2419474611994 1.e-4 100000 } @test "ClF" { # 0:01:55 [[ -n $TRAVIS ]] && skip qp set_file clf.ezfio - run_stoch -559.20157348 1.e-3 50000 + run_stoch -559.20666465 1.e-2 50000 } @test "SO2" { # 0:00:24 [[ -n $TRAVIS ]] && skip qp set_file so2.ezfio qp set_mo_class --core="[1-8]" --act="[9-87]" - run_stoch -41.57468087 1.e-4 50000 + run_stoch -41.57468756 1.e-4 50000 } @test "C2H2" { # 0:00:57 [[ -n $TRAVIS ]] && skip qp set_file c2h2.ezfio qp set_mo_class --act="[1-30]" --del="[31-36]" - run_stoch -12.38655876 1.e-3 50000 + run_stoch -12.3862664765532 1.e-3 50000 } @test "N2" { # 0:01:15 [[ -n $TRAVIS ]] && skip qp set_file n2.ezfio qp set_mo_class --core="[1,2]" --act="[3-40]" --del="[41-60]" - run_stoch -109.31133266 2.e-3 50000 + run_stoch -109.311954243348 2.e-3 50000 } @test "N2H4" { # 0:00:51 [[ -n $TRAVIS ]] && skip qp set_file n2h4.ezfio qp set_mo_class --core="[1-2]" --act="[3-24]" --del="[25-48]" - run_stoch -111.38161063 1.e-3 50000 + run_stoch -111.38119165053 1.e-3 50000 } @test "CO2" { # 0:01:00 [[ -n $TRAVIS ]] && skip qp set_file co2.ezfio qp set_mo_class --core="[1,2]" --act="[3-30]" --del="[31-42]" - run_stoch -188.00154729 2.e-3 50000 + run_stoch -188.002190327443 2.e-3 50000 } @test "[Cu(NH3)4]2+" { # 0:01:53 [[ -n $TRAVIS ]] && skip qp set_file cu_nh3_4_2plus.ezfio qp set_mo_class --core="[1-24]" --act="[25-45]" --del="[46-87]" - run_stoch -1862.98705091 1.e-05 50000 + run_stoch -1862.98705340328 1.e-05 50000 } @test "HCN" { # 0:01:26 [[ -n $TRAVIS ]] && skip qp set_file hcn.ezfio qp set_mo_class --core="[1,2]" --act="[3-40]" --del="[41-55]" - run_stoch -93.09855896 5.e-4 50000 + run_stoch -93.0980746734051 5.e-4 50000 } @test "F2" { # 0:03:34 [[ -n $TRAVIS ]] && skip qp set_file f2.ezfio qp set_frozen_core - run_stoch -199.30821487 0.002 100000 + run_stoch -199.307512211742 0.002 100000 } From 389db7b4cb4532793733d141339bf9dc1322e31c Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 10 Jun 2022 12:11:08 +0200 Subject: [PATCH 55/68] Fixed max memory detection --- external/qp2-dependencies | 2 +- src/mo_two_e_ints/mo_bi_integrals.irp.f | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/external/qp2-dependencies b/external/qp2-dependencies index 242151e0..bc856147 160000 --- a/external/qp2-dependencies +++ b/external/qp2-dependencies @@ -1 +1 @@ -Subproject commit 242151e03d1d6bf042387226431d82d35845686a +Subproject commit bc856147f6e626a6616b20344e5b8e3f30f44a92 diff --git a/src/mo_two_e_ints/mo_bi_integrals.irp.f b/src/mo_two_e_ints/mo_bi_integrals.irp.f index c03b363d..6f4c5c17 100644 --- a/src/mo_two_e_ints/mo_bi_integrals.irp.f +++ b/src/mo_two_e_ints/mo_bi_integrals.irp.f @@ -53,7 +53,7 @@ BEGIN_PROVIDER [ logical, mo_two_e_integrals_in_map ] ! call four_idx_novvvv call four_idx_novvvv_old else - if (ao_num*ao_num*ao_num*ao_num*32.d-9 < dble(qp_max_mem)) then + if (32.d-9*dble(ao_num)**4 < dble(qp_max_mem)) then call four_idx_dgemm else call add_integrals_to_map(full_ijkl_bitmask_4) @@ -130,7 +130,6 @@ subroutine four_idx_dgemm real(integral_kind), allocatable :: buffer_value(:) size_buffer = min(ao_num*ao_num*ao_num,16000000) - print *, 'Storing' !$OMP PARALLEL DEFAULT(SHARED) PRIVATE(i,j,k,l,buffer_value,buffer_i,n_integrals) allocate ( buffer_i(size_buffer), buffer_value(size_buffer) ) @@ -164,7 +163,6 @@ subroutine four_idx_dgemm deallocate (a1) - print *, 'Unique' call map_unique(mo_integrals_map) integer*8 :: get_mo_map_size, mo_map_size From 31572fddc3b8de11008e214e29b602d9f0ff5c8d Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 10 Jun 2022 14:28:37 +0200 Subject: [PATCH 56/68] Prepared CFG H.Psi for Vijay --- src/davidson/diagonalize_ci.irp.f | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/davidson/diagonalize_ci.irp.f b/src/davidson/diagonalize_ci.irp.f index 46ad8f78..6930cc07 100644 --- a/src/davidson/diagonalize_ci.irp.f +++ b/src/davidson/diagonalize_ci.irp.f @@ -1,3 +1,13 @@ +BEGIN_PROVIDER [ character*(3), sigma_vector_algorithm ] + implicit none + BEGIN_DOC + ! If 'det', use in Davidson + ! + ! If 'cfg', use in Davidson + END_DOC + sigma_vector_algorithm = 'det' +END_PROVIDER + BEGIN_PROVIDER [ double precision, CI_energy, (N_states_diag) ] implicit none BEGIN_DOC @@ -61,9 +71,18 @@ END_PROVIDER if (diag_algorithm == "Davidson") then if (do_csf) then - call davidson_diag_H_csf(psi_det,CI_eigenvectors, & - size(CI_eigenvectors,1),CI_electronic_energy, & - N_det,N_csf,min(N_det,N_states),min(N_det,N_states_diag),N_int,0,converged) + if (sigma_vector_algorithm == 'det') then + call davidson_diag_H_csf(psi_det,CI_eigenvectors, & + size(CI_eigenvectors,1),CI_electronic_energy, & + N_det,N_csf,min(N_det,N_states),min(N_det,N_states_diag),N_int,0,converged) +! else if (sigma_vector_algorithm == 'cfg') then +! call davidson_diag_H_csf(psi_det,CI_eigenvectors, & +! size(CI_eigenvectors,1),CI_electronic_energy, & +! N_det,N_csf,min(N_det,N_states),min(N_det,N_states_diag),N_int,0,converged) +! else +! print *, irp_here +! stop 'bug' + endif else call davidson_diag_HS2(psi_det,CI_eigenvectors, CI_s2, & size(CI_eigenvectors,1),CI_electronic_energy, & From cc7943f3936a64dbe3ac9449d293a7144f793324 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 14 Jun 2022 16:19:14 +0200 Subject: [PATCH 57/68] Update qp2-dependencies --- external/qp2-dependencies | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/qp2-dependencies b/external/qp2-dependencies index bc856147..242151e0 160000 --- a/external/qp2-dependencies +++ b/external/qp2-dependencies @@ -1 +1 @@ -Subproject commit bc856147f6e626a6616b20344e5b8e3f30f44a92 +Subproject commit 242151e03d1d6bf042387226431d82d35845686a From f093592124457451eeb0b6817488b4591cf9295f Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 14 Jun 2022 18:10:32 +0200 Subject: [PATCH 58/68] Update guess in CISD --- src/cisd/cisd.irp.f | 37 ++++++++++++++++--- .../diagonalization_hcsf_dressed.irp.f | 19 +++------- src/determinants/determinants.irp.f | 4 +- 3 files changed, 38 insertions(+), 22 deletions(-) diff --git a/src/cisd/cisd.irp.f b/src/cisd/cisd.irp.f index 5f167686..3e1e8d97 100644 --- a/src/cisd/cisd.irp.f +++ b/src/cisd/cisd.irp.f @@ -47,6 +47,37 @@ program cisd PROVIDE N_states read_wf = .False. SOFT_TOUCH read_wf + + integer :: i,k + + if(pseudo_sym)then + call H_apply_cisd_sym + else + call H_apply_cisd + endif + double precision :: r1, r2 + double precision, allocatable :: U_csf(:,:) + + allocate(U_csf(N_csf,N_states)) + U_csf = 0.d0 + U_csf(1,1) = 1.d0 + do k=2,N_states + do i=1,N_csf + call random_number(r1) + call random_number(r2) + r1 = dsqrt(-2.d0*dlog(r1)) + r2 = dacos(-1.d0)*2.d0*r2 + U_csf(i,k) = r1*dcos(r2) + enddo + U_csf(k,k) = U_csf(k,k) +100.d0 + enddo + do k=1,N_states + call normalize(U_csf(1,k),N_csf) + enddo + call convertWFfromCSFtoDET(N_states,U_csf(1,1),psi_coef(1,1)) + deallocate(U_csf) + SOFT_TOUCH psi_coef + call run end @@ -56,13 +87,7 @@ subroutine run double precision :: cisdq(N_states), delta_e double precision,external :: diag_h_mat_elem - if(pseudo_sym)then - call H_apply_cisd_sym - else - call H_apply_cisd - endif psi_coef = ci_eigenvectors - SOFT_TOUCH psi_coef call save_wavefunction_truncated(save_threshold) call ezfio_set_cisd_energy(CI_energy) diff --git a/src/davidson/diagonalization_hcsf_dressed.irp.f b/src/davidson/diagonalization_hcsf_dressed.irp.f index 0c3c6f92..5f8aa4c9 100644 --- a/src/davidson/diagonalization_hcsf_dressed.irp.f +++ b/src/davidson/diagonalization_hcsf_dressed.irp.f @@ -263,29 +263,20 @@ subroutine davidson_diag_csf_hjj(dets_in,u_in,H_jj,energies,dim_in,sze,sze_csf,N ! =================== converged = .False. - + call convertWFfromDETtoCSF(N_st_diag,u_in(1,1),U_csf(1,1)) do k=N_st+1,N_st_diag - do i=1,sze + do i=1,sze_csf call random_number(r1) call random_number(r2) r1 = dsqrt(-2.d0*dlog(r1)) r2 = dtwo_pi*r2 - u_in(i,k) = r1*dcos(r2) * u_in(i,k-N_st) + U_csf(i,k) = r1*dcos(r2) * u_csf(i,k-N_st) enddo - u_in(k,k) = u_in(k,k) + 10.d0 + U_csf(k,k) = u_csf(k,k) + 10.d0 enddo do k=1,N_st_diag - call normalize(u_in(1,k),sze) + call normalize(U_csf(1,k),sze_csf) enddo - - do k=1,N_st_diag - do i=1,sze - U(i,k) = u_in(i,k) - enddo - enddo - - ! Make random verctors eigenstates of S2 - call convertWFfromDETtoCSF(N_st_diag,U(1,1),U_csf(1,1)) call convertWFfromCSFtoDET(N_st_diag,U_csf(1,1),U(1,1)) do while (.not.converged) diff --git a/src/determinants/determinants.irp.f b/src/determinants/determinants.irp.f index 4b317025..e1c14bfe 100644 --- a/src/determinants/determinants.irp.f +++ b/src/determinants/determinants.irp.f @@ -77,7 +77,7 @@ BEGIN_PROVIDER [ integer, psi_det_size ] END_DOC PROVIDE ezfio_filename logical :: exists - psi_det_size = 1 + psi_det_size = N_states PROVIDE mpi_master if (read_wf) then if (mpi_master) then @@ -85,7 +85,7 @@ BEGIN_PROVIDER [ integer, psi_det_size ] if (exists) then call ezfio_get_determinants_n_det(psi_det_size) else - psi_det_size = 1 + psi_det_size = N_states endif call write_int(6,psi_det_size,'Dimension of the psi arrays') endif From d11b7365cbd6c47718e84b908a5226dfb95d2f47 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 14 Jun 2022 18:15:53 +0200 Subject: [PATCH 59/68] Update itermax with CSF --- src/davidson/diagonalization_hcsf_dressed.irp.f | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/davidson/diagonalization_hcsf_dressed.irp.f b/src/davidson/diagonalization_hcsf_dressed.irp.f index 5f8aa4c9..7aaaa842 100644 --- a/src/davidson/diagonalization_hcsf_dressed.irp.f +++ b/src/davidson/diagonalization_hcsf_dressed.irp.f @@ -124,7 +124,7 @@ subroutine davidson_diag_csf_hjj(dets_in,u_in,H_jj,energies,dim_in,sze,sze_csf,N stop -1 endif - itermax = max(2,min(davidson_sze_max, sze/N_st_diag))+1 + itermax = max(2,min(davidson_sze_max, sze_csf/N_st_diag))+1 itertot = 0 if (state_following) then From bd719b72af00f249e14bb2718142f4026ae22cc4 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 16 Jun 2022 17:15:28 +0200 Subject: [PATCH 60/68] Update README.md New logo and European funding in readme --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b8141b88..24d6277e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Quantum Package 2.2 - + + [![DOI](https://zenodo.org/badge/167513335.svg)](https://zenodo.org/badge/latestdoi/167513335) @@ -44,9 +45,19 @@ https://arxiv.org/abs/1902.08154 # Credits +* [TREX Center of Excellence](https://trex-coe.eu) +* [ERC PTEROSOR](https://lcpq.github.io/PTEROSOR) * [CNRS](http://www.cnrs.fr) * [Laboratoire de Chimie et Physique Quantiques](http://lcpq.ups-tlse.fr) * [Laboratoire de Chimie Théorique](http://www.lct.jussieu.fr) * [Argonne Leadership Computing Facility](http://alcf.anl.gov) * [CALMIP](https://www.calmip.univ-toulouse.fr) + +------------------------------ + + + +[TREX: Targeting Real Chemical Accuracy at the Exascale](https://trex-coe.eu) project has received funding from the European Union’s Horizon 2020 - Research and Innovation program - under grant agreement no. 952165. The content of this document does not represent the opinion of the European Union, and the European Union is not responsible for any use that might be made of such content. + +[PTEROSOR](https://lcpq.github.io/PTEROSOR) project has received funding from the European Research Council (ERC) under the European Union’s Horizon 2020 research and innovation programme (Grant agreement No. 863481). From a0949cba45749d1e43a28273a1a9bdb05c2d1ab1 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sat, 18 Jun 2022 11:39:36 +0200 Subject: [PATCH 61/68] Better error handling on ocaml --- etc/qp.rc | 2 -- external/qp2-dependencies | 2 +- ocaml/Command_line.ml | 19 +++++++++++-------- ocaml/Command_line.mli | 2 ++ ocaml/qp_create_ezfio.ml | 11 ++++++++--- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/etc/qp.rc b/etc/qp.rc index c56661c7..064ca3f7 100644 --- a/etc/qp.rc +++ b/etc/qp.rc @@ -80,8 +80,6 @@ function qp() if [[ -d $NAME ]] ; then [[ -d $EZFIO_FILE ]] && ezfio unset_file ezfio set_file $NAME - else - qp_create_ezfio -h | more fi unset _ARGS ;; diff --git a/external/qp2-dependencies b/external/qp2-dependencies index 242151e0..90ee61f5 160000 --- a/external/qp2-dependencies +++ b/external/qp2-dependencies @@ -1 +1 @@ -Subproject commit 242151e03d1d6bf042387226431d82d35845686a +Subproject commit 90ee61f5041c7c94a0c605625a264860292813a0 diff --git a/ocaml/Command_line.ml b/ocaml/Command_line.ml index 1dd57892..602315c6 100644 --- a/ocaml/Command_line.ml +++ b/ocaml/Command_line.ml @@ -1,3 +1,5 @@ +exception Error of string + type short_opt = char type long_opt = string type optional = Mandatory | Optional @@ -181,15 +183,16 @@ let set_specs specs_in = Getopt.parse_cmdline cmd_specs (fun x -> anon_args := !anon_args @ [x]); if show_help () then - (help () ; exit 0); + help () + else + (* Check that all mandatory arguments are set *) + List.filter (fun x -> x.short <> ' ' && x.opt = Mandatory) !specs + |> List.iter (fun x -> + match get x.long with + | Some _ -> () + | None -> raise (Error ("--"^x.long^" option is missing.")) + ) - (* Check that all mandatory arguments are set *) - List.filter (fun x -> x.short <> ' ' && x.opt = Mandatory) !specs - |> List.iter (fun x -> - match get x.long with - | Some _ -> () - | None -> failwith ("Error: --"^x.long^" option is missing.") - ) ;; diff --git a/ocaml/Command_line.mli b/ocaml/Command_line.mli index 9f6e7022..5ad4ee08 100644 --- a/ocaml/Command_line.mli +++ b/ocaml/Command_line.mli @@ -59,6 +59,8 @@ let () = *) +exception Error of string + type short_opt = char type long_opt = string diff --git a/ocaml/qp_create_ezfio.ml b/ocaml/qp_create_ezfio.ml index be6c305b..4583b118 100644 --- a/ocaml/qp_create_ezfio.ml +++ b/ocaml/qp_create_ezfio.ml @@ -677,6 +677,7 @@ let run ?o b au c d m p cart xyz_file = let () = + try ( let open Command_line in begin @@ -734,7 +735,7 @@ If a file with the same name as the basis set exists, this file will be read. O let basis = match Command_line.get "basis" with - | None -> assert false + | None -> "" | Some x -> x in @@ -773,10 +774,14 @@ If a file with the same name as the basis set exists, this file will be read. O let xyz_filename = match Command_line.anon_args () with - | [x] -> x - | _ -> (Command_line.help () ; failwith "input file is missing") + | [] -> failwith "input file is missing" + | x::_ -> x in run ?o:output basis au charge dummy multiplicity pseudo cart xyz_filename + ) + with + | Failure txt -> Printf.eprintf "Fatal error: %s\n%!" txt + | Command_line.Error txt -> Printf.eprintf "Command line error: %s\n%!" txt From f1a9a223997fa521e681ece7ce043f626c82c341 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sat, 18 Jun 2022 15:54:59 +0200 Subject: [PATCH 62/68] Improved truncate_wf --- src/tools/truncate_wf.irp.f | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/tools/truncate_wf.irp.f b/src/tools/truncate_wf.irp.f index 6c66c8ec..64c15bf7 100644 --- a/src/tools/truncate_wf.irp.f +++ b/src/tools/truncate_wf.irp.f @@ -54,11 +54,23 @@ subroutine routine_s2 double precision, allocatable :: psi_coef_tmp(:,:) integer :: i,j,k double precision :: accu(N_states) + integer :: weights(0:16), ix + double precision :: x - print *, 'Weights of the CFG' + weights(:) = 0 do i=1,N_det - print *, i, real(weight_configuration(det_to_configuration(i),:)), real(sum(weight_configuration(det_to_configuration(i),:))) + x = -dlog(1.d-32+sum(weight_configuration(det_to_configuration(i),:)))/dlog(10.d0) + ix = min(int(x), 16) + weights(ix) += 1 enddo + + print *, 'Histogram of the weights of the CFG' + do i=0,15 + print *, ' 10^{-', i, '} ', weights(i) + end do + print *, '< 10^{-', 15, '} ', weights(16) + + print*, 'Min weight of the configuration?' read(5,*) wmin From 0407def6782badc884946023753ba49196f0152d Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 22 Jun 2022 23:19:18 +0200 Subject: [PATCH 63/68] dummy args in ocaml --- external/qp2-dependencies | 2 +- ocaml/Molecule.ml | 4 ++-- ocaml/qp_run.ml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/external/qp2-dependencies b/external/qp2-dependencies index 90ee61f5..242151e0 160000 --- a/external/qp2-dependencies +++ b/external/qp2-dependencies @@ -1 +1 @@ -Subproject commit 90ee61f5041c7c94a0c605625a264860292813a0 +Subproject commit 242151e03d1d6bf042387226431d82d35845686a diff --git a/ocaml/Molecule.ml b/ocaml/Molecule.ml index 9b01ac3a..603244c8 100644 --- a/ocaml/Molecule.ml +++ b/ocaml/Molecule.ml @@ -101,7 +101,7 @@ let to_string_general ~f m = |> String.concat "\n" let to_string = - to_string_general ~f:(fun x -> Atom.to_string Units.Angstrom x) + to_string_general ~f:(fun x -> Atom.to_string ~units:Units.Angstrom x) let to_xyz = to_string_general ~f:Atom.to_xyz @@ -113,7 +113,7 @@ let of_xyz_string s = let l = String_ext.split s ~on:'\n' |> List.filter (fun x -> x <> "") - |> list_map (fun x -> Atom.of_string units x) + |> list_map (fun x -> Atom.of_string ~units x) in let ne = ( get_charge { nuclei=l ; diff --git a/ocaml/qp_run.ml b/ocaml/qp_run.ml index d096b15b..dfbab167 100644 --- a/ocaml/qp_run.ml +++ b/ocaml/qp_run.ml @@ -110,7 +110,7 @@ let run slave ?prefix exe ezfio_file = let task_thread = let thread = Thread.create ( fun () -> - TaskServer.run port_number ) + TaskServer.run ~port:port_number ) in thread (); in From f629fc993e05222e3e97674c51f39fa34f2b204c Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 29 Jun 2022 15:25:19 +0200 Subject: [PATCH 64/68] Fix normf=1 problem with gamess conversion --- bin/qp_convert_output_to_ezfio | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/qp_convert_output_to_ezfio b/bin/qp_convert_output_to_ezfio index 07ad2236..4c440dd9 100755 --- a/bin/qp_convert_output_to_ezfio +++ b/bin/qp_convert_output_to_ezfio @@ -146,6 +146,7 @@ def write_ezfio(res, filename): ezfio.set_ao_basis_ao_nucl(at) ezfio.set_ao_basis_ao_prim_num(num_prim) ezfio.set_ao_basis_ao_power(power_x + power_y + power_z) + ezfio.set_ao_basis_ao_normalized(False) # ~#~#~#~#~#~#~ # # P a r s i n g # From b1c91c205b98a2ea36c44d1870e4ef2e4206af95 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 29 Jun 2022 15:38:03 +0200 Subject: [PATCH 65/68] Better handling of normf=1 --- bin/qp_convert_output_to_ezfio | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/qp_convert_output_to_ezfio b/bin/qp_convert_output_to_ezfio index 4c440dd9..a6bbcf85 100755 --- a/bin/qp_convert_output_to_ezfio +++ b/bin/qp_convert_output_to_ezfio @@ -146,7 +146,13 @@ def write_ezfio(res, filename): ezfio.set_ao_basis_ao_nucl(at) ezfio.set_ao_basis_ao_prim_num(num_prim) ezfio.set_ao_basis_ao_power(power_x + power_y + power_z) - ezfio.set_ao_basis_ao_normalized(False) + try: + if res.normf == 0: + ezfio.set_ao_basis_ao_normalized(True) + elif res.normf == 1: + ezfio.set_ao_basis_ao_normalized(False) + except: + ezfio.set_ao_basis_ao_normalized(True) # ~#~#~#~#~#~#~ # # P a r s i n g # From 0e6ebdc5a2f806297bdb8eb6cc46d901ed4a7167 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 29 Jun 2022 15:43:35 +0200 Subject: [PATCH 66/68] Better handling of normf=1 --- bin/qp_convert_output_to_ezfio | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/qp_convert_output_to_ezfio b/bin/qp_convert_output_to_ezfio index a6bbcf85..e7c44b37 100755 --- a/bin/qp_convert_output_to_ezfio +++ b/bin/qp_convert_output_to_ezfio @@ -147,11 +147,15 @@ def write_ezfio(res, filename): ezfio.set_ao_basis_ao_prim_num(num_prim) ezfio.set_ao_basis_ao_power(power_x + power_y + power_z) try: - if res.normf == 0: + normf = res.normf + if normf == 0: ezfio.set_ao_basis_ao_normalized(True) - elif res.normf == 1: + elif normf == 1: ezfio.set_ao_basis_ao_normalized(False) - except: + else: + print("BUG in NORMF") + sys.exit(0) + except AttributeError: ezfio.set_ao_basis_ao_normalized(True) # ~#~#~#~#~#~#~ # From a6ffaa7da148bd24313112425507fe68bc4d0a6a Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 21 Apr 2022 13:39:01 +0200 Subject: [PATCH 67/68] Update test values --- src/fci/40.fci.bats | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/fci/40.fci.bats b/src/fci/40.fci.bats index 1a0c5507..b8528e97 100644 --- a/src/fci/40.fci.bats +++ b/src/fci/40.fci.bats @@ -71,7 +71,7 @@ function run_stoch() { @test "HBO" { # 13.3144s [[ -n $TRAVIS ]] && skip qp set_file hbo.ezfio - run -100.214099486337 1.e-3 100000 + run -100.213 1.e-3 100000 } @test "H2O" { # 11.3727s @@ -89,7 +89,7 @@ function run_stoch() { @test "SO" { # 13.4952s [[ -n $TRAVIS ]] && skip qp set_file so.ezfio - run -26.0176563764039 1.e-3 100000 + run -26.014 5.e-3 100000 } @test "H2S" { # 13.6745s @@ -119,7 +119,7 @@ function run_stoch() { @test "SiH3" { # 15.99s [[ -n $TRAVIS ]] && skip qp set_file sih3.ezfio - run -5.57241217753818 5.e-4 100000 + run -5.572 1.e-3 100000 } @test "CH4" { # 16.1612s @@ -153,7 +153,7 @@ function run_stoch() { [[ -n $TRAVIS ]] && skip qp set_file n2.ezfio qp set_mo_class --core="[1,2]" --act="[3-40]" --del="[41-60]" - run -109.287917088107 1.5e-3 100000 + run -109.288 2.e-3 100000 } @test "N2H4" { # 18.5006s From d2c40fc1cb3afa6c22a0ef05eb16f25abf8b631f Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 21 Apr 2022 13:42:10 +0200 Subject: [PATCH 68/68] Update test values --- src/fci/40.fci.bats | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/fci/40.fci.bats b/src/fci/40.fci.bats index b8528e97..d890d586 100644 --- a/src/fci/40.fci.bats +++ b/src/fci/40.fci.bats @@ -42,7 +42,7 @@ function run_stoch() { [[ -n $TRAVIS ]] && skip qp set_file f2.ezfio qp set_frozen_core - run_stoch -199.304922384814 3.e-4 100000 + run_stoch -199.304922384814 3.e-3 100000 } @test "NH3" { # 10.6657s @@ -89,7 +89,7 @@ function run_stoch() { @test "SO" { # 13.4952s [[ -n $TRAVIS ]] && skip qp set_file so.ezfio - run -26.014 5.e-3 100000 + run -26.015 3.e-3 100000 } @test "H2S" { # 13.6745s @@ -146,7 +146,7 @@ function run_stoch() { [[ -n $TRAVIS ]] && skip qp set_file c2h2.ezfio qp set_mo_class --act="[1-30]" --del="[31-36]" - run -12.3685464085969 2.e-3 100000 + run -12.367 3.e-3 100000 } @test "N2" { # 18.0198s @@ -182,6 +182,6 @@ function run_stoch() { [[ -n $TRAVIS ]] && skip qp set_file hcn.ezfio qp set_mo_class --core="[1,2]" --act="[3-40]" --del="[41-55]" - run -93.0777619629755 1.e-3 100000 + run -93.078 2.e-3 100000 }