Skip to content

Commit

Permalink
FIX: resolve issue on flow distances computation
Browse files Browse the repository at this point in the history
This commit fix an error when flow distances are computed
on adjacent non-nested catchments
  • Loading branch information
inoelloc committed Jul 12, 2023
1 parent 1ab786c commit b5d3205
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
11 changes: 9 additions & 2 deletions doc/source/release/0.5.0-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,17 @@ Segmentation algorithm

If multiple events are detected, the duration of the merged event is no longer constrained by the max duration parameter. Instead, its duration may exceed this value.

``smash.generate_mesh`` segmentation fault
******************************************
Catchment delineation segmentation fault
****************************************

An error occured when two neighboring cells have antagonistic flow directions ``(1, 5)``, ``(2, 6)``, ``(3, 7)``, ``(4, 8)``. This should be corrected directly in the flow direction file but to avoid
segmentation faults when the maximum number of recursions has been reached, a check is added to the code to exit recursion in that case.

See issue `#31 <https://github.com/DassHydro-dev/smash/issues/31>`__.

Catchment flow distances on adjacent non-nested catchments
**********************************************************

There is a bug when calculating flow distances when two adjacent catchments are considered in the mesh but non-nested. During calculation, a flag is set around the 8 adjacent cells of each upstream cell and not on the upstream cell in particular. As a result, a gauge stuck to a cell of another catchment will not be considered as a non-nested gauge and will be filled with -99. The bug has been solved by flagging only the upstream cell and not the 8 adjacent cells.

See issue `#38 <https://github.com/DassHydro-dev/smash/issues/38>`__.
14 changes: 7 additions & 7 deletions smash/mesh/mw_meshing.f90
Original file line number Diff line number Diff line change
Expand Up @@ -345,18 +345,18 @@ recursive subroutine distance_upstream_cells(nrow, ncol, ng, &
row_imd = row + drow(i)
col_imd = col + dcol(i)

do j = 1, ng

if (row_imd .eq. row_dln(j) .and. &
& col_imd .eq. col_dln(j)) flag(j) = 1

end do

if (row_imd .gt. 0 .and. row_imd .le. nrow .and. &
& col_imd .gt. 0 .and. col_imd .le. ncol) then

if (flwdir(row_imd, col_imd) .eq. i) then

do j = 1, ng

if (row_imd .eq. row_dln(j) .and. &
& col_imd .eq. col_dln(j)) flag(j) = 1

end do

!% Avoid to compute square root if not diagonal
if (dcol(i) .eq. 0) then

Expand Down

0 comments on commit b5d3205

Please sign in to comment.