$hidden MPSGESET  MPSGE setup and HDR file generation
$log --- Running the MPSGE preprocessor ...
* Default values for named arguments
$if %1a == a    $goto missing
$if declared %1 $goto badname
$set model %1
$shift
$set mt 0
$if set MPSGEMT $set mt %MPSGEMT%
$label ProcessNamedArguments
$  splitOption "%1" key val
$  if x%key%==x $goto FinishProcessNamedArguments
$  iftheni.NamedArguments %key%==mt
$    set mt %val%
$  else.NamedArguments
$    error Unkown named argument "%key%"
$  endif.NamedArguments
$  shift
$goto ProcessNamedArguments
$label FinishProcessNamedArguments

$if NOT setglobal n_models $setglobal n_models 0
$if NOT setglobal n_constr $setglobal n_constr 0
$setlocal datetime %system.date%%system.time%
$setglobal %model% %datetime%
$setlocal par %gams.scrdir%gamscge.%gams.scrext%
$setlocal hdr %gams.scrdir%gamsgeh.%gams.scrext%
$hidden  $show      to dump symbols to listingfile
$echo INP %system.incparent%       > %par%
$echo SCR gamscge.%gams.scrext%   >> %par%
$if     x%mt%==x0 $echo SCD %gams.workdir% >> %par%
$if not x%mt%==x0 $echo SCD %gams.scrdir%  >> %par%
$echo NMO %n_models%              >> %par%
$echo NCO %n_constr%              >> %par%
$echo MDL %model%                 >> %par%
$echo HDR %hdr%                   >> %par%
$echo TIM %datetime%              >> %par%
$if not %system.filesys%==UNIX  $call gmsge_nx "%par%"
$if     %system.filesys%==UNIX  $call gmsge_ux.out "%par%"
$if errorlevel 1  $abort MPSGE preprocessor failed: further processing would be misleading
$include %hdr%
$hidden option oldname taken out for 21.3 builds, no longer supported
$exit
$label missing
$error missing model name argument for mpsgeset

*  $sysinclude mpsgeset mymodel
*
$abort MPSGE further processing would be misleading

$label badname
$error model name already in use
* more explanation comes here
$abort MPSGE further processing would be misleading
