load15.gms : Test consistent compile time error checking when loading symbols

Description

This test ensures consistent error checking when loading data into GAMS with

- $[gdx]load                [CT load]
- execute_load              [ET load]
- $offEmbeddedCode
  - explicit loaded sybols  [CT expl]
  - implicit loaded sybols  [CT impl]
- endEmbeddedCode
  - explicit loaded sybols  [ET expl]
  - implicit loaded sybols  [ET impl]

Not everything behaves the same. This gives an overview about the test that
expect an error (ERR) or should work fine (OK). Some tests cannot be done (-).
This can be sorted in 6 categories:

                                            |CT load|ET load|CT expl|CT impl|ET expl|ET impl|
---------------------------------------------------------------------------------------------
Errors in any case
Not allowed to change protected symbols     |  ERR  |  ERR  |  ERR  |  ERR  |  ERR  |  ERR  |
Symbol loaded needs to be a "GDX Type"      |  ERR  |  ERR  |  ERR  |  ERR  |  ERR  |  ERR  |
Symbol loaded need to be of same dimension  |  ERR  |  ERR  |  ERR  |  ERR  |  ERR  |  ERR  |
Singleton with more than one entry          |  ERR  |  ERR  |  ERR  |  ERR  |  ERR  |  ERR  |
---------------------------------------------------------------------------------------------
Errors in any case - but cannot be tested for implicit loading
Symbol loaded need to be a valid identifier |  ERR  |  ERR  |  ERR  |   -   |  ERR  |   -   |
Symbol loaded need to be known              |  ERR  |  ERR  |  ERR  |   -   |  ERR  |   -   |
No suffix allowed                           |  ERR  |  ERR  |  ERR  |   -   |  ERR  |   -   |
---------------------------------------------------------------------------------------------
Errors in any case - but implicit loading
Symbol loaded cannot be an Alias            |  ERR  |  ERR  |  ERR  |   OK  |  ERR  |   OK  |
---------------------------------------------------------------------------------------------
Errors at ET, but OK at CT
Can not assign external input symbol        |   OK  |  ERR  |   OK  |   OK  |  ERR  |  ERR  |
Cannot assign to domain set                 |   OK  |  ERR  |   OK  |   OK  |  ERR  |  ERR  |
Cannot redefine loop control set            |   OK  |  ERR  |   OK  |   OK  |  ERR  |  ERR  |
---------------------------------------------------------------------------------------------
Errors at CT, but OK at ET
Cannot load symbol from implicit GDX input, |  ERR  |   OK  |  ERR  |  ERR  |   OK  |   OK  |
   if it was not declared as external input
---------------------------------------------------------------------------------------------
Special ET load treatment
Symbol loaded need to be of same type       |  ERR  |   OK  |  ERR  |  ERR  |  ERR  |  ERR  |
---------------------------------------------------------------------------------------------

Contributor: Lutz Westermann, May 2022


Small Model of Type : GAMS


Category : GAMS Test library


Main file : load15.gms

$title Test consistent compile time error checking when loading symbols (LOAD15,SEQ=904)

$onText
This test ensures consistent error checking when loading data into GAMS with

- $[gdx]load                [CT load]
- execute_load              [ET load]
- $offEmbeddedCode
  - explicit loaded sybols  [CT expl]
  - implicit loaded sybols  [CT impl]
- endEmbeddedCode
  - explicit loaded sybols  [ET expl]
  - implicit loaded sybols  [ET impl]
  
Not everything behaves the same. This gives an overview about the test that
expect an error (ERR) or should work fine (OK). Some tests cannot be done (-).
This can be sorted in 6 categories:

                                            |CT load|ET load|CT expl|CT impl|ET expl|ET impl|
