added saving on disk
This commit is contained in:
parent
9e330dc880
commit
17622128c9
2 changed files with 50 additions and 32 deletions
Binary file not shown.
|
|
@ -1,27 +1,26 @@
|
||||||
program test
|
program test
|
||||||
implicit none
|
implicit none
|
||||||
1 format(20i10)
|
1 format(1i10)
|
||||||
|
|
||||||
integer (kind = 8), parameter :: base = 2
|
integer (kind = 8), parameter :: base = 2, chunk = 10
|
||||||
integer (kind = 8), dimension (:), allocatable :: ls, temp1, temp2
|
|
||||||
double precision :: S
|
double precision :: S
|
||||||
integer (kind = 8) :: i
|
integer (kind = 8) :: i, len
|
||||||
|
|
||||||
allocate(ls(1))
|
open(1, file = "prev.txt")
|
||||||
ls = (/1/)
|
write(1,1) 1
|
||||||
S = 0
|
close(1)
|
||||||
|
|
||||||
do i = 1, 63
|
S = 0.5
|
||||||
S = S + (real(size(ls)) / real(2 ** i))
|
|
||||||
|
do i = 2, 63
|
||||||
|
len = next()
|
||||||
|
call rename("array.txt", "prev.txt")
|
||||||
|
S = S + (real(len) / 2.0 ** i)
|
||||||
print *, "ITERATION", i
|
print *, "ITERATION", i
|
||||||
print *, "NUMBER ", size(ls)
|
print *, "NUMBER ", len
|
||||||
print *, "SUM ", S
|
print *, "SUM ", S
|
||||||
print *, ""
|
print *, ""
|
||||||
call flush()
|
call flush()
|
||||||
temp1 = next(ls)
|
|
||||||
temp2 = ls
|
|
||||||
ls = temp1
|
|
||||||
deallocate(temp2)
|
|
||||||
end do
|
end do
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -112,33 +111,52 @@ implicit none
|
||||||
|
|
||||||
end function step
|
end function step
|
||||||
|
|
||||||
function next (ls)
|
function next()
|
||||||
1 format(20i10)
|
implicit none
|
||||||
|
1 format(1i10)
|
||||||
|
|
||||||
integer (kind = 8), dimension (:), allocatable, intent (in) :: ls
|
integer (kind = 8), dimension (:), allocatable :: temp, temp2
|
||||||
integer (kind = 8), dimension (:), allocatable :: temp, temp2, next
|
integer (kind = 8) :: current, next
|
||||||
integer :: s, i, j, count
|
integer :: i, j, templen, ios
|
||||||
|
logical :: done
|
||||||
|
|
||||||
count = 0
|
templen = 0
|
||||||
s = size(ls)
|
next = 0
|
||||||
allocate(temp(s * base))
|
done = .false.
|
||||||
|
allocate(temp(chunk))
|
||||||
|
|
||||||
do i = 1, s
|
open(1, file = "array.txt")
|
||||||
temp2 = step(ls(i))
|
open(2, file = "prev.txt")
|
||||||
do j = 1, size(temp2)
|
|
||||||
temp(j + count) = temp2(j)
|
do while (.not. done)
|
||||||
|
read(2, 1, iostat = ios) current
|
||||||
|
if (ios .ne. 0) then
|
||||||
|
done = .true.
|
||||||
|
exit
|
||||||
|
end if
|
||||||
|
|
||||||
|
temp2 = step(current)
|
||||||
|
do i = 1, size(temp2)
|
||||||
|
templen = templen + 1
|
||||||
|
temp(templen) = temp2(i)
|
||||||
|
next = next + 1
|
||||||
|
if (templen >= chunk) then
|
||||||
|
write(1,1) temp
|
||||||
|
call flush(1)
|
||||||
|
deallocate(temp)
|
||||||
|
allocate(temp(chunk))
|
||||||
|
templen = 0
|
||||||
|
end if
|
||||||
end do
|
end do
|
||||||
count = count + size(temp2)
|
|
||||||
deallocate(temp2)
|
deallocate(temp2)
|
||||||
end do
|
end do
|
||||||
|
|
||||||
allocate(next(count))
|
write(1,1) temp(:templen)
|
||||||
do i = 1, count
|
|
||||||
next(i) = temp(i)
|
|
||||||
end do
|
|
||||||
|
|
||||||
deallocate(temp)
|
deallocate(temp)
|
||||||
|
|
||||||
|
close(1)
|
||||||
|
close(2)
|
||||||
|
|
||||||
end function next
|
end function next
|
||||||
|
|
||||||
end program test
|
end program test
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue