Hi everyone,
Thanks a lot for your help. Fortran II is really very primitive, I just read the manual mentioned above. The supported int range is only -2047,+2047. So it could not properly represent a large Fibonacci number, unless I use REAL...
I now moved on to play with FOTRAN IV😂, I wanted to port some code (in F77 or F90?) back to FORTRAN IV to calculate PI digits,
program pi
implicit none
integer,dimension(3350) :: vect
integer,dimension(201) :: buffer
integer :: more,karray,num,k,l,n
more = 0
vect = 2
do n = 1,201
karray = 0
do l = 3350,1,-1
num = 100000*vect(l) + karray*l
karray = num/(2*l - 1)
vect(l) = num - karray*(2*l - 1)
end do
k = karray/100000
buffer(n) = more + k
more = karray - k*100000
end do
write (*,'(i2,"."/(1x,10i5.5))') buffer
end program pi
I ported back as:
C THIS PROGRAM CALCULATES THE DIGITS OF PI
C IN FORTRAN IV
DIMENSION(3350) IVEC
DIMENSION(201) IBUF
MORE=0
KARR=0
NUM=0
K=0
L=0
N=0
C INIT OF IVEC
DO 10 IM=1,3350
IVEC(IM)=2
10 CONTINUE
C ========CALC OF PI========
DO 200 N=1,201
KARR=0
DO 150 L=3350,1,-1
NUM = 100000 * IVEC(L) + KARR * L
KARR = NUM/(2*L - 1)
IVEC(L) = NUM - KARR * (2*L - 1)
150 CONTINUE
K = KARR/100000
IBUF(N) = MORE + K
MORE = KARR - K * 100000
200 CONTINUE
C WRITE OUT BUFFER
DO 260 IM=1,201
WRITE(4,255) IBUF(IM)
255 FORMAT(I1)
260 CONTINUE
END
But when I do .EXE PIDIG
I got several errors:
TD 0002
TD 0003
SF 0022
SF 0031
(1) I read the manual it says that after the error code, there is the ISN, does ISN mean something about line number? So 0002 is the 2nd line (including the comments lines or not?)?
I checked the manual TD means that there was a bad type declaration, but I declared IVEC and IBUF as integer arrays (with I in front) ...
How can I correct this code to calculate the PI digits?
Thanks a lot.
Happy New Year!
Yifan