Skip to main content

4.15) Stop The Code!


1       program example11
2       real :: a
3       real :: b
4       a=10.0
5       b=5.0
6       if ( a > b ) then
7          print *, ‘a is greater than b’
8          a=b
9          stop
10      else
11         print *, ‘increase the value of a’
12         a=40.0
13         print *, ‘try a value of ‘, a
14      endif
15      end program example11

Example of a program with a stop used. When the program reaches line 9 it will terminate at that point and go no farther.
You can add text on the same line after the stop and it will be printed when it stops, for example: stop ended at point A.    So if you see the program end and the 'ended at point A' is printed to the screen then you know where it stopped in the program.