Josef 'Jupp' Schugt
3/3/2006 12:06:00 AM
Hi!
At Thu, 2 Mar 2006 20:48:37 +0900,Bil Kleb wrote:
>
> Try to write the following Fortran 77 program (note the
> 6 space indentation) in Ruby so that it looks as close
> to the Fortran as possible without extending Ruby:
>
> program ii
> integer i
> do i=0,10
> print*,i
> if (i.gt.5) goto 1
> enddo
> 1 print*,i*i
> end
First of all there is no programming language calles "Fortran 77". The
correct name is "FORTRAN 77". The spelling "Fortran" is used for more
recent versions like "Fortran 90". Next the above program is no valid
FORTRAN 77. If a compiler sticks to the FORTRAN 77 specification it
will issue a syntax error because "enddo" is unknown to it. FORTRAN 77
do-loops start with the DO keyword followed by a label. The label
names the line that marks the end of the loop. The labelled statement
*must* be an executable one. People tend to use "continue" for this
purpose.
program ii
integer i
do 1 i=0,10
print*,i
if (i.gt.5) goto 2
1 continue
2 print*,i*i
end
If your compiler supports "end do" (which is no F77) it may as well
support "exit" (which isn't either) so that you can write:
program ii
integer i
do i=0,10
print*,i
if (i.gt.5) exit
end do
print*,i*i
end
Besides that all variables starting with an 'i' are already integers
so that you can write
program ii
do i=0,10
print*,i
if (i.gt.5) exit
end do
print*,i*i
end
Nevertheless I prefer Fortran 90+ and write
program ii
do i=0,10
print*,i
if (i>5) exit
end do
print*,i*i
end
You may need to provide the command line option "-free" or similar :->
I learned FORTRAN 77 on an IBM Mainframe using a terminal that had a
"Mixed case display/Uppercase only display" switch :-)
Josef 'Jupp' Schugt
--
50°40'8"N/7°9'58"E = 50°40.1333'N/7°9.9667'E = 50.668889°/7.166111°