Skip to content

Commit 2de5aee

Browse files
committed
Refactor all source-allocations
Refactor all source-allocations by mold-allocations and assigments. Why: Soucer-allocation generates memory leaks that must be avoided. Hopefully, mold-allocation/assignment should not. Side effects: Nothing (apparently), memory leaks occurences must still be checked.
1 parent 025adc7 commit 2de5aee

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/lib/foodie_integrator_adams_moulton.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,8 @@ subroutine integrate(self, U, previous, Dt, t, iterations, autoupdate)
352352
autoupdate_ = .true. ; if (present(autoupdate)) autoupdate_ = autoupdate
353353
if (self%steps>0) then
354354
if (present(iterations)) then ! perform fixed point iterations
355-
allocate(delta, source=previous(self%steps))
355+
allocate(delta, mold=U)
356+
delta = previous(self%steps)
356357
do s=0, self%steps - 1
357358
delta = delta + previous(s+1)%t(t=t(s+1)) * (Dt * self%b(s))
358359
enddo

src/lib/foodie_integrator_backward_differentiation_formula.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ subroutine integrate(self, U, previous, Dt, t, iterations, autoupdate)
224224

225225
autoupdate_ = .true. ; if (present(autoupdate)) autoupdate_ = autoupdate
226226
iterations_ = 1 ; if (present(iterations)) iterations_ = iterations
227-
allocate(delta, source=previous(self%steps) * (-self%a(self%steps)))
227+
allocate(delta, mold=U)
228+
delta = previous(self%steps) * (-self%a(self%steps))
228229
do s=1, self%steps - 1
229230
delta = delta + previous(s) * (-self%a(s))
230231
enddo

src/lib/foodie_integrator_runge_kutta_embedded.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,8 @@ subroutine integrate(self, U, stage, Dt, t)
679679
integer(I_P) :: s !< First stages counter.
680680
integer(I_P) :: ss !< Second stages counter.
681681

682-
allocate(U1, source=U)
683-
allocate(U2, source=U)
682+
allocate(U1, mold=U) ; U1 = U
683+
allocate(U2, mold=U) ; U2 = U
684684
error = 1e6
685685
do while(error>self%tolerance)
686686
! compute stages

0 commit comments

Comments
 (0)