Cex2.gms : Test expert level C API to read and write GDX, set options and execute GAMS

Description

Contributor: Lutz Westermann, October 2012


Small Model of Type : C and CPP


Category : GAMS API library


Main file : Cex2.gms

$TITLE 'Test expert level C API to read and write GDX, set options and execute GAMS' (CEX2,SEQ=14)

$ontext
Contributor: Lutz Westermann, October 2012
$offtext


$set srcRoot %gams.sysdir%apifiles%system.dirsep%C%system.dirsep%

$ifThen %system.filesys% == UNIX
$  if not set COMPILER $set COMPILER GNU
$else
$  if not set COMPILER $set COMPILER INTEL
$endIf

$ifThen %COMPILER% == GNU
$  set CCOMP gcc
$  ifThen %system.filesys% == UNIX
$    set OUT -oxp_example2
$    set FLAGS -m64 -ldl
$  else
$    set OUT -oxp_example2.exe
$    ifThen %system.buildcode% == VS8
$      set FLAGS -m32
$    else
$      set FLAGS -m64
$    endIf
$  endIf
$elseIf %COMPILER% == INTEL
$  set CCOMP cl
$  set FLAGS
$  set OUT   -Fexp_example2.exe
$else
$  abort Unknown compiler: %COMPILER%
$endIf

$call rm -rf demanddata.gdx

$call %CCOMP% "%srcRoot%xp_example2.c" "%srcRoot%api%system.dirsep%gdxcc.c" "%srcRoot%api%system.dirsep%optcc.c" "%srcRoot%api%system.dirsep%gamsxcc.c" -I"%srcRoot%api" %OUT% %FLAGS%
$if errorlevel 1 $abort 'Problem compiling xp_example2.c'
$call .%system.dirsep%xp_example2 "%gams.sysdir%." model2.gms
$if errorlevel 1 $abort 'Problem executing xp_example2'
$call gdxdiff demanddata.gdx demandwant.gdx
$if errorlevel 1 $abort 'Demanddata not as expected'