---------------------------------------------------------------------------------------------
Errors in any case
Not allowed to change protected symbols     |  ERR  |  ERR  |  ERR  |  ERR  |  ERR  |  ERR  |
Symbol loaded needs to be a "GDX Type"      |  ERR  |  ERR  |  ERR  |  ERR  |  ERR  |  ERR  |
Symbol loaded need to be of same dimension  |  ERR  |  ERR  |  ERR  |  ERR  |  ERR  |  ERR  |
Singleton with more than one entry          |  ERR  |  ERR  |  ERR  |  ERR  |  ERR  |  ERR  |
---------------------------------------------------------------------------------------------
Errors in any case - but cannot be tested for implicit loading
Symbol loaded need to be a valid identifier |  ERR  |  ERR  |  ERR  |   -   |  ERR  |   -   |
Symbol loaded need to be known              |  ERR  |  ERR  |  ERR  |   -   |  ERR  |   -   |
No suffix allowed                           |  ERR  |  ERR  |  ERR  |   -   |  ERR  |   -   |
---------------------------------------------------------------------------------------------
Errors in any case - but implicit loading
Symbol loaded cannot be an Alias            |  ERR  |  ERR  |  ERR  |   OK  |  ERR  |   OK  |
---------------------------------------------------------------------------------------------
Errors at ET, but OK at CT
Can not assign external input symbol        |   OK  |  ERR  |   OK  |   OK  |  ERR  |  ERR  |
Cannot assign to domain set                 |   OK  |  ERR  |   OK  |   OK  |  ERR  |  ERR  |
Cannot redefine loop control set            |   OK  |  ERR  |   OK  |   OK  |  ERR  |  ERR  |
---------------------------------------------------------------------------------------------
Errors at CT, but OK at ET
Cannot load symbol from implicit GDX input, |  ERR  |   OK  |  ERR  |  ERR  |   OK  |   OK  |
   if it was not declared as external input
---------------------------------------------------------------------------------------------
Special ET load treatment
Symbol loaded need to be of same type       |  ERR  |   OK  |  ERR  |  ERR  |  ERR  |  ERR  |
---------------------------------------------------------------------------------------------

Contributor: Lutz Westermann, May 2022
$offText


********************************************************************
* Prepare GDX File with data
$onEcho > data.gms
Scalar   f    / 7      /;
Set      i    / i1*i3  /;
Variable v(i) / i1.l 4 /;
$offEcho
$call.checkErrorLevel gams data.gms lo=%GAMS.lo% gdx=data


********************************************************************
* Symbol loaded need to be a valid identifier
* Note: Not possible with implicit load - EC throws an error already
$onEcho > gdxLoad.gms
$gdxLoad data.gdx sum
$offEcho
$call gams gdxLoad.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > exec_load.gms
execute_load 'data.gdx', sum;
$offEcho
$call gams exec_load.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > offECExpl.gms
$onEmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i, newName: sum}]
$offEmbeddedCode sum
$offEcho
$call gams offECExpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > endECExpl.gms
EmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i, newName: sum}]
endEmbeddedCode sum
$offEcho
$call gams endECExpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%


********************************************************************
* Symbol loaded need to be known
* Note: Not possible with implicit load - EC throws an error already
$onEcho > gdxLoad.gms
$gdxLoad data.gdx i
$offEcho
$call gams gdxLoad.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > exec_load.gms
execute_load 'data.gdx', i;
$offEcho
$call gams exec_load.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > offECExpl.gms
$onEmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i}]
$offEmbeddedCode i
$offEcho
$call gams offECExpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > endECExpl.gms
EmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i}]
endEmbeddedCode i
$offEcho
$call gams endECExpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%


********************************************************************
* No suffix allowed
* Note: Not possible with implicit load - no way to specify a suffix
$onEcho > gdxLoad.gms
Set i; Variable v(i<);
$gdxLoad data.gdx v.l
$offEcho
$call gams gdxLoad.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > exec_load.gms
Set i; Variable v(i);
$gdxLoad data.gdx i
execute_load 'data.gdx', v.l;
$offEcho
* This should work
$call gams exec_load.gms lo=%GAMS.lo%
$ifE errorlevel<>0 $abort No error expected at line %system.line%

$onEcho > offECExpl.gms
Set i; Variable v(i);
$onEmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}, {name: v}]
- GAMSWriter:
    symbols: [{name: i}, {name: v}]
$offEmbeddedCode i v.l
$offEcho
$call gams offECExpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > endECExpl.gms
Set i; Variable v(i);
$gdxLoad data.gdx i
EmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: v}]
- GAMSWriter:
    symbols: [{name: v}]
endEmbeddedCode v.l
$offEcho
$call gams endECExpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%


