CPPex1.gms : Test expert level C++ API to read and write GDX

Description

Contributor: Lutz Westermann, October 2012


Small Model of Type : C and CPP


Category : GAMS API library


Main file : CPPex1.gms

$TITLE 'Test expert level C++ API to read and write GDX' (CPPEX1,SEQ=5)

$ontext
Contributor: Lutz Westermann, October 2012
$offtext


$set srcRoot  %gams.sysdir%apifiles%system.dirsep%C++%system.dirsep%
$set srcRootC %gams.sysdir%apifiles%system.dirsep%C%system.dirsep%
$set exaDir   %srcRoot%xp_example1%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 CPPCOMP g++
$  ifThen %system.filesys% == UNIX
$    set OUT -oxp_example1
$    set FLAGS -m64 -ldl
$  else
$    set OUT -oxp_example1.exe
$    ifThen %system.buildcode% == VS8
$      set FLAGS -m32
$    else
$      set FLAGS -m64
$    endIf
$  endIf
$elseIf %COMPILER% == INTEL
$  set CPPCOMP cl
$  set FLAGS
$  set OUT   -Fexp_example1.exe
$else
$  abort Unknown compiler: %COMPILER%
$endIf

$call rm -rf demanddata.gdx

$call %CPPCOMP% "%exaDir%xp_example1.cpp" "%srcRoot%api%system.dirsep%gdxco.cpp" "%srcRootC%api%system.dirsep%gdxcc.c" -I"%srcRoot%api" -I"%srcRootC%api" %OUT% %FLAGS%
$if errorlevel 1 $abort 'Problem compiling xp_example1.cpp'
$call .%system.dirsep%xp_example1 "%gams.sysdir%."
$if errorlevel 1 $abort 'Problem executing xp_example1 writing GDX file'
$call gdxdiff demanddata.gdx demandwant.gdx
$if errorlevel 1 $abort 'Demanddata not as expected'
$call .%system.dirsep%xp_example1 "%gams.sysdir%." trnsport.gdx
$if errorlevel 1 $abort 'Problem executing xp_example1 reading GDX file'