gdxcomp2.gms : GDX - compressed and MT operation

Description

This model checks that the GDX file produced by GAMSCMEX with "gdx=<filename>"
is what we expect for different settings of the environment variables
GDXCOMPRESS and GDXTHREADS.

Contributor: Steve Dirkse, May 2012


Small Model of Type : GAMS


Category : GAMS Test library


Main file : gdxcomp2.gms

$title 'GDX - compressed and MT operation' (GDXCOMP2,SEQ=559)

$onText
This model checks that the GDX file produced by GAMSCMEX with "gdx=<filename>"
is what we expect for different settings of the environment variables
GDXCOMPRESS and GDXTHREADS.

Contributor: Steve Dirkse, May 2012
$offText

$call gamslib -q 1
$onEcho > subtest.gms
$onDollar
$setDDList GDXDEF GDXTMP GDXCOMPRESS_VAL GDXTHREADS_VAL

$if not set GDXDEF $set GDXDEF def.gdx
$if not set GDXTMP $set GDXTMP tmp.gdx
$if not set GDXCOMPRESS_VAL $abort 'expected GDXCOMPRESS_VAL to be set'
$if not set GDXTHREADS_VAL $abort 'expected GDXTHREADS_VAL to be set'

$setEnv GDXCOMPRESS %GDXCOMPRESS_VAL%
$setEnv GDXTHREADS %GDXTHREADS_VAL%
$call =gams trnsport lp=soplex gdx=%GDXTMP% lo=0

$call wc -c %GDXDEF% | sed s/%GDXDEF%// > "%gams.scrdir%def.%gams.scrext%"
$call wc -c %GDXTMP% | sed s/%GDXTMP%// > "%gams.scrdir%tmp.%gams.scrext%"

scalar def 'size of default GDX file' /
$include "%gams.scrdir%def.%gams.scrext%"
/

display 'GDXCOMPRESS_VAL = %GDXCOMPRESS_VAL%';
display 'GDXTHREADS_VAL  = %GDXTHREADS_VAL%';

$ifThen %GDXCOMPRESS_VAL% == 0

scalar tmp 'size of uncompressed GDX file' /
$include "%gams.scrdir%tmp.%gams.scrext%"
/
abort$(def>tmp) "wrong file sizes: default > uncompressed"

$else

scalar tmp 'size of compressed GDX file' /
$include "%gams.scrdir%tmp.%gams.scrext%"
/
abort$(def<tmp) "wrong file sizes: default < compressed"

$endIf

scalar rc;
execute 'gdxdiff %GDXDEF% %GDXTMP% > %system.nullfile%';
rc = errorlevel;
abort$[rc <> 0] 'GDXDIFF says %GDXDEF% and %GDXTMP% are different', rc;
$offEcho

* first generate with defaults
$call =gams trnsport lp=soplex gdx=def.gdx lo=0
$if errorlevel 1 $abort 'could not run trnsport'

scalar rc;
file fp;

set nthreads / '-8' * '-1', 0, 1 * 8 /;
set compr / 0, 1/;

loop {(compr, nthreads),
  put_utility fp 'shell' / 'gams subtest lo=0 --GDXDEF=def.gdx --GDXCOMPRESS_VAL=',compr.val:0:0,' --GDXTHREADS_VAL=',nthreads.val:0:0;
  rc = errorlevel;
  abort$[rc <> 0] 'subtest failed', rc, compr, nthreads;
};