Skip to content

Commit

Permalink
Merge pull request #1769 from deslaughter/bug/ifw-periodic-351
Browse files Browse the repository at this point in the history
Add additional modulo in IfW_FlowField
  • Loading branch information
deslaughter authored Sep 13, 2023
2 parents 900d12b + fae54fb commit 8720f4f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions modules/inflowwind/src/IfW_FlowField.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1237,9 +1237,13 @@ subroutine GetBoundsT(PosX, DT)

! If field is periodic
if (G3D%Periodic) then
! Take modulus of negative grid to get positive value between 0 and NSteps
T_GRID = MODULO(T_GRID, real(G3D%NSteps, ReKi))
! For very small negative numbers, the above modulus will return exactly NSteps
! so take modulus again to ensure that T_GRID is less than NSteps
T_GRID = MODULO(T_GRID, real(G3D%NSteps, ReKi))
end if

! Calculate bounding grid indices
IT_LO = floor(T_GRID, IntKi) + 1
IT_HI = IT_LO + 1
Expand Down Expand Up @@ -1267,7 +1271,8 @@ subroutine GetBoundsT(PosX, DT)
! Time exceeds array bounds
call SetErrStat(ErrID_Fatal, ' Error: GF wind array was exhausted at '// &
TRIM(Num2LStr(TIME))//' seconds (trying to access data at '// &
TRIM(Num2LStr(TimeShifted))//' seconds).', &
TRIM(Num2LStr(TimeShifted))//' seconds). IT_Lo='//TRIM(Num2LStr(IT_Lo))// &
', IT_HI='//TRIM(Num2LStr(IT_Hi)), &
ErrStat, ErrMsg, RoutineName)
end if

Expand Down

0 comments on commit 8720f4f

Please sign in to comment.