From: Yi on
Hi,

I am using matlab engine application to solve matrices (fortran call matlab software). everything is OK until I solved matrices for 10250 times.

The program give the following information "Can't start Matlab engine"

I am just wondering is there any limitation for the times Fortran can call in engine application? What can i do if I want to call matlab software for more times?

If there is no limitation, then what could be the problem?

Thanks
Yi
From: James Tursa on
"Yi " <njumeiyi(a)gmail.com> wrote in message <hup1o9$kvp$1(a)fred.mathworks.com>...
> Hi,
>
> I am using matlab engine application to solve matrices (fortran call matlab software). everything is OK until I solved matrices for 10250 times.
>
> The program give the following information "Can't start Matlab engine"
>
> I am just wondering is there any limitation for the times Fortran can call in engine application? What can i do if I want to call matlab software for more times?
>
> If there is no limitation, then what could be the problem?

Are you stopping and then restarting your Fortran program each time? Are you closing your MATLAB engine each time? Do you run your program only once and inside your program open the MATLAB engine 10250 times? etc. etc. Exactly how are you doing this?

James Tursa
From: Yi on
Sorry, I should have get every detail here.

I wrote all the code related to engine function in a fortran subroutine, and
I execute a fortran main program to call this subroutine.
The main program do a loop to call the matlab engine subroutine every iteration to solve matrix. The loop is more than 400000.
I did open and close the engine every time I solved matrix.
I do run my program only once and inside my program open the MATLAB engine 10250 times.

Do you mean I just need to open the engine once until the end of the main program?
Any other things I need to clarify?

Thank you so much!!




"James Tursa" <aclassyguy_with_a_k_not_a_c(a)hotmail.com> wrote in message <hupem1$8fo$1(a)fred.mathworks.com>...
> "Yi " <njumeiyi(a)gmail.com> wrote in message <hup1o9$kvp$1(a)fred.mathworks.com>...
> > Hi,
> >
> > I am using matlab engine application to solve matrices (fortran call matlab software). everything is OK until I solved matrices for 10250 times.
> >
> > The program give the following information "Can't start Matlab engine"
> >
> > I am just wondering is there any limitation for the times Fortran can call in engine application? What can i do if I want to call matlab software for more times?
> >
> > If there is no limitation, then what could be the problem?
>
> Are you stopping and then restarting your Fortran program each time? Are you closing your MATLAB engine each time? Do you run your program only once and inside your program open the MATLAB engine 10250 times? etc. etc. Exactly how are you doing this?
>
> James Tursa
From: James Tursa on
"Yi " <njumeiyi(a)gmail.com> wrote in message <hupj2l$l31$1(a)fred.mathworks.com>...
>
> I wrote all the code related to engine function in a fortran subroutine, and
> I execute a fortran main program to call this subroutine.
> The main program do a loop to call the matlab engine subroutine every iteration to solve matrix. The loop is more than 400000.
> I did open and close the engine every time I solved matrix.
> I do run my program only once and inside my program open the MATLAB engine 10250 times.
>
> Do you mean I just need to open the engine once until the end of the main program?

yes, Yes, YES !!! Just open it once at the beginning of your program and then pass the engine pointer ... keep reusing the same pointer over and over again. When the program is done then close the engine at that time. Or, if you prefer, don't close it but leave it open when the program ends. This latter tact can be useful if you want any figures/plots you created to remain on the screen after the program ends. Then once you are done looking at the figures you can close the MATLAB engine manually whenever you want.

What you are currently doing is a tremendous waste of time and resources and is certainly slowing your program down.

James Tursa
From: Yi on
Problem solved !!!
Thank you so much!!

"James Tursa" <aclassyguy_with_a_k_not_a_c(a)hotmail.com> wrote in message <hupkl8$31j$1(a)fred.mathworks.com>...
> "Yi " <njumeiyi(a)gmail.com> wrote in message <hupj2l$l31$1(a)fred.mathworks.com>...
> >
> > I wrote all the code related to engine function in a fortran subroutine, and
> > I execute a fortran main program to call this subroutine.
> > The main program do a loop to call the matlab engine subroutine every iteration to solve matrix. The loop is more than 400000.
> > I did open and close the engine every time I solved matrix.
> > I do run my program only once and inside my program open the MATLAB engine 10250 times.
> >
> > Do you mean I just need to open the engine once until the end of the main program?
>
> yes, Yes, YES !!! Just open it once at the beginning of your program and then pass the engine pointer ... keep reusing the same pointer over and over again. When the program is done then close the engine at that time. Or, if you prefer, don't close it but leave it open when the program ends. This latter tact can be useful if you want any figures/plots you created to remain on the screen after the program ends. Then once you are done looking at the figures you can close the MATLAB engine manually whenever you want.
>
> What you are currently doing is a tremendous waste of time and resources and is certainly slowing your program down.
>
> James Tursa