There are various options to execute GAMS (or other programs) within GAMS:
$call 'external program'
execute 'external program';
$call 'external program' calls the shell to execute you command and shell commands like redirection (
>) or piping (
|) are possible.
$call '=external program' calls a single executable without using the shell. In most cases you can use just
$call 'external program', but is a slight overhead with the shell call.
The Bruce McCarl User Guide features some nice information about this, please search for: “Executing an external program” and “Executing an external program”. If you are using the Windows version, you will find the Mc Carl User Guide at: Help → Expanded GAMS Guide (Mc Carl). Please also have a look at this entry: “User defined Functions or Subroutines”.
Within the optimization (while the solver is running) you can:
If using the GAMS IDE, then the log of a model if called by
$call =gams your_model.gms or
execute “gams trnsport.gms”; will not be shown in the process window of the GAMS IDE and will not be accessible after the model run. To make the log also appear in the GAMS IDE process window, add the following lines to your model:
$setglobal ide "ide=%gams.ide% lo=%gams.lo% errorlog=%gams.errorlog% errmsg=1" $call =gams your_model.gms %ide% $if errorlevel 1 $abort your_model failed
$setglobal ide "ide=%gams.ide% lo=%gams.lo% errorlog=%gams.errorlog% errmsg=1" execute "gams your_model.gms %ide%"; abort$errorlevel 'your_model failed';
Note, that also other options that have been set for the main GAMS run are not automatically passed on. For example, if you use an alternative license file, then you may want to add
license=%gams.license% to the GAMS call.