********************************************************************
* Not allowed to change protected symbols
$onEcho > gdxLoad.gms
Set i(*);
$protect i
$gdxLoad data.gdx i
$offEcho
$call gams gdxLoad.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > exec_load.gms
Set i(*);
$protect i
execute_load 'data.gdx', i;
$offEcho
$call gams exec_load.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > offECExpl.gms
Set i(*);
$protect i
$onEmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i}]
$offEmbeddedCode i
$offEcho
$call gams offECExpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > offECImpl.gms
Set i(*);
$protect i
$onEmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i}]
$offEmbeddedCode
$offEcho
$call gams offECImpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > endECExpl.gms
Scalar f;
$protect f
EmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: f}]
- GAMSWriter:
    symbols: [{name: f}]
endEmbeddedCode f
$offEcho
$call gams endECExpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > endECImpl.gms
Set    d /i1*i3/;
Scalar f;
$protect f
EmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: f}]
- GAMSWriter:
    symbols: [{name: f}]
endEmbeddedCode
$offEcho
$call gams endECImpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%


********************************************************************
* Symbol loaded needs to be a set, parameter, equation or variable
$onEcho > gdxLoad.gms
Model i;
$gdxLoad data.gdx i
$offEcho
$call gams gdxLoad.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > exec_load.gms
Model i;
execute_load 'data.gdx', i;
$offEcho
$call gams exec_load.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > offECExpl.gms
Model i;
$onEmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i}]
$offEmbeddedCode i
$offEcho
$call gams offECExpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > offECImpl.gms
Model i;
$onEmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i}]
$offEmbeddedCode
$offEcho
$call gams offECImpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > endECExpl.gms
Model i;
EmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i}]
endEmbeddedCode i
$offEcho
$call gams endECImpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > endECImpl.gms
Model i;
EmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i}]
endEmbeddedCode
$offEcho
$call gams endECImpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%


********************************************************************
* Symbol loaded cannot be an Alias
$onEcho > gdxLoad.gms
Set j(*); Alias (j,i);
$gdxLoad data.gdx i
$offEcho
$call gams gdxLoad.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > exec_load.gms
Set j(*); Alias (j,i);
execute_load 'data.gdx', i;
$offEcho
$call gams exec_load.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > offECExpl.gms
Set j(*); Alias (j,i);
$onEmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i}]
$offEmbeddedCode i
$offEcho
$call gams offECExpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > offECImpl.gms
Set j(*); Alias (j,i);
$onEmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i}]
$offEmbeddedCode
$offEcho
* This should work - implict loading is special
$call gams offECImpl.gms lo=%GAMS.lo%
$ifE errorlevel<>0 $abort No error expected at line %system.line%

$onEcho > endECExpl.gms
Set j(*) /i1*i7/; Alias (j,i);
EmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i}]
endEmbeddedCode i
$offEcho
$call gams endECExpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > endECImpl.gms
Set j(*) /i1*i7/; Alias (j,i);
EmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i}]
endEmbeddedCode
$offEcho
* This should work - implict loading is special
$call gams endECImpl.gms lo=%GAMS.lo%
$ifE errorlevel<>0 $abort No error expected at line %system.line%


********************************************************************
*Cannot load symbol from implicit GDX input, if it was not declared as external input
$onEcho > gdxLoad.gms
Set i(*);
$onExternalInput
$gdxLoad data.gdx i
$offExternalInput
$offEcho
$call gams gdxLoad.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > exec_load.gms
Set i(*);
$onExternalInput
execute_load 'data.gdx', i;
$offExternalInput
$offEcho
* This should work
$call gams exec_load.gms lo=%GAMS.lo%
$ifE errorlevel<>0 $abort No error expected at line %system.line%

$onEcho > offECExpl.gms
Set i(*);
$onExternalInput
$onEmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i}]
$offEmbeddedCode i
$offExternalInput
$offEcho
$call gams offECExpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > offECImpl.gms
Set i(*);
$onExternalInput
$onEmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i}]
$offEmbeddedCode
$offExternalInput
$offEcho
$call gams offECImpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > endECExpl.gms
Set      i    / i1*i3  /;
Scalar   f;
$onExternalInput
EmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: f}]
- GAMSWriter:
    symbols: [{name: f}]
endEmbeddedCode f
$offExternalInput
$offEcho
* This should work
$call gams endECExpl.gms lo=%GAMS.lo%
$ifE errorlevel<>0 $abort No error expected at line %system.line%

$onEcho > endECImpl.gms
Set      i    / i1*i3  /;
Scalar   f;
$onExternalInput
EmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: f}]
- GAMSWriter:
    symbols: [{name: f}]
