Open
Description
https://fortran-lang.discourse.group/t/for-else-or-do-else-in-fortran/8696
Example:
condition = .false.
do i = 1, 10
.......
if (condition) exit
else
! This block only executes if the do loop doesn't exit.
error stop "Condition not met"
enddo
which would be equivalent to:
condition = .false.
do i = 1, 10
......
if (condition) exit
enddo
if (.not. condition) error stop "Condition not met"
Similar to Python's "for else": https://docs.python.org/3/tutorial/controlflow.html#else-clauses-on-loops
Metadata
Metadata
Assignees
Labels
No labels