answersLogoWhite

0

The use of GOTOs in programming is generally considered to be bad form, because it very rapidly leads to "spaghetti code" where it is difficult or impossible to follow the program's logic flow.

However, given Fortran's comparatively weak set of flow controls, there are times when a GOTO is unavoidable or actually clearer than using a more-structured layout. A simple example would be a subroutine that checks its arguments for validity and exits immediately if it finds something incompatible. The alternatives would be

(A) Put a GOTO 99999 after each invalid condition is detected, where 99999 is the program's RETURN statement

(B) Set flags after each condition, falling through and checking more and more flags until you "naturally" reach the module's RETURN.

An example of (A) would be (using slight variations on Fortran 90 syntax)

subroutine foo(x,y)

implicit none

real*4 x, y

! Check for negative arguments

if (x < 0.0) then

print *, 'Argument X is negative'

goto 99999

endif

if (y < 0.0) then

print *, 'Argument Y is negative'

goto 99999

endif

! (Code body goes here ....)

99999 continue

return

end

User Avatar

Wiki User

17y ago

What else can I help you with?

Related Questions

Write a FORTRAN program using if statement to calculate the smallest of three numbers xyz?

N = x If y &lt; N then N = Y If z &lt; N then N = z Print N


How do you write a c program to convert binary to decimal by using while statement?

write a c++ program to convert binary number to decimal number by using while statement


Write a program By using if else statement to read a number and check whether it is positive or negative?

write a c++program by using if statement to read a number and check whether it is positive or negative


How do you write a program on watfor77?

To write a program in Watfor77, you start by using a text editor to create a source code file with a .f extension. The program follows Fortran 77 syntax, which includes defining variables, writing subroutines, and using control structures like loops and conditionals. Once your code is written, you compile it using the Watfor77 compiler, which translates the Fortran code into an executable format. Finally, you run the compiled program to see the output.


Write a program that will graph using for loop?

A = 5do{statement;A = A + 1;} while (A < 10)


Write a C program to declare result of a student using multilevel?

This is a statement with a question mark?


How do you write a program using the gotoxy statement and print function to display letters of the alphabet on the computer screen?

There is no gotoxy statement in C.


Write FORTRAN90 program using gauss-quadrature rule?

you can finde integral with 4 gauss quadrature in book for meshfree writed by G.R.Liu after one chaper there is a program .in that is program that use gauss-quadrature for integral with fortran. excuse me for my bad writing.


Write a program large number and small number among n numbers by using If statement?

12


What has the author Francis D Tuggle written?

Francis D. Tuggle has written: 'How to program a computer, using Fortran IV' -- subject(s): FORTRAN IV (Computer program language) 'Organizational processes' -- subject(s): Management, Organization


How do you write a program using goto statement?

int main (void) { puts ("Hello"); goto LABEL; LABEL: return 0; }


How can i plot graph in gnuplot-fortran progarm?

To plot a graph in a Gnuplot-Fortran program, you typically write your data to a file in a format that Gnuplot can read, such as plain text or CSV. Then, you can call Gnuplot from your Fortran code using system commands to execute a Gnuplot script or command that specifies how to display the data. For example, you might use SYSTEM('gnuplot -p -e &quot;plot \'data.txt\' using 1:2 with lines&quot;') to plot the data from the file data.txt. Ensure Gnuplot is installed and accessible in your system's PATH for this to work.