Brereton, Ashley on Sat, 25 Jun 2022 18:12:59 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
FORTRAN memory issues and use of the sum function 'somme' |
Hi there,
I was hoping somebody could help with an issue with memory usage.
My code is written in Fortran. In my code, I have a (simplified) loop (see below). The code fails because the pari stack size isn't big enough.
It seems like 'u' is stored at a new memory address for each loop iteration, and so the memory fills up - though I may be wrong!
If I am indeed correct, my question is, does anybody know how to either:
a) overwrite at the same memory address or
b) clear the memory (I tried to use allocatable for 'u' and deallocate inside the loop, but with no success).
My loop will be used for a simple sum: glog(X) for X=1:N, how do I use the 'somme' function in my Fortran code? This is the gadd function for reference. I'm hoping the somme function can get around the memory issue!
!
type(C_PTR) function gadd( x , y) bind(C,name='gadd')
import C_PTR
type(C_PTR), VALUE :: x
type(C_PTR), VALUE :: y
end function gadd
!
Any help would be greatly appreciated!
Thank you in advance,
Ash
%%%%%%%%%%%%%%%
use ISO_C_BINDING, only : C_PTR
use PARI
type(C_PTR) :: u
integer(kind=C_LONG) :: I
integer(kind=C_LONG) :: prec = 10 ! 152 decimal digits
CALL pari_init(10000000_8, 2_8)
DO I=1_8,100000_8
u = stor(I,prec)
CALL pari_close()
%%%%%%%%%%%%%%%
|