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.