Recognitions:
Gold Member

## Fortran 90, goto

I don't understand why I get an error when I use the goto "command" like this:

(...)

goto 11

(...)

11 end program

----------------------------------------------------------
The (...) represent the other part of my program. I tried to change the place of the 11. Because if I compile my program with the "11 end program" line I get the error "Label 11 referenced at (1) is never defined" so basically it doesn't see the 11 in front of "end program".
When I changed the place of the "11" the program could compile.
Can someone explain me why fortran can't see the 11 in front of the end program?
Now I need to think about a substitute of my original idea.

 PhysOrg.com science news on PhysOrg.com >> Front-row seats to climate change>> Attacking MRSA with metals from antibacterial clays>> New formula invented for microscope viewing, substitutes for federally controlled drug
 Mentor Try attaching the statement number to a "continue" statement right before the "end program" statement. I suspect the problem is that "end program" is not an executable statement, but simply a signal (directive) to the compiler. You might as well try to put a statement number on a "dimension" statement.
 End is not an executable statement it's a compiler directive. Use this: 11 STOP END

Recognitions:

## Fortran 90, goto

I would prefer
11 CONTINUE
or
11 RETURN
rather than
11 STOP

If you use a "stop" statement, you may get some output saying "program terminated by stop statement at line xxx in subprogram main" or something similar.

Even better, replace the
GOTO 11
with
RETURN

 Recognitions: Gold Member Thanks guys. My program now compile and works well (I believe. I must test an .and. command but I think it works great). Instead of stopping the program as I initially thought, I redirect to the statement before a "if (...) end if" so basically my program restart from a certain point. So the main problem is that "end program" is not an executable statement... wow.
 i have similar problem in go to statement. i get a warning, please answer my problem rapidly. go to 3 . . . . . 3 write(10,*),"variables=x,y,say" . . . . end program

Mentor
We will answer your problem rapidly when we get around to it.

 warning is: Warning: A jump into a block from outside the block has occurred. [3]
 Recognitions: Science Advisor A "block" is something like a DO loop, or an IF ... THEN .. ELSE ... ENDIF structure. If you write code like Code: GOTO 10 ... DO I = J, K ... 10 ... ... ENDDO It isn't very obvious what should happen at the ENDDO statement, because I, J and K might not have any values, or they might have values that mean you shouldn't be executing the code insude the loop at all. Similarly for Code: IF (X .GT. 0} ... 10 ... ... ELSE ... ENDIF you could junp to label 10 when X was not > 0. An optimising compiler might generate code that just doesn't work at all in those situations. For example at statement 10 the compiler should be able to assume that X really is greater than 0, so dividing by X can't produce a "divide by zero" error when the program runs, or evaluating X**0.25 can't prodice an error saying "X is negative", etc. That's why Fortran says it is illegal to jump into a block from outside - though your compuler let you off with a warning message instead of an error.
 GOTO's are a poor programming practice in Fortran. It is a desperate last resort which results in spaghetti code.
 Hey guys could any one teell me a print format by which i could print 3 arrays as a table like first array on the first column and the second array on the second colomn,,, in short i just want to print 3 RRAYS TOGETHER as a table each array ON ONE COLUMN thanks in advance
 Hardy, you might want to create a new thread with a more clear definition on what you need help with. You just randomly posted in someone's thread, in case you didn't realize.

Mentor
 Quote by hardy03 Hey guys could any one teell me a print format by which i could print 3 arrays as a table like first array on the first column and the second array on the second colomn,,, in short i just want to print 3 RRAYS TOGETHER as a table each array ON ONE COLUMN