Topic: go to label

when I write:  if (foo .GT. 0) go to 30
and then put "30" where the line number would have been (if line#s were shown) then
program will not build.  I get "Error. 30 not defined."

How do I get a line label to work?

Re: go to label

Is that your exact code? Shouldn't "go to" be one word? GOTO 30
What variety of Fortran are you using?

I'm not asking what version of SimplyFortran. I mean are you using .F95 or some other.

Re: go to label

jackmitchener wrote:

... then put "30" where the line number would have been (if line#s were shown) then
program will not build.  I get "Error. 30 not defined."

Can you provide a little more context?  It seems that the issue is how the numbered label is defined, and you didn't provide the actual text of said line.  I'm not sure what "put "30" where the line number would have been" means.

Jeff Armstrong
Approximatrix, LLC

Re: go to label

!Using f90
program helloworld   
    implicit none     
    integer i, row, col
    real a(9), summ
    a=0   
    summ=0
    row =0
    col =0
    print*,"Hello World"     
    read*, a
    Print*,a
    DO i=0, 8
      col= REAL(i)
      if ((i .GT. 0).AND.(a(i) .EQ.0 )) go to 17  ! This is the problem line.
      summ = summ + 2**i
17    PRINT*(I1,f3.0),i, summ
    end do
end program helloworld

Re: go to label

Your code actually produces two errors, and the important one is actually causing the error you're reporting.  The line with label 17 is not formatted correctly.  The compiler actually does produce an error:

going.f90:19:13:

   19 | 17    PRINT*(I1,f3.0),i, summ
      |             1
Error: Expected comma in I/O list at (1)

You actually need to fix this line first.  I would personally rewrite it as:

17    Write(*, '(I1,f3.0)') i, summ

The format you had used isn't valid Fortran, at least in the modern, standards-compliant sense.  After I change it to what I've suggested, it works fine.  The label couldn't be found because it couldn't successfully compile the labeled line.

Jeff Armstrong
Approximatrix, LLC

Re: go to label

Thanks Jeff. Sure appreciate it.