From c854019cc5e86bca878b998d83ca912505c92e38 Mon Sep 17 00:00:00 2001 From: Rafael M Mudafort Date: Mon, 21 Oct 2019 12:54:41 -0600 Subject: [PATCH] AD14: Restructure loop to fix optimization bug Since there is a read and write in the same line, these do-loops shouldnt be optimization by the compiler. However, GNU Fortran version 8+ does optimize anyway leading to a seg fault. This change removes the read-write operation in the same line by replacing the loops with a more explicit summation. --- modules/aerodyn14/src/AeroSubs.f90 | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/modules/aerodyn14/src/AeroSubs.f90 b/modules/aerodyn14/src/AeroSubs.f90 index 71fd4eb2d0..c6141806c5 100644 --- a/modules/aerodyn14/src/AeroSubs.f90 +++ b/modules/aerodyn14/src/AeroSubs.f90 @@ -4693,13 +4693,8 @@ SUBROUTINE infdist( P, m, ErrStat, ErrMess ) RHScos(i) = 0. RHSsin(i) = 0. ! First, calculate {rhs} = V[L]^-1*{alpha} - DO k = 1, maxInfl -! DO 260 k = MaxInflo+1, maxInfl - RHScos(i) = RHScos(i) + m%DynInflow%xLcos(i,k) * m%DynInflow%old_Alph(k) - END DO !k - DO k = P%DynInflow%MaxInflo+1, maxInfl - RHSsin(i) = RHSsin(i) + m%DynInflow%xLsin(i,k) * m%DynInflow%old_Beta(k) - END DO !k + RHScos(i) = sum(m%DynInflow%xLcos(i,1:maxInfl) * m%DynInflow%old_Alph(1:maxInfl)) + RHSsin(i) = sum(m%DynInflow%xLsin(i,P%DynInflow%MaxInflo+1:maxInfl) * m%DynInflow%old_Beta(P%DynInflow%MaxInflo+1:maxInfl)) ! Second, calculate {rhs} = 0.5*{tau} - [V]{rhs} ! = 0.5*{tau} - [V][L]^-1*{alpha} ! USE "VPARAM" for m>0