Can a GOTO command refers to outside a subroutine?

Can a GOTO command refers to outside a subroutine?

Rasoul K.'s picture

Is it possible to have a GOTO command inside a subroutine which points to outside the subroutine?
In a subroutine, I have the follo‌wing line:

IF(BN.GT.100000E+02) GOTO 1000

And there is no 1000 in that subroutine.

Another line in the same subroutine is:
GOTO 5000
There is no 5000 in the same subroutine but there are may 5000 in the main program.

It is sort of confusing for me but as the program is written by my professor, I can't easily say it is wrong.

Also if it possible, if there are more than 5000 in the main program, will it go to the next 5000 after call subroutine?

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
IanH's picture

No. The branch target label needs to designate a statement in the same inclusive scope. A modern Fortran compiler must detect this and report an error. Are you sure that things are as you describe?

Rasoul K.'s picture

Quote:

IanH wrote:

No. The branch target label needs to designate a statement in the same inclusive scope. A modern Fortran compiler must detect this and report an error. Are you sure that things are as you describe?

Dear Ian.
You are correct. I had a mistake. I figured it out.
Sorry for fast decision, I should look completely before reporting.

Login to leave a comment.