Dear all
I am trying to implement nested GAMS calls.
To be more concrete, I have a top-level GAMS file, say, root.GMS, which calls a PowerShell script, say myscript.ps1, with the following code:
execute "powershell -File C:\gams\MyModel\myscript.ps1"
This PowerShell script loops through a series of parameters to call a set of other GAMS scripts:
$Years = (2013..2030)
foreach ($CurrentYr in $Years ) {
gams branch.GMS --year=$CurrentYr
}
The problem is that branch.GMS does not recognize the parameters that are used in root.GMS.
One obvious solution would be to split root.GMS in two, and to use the save and restart facilities. The first part would include all the code up to the call to myscript.ps1 (call this root1.GMS), and the second part would include all the code from myscript.ps1. (call this root2.GMS).
The following PowerShell code should work then (assuming no parameters are defined in branch.GMS that are needed in root2.GMS):
gams root1.GMS s=root1
$Years = (2013..2030)
foreach ($CurrentYr in $Years ) {
gams branch.GMS --year=$CurrentYr r=root1
}
gams root2.GMS r=root1
However, this solution would quickly become unwieldy with several layers of nesting. Is there any other approach that would allow me to pass on the parameters defined in root1.GMS to branch.GMS without abandoning the nesting structure?