1

Currently, I'm working with a finite element software called DIANA, I've been always capable of running "simple" models with MATLAB executing a batch file. Nevertheless, now I'm starting to use more "complex" models (just more robust, with more elements), but the procedure is exactly the same to the one that I've been using before. The problem is that now I can't run the model from MATLAB, it apparently start to run it, but stops suddenly. I'm using the next commands:

dos('path\filename.bat')

or

system(fullfile(path,'filename.bat' ))

Both lines execute the .bat file. I thought that I had something wrong with the files, so I reviewed them but apparently there's nothing wrong with them. Then I just made double click on the .bat file, and the procedure runs without problems. Then I realized that the problem wasn't the files, it was the execution from MATLAB. Now that you know the context of the problem, can you giving me some advice in order to avoid that MATLAB "kills" the process internally?

The trace of execution showed in MATLAB:

diana: working directory is *CURRENT DIRECTORY NAME*
diana: input file is *FILENAME*.dat
diana: command file is *FILENAME*.dcf
diana: output file is *FILENAME*.out
diana: filos file is diana.ff
DIANA JOB 8028 finished 

The trace execution making directly double click in the batch file is the following:

enter image description here

In the remarked files showed in the previous figure, are contained the output of the model, while executing directly from MATLAB, those don't appear, because MATLAB finish the process before.

Thanks in advance for any answer!

Pd: I'm using a computer with the next characteristics: Windows7, 12 Gb RAM, OS 64bits, Processor Intel Xeon 2.53 GHz.

lisandrojim
  • 509
  • 5
  • 18

2 Answers2

1

What you are running is not strictly equivalent to a double click on the .bat file, specially because current directory is different, and if the batch file needs to access to auxiliary files (relative path), then the files won't be found.

Try adding this in your batch file as the first command (or right after echo off)

Cd /d %~dp0
Jean-François Fabre
  • 137,073
  • 23
  • 153
  • 219
  • Thanks! Jean-François Fabre for the reply! Well, I understand what you mean, but actually, I'm changing the current directory from MATLAB in order to avoid what you mentioned. However I tried what you suggest, including the line in the batch file like follows: [rem === Diana Environment Setup === // call "C:\Program Files\Diana 10.0\dialogin.bat" // Cd /d %~dp0 // diana FILENAME]. But unfortunately the same problem continues. – lisandrojim Aug 06 '16 at 21:34
  • Ok, then maybe add a `pause` statement in the end of your batch file. If it fails from matlab, at least you'll see why. – Jean-François Fabre Aug 06 '16 at 21:36
  • This is what I obtain in the command windows of MATLAB: diana: working directory is CURRENTDIRECTORY // diana: input file is FILENAME.dat // diana: command file is FILENAME.dcf // diana: output file is FILENAME.out // diana: filos file is diana.ff // DIANA JOB 8028 finished // No problems were reported. – lisandrojim Aug 06 '16 at 21:38
  • I already edited your post with execution trace. Feel free to accept/refuse the edit, but which would be great is that you post the execution trace with and without matlab (direct double click) in your question. I may delete my answer since it does not solve your problem, and in that case all comments are deleted too (plus it's more readable in the question!) – Jean-François Fabre Aug 06 '16 at 21:43
  • Ok, Let's do what you're suggesting. – lisandrojim Aug 06 '16 at 21:46
  • can you post the contents of `dialogin.bat`. Also I see "administrator" in your cmd prompt. Would it be possible that you don't execute matlab with the same privileges? – Jean-François Fabre Aug 07 '16 at 07:25
0

Here is the solution provided by Diana support team:

It seems that MATLAB sets some environment symbols that limit the memory usage per thread.

When you start Diana from Matlab via a batch file that resets the symbols all works fine.

Such a batch file may look like:

rem === Diana Environment Setup ===
    call "C:\Program Files\Diana 10.0\dialogin.bat"

rem Unset the symbols added by MATLAB
    set KMP_STACKSIZE=
    set KMP_HANDLE_SIGNALS=
    set KMP_BLOCKTIME=

rem start the diana job
    diana test2
rozsasarpi
  • 1,621
  • 20
  • 34