Fortran goto scope

I have an old fortran code with many statements like 'goto 50'. I was wondering if the goto target is global or local. I mean, if several functions have a target of "50", which goto leads to.

Thanks for answering.

+4
source share
2 answers

Operator signs (eg, β€œ50”) should be defined in the current β€œreach node”, which basically translates in this context the routine / function in which the goto call is located (or the main program if the call is in the main program).

So, for example, in the next program, the main program and both contained routines have their own label 50, and gotos go to "their" line 50.

program testgotos implicit none goto 50 call second 50 call first call second contains subroutine first integer :: a = 10 goto 50 a = 20 50 print *,'First: a = ', a end subroutine first subroutine second integer :: a = 20 goto 50 a = 40 50 print *,'Second: a = ', a end subroutine second end program testgotos 
+7
source

Local

Technically from the f77 standard ( http://www.fortran.com/fortran/F77_std/f77_std.html )

"Labels for operators have the scope of the program.

+6
source

Source: https://habr.com/ru/post/1403784/


All Articles