When I am using a fortran function defined with an array and trying to access the function inside another routine, that is giving segmentation fault. Below is my code.
module abcd
implicit none
contains
real*8 function f(x)
real*8,intent(in)::x(:)
f=sum(x)
end function f
real*8 function funco(f,n)
real*8,external::f
integer,intent(in)::n !dimension of array to be used with f
real*8::y(n)
y=1
funco=f(y)
end function funco
end module abcd
use abcd
implicit none
write(*,*) funco(f,10)
end
Here, I have explicitly defined the array y inside funco, still segmentation fault is coming. My original program is required to use a function that behaves like the function funco. I gave this small example for demonstrating my issue.