Command line parameters in a file

Top  Previous  Next

Command line parameters can be placed in a text file then read.  This is indicated by including an entry in the program invocation that contains an @ followed by the name of the parameter file of instructions to read.

Example:

Suppose I wish to enter many of the Gdxxrw commands in the gdxxrwread.gms example into a file and execute all the commands with one execution of Gdxxrw.  I can do this using a parameter file gdxxrwparam.txt and the GAMS code in the example Gdxxrwread3.gms as follows

 

$call 'gdxxrw gdxxrwss.xls  o=gdxall.gdx @gdxxrwparam.txt'

 

where the parameter file gdxxrwparam.txt  is

 

se=0

set=i1            Rng=sheet1!a2:c2      cdim=1

dset=i1a          Rng=sheet1!a2:c2      cdim=1

set=i3            Rng=sheet1!a9:e10     cdim=1

dset=i4           Rng=sheet1!a13        cdim=1

se=0

set=i4a           Rng=sheet1!a13        cdim=1            dim=1

se=0

set=i5            Rng=sheet1!a16        cdim=1

set=i6            Rng=sheet1!b20:d20    cdim=1

dset=i6a          Rng=sheet1!b20:d20    cdim=1

dset=i6c          Rng=sheet1!b20:d21    cdim=1

dset=i7           Rng=sheet1!b26:e26    cdim=1

dset=i8           Rng=sheet1!b27:e27    cdim=1

set=i9            Rng=sheet1!b20:c21    cdim=1

set=i10           Rng=sheet1!b26:e27    cdim=2

set=i10a          Rng=sheet1!b26:e27    cdim=2

set=j1            Rng=sheet1!a35:a37    cdim=0    rdim=1

dset=j1a          Rng=sheet1!a35:a37    cdim=0    rdim=1

set=j2            Rng=sheet1!a40:b43    cdim=0    rdim=1

set=j3            Rng=sheet1!a46:b50    cdim=0    rdim=1

dset=j4           Rng=sheet1!a21:a23    cdim=0    rdim=1

dset=j5           Rng=sheet1!a53:a56    cdim=0    rdim=1

dset=j6           Rng=sheet1!b53:b56    cdim=0    rdim=1

par=distance      Rng=sheet1!a20:d23    cdim=1    rdim=1

par=distance2     Rng=sheet1!a20:d23

par=modedistance  Rng=sheet1!a26:e31    cdim=2    rdim=1

par=modedistance2 Rng=sheet1!a52:e56    cdim=1    rdim=2

par=modedistance3 Rng=skipempty!a2:g69  cdim=1    rdim=2

par=modedistance4 Rng=skipempty!a2:g69  cdim=1    rdim=2

 

that will control the Gdxxrw actions.

Notes:

A parameter file can contain multiple lines to increase readability.
When reading parameters from a text file, lines starting with an asterisk (*) will be ignored and act as a comment.
A put file can be used to write a parameter file can also be written during the execution of a GAMS model where one must use a Putclose as discussed in the Output using Put Commands chapter in the option file section or as implemented in Xlexport.gms and the subsequent Gdxxrw commands must use Execute so the put file is written before it is to be read (This will not happen with $Call).