9
1
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-11-07 05:53:37 +01:00

Saving MOs in TREXIO format
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Anthony Scemama 2022-07-01 12:40:36 +02:00
parent 6fd5cd08b6
commit 8a08cfc33b
10 changed files with 225 additions and 217 deletions

1
configure vendored
View File

@ -204,6 +204,7 @@ EOF
cd trexio-${VERSION} cd trexio-${VERSION}
./configure --prefix=\${QP_ROOT} ./configure --prefix=\${QP_ROOT}
make -j 8 && make -j 8 check && make -j 8 install make -j 8 && make -j 8 check && make -j 8 install
cp ${QP_ROOT}/include/trexio_f.f90 ${QP_ROOT}/src/ezfio_files
EOF EOF
elif [[ ${PACKAGE} = gmp ]] ; then elif [[ ${PACKAGE} = gmp ]] ; then

View File

@ -40,7 +40,7 @@ from qp_path import QP_ROOT, QP_SRC, QP_EZFIO
LIB = " -lz" LIB = " -lz"
EZFIO_LIB = join("$QP_ROOT", "lib", "libezfio_irp.a") EZFIO_LIB = join("$QP_ROOT", "lib", "libezfio_irp.a")
ZMQ_LIB = join("$QP_ROOT", "lib", "libf77zmq.a") + " " + join("$QP_ROOT", "lib", "libzmq.a") + " -lstdc++ -lrt -ldl" ZMQ_LIB = join("$QP_ROOT", "lib", "libf77zmq.a") + " " + join("$QP_ROOT", "lib", "libzmq.a") + " -ltrexio -lstdc++ -lrt -ldl"
ROOT_BUILD_NINJA = join("$QP_ROOT", "config", "build.ninja") ROOT_BUILD_NINJA = join("$QP_ROOT", "config", "build.ninja")
ROOT_BUILD_NINJA_EXP = join(QP_ROOT, "config", "build.ninja") ROOT_BUILD_NINJA_EXP = join(QP_ROOT, "config", "build.ninja")
ROOT_BUILD_NINJA_EXP_tmp = join(QP_ROOT, "config", "build.ninja.tmp") ROOT_BUILD_NINJA_EXP_tmp = join(QP_ROOT, "config", "build.ninja.tmp")

View File

@ -1,45 +0,0 @@
#!/bin/bash
# This script is used by the MOs module, and should not be used by users.
# It copies the EZFIO/mo_basis directory in the save/EZFIO/mo_basis/xxx
# directory, where xxx is the corresponding mo_label.
# Wed Apr 2 14:35:15 CEST 2014
if [[ -z ${QP_ROOT} ]] ; then
print "The QP_ROOT environment variable is not set."
print "Please reload the quantum_package.rc file."
exit -1
fi
EZFIO="$1"
if [[ -z "${EZFIO}" ]] ; then
echo "Error in $0"
exit 1
fi
if [[ ! -f "${EZFIO}/mo_basis/mo_label" ]] ; then
LABEL='no_label'
else
LABEL=$(head -1 "${EZFIO}/mo_basis/mo_label" | xargs) #xargs trims the result
fi
DESTINATION="save/mo_basis/${LABEL}"
cd "${EZFIO}"
if [[ ! -d save/mo_basis ]] ; then
mkdir -p save/mo_basis
fi
BACKUP="${DESTINATION}.old"
if [[ -d "${BACKUP}" ]] ; then
rm -rf "${BACKUP}"
fi
if [[ -d "${DESTINATION}" ]] ; then
mv "${DESTINATION}" "${BACKUP}"
fi
cp -r mo_basis "${DESTINATION}"

View File

@ -1,48 +0,0 @@
ao_basis
ao_one_e_ints
ao_two_e_erf_ints
ao_two_e_ints
aux_quantities
becke_numerical_grid
bitmask
cipsi
cis
cisd
davidson
davidson_dressed
davidson_undressed
density_for_dft
determinants
dft_keywords
dft_utils_in_r
dft_utils_func
dressing
electrons
ezfio_files
fci
functionals
generators_cas
generators_full
hartree_fock
iterations
kohn_sham
kohn_sham_rs
mo_basis
mo_guess
mo_one_e_ints
mo_two_e_erf_ints
mo_two_e_ints
mpi
nuclei
perturbation
pseudo
psiref_cas
psiref_utils
scf_utils
selectors_cassd
selectors_full
selectors_utils
single_ref_method
tools
utils
zmq

