Fortran,外部函数中数组变量作为参数引用出错,求解答 60
程序如下::programmainINCLUDE'link_fnl_shared.h'useqmc_intimplicitnoneinteger,parameter::n...
程序如下::
program main
INCLUDE 'link_fnl_shared.h'
use qmc_int
implicit none
integer, parameter :: ndim=10
real(kind(1d0)) :: a(ndim)
real(kind(1d0)) :: b(ndim)
real(kind(1d0)) :: result
integer :: I
external fcn
a = 0.d0
b = 1.d0
call qmc(fcn, a, b, result)
write (*,*) 'result = ', result
read(*,*)
end
real(kind(1d0)) function fcn(x)
implicit none
real(kind(1d0)), dimension(:) :: x
integer :: i, j
real(kind(1d0)) :: prod, sum, sign
sign = -1.d0
sum = 0.d0
do i=1, size(x)
prod = 1.d0
prod = product(x(1:i))
sum = sum + (sign * prod)
sign = -sign
enddo
fcn = sum
end function fcn
运行后显示
错误 1 error #6633:The type of the actual argument differs from the type of the dummy argument. [FCN] 展开
program main
INCLUDE 'link_fnl_shared.h'
use qmc_int
implicit none
integer, parameter :: ndim=10
real(kind(1d0)) :: a(ndim)
real(kind(1d0)) :: b(ndim)
real(kind(1d0)) :: result
integer :: I
external fcn
a = 0.d0
b = 1.d0
call qmc(fcn, a, b, result)
write (*,*) 'result = ', result
read(*,*)
end
real(kind(1d0)) function fcn(x)
implicit none
real(kind(1d0)), dimension(:) :: x
integer :: i, j
real(kind(1d0)) :: prod, sum, sign
sign = -1.d0
sum = 0.d0
do i=1, size(x)
prod = 1.d0
prod = product(x(1:i))
sum = sum + (sign * prod)
sign = -sign
enddo
fcn = sum
end function fcn
运行后显示
错误 1 error #6633:The type of the actual argument differs from the type of the dummy argument. [FCN] 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询