Timtam
Timtam

Reputation: 223

Syntax error when using caret for exponentiation

When I do:

   REAL FUNCTION  f(x)          
      REAL, INTENT(IN) :: x
      f = exp(-x)
    END FUNCTION  f 

it works but if I do:

   REAL FUNCTION  f(x)          
      REAL, INTENT(IN) :: x
      f = exp(-x^2)
    END FUNCTION  f 

I get an error:

  Error: Syntax error in argument list at (1)

but I need the x^2 function not the x. What to do?

Upvotes: 1

Views: 274

Answers (1)

Joni
Joni

Reputation: 111219

Use x ** 2 to exponentiate. Or x*x in this case.

Upvotes: 8

Related Questions