- #1

- 5

- 0

## Main Question or Discussion Point

I am trying to run a program with fortran. The program is about solving the Oscillator using Euler Method. I am trying to run this code and applying array arguments (as I want to extend it to 3 dimensions afterwards).

When I try to compile, it comes up with an error "Unclassifiable statement at (1)". I don't know how to resolved this error.

This is my code:

program Oscilator

implicit none

real :: h !(Step size)

integer, parameter :: n=100

real, dimension(1:n) :: x,v,t

external dx,dv

integer :: i

x(1) = 0.017

t(1) = 0.0

v(1) = 0.0

write(*,*) 't x v'

do while(t(i) <= n)

h = t(i+1) - t(i)

call Euler(h,x,v)

write(6,'(4(e12.5,3x))') t(i), x(i), v(i)

t(i)=t(i+1)

x(i)=x(i+1)

v(i)=v(i+1)

end do

end program Oscilator

function dx(t)

implicit none

real dx, t

dx = exp(-0.9*t)*(-2.5*exp(0.557*t)-2.8*exp(-0.557*t))

end function dx

function dv(t)

implicit none

real dv, t

dv=-0.2941*exp(-0.343*t)-5.9439*exp(-1.457*t)

end function dv

subroutine Euler(h,x,v)

implicit none

real :: v,x,h,dv

integer :: i

x(i+1) = x(i) + v(i)*h

v(i+1) = v(i) + dv(i)*h

end subroutine Euler

When I try to compile, it comes up with an error "Unclassifiable statement at (1)". I don't know how to resolved this error.

This is my code:

program Oscilator

implicit none

real :: h !(Step size)

integer, parameter :: n=100

real, dimension(1:n) :: x,v,t

external dx,dv

integer :: i

x(1) = 0.017

t(1) = 0.0

v(1) = 0.0

write(*,*) 't x v'

do while(t(i) <= n)

h = t(i+1) - t(i)

call Euler(h,x,v)

write(6,'(4(e12.5,3x))') t(i), x(i), v(i)

t(i)=t(i+1)

x(i)=x(i+1)

v(i)=v(i+1)

end do

end program Oscilator

function dx(t)

implicit none

real dx, t

dx = exp(-0.9*t)*(-2.5*exp(0.557*t)-2.8*exp(-0.557*t))

end function dx

function dv(t)

implicit none

real dv, t

dv=-0.2941*exp(-0.343*t)-5.9439*exp(-1.457*t)

end function dv

subroutine Euler(h,x,v)

implicit none

real :: v,x,h,dv

integer :: i

x(i+1) = x(i) + v(i)*h

v(i+1) = v(i) + dv(i)*h

end subroutine Euler