I am trying to invoke an external function through a dummy function name. The error is:
Error 1 error #6634: The shape matching rules of actual arguments and dummy arguments have been violated. [G]
the code is:
Module DummyFG
contains
function DF(DummyF, x,n)
implicit none
integer :: n
real(kind=8) ,intent(in):: x(n)
real(kind=8) :: DF
real (kind=8) :: DummyF
DF = DummyF(x,n)
end function DF
function DG(DummyG, x, n)
implicit none
integer :: n
real(kind=8) , intent(in):: x(n)
real(kind=8) :: dG(n)
real (kind=8), external :: DummyG
dg= DummyG(x,n)
end function DG
end Module DummyFG
!
function f(x,n) !result(f1)
implicit none
real(kind=8) :: f
real(kind=8) ,intent(in) :: x(n)
integer :: n
f=(1.0-x(1))**2+100.0*((x(2)-x(1)**2))**2;
end function f
function G(x,n) result(g1)
implicit none
integer :: n
real(kind=8) ,intent(in) :: x(n)
real(kind=8) :: g1(n)
g1(1)=-2.0*(1.0-x(1))-400.0*x(1)*(x(2)-x(1)**2)
g1(2)= 200.0*(x(2)-x(1)**2)
end function g
The driver routine is:
program Test
implicit none
! Variables
integer, parameter :: n=2
real(kind=8) :: x(n)=(/2.0,1.0/)
call check(x,n)
contains
subroutine check(x,n)
use dummyfg
implicit none
interface
function f(x,n)
implicit none
integer :: n
real(kind=8) :: f
real(kind=8) ,intent(in) :: x(:)
end function f
function g(x,n) result(g1)
implicit none
integer :: n
real(kind=8) ,intent(in) :: x(n)
real(kind=8) :: g1(n)
end function g
end interface
integer :: n
real(kind=8) :: x(n),fc, gc(size(x))
fc=df(f,x,n)
gc=dg(g,x,n)
end subroutine check
end program Test
Any help is appreciated very much!!!