<p>Hi everybody,</p><p>I am trying to use fsolve with a fortran subroutine as argument. For example, consider the following calling sequence:</p><p>X0=[0 0]</p><p>tol=1E-15</p><p>[X,v]=fsolve(X0,'fequil_fortran',tol) </p>

<p> </p><p>In this case 'fequil_fortran' is my external fortran subroutine, given below:</p><p>--------------------------------------------------------------------</p><p>subroutine fequil_fortran(n,x,v,iflag)</p>
<p>
implicit none</p><p>integer,intent(in)::n,iflag</p><p>real(kind=8),dimension(n),intent(in)::x</p><p>real(kind=8),dimension(n),intent(out)::vreal(kind=8)::a,b</p><p> a=1.0_dp</p><p>b=2.0_dp</p><p>v(1)=a*x(1)+b*x(2)-1.0_dp</p>

<p>v(2)=2.0_dp*a*x(1)-b*x(2)-5.0_dp</p><p>end subroutine fequil_fortran</p><p>---------------------------------------------------------------------</p><p>It
 worked fine and fsolve found the solution. Now, suppose I have to pass 
arguments to the fortran subroutine, in addition to the default 
(n,x,v,iflag). For instance, imagine I had to pass the 'a' and 'b' 
variables from Scilab to the fortran subroutine in the code above. I 
have already performed something like this but with "optim". In fact, 
"optim" gives you the possibility to pass a list of integer, real or 
double variables to the external code. Is there anything similar to be 
used with fsolve?</p>Regards,<br clear="all"><br>-- <br>Eduardo Torrecillas<br>AER-09<br>