Bill Allombert on Sat, 25 Jun 2022 19:15:10 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: FORTRAN memory issues and use of the sum function 'somme' |
On Sat, Jun 25, 2022 at 04:12:56PM +0000, Brereton, Ashley wrote: > 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! Yes, this is correct, you should read the chapter 'Garbage collection' of the documentation. Let say you want to do the sum DO I=1_8,100000_8 u = gadd(u, stor(I,prec)) ENDDO you should do av = avma DO I=1_8,100000_8 u = gadd(u, stor(I,prec)) u = gerepilecopy(av, u); ENDDO or better, only do 'u = gerepilecopy(av, u);' every 1000 iterations or so. (avma is a global variable from libpari) Cheers, Bill.