(adsbygoogle = window.adsbygoogle || []).push({}); Getting an "unclassifiable statement" error in Fortran 95

I am trying to integrate the function x from 0 to 1. Here is my code:

program myownmonte

!This program will integrate the function x from 0 to 1

implicit none

real :: ans0,y,f,x,xmax

integer :: icount,nmax,i,iseed

iseed = 89237

call srand(iseed)

nmax = 100000

icount = 0

xmax = 1

ans0 = 0

do i=1,nmax

x = rand()

y = rand()

f = f(x)

if (y.le.f) then

icount = icount + 1

end if

ans0 = ans0 + f(x)

end do

print *, icount/nmax,ans0/nmax

end program myownmonte

function f(x)

implicit none

real :: x,f

f = x

end function f

And here are the errors I'm getting:

f = f(x)

1

Error: Unclassifiable statement at (1)

mymonte.f95:21:

ans0 = ans0 + f(x)

1

Error: Unclassifiable statement at (1)

Could someone help me fix this, and kindly let me know what the phrase "unclassifiable statement" means? Thanks in advance!

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Getting an unclassifiable statement error in Fortran 95

**Physics Forums | Science Articles, Homework Help, Discussion**