mirror of
https://github.com/TREX-CoE/Sherman-Morrison.git
synced 2024-12-26 14:23:47 +01:00
Put importing the dataset into a module.
This commit is contained in:
parent
6b699143b5
commit
90469df3c2
4
Makefile
4
Makefile
@ -17,8 +17,8 @@ fMaponiA3_testOBJ = SM_MaponiA3.o SM_MaponiA3_mod.o fMaponiA3_test.o
|
|||||||
fMaponiA3_testLIB = -lstdc++
|
fMaponiA3_testLIB = -lstdc++
|
||||||
|
|
||||||
## Deps & objs for Fortran QMCChem_dataset_test
|
## Deps & objs for Fortran QMCChem_dataset_test
|
||||||
QMCChem_dataset_testDEP = QMCChem_dataset_test.f90 SM_MaponiA3_mod.f90
|
QMCChem_dataset_testDEP = QMCChem_dataset_test.f90 SM_MaponiA3_mod.f90 Utils_mod.f90
|
||||||
QMCChem_dataset_testOBJ = SM_MaponiA3.o SM_MaponiA3_mod.o QMCChem_dataset_test.o
|
QMCChem_dataset_testOBJ = SM_MaponiA3.o Utils_mod.o SM_MaponiA3_mod.o QMCChem_dataset_test.o
|
||||||
QMCChem_dataset_testLIB = -lstdc++
|
QMCChem_dataset_testLIB = -lstdc++
|
||||||
|
|
||||||
## Compile recipes for C++ cMaponiA3_test
|
## Compile recipes for C++ cMaponiA3_test
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
program QMCChem_dataset_test
|
program QMCChem_dataset_test
|
||||||
use Sherman_Morrison, only : MaponiA3
|
use Sherman_Morrison, only : MaponiA3
|
||||||
|
use Utils, only : Read_dataset
|
||||||
use, intrinsic :: iso_c_binding, only : c_int, c_double
|
use, intrinsic :: iso_c_binding, only : c_int, c_double
|
||||||
implicit none
|
implicit none
|
||||||
|
|
||||||
@ -7,37 +8,15 @@ program QMCChem_dataset_test
|
|||||||
integer :: cycle_id, dim, n_updates
|
integer :: cycle_id, dim, n_updates
|
||||||
integer(c_int), dimension(:), allocatable :: Updates_index
|
integer(c_int), dimension(:), allocatable :: Updates_index
|
||||||
real(c_double), dimension(:,:), allocatable :: S, S_inv, Updates
|
real(c_double), dimension(:,:), allocatable :: S, S_inv, Updates
|
||||||
character (len = 32) :: ignore
|
|
||||||
|
|
||||||
!! Start of reading the dataset from file
|
call Read_dataset("test.dataset.dat", &
|
||||||
open(unit = 1000, file = "test.dataset.dat")
|
cycle_id, &
|
||||||
read(1000,*)
|
dim, &
|
||||||
read(1000,*) ignore, cycle_id
|
n_updates, &
|
||||||
read(1000,*) ignore, dim
|
S, &
|
||||||
read(1000,*) ignore,n_updates
|
S_inv, &
|
||||||
|
Updates_index, &
|
||||||
allocate(Updates_index(n_updates), S(dim,dim), &
|
Updates)
|
||||||
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
|
|
||||||
|
|
||||||
!! Write current S and S_inv to file for check in Octave
|
!! Write current S and S_inv to file for check in Octave
|
||||||
open(unit = 2000, file = "Slater_old.dat")
|
open(unit = 2000, file = "Slater_old.dat")
|
||||||
|
@ -1,15 +1,21 @@
|
|||||||
module Utils
|
module Utils
|
||||||
implicit none
|
implicit none
|
||||||
|
|
||||||
contains
|
contains
|
||||||
subroutine Read_dataset(filename, cycle_id, dim, n_updates &
|
subroutine Read_dataset(filename, cycle_id, dim, n_updates, &
|
||||||
S, S_inv, Updates_index, Updates)
|
S, S_inv, Updates_index, Updates)
|
||||||
|
use, intrinsic :: iso_c_binding, only : c_int, c_double
|
||||||
|
implicit none
|
||||||
|
|
||||||
character (len = 64), intent(in) :: filename
|
character (len = *), intent(in) :: filename
|
||||||
|
integer, intent(inout) :: cycle_id, dim, n_updates
|
||||||
|
integer(c_int), allocatable, intent(inout) :: Updates_index(:)
|
||||||
|
real(c_double), allocatable, intent(inout) :: S(:,:), S_inv(:,:)
|
||||||
|
real(c_double), allocatable, intent(inout) :: Updates(:,:)
|
||||||
|
integer :: i, j
|
||||||
|
character (len = 32) :: ignore
|
||||||
|
|
||||||
!! Start of reading the dataset from file
|
!! Start of reading the dataset from file
|
||||||
open(unit = 1000, file = "test.dataset.dat")
|
open(unit = 1000, file = filename)
|
||||||
read(1000,*)
|
read(1000,*)
|
||||||
read(1000,*) ignore, cycle_id
|
read(1000,*) ignore, cycle_id
|
||||||
read(1000,*) ignore, dim
|
read(1000,*) ignore, dim
|
||||||
@ -38,7 +44,4 @@ module Utils
|
|||||||
close(1000)
|
close(1000)
|
||||||
!! End of reading the dataset from file
|
!! End of reading the dataset from file
|
||||||
end subroutine Read_dataset
|
end subroutine Read_dataset
|
||||||
end module Utils
|
end module Utils
|
||||||
|
|
||||||
|
|
||||||
end module Sherman_Morrison
|
|
Loading…
Reference in New Issue
Block a user