Compiled Model Question...

Use this forum to post Vensim related questions.
Post Reply
SionC
Member
Posts: 39
Joined: Tue Nov 18, 2008 8:44 am

Compiled Model Question...

Post by SionC »

Hello,

I was wondering if you can help. I am trying to create a compiled model but having difficulties.

I am running Vensim 6.0 and have installed Microsoft Visual studio express 2010.

I have followed the intructions on your website and have updated the mdl.bat file and pointed to this file in the Tools/start up.

When I run the simulation, the cmd.exe window fires up and says

Setting environment for using Microsoft Visual Studio 2010 x86 tools.
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.

mdl.c


And the Vensim WIP form comes up with "Compiling Model Equations" with the '...' changing, but it does not complete the compiling equations process.

Any ideas? Im sure I am missing something obvious here!

Many thanks!
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Compiled Model Question...

Post by tomfid »

Have you checked http://blog.metasd.com/2011/06/setting- ... n-windows/?

The most likely error is a path problem - perhaps your MSVC 2010 installed to a path that's a bit different from that in mdl.bat. I'd check that first. Specifically, you need the CL command (cl.exe) to be in the path.
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Compiled Model Question...

Post by tomfid »

A likely candidate: on 64 bit systems, viz studio will be in C:\Program Files (x86) rather than C:\Program Files.
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Re: Compiled Model Question...

Post by Administrator »

Tom, our instructions ignore all the settings in mdl.bat and call VCVARS32.bat instead to set the environment (which seems ok as Sion's cmd window has the "Setting environment for...." appearing).


Is it a large model? Sometimes the new compiler can take an age to compile the model.

You can test if you remove the /O2 switch from the compiler option. Search mdl.bat and find "/O2" and just remove them.

Eg, change

Code: Select all

CL  /O2 /c /I "%2" /DWIN32 mdl.c 
to

Code: Select all

CL  /c /I "%2" /DWIN32 mdl.c 
and try again. It should dramatically increase compile time (at the expense of an optimization on run speed, that's what /O2 does).
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
SionC
Member
Posts: 39
Joined: Tue Nov 18, 2008 8:44 am

Re: Compiled Model Question...

Post by SionC »

Hi Tony, Tom,

Thanks for your help - I have got it working now :D ...

The compile was taking a long time to run through, and the time was greatly reduced by taking out the /02 switch. For info the improvements were as follows:

Run time without compilation = 49s
Compilation time without 02 switch = 49s, run time = 12 s
Compilation time with O2 switch = 18 minutes, run time = 10 s

From your previous posts you suggest that other compilers may be more efficient in terms of compilation time and the resulting simulation time - Are there any other compilers you would recommend using?

Thanks!
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Re: Compiled Model Question...

Post by Administrator »

The long compile time seems to have been introduced with Visual Studio 2005. If you can get hold of Visual Studio 6, the "optimized" compile time is not that different from the standard compile.

But I'd stick with just removing the /O2. A 2s saving is not really worth waiting 18 mins for.

The only experience I've had of other compilers was many years ago (the Borland C compiler came free with a magazine, so I tried to get it working (and failed)). The GCC compilers or MinGW ones should work, but the Microsoft compiler has always given very few problems so we stick with that (but without the /O2 switch).
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Compiled Model Question...

Post by tomfid »

The other obvious choice is gcc, which works fine on Mac & Linux. I have no personal experience with it on Windows though.
Post Reply