endEmbeddedCode
$offExternalInput
$offEcho
* This should work
$call gams endECImpl.gms lo=%GAMS.lo%
$ifE errorlevel<>0 $abort No error expected at line %system.line%emp.info%


********************************************************************
*Can not assign to a symbol declared as external input
$onEcho > gdxLoad.gms
$onExternalInput
Scalar f / 0 /;
$offExternalInput
$onMulti
$gdxLoad data.gdx f
$offEcho
* This should work
$call gams gdxLoad.gms lo=%GAMS.lo%
$ifE errorlevel<>0 $abort No error expected at line %system.line%

$onEcho > exec_load.gms
$onExternalInput
Scalar f / 0 /;
$offExternalInput
$onMulti
execute_load 'data.gdx', f;
$offEcho
$call gams exec_load.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > offECExpl.gms
$onExternalInput
Scalar f / 0 /;
$offExternalInput
$onMulti
$onEmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: f}]
- GAMSWriter:
    symbols: [{name: f}]
$offEmbeddedCode f
$offEcho
* This should work
$call gams offECExpl.gms lo=%GAMS.lo%
$ifE errorlevel<>0 $abort No error expected at line %system.line%

$onEcho > offECImpl.gms
$onExternalInput
Scalar f / 0 /;
$offExternalInput
$onMulti
$onEmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: f}]
- GAMSWriter:
    symbols: [{name: f}]
$offEmbeddedCode
$offEcho
* This should work
$call gams offECImpl.gms lo=%GAMS.lo%
$ifE errorlevel<>0 $abort No error expected at line %system.line%

$onEcho > endECExpl.gms
$onExternalInput
Scalar f / 0 /;
$offExternalInput
$onMulti
EmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: f}]
- GAMSWriter:
    symbols: [{name: f}]
endEmbeddedCode f
$offEcho
$call gams endECExpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > endECImpl.gms
$onExternalInput
Set    i / i1*i3  /;
Scalar f / 0 /;
$offExternalInput
$onMulti
EmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: f}]
- GAMSWriter:
    symbols: [{name: f}]
endEmbeddedCode
$offEcho
$call gams endECImpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%emp.info%


********************************************************************
* Symbol loaded need to be of same type
$onEcho > gdxLoad.gms
Parameter i(*);
$gdxLoad data.gdx i
$offEcho
$call gams gdxLoad.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > exec_load.gms
Set    d / i1*i3  /;
Parameter i(*);
execute_load 'data.gdx', i;
$offEcho
* This should work
$call gams exec_load.gms lo=%GAMS.lo%
$ifE errorlevel<>0 $abort No error expected at line %system.line%

$onEcho > offECExpl.gms
Parameter i(*);
$onEmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i}]
$offEmbeddedCode i
$offEcho
$call gams offECExpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > offECImpl.gms
Parameter i(*);
$onEmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i}]
$offEmbeddedCode
$offEcho
$call gams offECImpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > endECExpl.gms
Parameter i(*);
EmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i}]
endEmbeddedCode i
$offEcho
$call gams endECImpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > endECImpl.gms
Parameter i(*);
EmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i}]
endEmbeddedCode
$offEcho
$call gams endECImpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%emp.info%


********************************************************************
* Symbol loaded need to be of same dimension
$onEcho > gdxLoad.gms
Parameter f(*);
$gdxLoad data.gdx f
$offEcho
$call gams gdxLoad.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > exec_load.gms
Set    d / i1*i3  /;
Parameter f(*);
execute_load 'data.gdx', f;
$offEcho
$call gams exec_load.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > offECExpl.gms
Parameter f(*);
$onEmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: f}]
- GAMSWriter:
    symbols: [{name: f}]
$offEmbeddedCode f
$offEcho
$call gams offECExpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > offECImpl.gms
Parameter f(*);
$onEmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: f}]
- GAMSWriter:
    symbols: [{name: f}]
$offEmbeddedCode
$offEcho
$call gams offECImpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > endECExpl.gms
Parameter f(*);
EmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: f}]
- GAMSWriter:
    symbols: [{name: f}]
endEmbeddedCode f
$offEcho
$call gams endECImpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > endECImpl.gms
Parameter f(*);
EmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: f}]
- GAMSWriter:
    symbols: [{name: f}]
endEmbeddedCode
$offEcho
$call gams endECImpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%emp.info%


