Command line Keyword in the gams script

Problems with syntax of GAMS
Post Reply
Jubeyer
User
User
Posts: 41
Joined: 4 years ago

Command line Keyword in the gams script

Post by Jubeyer »

Hi,

What is the correct syntax of including the command line keyword in the code?
For example, I am executing this command

>gams mycode keep=1 --USE_GAMS='YES'
So, how should I write the 'keep=1 --USE_GAMS='YES' ' in the syntax of the .gms file instead of writing each time in the command line.

My other question is:
What is the correct syntax of a set command in the .gms script.
For example:

In the command prompt I write:
>set GMSPYTHONLIB=c:\path\to\python\python38.dll
So, how should I write it inside the .gms script so that I don't need to set it each time in the command line when I wish to run the script?

Regards,
Jubeyer
Fred
Posts: 372
Joined: 7 years ago

Re: Command line Keyword in the gams script

Post by Fred »

Hi,
please find some commnets below.
Jubeyer wrote: 2 years ago Hi,

What is the correct syntax of including the command line keyword in the code?
For example, I am executing this command

>gams mycode keep=1 --USE_GAMS='YES'
So, how should I write the 'keep=1 --USE_GAMS='YES' ' in the syntax of the .gms file instead of writing each time in the command line.
keep is a GAMS command line parameter that cannot be set inside the gms file. If you aplways want to keep your scratch directory for all GAMS runs, you could put that command line parameter into your GAMS configuration file.
--USE_GAMS is a double dash parameter that defines a compile time variable. In your gms file you could add

Code: Select all

$if not set USE_GAMS $set USE_GAMS YES
You use 'YES' as the default value for the compile time variable.

Jubeyer wrote: 2 years ago My other question is:
What is the correct syntax of a set command in the .gms script.
For example:

In the command prompt I write:
>set GMSPYTHONLIB=c:\path\to\python\python38.dll
So, how should I write it inside the .gms script so that I don't need to set it each time in the command line when I wish to run the script?
You could use the GAMS configuration file again or your OS' way to permanently set environment variables. You cannot control the Python lib used for embedded code from within your gms file.

I hope this helps!

Fred
shih
User
User
Posts: 8
Joined: 1 year ago

Re: Command line Keyword in the gams script

Post by shih »

Hi,

I have a similar question about the correct syntax for passing double dash parameter value from command line to the main program.

For example, I am executing this command

$call gams test_doubledash.gms --month = July

I am passing "July" to the main program. In the main program I have:

$if not set month $set month Jan
if ( %month% = Jan,
Display "Jan";
elseif %month% = Apr,
Display "Apr";
elseif %month% = July,
Display "July";
elseif %month% = Oct,
Display "October";
);

I am getting unknow symbol error messages for every elseif command line, except July. Any idea where I got it wrong? Thanks for the help in advance! JSS
Fred
Posts: 372
Joined: 7 years ago

Re: Command line Keyword in the gams script

Post by Fred »

Hi,

You can use $ifthen (or its case insensitove variant $iftheni).

Code: Select all

$if not set month $set month Jan
$iftheni %month%==Jan
  Display "Jan";
$elseIfi %month%== Apr
  Display "Apr";
$elseIfi %month%==July
  Display "July";
$elseIfi %month%==Oct
  Display "October";
$endif
I hope this helps!

Fred
shih
User
User
Posts: 8
Joined: 1 year ago

Re: Command line Keyword in the gams script

Post by shih »

Thanks Fred! It is very helpful!
Post Reply