0

I have the code. And when I want an output, I get the error stated in the headline of this question. Can anyone tell me exactly what is the problem here?

program func
    implicit none
    real:: f
    print*, f(1,1,0), f(1,0)
end program func

function f(x,y,k)
real:: x,y, d = 1
real, optional:: k
if(present(k)) then
    d = 0
end if
if (d == 0) then
    f = x**2 - y**2
else
    f = x**2 + y**2
end if
end function f

The error this code is showing: Fortran: Explicit interface required for 'f' : optional argument.

Ian Bush
  • 6,514
  • 1
  • 19
  • 24
Pratyya10
  • 27
  • 1
  • 6
  • 1
    Does this answer your question? [Fortran - explicit interface](https://stackoverflow.com/questions/16486822/fortran-explicit-interface) – veryreverie Oct 28 '21 at 07:24

0 Answers0