********************************************************************
* Singleton with more than one entry
$onEcho > gdxLoad.gms
Singleton Set i(*);
$gdxLoad data.gdx i
$offEcho
$call gams gdxLoad.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > exec_load.gms
Set    d / i1*i3  /;
Singleton Set i(*);
execute_load 'data.gdx', i;
$offEcho
$call gams exec_load.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > offECExpl.gms
Singleton Set i(*);
$onEmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i}]
$offEmbeddedCode i
$offEcho
$call gams offECExpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > offECImpl.gms
Singleton Set i(*);
$onEmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i}]
$offEmbeddedCode
$offEcho
$call gams offECImpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > endECExpl.gms
Set    d / i1*i3  /;
Singleton Set i(*);
EmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i}]
endEmbeddedCode i
$offEcho
$call gams endECImpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > endECImpl.gms
Set    d / i1*i3  /;
Singleton Set i(*);
EmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i}]
endEmbeddedCode
$offEcho
$call gams endECImpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%emp.info%


********************************************************************
* Cannot assign to domain set
$onEcho > gdxLoad.gms
Set       i    / i2   /;
Parameter p(i) / i2 2 /;
$onMulti
$gdxLoad data.gdx i
$offEcho
* This should work
$call gams gdxLoad.gms lo=%GAMS.lo%
$ifE errorlevel<>0 $abort No error expected at line %system.line%

$onEcho > exec_load.gms
Set       i    / i2   /;
Parameter p(i) / i2 2 /;
execute_load 'data.gdx', i;
$offEcho
$call gams exec_load.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > offECExpl.gms
Set       i    / i2   /;
Parameter p(i) / i2 2 /;
$onMulti
$onEmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i}]
$offEmbeddedCode i
$offEcho
* This should work
$call gams offECExpl.gms lo=%GAMS.lo%
$ifE errorlevel<>0 $abort No error expected at line %system.line%

$onEcho > offECImpl.gms
Set       i    / i2   /;
Parameter p(i) / i2 2 /;
$onMulti
$onEmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i}]
$offEmbeddedCode
$offEcho
* This should work
$call gams offECImpl.gms lo=%GAMS.lo%
$ifE errorlevel<>0 $abort No error expected at line %system.line%

$onEcho > endECExpl.gms
Set       i    / i2   /;
Parameter p(i) / i2 2 /;
EmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i}]
endEmbeddedCode i
$offEcho
$call gams endECImpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > endECImpl.gms
Set       d    / i1*i3 /;
Set       i    / i2    /;
Parameter p(i) / i2 2  /;
EmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i}]
endEmbeddedCode
$offEcho
$call gams endECImpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%emp.info%


********************************************************************
* Cannot redefine loop control set
$onEcho > gdxLoad.gms
Set       i    / i2   /;
$onMulti
loop(i,
$ gdxLoad data.gdx i
  display i;
);
$offEcho
* This should work
$call gams gdxLoad.gms lo=%GAMS.lo%
$ifE errorlevel<>0 $abort No error expected at line %system.line%

$onEcho > exec_load.gms
Set       i    / i2   /;
loop(i,
  display i;
  execute_load 'data.gdx', i;
);
$offEcho
$call gams exec_load.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > offECExpl.gms
Set       i    / i2   /;
$onMulti
loop(i,
$onEmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i}]
$offEmbeddedCode i
  display i;
);
$offEcho
* This should work
$call gams offECExpl.gms lo=%GAMS.lo%
$ifE errorlevel<>0 $abort No error expected at line %system.line%

$onEcho > offECImpl.gms
Set       i    / i2   /;
$onMulti
loop(i,
$onEmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i}]
$offEmbeddedCode
  display i;
);
$offEcho
* This should work
$call gams offECImpl.gms lo=%GAMS.lo%
$ifE errorlevel<>0 $abort No error expected at line %system.line%

$onEcho > endECExpl.gms
Set       i    / i2   /;
loop(i,
EmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i}]
endEmbeddedCode i
  display i;
);
$offEcho
$call gams endECImpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%

$onEcho > endECImpl.gms
Set       d    / i1*i3 /;
Set       i    / i2   /;
loop(i,
EmbeddedCode Connect:
- GDXReader:
    file: data.gdx
    symbols: [{name: i}]
- GAMSWriter:
    symbols: [{name: i}]
endEmbeddedCode
  display i;
);
$offEcho
$call gams endECImpl.gms lo=%GAMS.lo%
$ifE errorlevel=0 $abort Error expected at line %system.line%emp.info%