fsolve with external fortran subroutine
Eduardo Torrecillas
eduardo.torrecillas at gmail.com
Mon Jul 16 16:04:51 CEST 2012
Hi everybody,
I am trying to use fsolve with a fortran subroutine as argument. For
example, consider the following calling sequence:
X0=[0 0]
tol=1E-15
[X,v]=fsolve(X0,'fequil_fortran',tol)
In this case 'fequil_fortran' is my external fortran subroutine, given
below:
--------------------------------------------------------------------
subroutine fequil_fortran(n,x,v,iflag)
implicit none
integer,intent(in)::n,iflag
real(kind=8),dimension(n),intent(in)::x
real(kind=8),dimension(n),intent(out)::vreal(kind=8)::a,b
a=1.0_dp
b=2.0_dp
v(1)=a*x(1)+b*x(2)-1.0_dp
v(2)=2.0_dp*a*x(1)-b*x(2)-5.0_dp
end subroutine fequil_fortran
---------------------------------------------------------------------
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?
Regards,
--
Eduardo Torrecillas
AER-09
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20120716/0d6ec753/attachment.htm>
More information about the users
mailing list