View File

@ -1,6 +0,0 @@
=====
dummy
=====
Module necessary to avoid the ``xxx is a root module but does not contain a main file`` message.

View File

@ -1,7 +0,0 @@
program dummy
implicit none
BEGIN_DOC
! Dummy test file
END_DOC
print *, 'OK'
end

View File

@ -1,7 +1,4 @@
! DO NOT MODIFY BY HAND use trexio
! Created by $QP_ROOT/scripts/ezfio_interface/ei_handler.py
! from file /home/eginer/programs/qp2/src/mo_basis/EZFIO.cfg
BEGIN_PROVIDER [ character*(32), mo_class , (mo_num) ] BEGIN_PROVIDER [ character*(32), mo_class , (mo_num) ]
implicit none implicit none
@ -10,16 +7,27 @@ BEGIN_PROVIDER [ character*(32), mo_class , (mo_num) ]
END_DOC END_DOC
logical :: has logical :: has
PROVIDE ezfio_filename integer(trexio_exit_code) :: rc
PROVIDE ezfio_filename trexio_file
mo_class(:) = 'Active'
if (mpi_master) then if (mpi_master) then
if (size(mo_class) == 0) return if (size(mo_class) == 0) return
call ezfio_has_mo_basis_mo_class(has) if (use_trexio) then
if (has) then rc = trexio_has_mo_class(trexio_file)
write(6,'(A)') '.. >>>>> [ IO READ: mo_class ] <<<<< ..' if (rc == TREXIO_SUCCESS) then
call ezfio_get_mo_basis_mo_class(mo_class) rc = trexio_read_mo_class(trexio_file, mo_class, len(mo_class(1)))
call trexio_assert(rc, TREXIO_SUCCESS)
endif
else else
mo_class(:) = 'Active' call ezfio_has_mo_basis_mo_class(has)
if (has) then
write(6,'(A)') '.. >>>>> [ IO READ: mo_class ] <<<<< ..'
call ezfio_get_mo_basis_mo_class(mo_class)
endif
endif endif
endif endif
IRP_IF MPI_DEBUG IRP_IF MPI_DEBUG

View File

