Description
This test ensures that embedded code can be started as very first action after restarting from a restart file and that the correct scratch dir is used when continuing from a restart file. Also, it ensures correct behavior with a restart file created by put_utility. Contributor: Lutz Westermann, June 2021
Small Model of Type : GAMS
Category : GAMS Test library
Main file : embpy09.gms
$title Test Embedded Code after restart (EMBPY09,SEQ=866)
$onText
This test ensures that embedded code can be started as very first action
after restarting from a restart file and that the correct scratch dir is
used when continuing from a restart file.
Also, it ensures correct behavior with a restart file created by
put_utility.
Contributor: Lutz Westermann, June 2021
$offText
$log --- Using Python library %sysEnv.GMSPYTHONLIB%
$onEcho > disp.gms
Display 'hello';
$offEcho
$onEcho > emb.gms
embeddedCode Python:
pass
endEmbeddedCode
$offEcho
$call.checkErrorLevel 'gams disp.gms lo=%GAMS.lo% s=1'
$call.checkErrorLevel 'gams emb.gms lo=%GAMS.lo% r=1'
* Make sure, that the temporary Python script used with execution time embedded code
* is in the scratch dir used at execution time, not compile time
$call.checkErrorLevel 'rm -rf gams*.put'
$call.checkErrorLevel 'mkdir subDir'
$call.checkErrorLevel 'cp emb.gms subDir%system.dirSep%emb.gms'
$call.checkErrorLevel 'cd subDir && gams emb.gms lo=%GAMS.lo% s=..%system.dirSep%11 a=c'
$call.checkErrorLevel 'rm -rf subDir'
$call.checkErrorLevel 'gams disp.gms lo=%GAMS.lo% r=11'
$if exist gams1.put $abort Py script should be written to scratch dir
* Make sure, that we can continue w/o problems from a save file written with put_utility
* and execute embedded code again afterwards
$onEcho > test1.gms
embeddedCode Python:
pass
endEmbeddedCode
put_utility 'save' / 'savefile';
$offEcho
$onEcho > test2.gms
embeddedCode Python:
pass
endEmbeddedCode
$offecho
$call.checkErrorLevel gams test1 lo=%GAMS.lo%
$call.checkErrorLevel gams test2 lo=%GAMS.lo% r=savefile