求解嵌套非线性方程组,改程序,求助
我要求A1,A3,可是只有含有A1,A3的表达式A,B,C,D的关系式,编程如下,求大师指导program tu2
use IMSL
implicit none
external FCN
real*8 FCN
real,parameter::ERRREL=0.0001
integer,parameter::N=2
integer,parameter::ITMAX=100
real*8::XGUESS(N)=(/0.0467,0.0732/)
real X(N),FNORM
real*8 A1,A2,A3,A,B,C,D
real*8 Z0,Zi
real*8 E,F
real,parameter::pi=3.14159
integer,parameter::Zrs=5
integer,parameter::A4s=9
integer k,i
real*8::Zr(Zrs)=(/1.0,2.0,3.0,4.0,5.0/)
real*8::A4(A4s)=(/0.075,0.10,0.15,0.20,0.25,0.30,0.35,0.40,0.425/)
common /group2/ zi
common /group3/ A2
!!**************************************************
Zi=-3.0 !!天线阻抗虚部的值
Z0=50.0 !!传输线的特性阻抗
A2=0.25 !!第二个支节的长度
!!***************************************************
do i=1,Zrs
do k=1,A4s
callNEQNF(Zr(i),A4(k),FCN(i,k),ERRREL,N,ITMAX,XGUESS,X,FNORM)
write(*,*) X
stop
end
!!!**************************
subroutine A4_get_A(A4,A)
implicit none
real*8 A2,A3,A4,A
real,parameter::pi=3.14159
common /group3/ A2
A=cos(2.0*pi*A2)*cos(2.0*pi*A4)-sin(2.0*pi*A2)*(-cos(2.0*pi*A4)/tan(2.0*pi*A3)+sin(2.0*pi*A4)) !!A的函数式
return
end
!!!***************************
subroutine A4_get_B(A4,B)
implicit none
real*8 A2,A3,A4,z0,B
real,parameter::pi=3.14159
common /group3/ A2
common /group1/ Z0
B=Z0*(cos(2.0*pi*A2)*sin(2.0*pi*A4)+sin(2.0*pi*A2)*(sin(2.0*pi*A4)/tan(2.0*pi*A3)+cos(2.0*pi*A4))) !!B的函数式
return
end
!!*****************************
subroutine A4_get_C(A4,C)
implicit none
real*8 A1,A2,A3,A4,Z0,C
real,parameter::pi=3.14159
common /group3/ A2
common /group1/ Z0
C=1.0/Z0*(cos(2.0*pi*A4)*((-cos(2.0*pi*A2))/tan(2.0*pi*A1)+sin(2.0*pi*A2))+(sin(2.0*pi*A2)/tan(2.0*pi*A1)+cos(2.0*pi*A2))*((-cos(2.0*pi*A4))/tan(2.0*pi*A3)+sin(2.0*pi*A4)))
return
end
!!*******************************
subroutine A4_get_D(A4,D)
implicit none
real*8 A1,A2,A3,A4,D
real,parameter::pi=3.14159
common /group3/ A2
D=-sin(2.0*pi*A4)*(-cos(2.0*pi*A2)/tan(2.0*pi*A1)+sin(2.0*pi*A2))+(sin(2.0*pi*A2)/tan(2.0*pi*A1)+cos(2.0*pi*A2))*(sin(2.0*pi*A4)/tan(2.0*pi*A3)+cos(2.0*pi*A4))
return
end
!!****************************************************
subroutine FCN(A,B,C,D,A4,Zr,XA,F,N)
implicit none
integer N
real,target::XA(N)
real F(N)
real,pointer::A1,A3
real*8 A,B,C,D,A4,Z0,Zr,Zi
common /group1/Z0
common /group2/Zi
A1=>XA(1)
A3=>XA(2)
call A4_get_A(A4,A)
call A4_get_B(A4,B)
call A4_get_C(A4,C)
call A4_get_D(A4,D)
F(1)=A*D+B*C-Z0*((D-C*Zi)*(D-C*Zi)+(C*Zr)*(C*Zr))
F(2)=(D*A-B*C)*Zi-A*C*(Zr*Zr+Zi*Zi)+D*B
return
end
以下是错误指示
Compiling Fortran...
C:\Program Files\Microsoft Visual Studio\MyProjects\tu2\tu2.f90
C:\Program Files\Microsoft Visual Studio\MyProjects\tu2\tu2.f90(29) : Error: The number of actual arguments cannot be greater than the number of dummy arguments.
callNEQNF(Zr(i),A4(k),FCN(i,k),ERRREL,N,ITMAX,XGUESS,X,FNORM)
------^
C:\Program Files\Microsoft Visual Studio\MyProjects\tu2\tu2.f90(29) : Error: The type of the actual argument differs from the type of the dummy argument.
callNEQNF(Zr(i),A4(k),FCN(i,k),ERRREL,N,ITMAX,XGUESS,X,FNORM)
------------------^
C:\Program Files\Microsoft Visual Studio\MyProjects\tu2\tu2.f90(29) : Error: The type of the actual argument differs from the type of the dummy argument.
callNEQNF(Zr(i),A4(k),FCN(i,k),ERRREL,N,ITMAX,XGUESS,X,FNORM)
------------------------^
C:\Program Files\Microsoft Visual Studio\MyProjects\tu2\tu2.f90(29) : Error: The type of the actual argument differs from the type of the dummy argument.
callNEQNF(Zr(i),A4(k),FCN(i,k),ERRREL,N,ITMAX,XGUESS,X,FNORM)
---------------------------------^
C:\Program Files\Microsoft Visual Studio\MyProjects\tu2\tu2.f90(29) : Error: The type of the actual argument differs from the type of the dummy argument.
callNEQNF(Zr(i),A4(k),FCN(i,k),ERRREL,N,ITMAX,XGUESS,X,FNORM)
----------------------------------------^
C:\Program Files\Microsoft Visual Studio\MyProjects\tu2\tu2.f90(29) : Error: The type of the actual argument differs from the type of the dummy argument.
callNEQNF(Zr(i),A4(k),FCN(i,k),ERRREL,N,ITMAX,XGUESS,X,FNORM)
------------------------------------------^
C:\Program Files\Microsoft Visual Studio\MyProjects\tu2\tu2.f90(29) : Error: The type of the actual argument differs from the type of the dummy argument.
callNEQNF(Zr(i),A4(k),FCN(i,k),ERRREL,N,ITMAX,XGUESS,X,FNORM)
------------------------------------------------^
C:\Program Files\Microsoft Visual Studio\MyProjects\tu2\tu2.f90(29) : Error: This actual argument must be the name of a user subroutine or the name of intrinsic subroutine.
callNEQNF(Zr(i),A4(k),FCN(i,k),ERRREL,N,ITMAX,XGUESS,X,FNORM)
------------^
C:\Program Files\Microsoft Visual Studio\MyProjects\tu2\tu2.f90(29) : Error: The shape matching rules of actual arguments and dummy arguments have been violated.
callNEQNF(Zr(i),A4(k),FCN(i,k),ERRREL,N,ITMAX,XGUESS,X,FNORM)
------------------------------------------------^
C:\Program Files\Microsoft Visual Studio\MyProjects\tu2\tu2.f90(28) : Error: An unterminated block exists.
do k=1,A4s
^
C:\Program Files\Microsoft Visual Studio\MyProjects\tu2\tu2.f90(27) : Error: An unterminated block exists.
do i=1,Zrs
^
Error executing df.exe.
tu2.obj - 11 error(s), 0 warning(s)
在此谢过!!
你的代码问题比较多。
1.主程序中,少两个 End Do
2.我在 IMSL 里找到的 NEQNF 是 7 个参数,而你给了 9 个。且第一个参数应该为一个外部函数,你给的是 Zr(i)
你先改这两个问题吧。
另外,我很好奇,这代码是你自己书写的吗?
为什么要用 common 呢?而且还用了 pointer
一个很新潮的指针,和一个老掉牙的 common 语句,放一起真是...很另类 fcode 发表于 2014-4-26 12:45
你的代码问题比较多。
1.主程序中,少两个 End Do
见笑了,我改改,那个啥我是模仿来的,嗯,谢谢你 fcode 发表于 2014-4-26 12:45
你的代码问题比较多。
1.主程序中,少两个 End Do
这是新手,我也是新学的,其中关于传递参数,指针有这个功能,common也有这个功能,但是common又有面临参数很多的问题,所以我们会几种方法混合用 您好,请问您求解嵌套非线性方程组的问题解决了吗?
页:
[1]