@ -1,3 +1,4 @@
use trexio
BEGIN_PROVIDER [ integer, mo_num ] BEGIN_PROVIDER [ integer, mo_num ]
implicit none implicit none
BEGIN_DOC BEGIN_DOC
@ -5,37 +6,51 @@ BEGIN_PROVIDER [ integer, mo_num ]
END_DOC END_DOC
logical :: has logical :: has
PROVIDE ezfio_filename integer :: ierr
integer(trexio_exit_code) :: rc
PROVIDE ezfio_filename trexio_file
if (mpi_master) then if (mpi_master) then
call ezfio_has_mo_basis_mo_num(has) if (use_trexio) then
endif rc = trexio_has_mo_num(trexio_file)
IRP_IF MPI_DEBUG has = (rc == TREXIO_SUCCESS)
print *, irp_here, mpi_rank else
call MPI_BARRIER(MPI_COMM_WORLD, ierr) call ezfio_has_mo_basis_mo_num(has)
IRP_ENDIF
IRP_IF MPI
include 'mpif.h'
integer :: ierr
call MPI_BCAST( has, 1, MPI_LOGICAL, 0, MPI_COMM_WORLD, ierr)
if (ierr /= MPI_SUCCESS) then
stop 'Unable to read mo_num with MPI'
endif
IRP_ENDIF
if (.not.has) then
mo_num = ao_ortho_canonical_num
else
if (mpi_master) then
call ezfio_get_mo_basis_mo_num(mo_num)
endif endif
IRP_IF MPI_DEBUG
print *, irp_here, mpi_rank
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
IRP_ENDIF
IRP_IF MPI IRP_IF MPI
call MPI_BCAST( mo_num, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr) include 'mpif.h'
call MPI_BCAST( has, 1, MPI_LOGICAL, 0, MPI_COMM_WORLD, ierr)
if (ierr /= MPI_SUCCESS) then if (ierr /= MPI_SUCCESS) then
stop 'Unable to read mo_num with MPI' stop 'Unable to read mo_num with MPI'
endif endif
IRP_ENDIF IRP_ENDIF
if (.not.has) then
mo_num = ao_ortho_canonical_num
else
if (mpi_master) then
if (use_trexio) then
rc = trexio_read_mo_num(trexio_file, mo_num)
call trexio_assert(rc, TREXIO_SUCCESS)
else
call ezfio_get_mo_basis_mo_num(mo_num)
endif
endif
IRP_IF MPI
call MPI_BCAST( mo_num, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
if (ierr /= MPI_SUCCESS) then
stop 'Unable to read mo_num with MPI'
endif
IRP_ENDIF
endif
call write_int(6,mo_num,'mo_num')
ASSERT (mo_num > 0)
endif endif
call write_int(6,mo_num,'mo_num')
ASSERT (mo_num > 0)
END_PROVIDER END_PROVIDER
@ -52,12 +67,16 @@ BEGIN_PROVIDER [ double precision, mo_coef, (ao_num,mo_num) ]
integer :: i, j integer :: i, j
double precision, allocatable :: buffer(:,:) double precision, allocatable :: buffer(:,:)
logical :: exists logical :: exists
PROVIDE ezfio_filename integer(trexio_exit_code) :: rc
PROVIDE ezfio_filename trexio_file
if (mpi_master) then if (mpi_master) then
! Coefs if (use_trexio) then
call ezfio_has_mo_basis_mo_coef(exists) rc = trexio_has_mo_coefficient(trexio_file)
exists = (rc == TREXIO_SUCCESS)
else
call ezfio_has_mo_basis_mo_coef(exists)
endif
endif endif
IRP_IF MPI_DEBUG IRP_IF MPI_DEBUG
print *, irp_here, mpi_rank print *, irp_here, mpi_rank
@ -74,7 +93,12 @@ BEGIN_PROVIDER [ double precision, mo_coef, (ao_num,mo_num) ]
if (exists) then if (exists) then
if (mpi_master) then if (mpi_master) then
call ezfio_get_mo_basis_mo_coef(mo_coef) if (use_trexio) then
rc = trexio_read_mo_coefficient(trexio_file, mo_coef)
call trexio_assert(rc, TREXIO_SUCCESS)
else
call ezfio_get_mo_basis_mo_coef(mo_coef)
endif
write(*,*) 'Read mo_coef' write(*,*) 'Read mo_coef'
endif endif
IRP_IF MPI IRP_IF MPI
@ -105,12 +129,16 @@ BEGIN_PROVIDER [ double precision, mo_coef_imag, (ao_num,mo_num) ]
integer :: i, j integer :: i, j
double precision, allocatable :: buffer(:,:) double precision, allocatable :: buffer(:,:)
logical :: exists logical :: exists
integer(trexio_exit_code) :: rc
PROVIDE ezfio_filename PROVIDE ezfio_filename
if (mpi_master) then if (mpi_master) then
! Coefs if (use_trexio) then
call ezfio_has_mo_basis_mo_coef_imag(exists) rc = trexio_has_mo_coefficient_im(trexio_file)
exists = (rc == TREXIO_SUCCESS)
else
call ezfio_has_mo_basis_mo_coef_imag(exists)
endif
endif endif
IRP_IF MPI_DEBUG IRP_IF MPI_DEBUG
print *, irp_here, mpi_rank print *, irp_here, mpi_rank
@ -127,7 +155,12 @@ BEGIN_PROVIDER [ double precision, mo_coef_imag, (ao_num,mo_num) ]
if (exists) then if (exists) then
if (mpi_master) then if (mpi_master) then
call ezfio_get_mo_basis_mo_coef_imag(mo_coef_imag) if (use_trexio) then
rc = trexio_read_mo_coefficient_im(trexio_file, mo_coef_imag)
call trexio_assert(rc, TREXIO_SUCCESS)
else
call ezfio_get_mo_basis_mo_coef_imag(mo_coef_imag)
endif
write(*,*) 'Read mo_coef_imag' write(*,*) 'Read mo_coef_imag'
endif endif
IRP_IF MPI IRP_IF MPI
@ -171,14 +204,27 @@ BEGIN_PROVIDER [ character*(64), mo_label ]
END_DOC END_DOC
logical :: exists logical :: exists
integer(trexio_exit_code) :: rc
PROVIDE ezfio_filename PROVIDE ezfio_filename
if (mpi_master) then if (mpi_master) then
call ezfio_has_mo_basis_mo_label(exists) if (use_trexio) then
if (exists) then rc = trexio_has_mo_type(trexio_file)
call ezfio_get_mo_basis_mo_label(mo_label) if (rc == TREXIO_SUCCESS) then
mo_label = trim(mo_label) rc = trexio_read_mo_type(trexio_file, mo_label, 64)
call trexio_assert(rc, TREXIO_SUCCESS)
mo_label = trim(mo_label)
else
mo_label = 'no_label'
endif
else else
mo_label = 'no_label' call ezfio_has_mo_basis_mo_label(exists)
if (exists) then
call ezfio_get_mo_basis_mo_label(mo_label)
mo_label = trim(mo_label)
else
mo_label = 'no_label'
endif
endif endif
write(*,*) '* mo_label ', trim(mo_label) write(*,*) '* mo_label ', trim(mo_label)
endif endif
@ -218,23 +264,34 @@ BEGIN_PROVIDER [ double precision, mo_occ, (mo_num) ]
BEGIN_DOC BEGIN_DOC
! |MO| occupation numbers ! |MO| occupation numbers
END_DOC END_DOC
integer(trexio_exit_code) :: rc
PROVIDE ezfio_filename elec_beta_num elec_alpha_num PROVIDE ezfio_filename elec_beta_num elec_alpha_num
mo_occ = 0.d0
integer :: i
do i=1,elec_beta_num
mo_occ(i) = 2.d0
enddo
do i=elec_beta_num+1,elec_alpha_num
mo_occ(i) = 1.d0
enddo
if (mpi_master) then if (mpi_master) then
logical :: exists if (use_trexio) then
call ezfio_has_mo_basis_mo_occ(exists) rc = trexio_has_mo_occupation(trexio_file)
if (exists) then if (rc == TREXIO_SUCCESS) then
call ezfio_get_mo_basis_mo_occ(mo_occ) rc = trexio_read_mo_occupation(trexio_file, mo_occ)
call trexio_assert(rc, TREXIO_SUCCESS)
write(*,*) 'Read mo_occ'
endif
else else
mo_occ = 0.d0 logical :: exists
integer :: i call ezfio_has_mo_basis_mo_occ(exists)
do i=1,elec_beta_num if (exists) then
mo_occ(i) = 2.d0 call ezfio_get_mo_basis_mo_occ(mo_occ)
enddo write(*,*) 'Read mo_occ'
do i=elec_beta_num+1,elec_alpha_num endif
mo_occ(i) = 1.d0
enddo
endif endif
write(*,*) 'Read mo_occ'
endif endif
IRP_IF MPI_DEBUG IRP_IF MPI_DEBUG
print *, irp_here, mpi_rank print *, irp_here, mpi_rank

View File

@ -1,58 +1,21 @@
subroutine save_mos subroutine save_mos
implicit none implicit none
double precision, allocatable :: buffer(:,:) BEGIN_DOC
integer :: i,j ! Write MO data to disk
END_DOC
call system('$QP_ROOT/scripts/save_current_mos.sh '//trim(ezfio_filename)) call save_mos_truncated(mo_num)
call ezfio_set_mo_basis_mo_num(mo_num)
call ezfio_set_mo_basis_mo_label(mo_label)
call ezfio_set_mo_basis_ao_md5(ao_md5)
allocate ( buffer(ao_num,mo_num) )
buffer = 0.d0
do j = 1, mo_num
do i = 1, ao_num
buffer(i,j) = mo_coef(i,j)
enddo
enddo
call ezfio_set_mo_basis_mo_coef(buffer)
call ezfio_set_mo_basis_mo_occ(mo_occ)
call ezfio_set_mo_basis_mo_class(mo_class)
deallocate (buffer)
end
subroutine save_mos_no_occ
implicit none
double precision, allocatable :: buffer(:,:)
integer :: i,j
call system('$QP_ROOT/scripts/save_current_mos.sh '//trim(ezfio_filename))
!call ezfio_set_mo_basis_mo_num(mo_num)
!call ezfio_set_mo_basis_mo_label(mo_label)
!call ezfio_set_mo_basis_ao_md5(ao_md5)
allocate ( buffer(ao_num,mo_num) )
buffer = 0.d0
do j = 1, mo_num
do i = 1, ao_num
buffer(i,j) = mo_coef(i,j)
enddo
enddo
call ezfio_set_mo_basis_mo_coef(buffer)
deallocate (buffer)
end end
subroutine save_mos_truncated(n) subroutine save_mos_truncated(n)
use trexio
implicit none implicit none
BEGIN_DOC
! Saves the first n MOs
END_DOC
integer, intent(in) :: n
double precision, allocatable :: buffer(:,:) double precision, allocatable :: buffer(:,:)
integer :: i,j,n integer :: i,j
call system('$QP_ROOT/scripts/save_current_mos.sh '//trim(ezfio_filename))
call ezfio_set_mo_basis_mo_num(n)
call ezfio_set_mo_basis_mo_label(mo_label)
call ezfio_set_mo_basis_ao_md5(ao_md5)
allocate ( buffer(ao_num,n) ) allocate ( buffer(ao_num,n) )
buffer = 0.d0 buffer = 0.d0
do j = 1, n do j = 1, n
@ -60,13 +23,97 @@ subroutine save_mos_truncated(n)
buffer(i,j) = mo_coef(i,j) buffer(i,j) = mo_coef(i,j)
enddo enddo
enddo enddo
call ezfio_set_mo_basis_mo_coef(buffer) if (use_trexio) then
call ezfio_set_mo_basis_mo_occ(mo_occ) integer (trexio_exit_code) :: rc
call ezfio_set_mo_basis_mo_class(mo_class)
rc = trexio_has_ao_num(trexio_file)
if (rc == TREXIO_HAS_NOT) then
rc = trexio_write_ao_num(trexio_file, ao_num)
call trexio_assert(rc, TREXIO_SUCCESS)
endif
rc = trexio_write_mo_num(trexio_file, n)
call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_mo_type(trexio_file, mo_label, len(trim(mo_label)))
call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_mo_occupation(trexio_file, mo_occ)
call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_mo_class(trexio_file, mo_class, len(mo_class(1)))
call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_mo_coefficient(trexio_file, buffer)
call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_close(trexio_file)
call trexio_assert(rc, TREXIO_SUCCESS)
FREE trexio_file
else
call ezfio_set_mo_basis_mo_num(n)
call ezfio_set_mo_basis_mo_label(mo_label(1:n))
call ezfio_set_mo_basis_mo_occ(mo_occ(1:n))
call ezfio_set_mo_basis_mo_class(mo_class(1:n))
call ezfio_set_mo_basis_mo_coef(buffer)
endif
call ezfio_set_mo_basis_ao_md5(ao_md5)
deallocate (buffer) deallocate (buffer)
end end
subroutine save_mo_coef
use trexio
implicit none
BEGIN_DOC
! Saves the MO coefficients
END_DOC
double precision, allocatable :: buffer(:,:)
integer :: i,j
allocate ( buffer(ao_num,mo_num) )
buffer = 0.d0
do j = 1, mo_num
do i = 1, ao_num
buffer(i,j) = mo_coef(i,j)
enddo
enddo
if (use_trexio) then
integer (trexio_exit_code) :: rc
rc = trexio_has_ao_num(trexio_file)
if (rc == TREXIO_HAS_NOT) then
rc = trexio_write_ao_num(trexio_file, ao_num)
call trexio_assert(rc, TREXIO_SUCCESS)
endif
rc = trexio_has_mo_num(trexio_file)
if (rc == TREXIO_HAS_NOT) then
rc = trexio_write_mo_num(trexio_file, mo_num)
call trexio_assert(rc, TREXIO_SUCCESS)
endif
rc = trexio_write_mo_coefficient(trexio_file, buffer)
call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_close(trexio_file)
call trexio_assert(rc, TREXIO_SUCCESS)
FREE trexio_file
else
call ezfio_set_mo_basis_mo_coef(buffer)
endif
deallocate (buffer)
end
subroutine save_mos_no_occ
call save_mo_coef
end
subroutine mo_as_eigvectors_of_mo_matrix(matrix,n,m,label,sign,output) subroutine mo_as_eigvectors_of_mo_matrix(matrix,n,m,label,sign,output)
implicit none implicit none
integer,intent(in) :: n,m, sign integer,intent(in) :: n,m, sign

View File

@ -3,3 +3,4 @@ type: logical
doc: If true, try to find symmetry in the MO coefficient matrices doc: If true, try to find symmetry in the MO coefficient matrices
interface: ezfio,provider,ocaml interface: ezfio,provider,ocaml
default: False default: False