diff --git a/F90subroutines/routing_reg.f90 b/F90subroutines/routing_reg.f90
index 57b0d017df7ef9353c87c95238a17e0ba8758222..0fb14293419f4207a94abc08b25b991c0fe9a37e 100644
--- a/F90subroutines/routing_reg.f90
+++ b/F90subroutines/routing_reg.f90
@@ -2291,13 +2291,20 @@ SUBROUTINE routing_reg_linkup(nbpt, neighbours, nwbas, basin_count, basin_area,
                          dop = minhloc(basin_id(sp,sb),1)
                          bop = minhloc(basin_id(sp,sb),2)
                          IF ((dop  < undef_int ) .AND. (dop .GT. 0) .AND. (bop < undef_int) .AND. (bop .GT. 0)) THEN
-                            !basin_hierarchy(sp,sb) = basin_hierarchy(dop,bop)
+
                             CALL routing_updateflow(sp, sb, dop, bop, nbpt,nwbas, nbxmax*8, outflow_grid, outflow_basin, &
                                  &   inflow_number, inflow_grid, inflow_basin)
-                         found = 1
-                         WRITE(numout,*) "Lowest basin hierarchy in the neighbours grid points"
-                         WRITE(numout,*) "hierarch of (sp,sb)", basin_hierarchy(sp,sb) 
-                         WRITE(numout,*) "Lowest basinid hierarch", basin_hierarchy(dop,bop)
+                            ! It is possible that the lowest hierarchy is in two grid cells
+                            ! In this case, if we have an error for this routing_updateflow
+                            ! We go to next step and make it a coastal flow 
+                            IF (outflow_basin(sp, sb) < undef_int) THEN
+                               found = 1
+                               WRITE(numout,*) "Lowest basin hierarchy in the neighbours grid points"
+                            ELSE
+                               WRITE(numout,*) "Lowest hierarchy may be in two different grid points"
+                            END IF
+                            WRITE(numout,*) "hierarch of (sp,sb)", basin_hierarchy(sp,sb) 
+                            WRITE(numout,*) "Lowest basinid hierarch", basin_hierarchy(dop,bop)
                          END IF
                       END IF
                    END DO