Azzera filtri
Azzera filtri

fortran matlab

2 visualizzazioni (ultimi 30 giorni)
Michael
Michael il 18 Giu 2012
Hi,
I am using intel fortran in matlab. While converting an existing matlab function to fortran, I get the following error message after successful compiling the file (upon the attempt to run my code): "MATLAB has attempted to use more stack space than is available. If a mex file was in use check for large local variables or infinite recursion"
How can I fix this? I am moving large arrays from matlab to fortran but I need to do that. Is there any way to get it to work? Thank you
Michael

Risposta accettata

James Tursa
James Tursa il 18 Giu 2012
Stack space typically comes from local variables and intermediate calculations. Try to avoid these for large variables. Use allocatable variables instead, which come from the heap. E.g., this causes the memory for x to come from the stack:
subroutine foo
real*8 x(10000000)
whereas this will cause the memory for x to come from the heap (generally much larger than the stack):
subroutine foo
real*8, allocatable :: x(:)
allocate(x(10000000))
:
deallocate(x)
If an intermediate calculation is causing a stack overflow, e.g. a large matrix calculation, try to break it down into old F77 style do-loops instead.
  1 Commento
Michael
Michael il 18 Giu 2012
Thanks a lot James, that solved my problem!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Fortran with MATLAB in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by