Changing stack size of system shell

조회 수: 4 (최근 30일)
Ross
Ross 2012년 1월 24일
I'm calling several pieces of FORTRAN code from within MATLAB using the system command as such:
system(['myFORTRANcode ', num2str(input variable)]);
This works great but one of the FORTRAN programs requires a stack size larger than the default 8192kB. I'm using Linux. If I was running the FORTRAN program from a standard terminal shell, I would simply use
ulimit -s unlimited
However, the ulimit command doesn't seem to work within the MATLAB shell interface, ie I cannot simply type:
system('ulimit -s unlimited');
The command doesn't error, but it doesn't change anything either. Using
system('ulimit -s');
to echo the stack size back returns 8192 as before, instead of the (expected) unlimited.
Any ideas? I don't understand how ulimit alters the stack size, nor do I have a good handle on MATLAB's memory issues with respect to its system shell.

채택된 답변

Walter Roberson
Walter Roberson 2012년 1월 24일
ulimit -s unlimited has to be run in the same shell session as your code. Each system() call invokes a new shell.
system(['ulimit -s unlimited; myFORTRANcode ', num2str(input variable)]);
  댓글 수: 1
Ross
Ross 2012년 1월 26일
Fantastic, that completely solves my problem. Thanks for your help.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Jason Ross
Jason Ross 2012년 1월 26일
You can change a lot of these parameters at the system level. It generally starts with editing limits.conf and making a few alterations to some of the PAM module configuration files. You didn't state what distro you are using, but google has some decent howtos on how to set this up so that the limit is set to higher value (or unlimited). It sounds harder than it is :)

카테고리

Help CenterFile Exchange에서 Fortran with MATLAB에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by