'Error Unclassifiable Statement at (1) in a fortran code for the Archimedes pi problem
i'm doing a code in Fortran for the Archimedes aproximation of Pi. When I compile the code in the Terminal send the Unclassifiable statement error.
This is the code.
implicit none
real*8 n,P0,P,F,G,H,I,J,pi,L,x
open(10,file='valordepi.out',status='unknown')
P0=2.d0*(2.d0**(0.5d0))
P=P0
do
n=1,100
pi=acos(x)
x=-1
P(n)=P/2.d0**n
F=-P(n)**2.d0
G=(1.d0-F)**0.5d0
H=1.d0-G
I=(2.d0*H)**0.5d0
J=I*2.d0**n
P=J
L=(J-pi)/pi
write(10,*) n,J,L
end do
close(10)
The idea is check the approximation of the Archimedes solution and get the data to do the graphic. The error is in the line when i wrote n=1,100
Greetings and thanks for the help.
Solution 1:[1]
I check the code several times, and now i got it like this.
implicit none
integer n
real*8 P0,P,F,G,H,I,J,pi,L,x
open(10,file='valordepi.out',status='unknown')
P0=2.d0*(2.d0**(0.5d0))
P=P0
x=-1.d0
pi=acos(x)
do n=2,50
P=P/2.d0**n
F=P**2.d0
G=(1.d0-F)**0.5d0
H=1.d0-G
I=(2.d0*H)**0.5d0
J=I*2.d0**n
P=J
L=abs(J-pi)
write(10,*) n,J,L
write(*,*) n,J,L
end do
close(10)
This code don't have errors, and do just what i asked.
Thanks to everyone for the reply.
The error I did was that the n=2,50 wasn't in the do line.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Juan Orrego |
