|
|
 |
 |
 |
 |
Fortran Programming Language
|
 |
 |
 |
 |
 |
 |
 |
 |
problem with NEQNF
Hi everybody Before that , I have used "NEQNF " , to solve system of nonlinear equations . but with below program I have a problem !! there is no problem in running it , the error is in its answer . the program doesn't really solve system , it only write initial guess ,instead of answers . can anybody helps me ? Use numerical_libraries implicit none !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! integer ITMAX, N real ERRREL parameter (N=2) integer K, NOUT real FNORM,X(N), XGUESS(N) external FCN data XGUESS/ 2 , 0.5 / ERRREL = 0.0001 ITMAX = 100 call UMACH (2, NOUT) call NEQNF (FCN, ERRREL, N, ITMAX, XGUESS, X, FNORM) write (*,*),X(1),X(2) ,FNORM end !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !C User-defined subroutine subroutine FCN (M, F, N) integer N real X(N), F(N) real u1,u2 real tE,b1,theta,t0,t pi=4.0*atan(1.0) theta=pi/3 t0=0.2 tE=10 b1=0.5 m1=0.5 m2=1-m1 B=0 d=1 t=-1 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! u1=b1*sin(theta)+((t-t0)/tE)*cos(theta) u2=b1*cos(theta)-((t-t0)/tE)*sin(theta) F(1)=X(1)-m1*X(1)/(X(1)**2+X(2)**2)-m2*(X(1)-m1*B*X(1)/(X(1)**2 &+X(2)**2)-d)/((X(1)-m1*B*X(1)/(X(1)**2+X(2)**2)-d)**2+(X(2)-m1* &B*X(2)/(X(1)**2+X(2)**2))**2)-u1 F(2)=X(2)-m1*X(2)/(X(1)**2+X(2)**2)-m2*(X(2)-m1*B*X(2)/(X(1)**2+ &X(2)**2))/((X(1)-m1*B*X(1)/(X(1)**2+X(2)**2)-d)**2+(X(2)- m1*B*X(2) &/(X(1)**2+X(2)**2))**2)-u2 end best,nakisa
On May 1, 9:31 am, nakisa <nakisa.noor@gmail.com> wrote: ... > Before that , I have used "NEQNF " , to solve system of nonlinear > equations . > but with below program I have a problem !! there is no problem in > running it , the error is in its answer . the program doesn't really > solve system , it only write initial guess ,instead of answers . > can anybody helps me ?
... Did you check for IMSL error returns/messages? Not time to actually try it right, now, but if no error messages, check that the function when called is actually computing what you think it is -- maybe you have an undiagnosed error there. --
Nakisa: Subroutine FCN is an independend subprogam that uses the 2-vector, X.. I may be misssing something, but... How are the vallues of X (as used to computer F) defined for this subprogram? (Also, M is not declared in FCN) Skip Knoble On 1 May 2007 07:31:29 -0700, nakisa <nakisa.noor@gmail.com> wrote: -|Hi everybody -|Before that , I have used "NEQNF " , to solve system of nonlinear -|equations . -|but with below program I have a problem !! there is no problem in -|running it , the error is in its answer . the program doesn't really -|solve system , it only write initial guess ,instead of answers . -|can anybody helps me ? -| -| -|Use numerical_libraries -| implicit none -| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -| integer ITMAX, N -| real ERRREL -| parameter (N=2) -| -| integer K, NOUT -| real FNORM,X(N), XGUESS(N) -| external FCN -| -| -| data XGUESS/ 2 , 0.5 / -| -| ERRREL = 0.0001 -| ITMAX = 100 -| -| call UMACH (2, NOUT) -| call NEQNF (FCN, ERRREL, N, ITMAX, XGUESS, X, -|FNORM) -| write (*,*),X(1),X(2) ,FNORM -| end -| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -|!C User-defined subroutine -| subroutine FCN (M, F, N) -| integer N -| real X(N), F(N) -| -| real u1,u2 -| real tE,b1,theta,t0,t -| -| pi=4.0*atan(1.0) -| theta=pi/3 -| -| t0=0.2 -| tE=10 -| b1=0.5 -| -| m1=0.5 -| m2=1-m1 -| B=0 -| d=1 -| -| t=-1 -| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -| u1=b1*sin(theta)+((t-t0)/tE)*cos(theta) -| u2=b1*cos(theta)-((t-t0)/tE)*sin(theta) -| -| F(1)=X(1)-m1*X(1)/(X(1)**2+X(2)**2)-m2*(X(1)-m1*B*X(1)/(X(1)**2 -| &+X(2)**2)-d)/((X(1)-m1*B*X(1)/(X(1)**2+X(2)**2)-d)**2+(X(2)-m1* -| &B*X(2)/(X(1)**2+X(2)**2))**2)-u1 -| -| F(2)=X(2)-m1*X(2)/(X(1)**2+X(2)**2)-m2*(X(2)-m1*B*X(2)/(X(1)**2+ -| &X(2)**2))/((X(1)-m1*B*X(1)/(X(1)**2+X(2)**2)-d)**2+(X(2)- -|m1*B*X(2) -| &/(X(1)**2+X(2)**2))**2)-u2 -| -| end -| -|best,nakisa
On May 1, 10:31 am, nakisa <nakisa.noor@gmail.com> wrote: > Hi everybody > Before that , I have used "NEQNF " , to solve system of nonlinear > equations . > but with below program I have a problem !! there is no problem in > running it , the error is in its answer . the program doesn't really > solve system , it only write initial guess ,instead of answers . > can anybody helps me ?
You didn't say which compiler you were using, but I have seen problems like this before and perhaps you have the same issue. Typically, the user with the problem was a former user of Compaq (or Digital) Visual Fortran and had converted their project to Intel Visual Fortran. This conversion applies the /iface:cvf option which changes the default calling convention to match CVF's, which is different from Intel Fortran's default. The problem is that the IMSL for Intel Fortran assumes the default conventions for callback procedures and there's no way to diagnose the mismatch. What happens then is that the stack is incrementally corrupted on each call to FCN, resulting in unpredictable behavior. If this situation applies to you, then the best option is to set the calling convention back to the Intel default. Right click on the project name in Visual Studio, select Properties, then Fortran, External Procedures. Change the Calling Convention to Default and make sure that "String length argument passing" is set to "After all args" or "inherit from project default". Then rebuild the application. If for some reason you cannot do that, then add the line: !DEC$ ATTRIBUTES DEFAULT :: FCN to the FCN routine. It may be that your problem is entirely different, and you may not even be using our compiler. but I have seen enough of these issues (maybe three or four) to suggest it as a possibility. Steve
dear dpb i don't know what IMSL error returns/message is ! can you guide me ? dear steve i think my problem is not the same with yours . i use Compaq visual fortran 6.5 . before that i have used " NEQNF " with this program . now , i checked that program again , it works nicely and gives answer ! but above program doesn't work !!! i think there is a problem with the program that i wrote , am i wrong ? best,nakisa
nakisa wrote: > Hi everybody > Before that , I have used "NEQNF " , to solve system of nonlinear > equations . > but with below program I have a problem !! there is no problem in > running it , the error is in its answer . the program doesn't really > solve system , it only write initial guess ,instead of answers . > can anybody helps me ? > Use numerical_libraries > implicit none > !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! > integer ITMAX, N > real ERRREL > parameter (N=2) > integer K, NOUT > real FNORM,X(N), XGUESS(N) > external FCN > data XGUESS/ 2 , 0.5 / > ERRREL = 0.0001 > ITMAX = 100 > call UMACH (2, NOUT) > call NEQNF (FCN, ERRREL, N, ITMAX, XGUESS, X, > FNORM) > write (*,*),X(1),X(2) ,FNORM > end > !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! > !C User-defined subroutine > subroutine FCN (M, F, N) > integer N > real X(N), F(N) > real u1,u2 > real tE,b1,theta,t0,t > pi=4.0*atan(1.0) > theta=pi/3 > t0=0.2 > tE=10 > b1=0.5 > m1=0.5 > m2=1-m1 > B=0 > d=1 > t=-1 > !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! > u1=b1*sin(theta)+((t-t0)/tE)*cos(theta) > u2=b1*cos(theta)-((t-t0)/tE)*sin(theta) > F(1)=X(1)-m1*X(1)/(X(1)**2+X(2)**2)-m2*(X(1)-m1*B*X(1)/(X(1)**2 > &+X(2)**2)-d)/((X(1)-m1*B*X(1)/(X(1)**2+X(2)**2)-d)**2+(X(2)-m1* > &B*X(2)/(X(1)**2+X(2)**2))**2)-u1 > F(2)=X(2)-m1*X(2)/(X(1)**2+X(2)**2)-m2*(X(2)-m1*B*X(2)/(X(1)**2+ > &X(2)**2))/((X(1)-m1*B*X(1)/(X(1)**2+X(2)**2)-d)**2+(X(2)- > m1*B*X(2) > &/(X(1)**2+X(2)**2))**2)-u2 > end > best,nakisa
Your function FCN does not depend on X! You also have some variables that are improperly typed by the default type rules. For example, "m1=0.5" assigns zero to m1, perhaps not what you intended. Add "implicit none" to your subroutine to see. -- mecej4
|
 |
 |
 |
 |
|