I have two questions regarding the following legacy code segment:
do i=1, n_total, increment diff = array(i) - x1 if (diff < 0.0_dp) then ! do something go to 10 else if (diff == 0.0_dp) then ! do something go to 10 else if (diff > 0.0_dp) then ! do something go to 10 end if end do ! We fell out of do loop, write error and stop write(unit=6,fmt='(''No Match'')') stop 10 continue
1. Does Fortran 1990/95/03/08 provide a specific keyword or state variable (maybe something like END_STATUS) to check if a do loop completes without a branch or break or, in the case above, do you have to check the value of i against n_total? The first approach would allow a standard set of code which would be independent of the index and terminal variable.
2. In the code above, would it be better to replace the go to statements with break and enclosed the error message in an if statement? Any performance difference between the two approaches? What would be best practice? Any other approach would be welcome.
Thanks....