mirror of
https://github.com/TREX-CoE/Sherman-Morrison.git
synced 2024-11-03 20:54:08 +01:00
Added QMCChem test dataset with 3 updates. Renamed files, added the Fortran program QMCChem_dataset_test.f90 to start testing the QMCChem dataset. Wrote and tested Fortran code to import the test dataset.
This commit is contained in:
parent
1983b7883f
commit
1b3a1d9d22
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,5 +1,7 @@
|
||||
*.o
|
||||
*.mod
|
||||
cppSherman-Morrison
|
||||
fSherman-Morrison
|
||||
.vscode
|
||||
cMaponiA3_test
|
||||
fMaponiA3_test
|
||||
QMCChem_dataset_test
|
||||
|
||||
|
41
Makefile
41
Makefile
@ -7,38 +7,47 @@ CXXFLAGS = -O0 #-debug full -traceback
|
||||
FFLAGS = -O0 #-debug full -traceback
|
||||
# ARCH = -xCORE-AVX2
|
||||
|
||||
## Deps & objs for the C++ stuff
|
||||
cppDEPS = cppmain.cpp SM_MaponiA3.cpp SM_MaponiA3.hpp Helpers.hpp
|
||||
cppOBJ = cppmain.o SM_MaponiA3.o
|
||||
## Deps & objs for C++ cMaponiA3_test
|
||||
cMaponiA3_testDEP = cMaponiA3_test.cpp SM_MaponiA3.cpp SM_MaponiA3.hpp Helpers.hpp
|
||||
cMaponiA3_testOBJ = cMaponiA3_test.o SM_MaponiA3.o
|
||||
|
||||
## Deps & objs for the Fortran stuff
|
||||
fDEPS = fmain.f90 SM_MaponiA3_mod.f90
|
||||
fOBJ = SM_MaponiA3.o SM_MaponiA3_mod.o fmain.o
|
||||
fLIBS = -lstdc++
|
||||
## Deps & objs for Fortran fMaponiA3_test
|
||||
fMaponiA3_testDEP = fMaponiA3_test.f90 SM_MaponiA3_mod.f90
|
||||
fMaponiA3_testOBJ = SM_MaponiA3.o SM_MaponiA3_mod.o fMaponiA3_test.o
|
||||
fMaponiA3_testLIB = -lstdc++
|
||||
|
||||
## Compile recipes for C++ stuff
|
||||
%.o: %.cpp $(cppDEPS)
|
||||
## Deps & objs for Fortran QMCChem_dataset_test
|
||||
QMCChem_dataset_testDEP = QMCChem_dataset_test.f90 SM_MaponiA3_mod.f90
|
||||
QMCChem_dataset_testOBJ = SM_MaponiA3.o SM_MaponiA3_mod.o QMCChem_dataset_test.o
|
||||
QMCChem_dataset_testLIB = -lstdc++
|
||||
|
||||
## Compile recipes for C++ cMaponiA3_test
|
||||
%.o: %.cpp $(cMaponiA3_testDEP)
|
||||
$(CXX) $(ARCH) $(CXXFLAGS) -c -o $@ $<
|
||||
|
||||
## Compile recepies for Fortran stuff
|
||||
%.o: %.f90 $(fDEPS)
|
||||
## Compile recepies for Fortran fMaponiA3_test
|
||||
%.o: %.f90 $(fMaponiA3_testDEP)
|
||||
$(FC) $(ARCH) $(FFLAGS) -c -o $@ $<
|
||||
|
||||
## Build tagets
|
||||
.PHONY: all clean distclean
|
||||
|
||||
all: cppSherman-Morrison fSherman-Morrison
|
||||
all: cMaponiA3_test fMaponiA3_test QMCChem_dataset_test
|
||||
|
||||
clean:
|
||||
@rm -vf *.o *.mod
|
||||
|
||||
distclean: clean
|
||||
@rm -vf cppSherman-Morrison fSherman-Morrison
|
||||
@rm -vf cMaponiA3_test fMaponiA3_test QMCChem_dataset_test
|
||||
|
||||
## Linking the C++ example program
|
||||
cppSherman-Morrison: $(cppOBJ)
|
||||
cMaponiA3_test: $(cMaponiA3_testOBJ)
|
||||
$(CXX) $(ARCH) $(CXXFLAGS) -o $@ $^
|
||||
|
||||
## Linking Fortran example program calling the C++ function 'Sherman_Morrison()'
|
||||
fSherman-Morrison: $(fOBJ)
|
||||
$(FC) $(ARCH) $(FFLAGS) $(fLIBS) -o $@ $^
|
||||
fMaponiA3_test: $(fMaponiA3_testOBJ)
|
||||
$(FC) $(ARCH) $(FFLAGS) $(fMaponiA3_testLIB) -o $@ $^
|
||||
|
||||
## Linking Fortran example program calling the C++ function 'Sherman_Morrison()'
|
||||
QMCChem_dataset_test: $(QMCChem_dataset_testOBJ)
|
||||
$(FC) $(ARCH) $(FFLAGS) $(QMCChem_dataset_testLIB) -o $@ $^
|
||||
|
48
QMCChem_dataset_test.f90
Normal file
48
QMCChem_dataset_test.f90
Normal file
@ -0,0 +1,48 @@
|
||||
program QMCChem_dataset_test
|
||||
use Sherman_Morrison, only : MaponiA3
|
||||
use, intrinsic :: iso_c_binding, only : c_int, c_double
|
||||
implicit none
|
||||
|
||||
integer :: i, j !! Iterators
|
||||
integer :: cycle_id, dim, n_updates
|
||||
integer(c_int), dimension(:), allocatable :: Updates_index
|
||||
real(c_double), dimension(:,:), allocatable :: S, S_inv, Updates
|
||||
character (len = 32) :: ignore
|
||||
|
||||
!! Start of reading the dataset from file
|
||||
open(unit = 1000, file = "test.dataset.dat")
|
||||
read(1000,*)
|
||||
read(1000,*) ignore, cycle_id
|
||||
read(1000,*) ignore, dim
|
||||
read(1000,*) ignore,n_updates
|
||||
|
||||
allocate(Updates_index(n_updates), S(dim,dim), &
|
||||
S_inv(dim,dim), Updates(dim,n_updates))
|
||||
|
||||
!! Read S and S_inv
|
||||
read(1000,*)
|
||||
do i=1,dim
|
||||
do j=1,dim
|
||||
read(1000,*) ignore, ignore, S(i,j), S_inv(i,j)
|
||||
end do
|
||||
end do
|
||||
|
||||
!! Read the updates Updates and Updates_index
|
||||
do j=1,n_updates
|
||||
read(1000,*) ignore, Updates_index(j)
|
||||
do i=1,dim
|
||||
read(1000,*) ignore, Updates(i,j)
|
||||
end do
|
||||
end do
|
||||
|
||||
read(1000,*) ignore
|
||||
close(1000)
|
||||
!! End of reading the dataset from file
|
||||
|
||||
!! Send S, S_inv and Updates to MaponiA3 algo
|
||||
!
|
||||
|
||||
!! Test if computed S_inv is indeed the inverse of S
|
||||
|
||||
deallocate(S, S_inv, Updates, Updates_index)
|
||||
end program
|
@ -92,10 +92,11 @@ void MaponiA3(double *Slater0, double *Slater_inv, unsigned int M,
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
void MaponiA3_f(double **linSlater0, double **linSlater_inv, unsigned int *Dim,
|
||||
unsigned int *N_updates, double **linUpdates,
|
||||
unsigned int **Updates_index) {
|
||||
MaponiA3(*linSlater0, *linSlater_inv, *Dim, *N_updates, *linUpdates,
|
||||
*Updates_index);
|
||||
}
|
||||
void MaponiA3_f(double **linSlater0, double **linSlater_inv, unsigned int *Dim,
|
||||
unsigned int *N_updates, double **linUpdates,
|
||||
unsigned int **Updates_index) {
|
||||
MaponiA3(*linSlater0, *linSlater_inv, *Dim,
|
||||
*N_updates, *linUpdates,
|
||||
*Updates_index);
|
||||
}
|
||||
}
|
||||
|
44
Utils_mod.f90
Normal file
44
Utils_mod.f90
Normal file
@ -0,0 +1,44 @@
|
||||
module Utils
|
||||
implicit none
|
||||
|
||||
contains
|
||||
subroutine Read_dataset(filename, cycle_id, dim, n_updates &
|
||||
S, S_inv, Updates_index, Updates)
|
||||
|
||||
character (len = 64), intent(in) :: filename
|
||||
|
||||
|
||||
!! Start of reading the dataset from file
|
||||
open(unit = 1000, file = "test.dataset.dat")
|
||||
read(1000,*)
|
||||
read(1000,*) ignore, cycle_id
|
||||
read(1000,*) ignore, dim
|
||||
read(1000,*) ignore,n_updates
|
||||
|
||||
allocate(Updates_index(n_updates), S(dim,dim), &
|
||||
S_inv(dim,dim), Updates(dim,n_updates))
|
||||
|
||||
!! Read S and S_inv
|
||||
read(1000,*)
|
||||
do i=1,dim
|
||||
do j=1,dim
|
||||
read(1000,*) ignore, ignore, S(i,j), S_inv(i,j)
|
||||
end do
|
||||
end do
|
||||
|
||||
!! Read the updates Updates and Updates_index
|
||||
do j=1,n_updates
|
||||
read(1000,*) ignore, Updates_index(j)
|
||||
do i=1,dim
|
||||
read(1000,*) ignore, Updates(i,j)
|
||||
end do
|
||||
end do
|
||||
|
||||
read(1000,*) ignore
|
||||
close(1000)
|
||||
!! End of reading the dataset from file
|
||||
end subroutine Read_dataset
|
||||
end module Utils
|
||||
|
||||
|
||||
end module Sherman_Morrison
|
Loading…
Reference in New Issue
Block a user