1 /***************************************************************************
2                        initsysvar.cpp  -  definition of GDL system variables
3                              -------------------
4     begin                : July 22 2002
5     copyright            : (C) 2002 by Marc Schellens
6     email                : m_schellens@users.sf.net
7  ***************************************************************************/
8 
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17 
18 #include "includefirst.hpp"
19 
20 #ifndef _WIN32
21 #include <sys/utsname.h>
22 #endif
23 #include <cmath>
24 
25 #include <limits>
26 
27 #ifdef _OPENMP
28 #include <omp.h> // for !CPU
29 #endif
30 
31 #include "nullgdl.hpp"
32 
33 #include "objects.hpp"
34 #include "dstructgdl.hpp"
35 #include "graphicsdevice.hpp"
36 
37 #include "file.hpp"
38 
39 #ifdef _MSC_VER
40 #include "gtdhelper.hpp"
41 #else
42 #include <sys/time.h>
43 #endif
44 
45 #ifndef BUILD_DATE
46 #define BUILD_DATE __DATE__
47 #endif
48 
49 namespace SysVar
50 {
51 
52   using namespace std;
53   //a static float[4] holding !SC[1..4] values
54   static DFloat sc[4];
GetSC()55   DFloat* GetSC()
56   {
57     return sc;
58   }
59   // the index of some system variables
60   UInt nullIx, trueIx, falseIx, pathIx, helppathIx, promptIx, edit_inputIx, quietIx, moreIx,
61     dIx, pIx, xIx, yIx, zIx, vIx, gdlWarningIx, gdlIx, cIx, MouseIx,
62     errorStateIx, errorIx, errIx, err_stringIx, valuesIx,
63     journalIx, exceptIx, mapIx, cpuIx, dirIx, stimeIx,
64     warnIx, usersymIx, orderIx, MakeDllIx, colorIx;
65   // the index of some obsolete system variables
66   UInt xdottitleIx,ydottitleIx,xdotticksIx,ydotticksIx,cxminIx,cxmaxIx,cyminIx,cymaxIx,
67     xminIx,xmaxIx,yminIx,ymaxIx,pdotnoclipIx,pdotlinestyleIx,pdottitleIx,pdotnoeraseIx,pdotnsumIx,
68     pdotpsymIx,errorstatedoterrorIx,errorstatedotmsgprefixIx,errorstatesyscodeIx,pdotticklenIx,
69     fancyIx,gridIx,typeIx,sc1Ix,sc2Ix,sc3Ix,sc4Ix;
70   // !D structs
71   const int nDevices = 5;
72   DStructGDL* devices[ 5]; // NULL, PS, Z, SVG, (X or WIN or nothing)
73 
74   // !STIME
75   const SizeT MAX_STIME_STRING_LENGTH=80;
76 
IsSTime(DVar * var)77   bool IsSTime( DVar* var)
78   {
79 // due to .RESET_SESSION we cannot use static here
80 // but the effect will be minimal anyway
81 //     static DVar* varSTime = sysVarList[ stimeIx];
82     return var == sysVarList[ stimeIx];
83   }
84 
85 //  bool IsD( DVar* var)
86 //  {
87 //    return var == sysVarList[ dIx];
88 //  }
89 
SetGDLPath(const DString & newPath)90   void SetGDLPath( const DString& newPath)
91   {
92     FileListT sArr;
93     SizeT d;
94     long   sPos=0;
95     do
96       {
97 	d=newPath.find(lib::SearchPathSeparator(),sPos);
98 	string act = newPath.substr(sPos,d-sPos);
99 
100 	lib::ExpandPath( sArr, act, "*.pro");
101 
102 	sPos=d+1;
103       }
104     while( d != newPath.npos);
105 
106     SizeT nArr = sArr.size();
107     if( nArr == 0) return;
108 
109     // get the path
110     DVar& pathSysVar=*sysVarList[pathIx];
111     DString& path=static_cast<DStringGDL&>(*pathSysVar.Data())[0];
112 
113     // set the path
114     path = sArr[0];
115     for( SizeT i=1; i<nArr; ++i)
116       path += lib::SearchPathSeparator() + sArr[i];
117     // GJ version    path = sArr[nArr-1];
118     // GJ version for( SizeT i=1; i<nArr; ++i)
119     // GJ version  path += pathsep + sArr[nArr-i-1];
120   }
121 
122   // returns !DIR (as a plain DString)
Dir()123   const DString& Dir()
124   {
125     DVar& dirSysVar = *sysVarList[ dirIx];
126     return static_cast<DStringGDL&>( *dirSysVar.Data())[0];
127   }
128 
129   // updates !STIME (as a plain DString)
UpdateSTime()130   void UpdateSTime()
131   {
132     DVar& stimeSysVar = *sysVarList[ stimeIx];
133     DString& stime=static_cast<DStringGDL&>(*stimeSysVar.Data())[0];
134 
135     struct timeval tval;
136     struct timezone tzone;
137     struct tm *tstruct;
138 
139     gettimeofday(&tval,&tzone);
140     time_t ttime = tval.tv_sec;
141     tstruct= localtime(&ttime);
142 
143     char st[MAX_STIME_STRING_LENGTH];
144     const char *format="%d-%b-%Y %H:%M:%S.00";// !STIME format.
145     SizeT res=strftime( st, MAX_STIME_STRING_LENGTH, format, tstruct);
146 
147     stime = st;
148   }
149 
D()150   DStructGDL* D()
151   {
152     DVar& var = *sysVarList[ dIx];
153     return static_cast<DStructGDL*>(var.Data());
154   }
155 
156 //  // updates !D in all modes (should insure correct update if Win, XWidgets ...)
157 //  void UpdateD()
158 //  {
159 //    DStructGDL* dD = D();
160 //
161 //    DLong windowIdx=(*static_cast<DLongGDL*>(dD->GetTag(dD->Desc()->TagIndex("WINDOW"), 0)))[0];
162 //    if( windowIdx <0)  return;
163 //
164 //    GraphicsDevice* actDevice = GraphicsDevice::GetDevice();
165 //    GDLGStream* actStream = actDevice->GetStream();
166 //
167 //    long xSizeGG,ySizeGG;
168 //    actStream->GetGeometry(xSizeGG,ySizeGG);
169 //    int debug=0;
170 //    if (debug) cout << "GetX11Geo in SysVar::UpdateD : " << xSizeGG <<" "<< ySizeGG << endl;
171 //
172 //    (*static_cast<DLongGDL*>(dD->GetTag(dD->Desc()->TagIndex("X_SIZE"), 0)))[0] = xSizeGG;
173 //    (*static_cast<DLongGDL*>(dD->GetTag(dD->Desc()->TagIndex("Y_SIZE"), 0)))[0] = ySizeGG;
174 //    (*static_cast<DLongGDL*>(dD->GetTag(dD->Desc()->TagIndex("X_VSIZE"), 0)))[0] = xSizeGG;
175 //    (*static_cast<DLongGDL*>(dD->GetTag(dD->Desc()->TagIndex("Y_VSIZE"), 0)))[0] = ySizeGG;
176 //  }
177 
178   // returns array of path strings
179 
GDLPath()180   const StrArr& GDLPath() {
181     static StrArr sArr;
182 
183     // clear whatever old value is stored
184     sArr.clear();
185 
186     // get the path
187     DVar& pathSysVar = *sysVarList[pathIx];
188     DString& path = static_cast<DStringGDL&> (*pathSysVar.Data())[0];
189 
190     if (path == "") return sArr;
191 
192     SizeT d;
193     long sPos = 0;
194 
195     do {
196       d = path.find(lib::SearchPathSeparator(), sPos);
197       sArr.push_back(path.substr(sPos, d - sPos));
198       sPos = d + 1;
199     }    while (d != path.npos);
200 
201     return sArr;
202   }
203 
Prompt()204   const string& Prompt()
205   {
206     DVar& promptSysVar=*sysVarList[promptIx];
207     return static_cast<DStringGDL&>(*promptSysVar.Data())[0];
208   }
209 
Edit_Input()210   int Edit_Input()
211   {
212     DVar& eiSysVar=*sysVarList[edit_inputIx];
213     return static_cast<DIntGDL&>(*eiSysVar.Data())[0];
214   }
215 
Quiet()216   DLong Quiet()
217   {
218     DVar& qSysVar=*sysVarList[quietIx];
219     return static_cast<DLongGDL&>(*qSysVar.Data())[0];
220   }
221 
GDL_Warning()222   DLong GDL_Warning()
223   {
224     DVar& gwSysVar=*sysVarList[gdlWarningIx];
225     return static_cast<DLongGDL&>(*gwSysVar.Data())[0];
226   }
227 
SetC(DLong cVal)228   void SetC( DLong cVal)
229   {
230     DVar& cSysVar=*sysVarList[cIx];
231     static_cast<DLongGDL&>(*cSysVar.Data())[0] = cVal;
232   }
233 
SetD(BaseGDL * newD)234   void SetD( BaseGDL* newD)
235   {
236     DVar& dSysVar = *sysVarList[ dIx];
237     dSysVar.Data() = newD;
238   }
239 
SetErr_String(const DString & eS)240   void SetErr_String( const DString& eS)
241   {
242     DVar& eSSysVar = *sysVarList[ err_stringIx];
243     static_cast<DStringGDL&>(*eSSysVar.Data())[0] = eS;
244   }
SetErrError(DLong eC)245   void SetErrError( DLong eC)
246   {
247     DVar& errSysVar = *sysVarList[ errIx];
248     DVar& errorSysVar = *sysVarList[ errorIx];
249     static_cast<DLongGDL&>(*errSysVar.Data())[0] = eC;
250     static_cast<DLongGDL&>(*errorSysVar.Data())[0] = eC;
251   }
252 
P()253   DStructGDL* P()
254   {
255     DVar& pSysVar = *sysVarList[ pIx];
256     return static_cast<DStructGDL*>(pSysVar.Data());
257   }
PFancyCallBack()258   void PFancyCallBack(){
259     DIntGDL* fancy=GetFancy();
260     DStructGDL* pStruct=SysVar::P();   //MUST NOT BE STATIC, due to .reset
261     DFloat charsizePos=(*static_cast<DFloatGDL*>(pStruct->GetTag(pStruct->Desc()->TagIndex("CHARSIZE"), 0)))[0];
262     (*fancy)[0]=charsizePos*5-4;
263   }
GetPMulti()264   DLongGDL* GetPMulti()
265   {
266     DStructGDL* pStruct = SysVar::P();   //MUST NOT BE STATIC, due to .reset
267     static int tag = pStruct->Desc()->TagIndex( "MULTI");
268     return static_cast<DLongGDL*>( pStruct->GetTag( tag, 0));
269   }
270 
GetPFont()271   DLong GetPFont()
272   {
273     DStructGDL* pStruct = SysVar::P();   //MUST NOT BE STATIC, due to .reset
274     static int tag = pStruct->Desc()->TagIndex( "FONT");
275     return (*static_cast<DLongGDL*>( pStruct->GetTag( tag)))[0];
276   }
277 
STime()278   DStringGDL* STime()
279   {
280     DVar& var = *sysVarList[ stimeIx];
281     return static_cast<DStringGDL*>(var.Data());
282   }
X()283   DStructGDL* X()
284   {
285     DVar& var = *sysVarList[ xIx];
286     return static_cast<DStructGDL*>(var.Data());
287   }
Y()288   DStructGDL* Y()
289   {
290     DVar& var = *sysVarList[ yIx];
291     return static_cast<DStructGDL*>(var.Data());
292   }
Z()293   DStructGDL* Z()
294   {
295     DVar& var = *sysVarList[ zIx];
296     return static_cast<DStructGDL*>(var.Data());
297   }
Version()298   DStructGDL* Version()
299   {
300     DVar& var = *sysVarList[ vIx];
301     return static_cast<DStructGDL*>(var.Data());
302   }
SetFakeRelease(DString release)303   void SetFakeRelease( DString release)
304   {
305     DVar& var = *sysVarList[ vIx];
306     DStructGDL *s=static_cast<DStructGDL*>(var.Data());
307     static int tag = s->Desc()->TagIndex( "RELEASE");
308     (*static_cast<DStringGDL*>( s->GetTag( tag)))[0] = release;
309   }
Values()310   DStructGDL* Values()
311   {
312     DVar& var = *sysVarList[ valuesIx];
313     return static_cast<DStructGDL*>(var.Data());
314   }
315 
Error_State()316   DStructGDL* Error_State()
317   {
318     DVar& var = *sysVarList[ errorStateIx];
319     return static_cast<DStructGDL*>(var.Data());
320   }
321 
Map()322   DStructGDL* Map()
323   {
324     DVar& var = *sysVarList[ mapIx];
325     return static_cast<DStructGDL*>(var.Data());
326   }
GetFancy()327   DIntGDL* GetFancy()
328   {
329     DVar& var = *obsoleteSysVarList[ fancyIx];
330     return static_cast<DIntGDL*>(var.Data());
331   }
CBGridToTicklen()332   void CBGridToTicklen(){
333     DVar& var = *obsoleteSysVarList[ gridIx];
334     DStructGDL* pStruct=SysVar::P();   //MUST NOT BE STATIC, due to .reset
335     DFloat* ticklen=&((*static_cast<DFloatGDL*>(pStruct->GetTag(pStruct->Desc()->TagIndex("TICKLEN"), 0)))[0]);
336     *ticklen=((*static_cast<DIntGDL*>(var.Data()))[0] > 0)?1.0:0.02;
337   }
CBFancyToCharsize()338   void CBFancyToCharsize(){  //makes connection between !FANCY and !P.CHARSIZE
339     DIntGDL* fancy=GetFancy();
340     DStructGDL* pStruct=SysVar::P();   //MUST NOT BE STATIC, due to .reset
341     DFloat* charsize=&((*static_cast<DFloatGDL*>(pStruct->GetTag(pStruct->Desc()->TagIndex("CHARSIZE"), 0)))[0]);
342     *charsize=(*fancy)[0]*0.2+0.8;
343   }
CBTypeToXandY()344   void CBTypeToXandY(){
345     DStructGDL* xStruct=SysVar::X();   //MUST NOT BE STATIC, due to .reset
346     DStructGDL* yStruct=SysVar::Y();   //MUST NOT BE STATIC, due to .reset
347     DStructGDL* pStruct=SysVar::P();   //MUST NOT BE STATIC, due to .reset
348     unsigned xtypeTag=xStruct->Desc()->TagIndex("TYPE");
349     unsigned ytypeTag=yStruct->Desc()->TagIndex("TYPE");
350     unsigned xstyleTag=xStruct->Desc()->TagIndex("STYLE");
351     unsigned ystyleTag=yStruct->Desc()->TagIndex("STYLE");
352     DLong    *xtype= &(*static_cast<DLongGDL*>(xStruct->GetTag(xtypeTag, 0)))[0];
353     DLong    *ytype= &(*static_cast<DLongGDL*>(yStruct->GetTag(ytypeTag, 0)))[0];
354     DLong   *xstyle= &(*static_cast<DLongGDL*>(xStruct->GetTag(xstyleTag, 0)))[0];
355     DLong   *ystyle= &(*static_cast<DLongGDL*>(yStruct->GetTag(ystyleTag, 0)))[0];
356     DFloat* ticklen= &((*static_cast<DFloatGDL*>(pStruct->GetTag(pStruct->Desc()->TagIndex("TICKLEN"), 0)))[0]);
357     DVar& var = *obsoleteSysVarList[ typeIx];
358     DInt value=(*static_cast<DIntGDL*>(var.Data()))[0];
359     *xtype=(value & 1 );
360     *ytype=(value & 2 )>>1;
361     *xstyle=(value & 4 )>>2;
362     *ystyle=(value & 8 )>>3;
363     *ticklen=( value & 16 )>>4;
364     *xstyle|=(value & 32 )>>3;
365     *ystyle|=(value & 64 )>>4;
366   }
CBPath()367   void CBPath() { //could be interesting to know if path has changed. may be used to speedup procedures fining & compilation?
368   }
Mouse()369   DStructGDL* Mouse()
370   {
371     DVar& var = *sysVarList[ MouseIx];
372     return static_cast<DStructGDL*>(var.Data());
373   }
374 
375   // returns !GDL
GDLconfig()376   DStructGDL* GDLconfig()
377   {
378     DVar* sysVarList_gdlIx = sysVarList[ gdlIx];
379     return static_cast<DStructGDL*>(sysVarList_gdlIx->Data());
380   }
381 
Cpu()382   DStructGDL* Cpu()
383   {
384     DVar* sysVarList_cpuIx = sysVarList[ cpuIx];
385     return static_cast<DStructGDL*>(sysVarList_cpuIx->Data());
386   }
387 
Warn()388   DStructGDL* Warn()
389   {
390     DVar* sysVarList_warnIx = sysVarList[ warnIx];
391     return static_cast<DStructGDL*>(sysVarList_warnIx->Data());
392   }
393 
MsgPrefix()394   DString MsgPrefix()
395   {
396     DStructGDL* errorState = Error_State();
397     static unsigned msgTag = errorState->Desc()->TagIndex( "MSG_PREFIX");
398     return (*static_cast<DStringGDL*>( errorState->GetTag( msgTag, 0)))[0];
399   }
400 
JournalLUN()401   DLong JournalLUN()
402   {
403     DVar& jSysVar=*sysVarList[journalIx];
404     return static_cast<DLongGDL&>(*jSysVar.Data())[0];
405   }
JournalLUN(DLong jLUN)406   void JournalLUN( DLong jLUN)
407   {
408     DVar& jSysVar=*sysVarList[journalIx];
409     static_cast<DLongGDL&>(*jSysVar.Data())[0] = jLUN;
410   }
411 
TV_ORDER()412   DLong TV_ORDER()
413   {
414     DVar& orderVar=*sysVarList[orderIx];
415     return static_cast<DLongGDL&>(*orderVar.Data())[0];
416   }
417 
418   // call only once in main
InitSysVar()419   void InitSysVar()
420   {
421     // for very sensitive compilers (which need a SizeT for dimension())
422     const SizeT one=1;
423 
424     // !NULL
425     NullGDL* nullInstance = NullGDL::GetSingleInstance();
426     DVar *nullVar = new DVar( "NULL", nullInstance);
427     nullIx=sysVarList.size();
428     sysVarList.push_back(nullVar);
429     sysVarNoSaveList.push_back(nullVar);
430 
431     // !TRUE
432     DByteGDL* trueData = new DByteGDL(1);
433     DVar *true_logical = new DVar( "TRUE", trueData );
434     trueIx=sysVarList.size();
435     sysVarList.push_back(true_logical);
436     sysVarNoSaveList.push_back(true_logical);
437 
438     // !FALSE
439     DByteGDL* falseData = new DByteGDL(0);
440     DVar *false_logical = new DVar( "FALSE", falseData );
441     falseIx=sysVarList.size();
442     sysVarList.push_back(false_logical);
443     sysVarNoSaveList.push_back(false_logical);
444 
445     // !PATH
446     //    DString initPath(""); // set here the initial path
447     DStringGDL* pathData=new DStringGDL( "");
448     DVar *path=new DVar( "PATH", pathData);path->SetCallback(CBPath);
449     pathIx=sysVarList.size();
450     sysVarList.push_back(path);
451     // !HELP_PATH
452     //    DString initHelpPath(""); // set here the initial path
453     DStringGDL* helppathData=new DStringGDL( "");
454     DVar *helppath=new DVar( "HELP_PATH", helppathData);
455     helppathIx=sysVarList.size();
456     sysVarList.push_back(helppath);
457     // !PROMPT
458     DStringGDL* promptData=new DStringGDL( "GDL> ");
459     DVar *prompt=new DVar( "PROMPT", promptData);
460     promptIx=sysVarList.size();
461     sysVarList.push_back(prompt);
462 
463     // !EDIT_INPUT
464     DIntGDL* edit_inputData=new DIntGDL( 1);
465     DVar *edit_input=new DVar( "EDIT_INPUT", edit_inputData);
466     edit_inputIx=sysVarList.size();
467     sysVarList.push_back(edit_input);
468 
469     // !QUIET
470     DLongGDL* quietData=new DLongGDL( 0);
471     DVar *quiet=new DVar( "QUIET", quietData);
472     quietIx=sysVarList.size();
473     sysVarList.push_back(quiet);
474 
475     // !MORE
476     DIntGDL* moreData=new DIntGDL( 1);
477     DVar *more=new DVar( "MORE", moreData);
478     moreIx=sysVarList.size();
479     sysVarList.push_back(more);
480 
481     // !C
482     DLongGDL* cData=new DLongGDL( 0);
483     DVar *c=new DVar( "C", cData);
484     cIx=sysVarList.size();
485     sysVarList.push_back(c);
486 
487     // !D defined in Graphics
488     DVar *d=new DVar( "D", NULL);
489     dIx=sysVarList.size();
490     sysVarList.push_back(d);
491     sysVarRdOnlyList.push_back( d); // make it read only
492     sysVarNoSaveList.push_back( d); // make it read only
493 
494     // plotting
495     // !P
496     SizeT clipDim = 6;
497 //    DLong p_clipInit[] = { 0, 0, 1024, 1024, 0, 1000};
498     DLong p_clipInit[] = { 0, 0, 639, 511, 0, 0};
499     DLongGDL* p_clip = new DLongGDL( dimension( &clipDim, one));
500     for( UInt i=0; i<clipDim; i++) (*p_clip)[ i] = p_clipInit[ i];
501     SizeT multiDim = 5;
502     SizeT positionDim = 4;
503     SizeT regionDim = 4;
504     SizeT tDim[] = { 4, 4};
505     DStructGDL*  plt = new DStructGDL( "!PLT");
506     plt->NewTag("BACKGROUND", new DLongGDL( 0));
507     plt->NewTag("CHARSIZE", new DFloatGDL( 0.0));
508     plt->NewTag("CHARTHICK", new DFloatGDL( 0.0));
509     plt->NewTag("CLIP", p_clip);
510     plt->NewTag("COLOR", new DLongGDL( 255));
511     plt->NewTag("FONT", new DLongGDL( -1));
512     plt->NewTag("LINESTYLE", new DLongGDL( 0)); //tag 6 for obsolete !LINETYPE
513     plt->NewTag("MULTI", new DLongGDL( dimension( &multiDim, one)));
514     plt->NewTag("NOCLIP", new DLongGDL( 0));  //tag 8 for obsolete !IGNORE
515     plt->NewTag("NOERASE", new DLongGDL( 0)); //tag 9 for obsolete !NOERAS
516     plt->NewTag("NSUM", new DLongGDL( 0)); //tag 10 for obsolete !NSUM
517     plt->NewTag("POSITION", new DFloatGDL( dimension( &positionDim, one)));
518     plt->NewTag("PSYM", new DLongGDL( 0)); //tag 12 for obsolete !PSYM
519     plt->NewTag("REGION", new DFloatGDL( dimension( &regionDim, one)));
520     plt->NewTag("SUBTITLE", new DStringGDL( ""));
521     plt->NewTag("SYMSIZE", new DFloatGDL( 0.0));
522     {
523       DDoubleGDL* tmp = new DDoubleGDL( dimension( tDim, 2));
524       (*tmp)[0] = (*tmp)[5] = (*tmp)[10] = (*tmp)[15] = 1;
525       plt->NewTag("T", tmp);
526     }
527     plt->NewTag("T3D", new DLongGDL( 0));
528     plt->NewTag("THICK", new DFloatGDL( 0.0));
529     plt->NewTag("TITLE", new DStringGDL( ""));  //tag 19 for obsolete !MTITLE
530     plt->NewTag("TICKLEN", new DFloatGDL( 0.02));
531     plt->NewTag("CHANNEL", new DLongGDL( 0));
532     DVar *p=new DVar( "P", plt); p->SetCallback(PFancyCallBack);
533     pIx=sysVarList.size();
534     sysVarList.push_back(p);
535 
536     //very old obsolete variables
537     DLongGDL* gdlpdotnoclip = new DLongGDL(dimension(1), BaseGDL::NOALLOC);
538     gdlpdotnoclip->SetBuffer((void*) &((*static_cast<DLongGDL*> (plt->GetTag(8, 0)))[0]));
539     gdlpdotnoclip->SetBufferSize(1);
540     gdlpdotnoclip->SetDim(dimension(1));
541     DVar *pdotnoclip = new DVar("IGNORE", gdlpdotnoclip);
542     pdotnoclipIx = obsoleteSysVarList.size();
543     obsoleteSysVarList.push_back(pdotnoclip);
544     DLongGDL* gdlpdotlinestyle = new DLongGDL(dimension(1), BaseGDL::NOALLOC);
545     gdlpdotlinestyle->SetBuffer((void*) &((*static_cast<DLongGDL*> (plt->GetTag(6, 0)))[0]));
546     gdlpdotlinestyle->SetBufferSize(1);
547     gdlpdotlinestyle->SetDim(dimension(1));
548     DVar *pdotlinestyle = new DVar("LINETYPE", gdlpdotlinestyle);
549     pdotlinestyleIx = obsoleteSysVarList.size();
550     obsoleteSysVarList.push_back(pdotlinestyle);
551     DLongGDL* gdlpdotnoerase = new DLongGDL(dimension(1), BaseGDL::NOALLOC);
552     gdlpdotnoerase->SetBuffer((void*) &((*static_cast<DLongGDL*> (plt->GetTag(9, 0)))[0]));
553     gdlpdotnoerase->SetBufferSize(1);
554     gdlpdotnoerase->SetDim(dimension(1));
555     DVar *pdotnoerase = new DVar("NOERAS", gdlpdotnoerase);
556     pdotnoeraseIx = obsoleteSysVarList.size();
557     obsoleteSysVarList.push_back(pdotnoerase);
558     DLongGDL* gdlpdotnsum = new DLongGDL(dimension(1), BaseGDL::NOALLOC);
559     gdlpdotnsum->SetBuffer((void*) &((*static_cast<DLongGDL*> (plt->GetTag(10, 0)))[0]));
560     gdlpdotnsum->SetBufferSize(1);
561     gdlpdotnsum->SetDim(dimension(1));
562     DVar *pdotnsum = new DVar("NSUM", gdlpdotnsum);
563     pdotnsumIx = obsoleteSysVarList.size();
564     obsoleteSysVarList.push_back(pdotnsum);
565     DLongGDL* gdlpdotpsym = new DLongGDL(dimension(1), BaseGDL::NOALLOC);
566     gdlpdotpsym->SetBuffer((void*) &((*static_cast<DLongGDL*> (plt->GetTag(12, 0)))[0]));
567     gdlpdotpsym->SetBufferSize(1);
568     gdlpdotpsym->SetDim(dimension(1));
569     DVar *pdotpsym = new DVar("PSYM", gdlpdotpsym);
570     pdotpsymIx = obsoleteSysVarList.size();
571     obsoleteSysVarList.push_back(pdotpsym);
572 
573     DStringGDL* gdlpdottitle = new DStringGDL(dimension(1), BaseGDL::NOALLOC);
574     gdlpdottitle->SetBuffer((void*) &((*static_cast<DStringGDL*> (plt->GetTag(19, 0)))[0]));
575     gdlpdottitle->SetBufferSize(1);
576     gdlpdottitle->SetDim(dimension(1));
577     DVar *pdottitle = new DVar("MTITLE", gdlpdottitle);
578     pdottitleIx = obsoleteSysVarList.size();
579     obsoleteSysVarList.push_back(pdottitle);
580     //FANCY --> must be interpreted it looks like: !P.CHARSIZE = 0.206 * !FANCY + 0.73 (probably it's just 0.2)
581     DIntGDL *fancyData = new DIntGDL( 1 );
582     DVar *fancy = new DVar( "FANCY", fancyData);fancy->SetCallback(CBFancyToCharsize);
583     fancyIx     = obsoleteSysVarList.size();
584     obsoleteSysVarList.push_back( fancy);
585     //GRID --> must be interpreted (ticklen >0)
586     DIntGDL *gridData = new DIntGDL(0);
587     DVar *grid = new DVar("GRID", gridData);grid->SetCallback(CBGridToTicklen);
588     gridIx = obsoleteSysVarList.size();
589     obsoleteSysVarList.push_back(grid);
590     //TYPE --> must be interpreted !X.TYPE, !X.STYLE, !Y.TYPE, !Y.STYLE, !P.TICKLEN
591     DIntGDL *typeData = new DIntGDL(0);
592     DVar *type = new DVar("TYPE", typeData);type->SetCallback(CBTypeToXandY);
593     typeIx = obsoleteSysVarList.size();
594     obsoleteSysVarList.push_back(type);
595     //SC1 --> must be interpreted !P.POSITION[0] * !D.X_VSIZE if !P.POSITION[2] is nonzero, or !X.WINDOW[0] * !D.X_VSIZE otherwise.
596 
597     DFloatGDL *sc1Data = new DFloatGDL(dimension(1), BaseGDL::NOALLOC);
598     sc1Data->SetBuffer((void*) &(sc[0]));
599     sc1Data->SetBufferSize(1);
600     sc1Data->SetDim(dimension(1));
601     DVar *sc1 = new DVar("SC1", sc1Data);
602     sc1Ix = obsoleteSysVarList.size();
603     obsoleteSysVarList.push_back(sc1);
604     //SC2 --> must be interpreted !P.POSITION[2] * !D.X_VSIZE if !P.POSITION[2] is nonzero, or !X.WINDOW[1] * !D.X_VSIZE otherwise.
605     DFloatGDL *sc2Data = new DFloatGDL(dimension(1), BaseGDL::NOALLOC);
606     sc2Data->SetBuffer((void*) &(sc[1]));
607     sc2Data->SetBufferSize(1);
608     sc2Data->SetDim(dimension(1));
609     DVar *sc2 = new DVar("SC2", sc2Data);
610     sc2Ix = obsoleteSysVarList.size();
611     obsoleteSysVarList.push_back(sc2);
612     //SC3 --> must be interpreted !P.POSITION[1] * !D.X_VSIZE if !P.POSITION[2] is nonzero, or !Y.WINDOW[0] * !D.X_VSIZE otherwise.
613     DFloatGDL *sc3Data = new DFloatGDL(dimension(1), BaseGDL::NOALLOC);
614     sc3Data->SetBuffer((void*) &(sc[2]));
615     sc3Data->SetBufferSize(1);
616     sc3Data->SetDim(dimension(1));
617     DVar *sc3 = new DVar("SC3", sc3Data);
618     sc3Ix = obsoleteSysVarList.size();
619     obsoleteSysVarList.push_back(sc3);
620     //SC4 --> must be interpreted !P.POSITION[3] * !D.X_VSIZE if !P.POSITION[2] is nonzero, or !Y.WINDOW[1] * !D.X_VSIZE otherwise.
621     DFloatGDL *sc4Data = new DFloatGDL(dimension(1), BaseGDL::NOALLOC);
622     sc4Data->SetBuffer((void*) &(sc[3]));
623     sc4Data->SetBufferSize(1);
624     sc4Data->SetDim(dimension(1));
625     DVar *sc4 = new DVar("SC4", sc4Data);
626     sc4Ix = obsoleteSysVarList.size();
627     obsoleteSysVarList.push_back(sc4);
628     // some constants
629 
630     // !ORDER
631     DLongGDL *orderData = new DLongGDL( 0 );
632     DVar *order = new DVar( "ORDER", orderData);
633     orderIx     = sysVarList.size();
634     sysVarList.push_back( order);
635 
636     // !GDL_WARNING (to be used in VOIGT() and BeselIJKY() to warm on
637     // different behaviour between IDL and GDL
638     DLongGDL *gdlWarningData = new DLongGDL( 1 );
639     DVar *gdlWarning = new DVar( "GDL_WARNING", gdlWarningData);
640     gdlWarningIx     = sysVarList.size();
641     sysVarList.push_back( gdlWarning);
642     sysVarNoSaveList.push_back( gdlWarning);
643 
644     // !GDL (to allow distinguish IDL/GDL with DEFSYSV, '!gdl', exists=exists )
645     DStructGDL*  gdlStruct = new DStructGDL( "!GNUDATALANGUAGE");
646     gdlStruct->NewTag("RELEASE", new DStringGDL( VERSION));
647 
648     // creating an explicit build date in !GDL (also exist in !version)
649     gdlStruct->NewTag("BUILD_DATE", new DStringGDL(BUILD_DATE));
650 
651     // creating and Epoch entry in order to have a simple incremental number
652     int CompilationMonth =0, CompilationYear=0, CompilationDay=0;
653     string MyDate= BUILD_DATE;
654     string SCompilationYear;
655     SCompilationYear=MyDate.substr(7,4);
656     CompilationYear=atoi(SCompilationYear.c_str());
657     string SCompilationDay;
658     SCompilationDay=MyDate.substr(4,2);
659     CompilationDay=atoi(SCompilationDay.c_str());
660 
661     // for the months, it is more difficult
662     if (MyDate.find("Jan")!=string::npos) CompilationMonth=1;
663     if (MyDate.find("Feb")!=string::npos) CompilationMonth=2;
664     if (MyDate.find("Mar")!=string::npos) CompilationMonth=3;
665     if (MyDate.find("Apr")!=string::npos) CompilationMonth=4;
666     if (MyDate.find("May")!=string::npos) CompilationMonth=5;
667     if (MyDate.find("Jun")!=string::npos) CompilationMonth=6;
668     if (MyDate.find("Jul")!=string::npos) CompilationMonth=7;
669     if (MyDate.find("Aug")!=string::npos) CompilationMonth=8;
670     if (MyDate.find("Sep")!=string::npos) CompilationMonth=9;
671     if (MyDate.find("Oct")!=string::npos) CompilationMonth=10;
672     if (MyDate.find("Nov")!=string::npos) CompilationMonth=11;
673     if (MyDate.find("Dec")!=string::npos) CompilationMonth=12;
674 
675     //cout << SCompilationYear << " "<< CompilationMonth <<endl;
676     //cout << CompilationYear<< endl;
677     struct tm t;
678     time_t t_of_day;
679     t.tm_year = CompilationYear -1900;
680     t.tm_mon = CompilationMonth-1;           // Month, 0 - jan
681     t.tm_mday = CompilationDay;          // Day of the month
682     t.tm_hour = 0;
683     t.tm_min = 0;
684     t.tm_sec = 0;
685     t.tm_isdst = -1;        // Is DST on? 1 = yes, 0 = no, -1 = unknown
686     t_of_day = mktime(&t);
687 
688     // printing Epoch on the Command Line $   date +"%s"
689     // printf("seconds since the Epoch: %ld\n", (long) t_of_day);
690 
691     gdlStruct->NewTag("EPOCH", new DLongGDL((long) t_of_day));
692     gdlStruct->NewTag("GDL_USE_DSFMT", new DByteGDL(1));
693     gdlStruct->NewTag("GDL_USE_WX", new DByteGDL(0));
694 #ifdef _WIN32
695     std::string use_posix=GetEnvString("GDL_USE_POSIX");
696     if( use_posix.length() > 0) lib::posixpaths = true;
697     gdlStruct->NewTag("GDL_POSIX", new DByteGDL(lib::posixpaths));
698 #else
699     gdlStruct->NewTag("GDL_POSIX", new DByteGDL(1));
700 #endif
701 
702     DVar *gdl        = new DVar( "GDL", gdlStruct);
703     gdlIx=sysVarList.size();
704     sysVarList.push_back(gdl);
705     sysVarRdOnlyList.push_back( gdl); // make it read only
706 
707     // !DPI
708     DDoubleGDL *dpiData = new DDoubleGDL( (double)(4*atan(1.0)) );
709     DVar *dpi = new DVar( "DPI", dpiData);
710     sysVarList.push_back( dpi);
711     sysVarRdOnlyList.push_back( dpi); // make it read only
712 
713     // !PI
714     DFloatGDL *piData = new DFloatGDL( (float)(4*atan(1.0)) );
715     DVar *pi = new DVar( "PI", piData);
716     sysVarList.push_back( pi);
717     sysVarRdOnlyList.push_back( pi); // make it read only
718 
719     // !DTOR
720     DFloatGDL *dtorData = new DFloatGDL((*piData)[0] / 180.);// 0.0174533);
721     DVar *dtor = new DVar( "DTOR", dtorData);
722     sysVarList.push_back( dtor);
723     sysVarRdOnlyList.push_back( dtor); // make it read only
724 
725     // !RADEG
726     DFloatGDL *radegData = new DFloatGDL(180. / (*piData)[0]);// 57.2957764);
727     DVar *radeg = new DVar( "RADEG", radegData);
728     sysVarList.push_back( radeg);
729     sysVarRdOnlyList.push_back( radeg); // make it read only
730 
731     // !CONST
732     // source : http://physics.nist.gov/cgi-bin/cuu/Results?category=abbr_in
733     DStructGDL *constantList   = new DStructGDL( "!CONST");
734     // Fine structure constant
735     constantList ->NewTag("ALPHA", new DDoubleGDL(7.2973525698e-3));
736     // Astronomical Unit [m]
737     constantList ->NewTag("AU", new DDoubleGDL(1.49597870700e11));
738     // Speed of Light in Vacuum [m/s]
739     constantList ->NewTag("C", new DDoubleGDL(299792458.));
740     // Degrees to radians
741     constantList ->NewTag("DTOR", new DDoubleGDL(0.0174532925199433));  //exact value in double. previous was wrong.
742     // Elementary Charge [Coulon]
743     constantList ->NewTag("E", new DDoubleGDL(1.602176565e-19));
744     // Electric Vacuum Permittivity [F/m]
745     constantList ->NewTag("EPS0", new DDoubleGDL(8.854187817e-12));
746     // Euler's number
747     constantList ->NewTag("EULER", new DDoubleGDL(2.7182818284590452));
748     // Faraday constant NAe [C/mol]
749     constantList ->NewTag("F", new DDoubleGDL(96485.3365));
750     // Gravitation constant [m^3/kg/s^2]
751     constantList ->NewTag("G", new DDoubleGDL(6.67384e-11));
752     // Earth standard gravity [m/s^2]
753     constantList ->NewTag("GN", new DDoubleGDL(9.80665));
754     // Planck constant [Js]
755     constantList ->NewTag("H", new DDoubleGDL(6.62606957e-34));
756     // h_bar (h/!pi) [Js]
757     constantList ->NewTag("HBAR", new DDoubleGDL(1.054571726e-34));
758     //Imaginary number
759     complex<double> imaginary(0., 1.);
760     constantList ->NewTag("I", new DComplexDblGDL(imaginary));
761     // Boltzmann constant (R/NA) [J/K]
762     constantList ->NewTag("K", new DDoubleGDL(1.3806488e-23 ));
763     // Light-Year distance [m]
764     constantList ->NewTag("LY", new DDoubleGDL(9.4607304725808e15));
765     // Mass of the Earth [kg]
766     constantList ->NewTag("M_EARTH", new DDoubleGDL(5.972186390e24));
767     // Mass of the Sun [kg]
768     constantList ->NewTag("M_SUN", new DDoubleGDL(1.98841586057e30));
769     // electron mass [kg]
770     constantList ->NewTag("ME", new DDoubleGDL(9.10938291e-31));
771     // neutron mass [kg]
772     constantList ->NewTag("MN", new DDoubleGDL(1.674927351e-27));
773     // proton mass [kg]
774     constantList ->NewTag("MP", new DDoubleGDL(1.672621777e-27));
775     // magnetic vacuum permeability [N/A^2]
776     constantList ->NewTag("MU0", new DDoubleGDL(12.566370614e-7));
777     // Loschmidt's number NAp0/(RT0) [m-3]
778     constantList ->NewTag("N0", new DDoubleGDL(2.6867805e25));
779     // Avogadro constant NA [mol-1]
780     constantList ->NewTag("NA", new DDoubleGDL(6.02214129e23));
781     // Standard atmosphere Pression [Pa]
782     constantList ->NewTag("P0", new DDoubleGDL(101325.));
783     // Parsec distance [m]
784     constantList ->NewTag("PARSEC", new DDoubleGDL(3.0856775814671912e16));
785     //golden ratio ((1+sqrt(5))/2)
786     constantList ->NewTag("PHI", new DDoubleGDL(1.6180339887498948));
787     // Pi
788     constantList ->NewTag("PI", new DDoubleGDL((*dpiData)[0]));
789     // molar gas constant [J/mol/K]
790     constantList ->NewTag("R", new DDoubleGDL(8.3144621));
791     // Earth radius (assuming spherical) [m]
792     constantList ->NewTag("R_EARTH", new DDoubleGDL(6378136.6));
793     // Radians to degrees
794     constantList ->NewTag("RTOD", new DDoubleGDL(180./(*dpiData)[0]));
795     // classical electron radius [m]
796     constantList ->NewTag("RE", new DDoubleGDL(2.8179403267e-15));
797     // Rydberg constant R∞ [1/m]
798     constantList ->NewTag("RYDBERG", new DDoubleGDL(10973731.568539));
799     // Stefan-Boltzmann constant [W/m^2/K^4]
800     constantList ->NewTag("SIGMA", new DDoubleGDL(5.670373e-8));
801     // Standard temperature [K]
802     constantList ->NewTag("T0", new DDoubleGDL(273.15));
803     // unified atomic mass unit [kg]
804     constantList ->NewTag("U", new DDoubleGDL(1.660538921e-27));
805     // Molar volume, ideal gas at Standard temperature and Pression (STP) [m^3/mol]
806     constantList ->NewTag("VM", new DDoubleGDL(22.413968e-3));
807 
808     DVar *constant = new DVar("CONST",constantList);
809     sysVarList.push_back(constant);
810     sysVarRdOnlyList.push_back(constant); // make it read only
811 
812 
813     // ![XYZ]
814     SizeT dim2  = 2;
815     SizeT dim60 = 60;
816     SizeT dim10 = 10;
817     DStructGDL*  xAxis = new DStructGDL( "!AXIS");
818     xAxis->NewTag("TITLE", new DStringGDL( "")); //tag #0 for !XTITLE
819     xAxis->NewTag("TYPE", new DLongGDL( 0));
820     xAxis->NewTag("STYLE", new DLongGDL( 0));
821     xAxis->NewTag("TICKS", new DLongGDL( 0)); //tag #3 for !XTICKS
822     xAxis->NewTag("TICKLEN", new DFloatGDL( 0.0));
823     xAxis->NewTag("THICK", new DFloatGDL( 0.0));
824     xAxis->NewTag("RANGE", new DDoubleGDL( dimension( &dim2,one))); //tag #6 for ![X|Y][MIN|MAX]
825     xAxis->NewTag("CRANGE", new DDoubleGDL( dimension( &dim2,one))); //tag #7 for !C[X|Y][MIN|MAX]
826     xAxis->NewTag("S", new DDoubleGDL( dimension( &dim2,one)));
827     xAxis->NewTag("MARGIN", new DFloatGDL( dimension( &dim2,one)));
828     xAxis->NewTag("OMARGIN", new DFloatGDL( dimension( &dim2,one)));
829     xAxis->NewTag("WINDOW", new DFloatGDL( dimension( &dim2,one)));
830     xAxis->NewTag("REGION", new DFloatGDL( dimension( &dim2,one)));
831     xAxis->NewTag("CHARSIZE", new DFloatGDL( 0.0));
832     xAxis->NewTag("MINOR", new DLongGDL( 0));
833     xAxis->NewTag("TICKV", new DDoubleGDL( dimension( &dim60,one)));
834     xAxis->NewTag("TICKNAME", new DStringGDL( dimension( &dim60,one)));
835     xAxis->NewTag("GRIDSTYLE", new DLongGDL( 0));
836     xAxis->NewTag("TICKFORMAT", new DStringGDL( dimension( &dim10,one)));
837     xAxis->NewTag("TICKINTERVAL", new DDoubleGDL( 0));
838     xAxis->NewTag("TICKLAYOUT", new DLongGDL( 0));
839     xAxis->NewTag("TICKUNITS", new DStringGDL( dimension( &dim10,one)));
840     (*static_cast<DDoubleGDL*>( xAxis->GetTag( 8, 0)))[1] = 1.0;
841     (*static_cast<DFloatGDL*>(  xAxis->GetTag( 9, 0)))[0] = 10.0;
842     (*static_cast<DFloatGDL*>(  xAxis->GetTag( 9, 0)))[1] = 3.0;
843     DVar *x            = new DVar( "X", xAxis);
844     xIx                = sysVarList.size();
845     sysVarList.push_back(x);
846     DStructGDL*  yAxis = new DStructGDL( "!AXIS");
847     (*static_cast<DDoubleGDL*>( yAxis->GetTag( 8, 0)))[1] = 1.0;
848     (*static_cast<DFloatGDL*>(  yAxis->GetTag( 9, 0)))[0] = 4.0;
849     (*static_cast<DFloatGDL*>(  yAxis->GetTag( 9, 0)))[1] = 2.0;
850     DVar*        y     = new DVar( "Y", yAxis);
851     yIx                = sysVarList.size();
852     sysVarList.push_back(y);
853     DStructGDL*  zAxis = new DStructGDL( "!AXIS");
854     (*static_cast<DDoubleGDL*>( zAxis->GetTag( 8, 0)))[1] = 1.0;
855     DVar*        z     = new DVar( "Z", zAxis);
856     zIx                = sysVarList.size();
857     sysVarList.push_back(z);
858 
859     //very old obsolete variables
860     DStringGDL* gdlxdottitle = new DStringGDL(dimension(1), BaseGDL::NOALLOC);
861     gdlxdottitle->SetBuffer((void*) &((*static_cast<DStringGDL*> (xAxis->GetTag(0, 0)))[0]));
862     gdlxdottitle->SetBufferSize(1);
863     gdlxdottitle->SetDim(dimension(1));
864     DVar *xdottitle = new DVar("XTITLE", gdlxdottitle);
865     xdottitleIx = obsoleteSysVarList.size();
866     obsoleteSysVarList.push_back(xdottitle);
867 
868     DStringGDL* gdlydottitle = new DStringGDL(dimension(1), BaseGDL::NOALLOC);
869     gdlydottitle->SetBuffer((void*) &((*static_cast<DStringGDL*> (yAxis->GetTag(0, 0)))[0]));
870     gdlydottitle->SetBufferSize(1);
871     gdlydottitle->SetDim(dimension(1));
872     DVar *ydottitle = new DVar("YTITLE", gdlydottitle);
873     ydottitleIx = obsoleteSysVarList.size();
874     obsoleteSysVarList.push_back(ydottitle);
875 
876     DLongGDL* xdotticksgdl = new DLongGDL(dimension(1), BaseGDL::NOALLOC);
877     xdotticksgdl->SetBuffer((void*) &((*static_cast<DLongGDL*> (xAxis->GetTag(3, 0)))[0]));
878     xdotticksgdl->SetBufferSize(1);
879     xdotticksgdl->SetDim(dimension(1));
880     DVar *xdotticks = new DVar("XTICKS", xdotticksgdl);
881     xdotticksIx = obsoleteSysVarList.size();
882     obsoleteSysVarList.push_back(xdotticks);
883     DLongGDL* ydotticksgdl = new DLongGDL(dimension(1), BaseGDL::NOALLOC);
884     ydotticksgdl->SetBuffer((void*) &((*static_cast<DLongGDL*> (yAxis->GetTag(3, 0)))[0]));
885     ydotticksgdl->SetBufferSize(1);
886     ydotticksgdl->SetDim(dimension(1));
887     DVar *ydotticks = new DVar("YTICKS", ydotticksgdl);
888     ydotticksIx = obsoleteSysVarList.size();
889     obsoleteSysVarList.push_back(ydotticks);
890 
891     DDoubleGDL* xmingdl = new DDoubleGDL(dimension(1), BaseGDL::NOALLOC);
892     xmingdl->SetBuffer((void*) &((*static_cast<DDoubleGDL*> (xAxis->GetTag(6, 0)))[0]));
893     xmingdl->SetBufferSize(1);
894     xmingdl->SetDim(dimension(1));
895     DVar *xmin = new DVar("XMIN", xmingdl);
896     xminIx = obsoleteSysVarList.size();
897     obsoleteSysVarList.push_back(xmin);
898     DDoubleGDL* xmaxgdl = new DDoubleGDL(dimension(1), BaseGDL::NOALLOC);
899     xmaxgdl->SetBuffer((void*) &((*static_cast<DDoubleGDL*> (xAxis->GetTag(6, 0)))[1]));
900     xmaxgdl->SetBufferSize(1);
901     xmaxgdl->SetDim(dimension(1));
902     DVar *xmax = new DVar("XMAX", xmaxgdl);
903     xmaxIx = obsoleteSysVarList.size();
904     obsoleteSysVarList.push_back(xmax);
905     DDoubleGDL* ymingdl = new DDoubleGDL(dimension(1), BaseGDL::NOALLOC);
906     ymingdl->SetBuffer((void*) &((*static_cast<DDoubleGDL*> (yAxis->GetTag(6, 0)))[0]));
907     ymingdl->SetBufferSize(1);
908     ymingdl->SetDim(dimension(1));
909     DVar *ymin = new DVar("YMIN", ymingdl);
910     yminIx = obsoleteSysVarList.size();
911     obsoleteSysVarList.push_back(ymin);
912     DDoubleGDL* ymaxgdl = new DDoubleGDL(dimension(1), BaseGDL::NOALLOC);
913     ymaxgdl->SetBuffer((void*) &((*static_cast<DDoubleGDL*> (yAxis->GetTag(6, 0)))[1]));
914     ymaxgdl->SetBufferSize(1);
915     ymaxgdl->SetDim(dimension(1));
916     DVar *ymax = new DVar("YMAX", ymaxgdl);
917     ymaxIx = obsoleteSysVarList.size();
918     obsoleteSysVarList.push_back(ymax);
919 
920     DDoubleGDL* cxmingdl = new DDoubleGDL(dimension(1), BaseGDL::NOALLOC);
921     cxmingdl->SetBuffer((void*) &((*static_cast<DDoubleGDL*> (xAxis->GetTag(7, 0)))[0]));
922     cxmingdl->SetBufferSize(1);
923     cxmingdl->SetDim(dimension(1));
924     DVar *cxmin = new DVar("CXMIN", cxmingdl);
925     cxminIx = obsoleteSysVarList.size();
926     obsoleteSysVarList.push_back(cxmin);
927     DDoubleGDL* cxmaxgdl = new DDoubleGDL(dimension(1), BaseGDL::NOALLOC);
928     cxmaxgdl->SetBuffer((void*) &((*static_cast<DDoubleGDL*> (xAxis->GetTag(7, 0)))[1]));
929     cxmaxgdl->SetBufferSize(1);
930     cxmaxgdl->SetDim(dimension(1));
931     DVar *cxmax = new DVar("CXMAX", cxmaxgdl);
932     cxmaxIx = obsoleteSysVarList.size();
933     obsoleteSysVarList.push_back(cxmax);
934     DDoubleGDL* cymingdl = new DDoubleGDL(dimension(1), BaseGDL::NOALLOC);
935     cymingdl->SetBuffer((void*) &((*static_cast<DDoubleGDL*> (yAxis->GetTag(7, 0)))[0]));
936     cymingdl->SetBufferSize(1);
937     cymingdl->SetDim(dimension(1));
938     DVar *cymin = new DVar("CYMIN", cymingdl);
939     cyminIx = obsoleteSysVarList.size();
940     obsoleteSysVarList.push_back(cymin);
941     DDoubleGDL* cymaxgdl = new DDoubleGDL(dimension(1), BaseGDL::NOALLOC);
942     cymaxgdl->SetBuffer((void*) &((*static_cast<DDoubleGDL*> (yAxis->GetTag(7, 0)))[1]));
943     cymaxgdl->SetBufferSize(1);
944     cymaxgdl->SetDim(dimension(1));
945     DVar *cymax = new DVar("CYMAX", cymaxgdl);
946     cymaxIx = obsoleteSysVarList.size();
947     obsoleteSysVarList.push_back(cymax);
948     // !VERSION
949     DStructGDL*  ver = new DStructGDL( "!VERSION");
950 #ifdef _WIN32
951 #ifdef __MINGW32__
952     typedef void (WINAPI *GetNativeSystemInfoFunc)(LPSYSTEM_INFO);
953     HMODULE hModule = LoadLibraryW(L"kernel32.dll");
954     GetNativeSystemInfoFunc GetNativeSystemInfo =(GetNativeSystemInfoFunc)
955       GetProcAddress(hModule, "GetNativeSystemInfo");
956 #endif
957     const char* SysName = "Windows";
958     SYSTEM_INFO stInfo;
959     GetNativeSystemInfo( &stInfo );
960     DStringGDL *arch;
961     switch(stInfo.wProcessorArchitecture) {
962     case PROCESSOR_ARCHITECTURE_AMD64:
963       arch = new DStringGDL("x64");
964       break;
965     case PROCESSOR_ARCHITECTURE_INTEL:
966       arch = new DStringGDL("x86");
967       break;
968     case PROCESSOR_ARCHITECTURE_ARM:
969       arch = new DStringGDL("ARM");
970       break;
971     default:
972       arch = new DStringGDL("unknown");
973     }
974     ver->NewTag("ARCH", arch);
975     ver->NewTag("OS", new DStringGDL(SysName));
976     ver->NewTag("OS_FAMILY", new DStringGDL(SysName));
977     ver->NewTag("OS_NAME", new DStringGDL(SysName));
978 #else
979     struct utsname uts;
980     uname(&uts);
981     ver->NewTag("ARCH", new DStringGDL( uts.machine));
982     const char *SysName=uts.sysname;
983     if (strcmp(SysName,"Linux") ==0) SysName="linux";
984     if (strcmp(SysName,"Darwin") ==0) SysName="darwin";
985     ver->NewTag("OS", new DStringGDL(SysName));    //correct IDL order
986     ver->NewTag("OS_FAMILY", new DStringGDL( "unix"));
987     // AC 2018-sep-07
988     if (strcmp(SysName,"darwin") ==0) SysName="Mac OS X";
989     ver->NewTag("OS_NAME", new DStringGDL(SysName));
990 #endif
991 
992     ver->NewTag("RELEASE", new DStringGDL( "8.2")); //we are at least 6.4
993     ver->NewTag("BUILD_DATE", new DStringGDL(BUILD_DATE));
994     ver->NewTag("MEMORY_BITS", new DIntGDL( sizeof(BaseGDL*)*8));
995     ver->NewTag("FILE_OFFSET_BITS", new DIntGDL( sizeof(SizeT)*8));
996     DVar *v            = new DVar( "VERSION", ver);
997     vIx                = sysVarList.size();
998     sysVarList.push_back(v);
999     sysVarRdOnlyList.push_back(v);
1000 
1001     // !Mouse
1002     DStructGDL*  MouseData = new DStructGDL( "!MOUSE");
1003     MouseData->NewTag("X", new DLongGDL( 0));
1004     MouseData->NewTag("Y", new DLongGDL( 0));
1005     MouseData->NewTag("BUTTON", new DLongGDL( 0));
1006     MouseData->NewTag("TIME", new DLongGDL( 0));
1007     DVar *Mouse      = new DVar( "MOUSE", MouseData);
1008     MouseIx          = sysVarList.size();
1009     sysVarList.push_back(Mouse);
1010 
1011     // !Make_dll
1012     DStructGDL*  MakeDllData = new DStructGDL( "!MAKE_DLL");
1013     MakeDllData->NewTag("COMPILE_DIRECTORY", new DStringGDL("/tmp/"));
1014     MakeDllData->NewTag("COMPILER_NAME", new DStringGDL("GCC"));
1015     MakeDllData->NewTag("CC", new DStringGDL("gcc %X -fPIC -I%Z -c -D_REENTRANT %C -o %O"));
1016     MakeDllData->NewTag("LD", new DStringGDL("ld -shared -o %L %O %X"));
1017     DVar *MakeDll      = new DVar( "MAKE_DLL", MakeDllData);
1018     MakeDllIx          = sysVarList.size();
1019     sysVarList.push_back(MakeDll);
1020     sysVarNoSaveList.push_back(MakeDll);
1021 
1022     // !ERROR_STATE
1023     DStructGDL*  eStateData = new DStructGDL( "!ERROR_STATE");
1024     eStateData->NewTag("NAME", new DStringGDL( "IDL_M_SUCCESS")); //0 see !ERROR_NAME
1025     eStateData->NewTag("BLOCK", new DStringGDL( "IDL_MBLK_CORE"));
1026     eStateData->NewTag("CODE", new DLongGDL( 0));
1027     eStateData->NewTag("SYS_CODE", new DLongGDL( dimension( &dim2,one))); //idl 8 //3 see SYSERROR
1028     eStateData->NewTag("SYS_CODE_TYPE", new DStringGDL( ""));
1029     eStateData->NewTag("MSG", new DStringGDL( ""));
1030     eStateData->NewTag("SYS_MSG", new DStringGDL( ""));
1031     eStateData->NewTag("MSG_PREFIX", new DStringGDL( "% "));//7 see !MSG_PREFIX
1032     DVar *eState       = new DVar( "ERROR_STATE", eStateData);
1033     errorStateIx       = sysVarList.size();
1034     sysVarList.push_back(eState);
1035     //    sysVarRdOnlyList.push_back(eState);
1036     //very old obsolete variables
1037     DStringGDL* gdlerrorstatedoterror = new DStringGDL(dimension(1), BaseGDL::NOALLOC);
1038     gdlerrorstatedoterror->SetBuffer((void*) &((*static_cast<DStringGDL*> (eStateData->GetTag(0, 0)))[0]));
1039     gdlerrorstatedoterror->SetBufferSize(1);
1040     gdlerrorstatedoterror->SetDim(dimension(1));
1041     DVar *errorstatedoterror = new DVar("ERROR_NAME", gdlerrorstatedoterror);
1042     errorstatedoterrorIx = obsoleteSysVarList.size(); //do not remove this!
1043     obsoleteSysVarList.push_back(errorstatedoterror); //must be in obsolete and cannot be Save/Restored.
1044     DStringGDL* gdlerrorstatedotmsgprefix = new DStringGDL(dimension(1), BaseGDL::NOALLOC);
1045     gdlerrorstatedotmsgprefix->SetBuffer((void*) &((*static_cast<DStringGDL*> (eStateData->GetTag(7, 0)))[0]));
1046     gdlerrorstatedotmsgprefix->SetBufferSize(1);
1047     gdlerrorstatedotmsgprefix->SetDim(dimension(1));
1048     DVar *errorstatedotmsgprefix = new DVar("MSG_PREFIX", gdlerrorstatedotmsgprefix);
1049     errorstatedotmsgprefixIx = obsoleteSysVarList.size(); //do not remove this!
1050     obsoleteSysVarList.push_back(errorstatedotmsgprefix); //must be in obsolete and cannot be Save/Restored.
1051     DLongGDL* errorstatesyscodegdl = new DLongGDL(dimension(2), BaseGDL::NOALLOC);
1052     errorstatesyscodegdl->SetBuffer((void*) &((*static_cast<DLongGDL*> (eStateData->GetTag(3, 0)))[0]));
1053     errorstatesyscodegdl->SetBufferSize(2);
1054     errorstatesyscodegdl->SetDim(dimension(2));
1055     DVar *errorstatesyscode = new DVar("SYSERROR", errorstatesyscodegdl);
1056     errorstatesyscodeIx = obsoleteSysVarList.size();
1057     obsoleteSysVarList.push_back(errorstatesyscode);
1058 
1059     // !ERROR
1060     DLongGDL *errorData = new DLongGDL( 0 );
1061     DVar *errorVar = new DVar( "ERROR", errorData );
1062     errorIx            = sysVarList.size();
1063     sysVarList.push_back( errorVar);
1064     //sysVarRdOnlyList.push_back( errorVar); !error is (no more?) a readonly variable.
1065 
1066     // !ERR
1067     DLongGDL *errData = new DLongGDL( 0 );
1068     DVar *errVar = new DVar( "ERR", errData );
1069     errIx              = sysVarList.size();
1070     sysVarList.push_back( errVar );
1071     //    sysVarRdOnlyList.push_back( errVar);
1072 
1073     // !ERR_STRING
1074     DStringGDL *err_stringData = new DStringGDL( "");
1075     DVar *err_stringVar = new DVar( "ERR_STRING", err_stringData );
1076     err_stringIx        = sysVarList.size();
1077     sysVarList.push_back( err_stringVar );
1078     sysVarRdOnlyList.push_back( err_stringVar); //!err_string IS a readonly variable!
1079 
1080     // !VALUES
1081     DStructGDL*  valuesData = new DStructGDL( "!VALUES");
1082     if( std::numeric_limits< DFloat>::has_infinity)
1083       {
1084 	valuesData->NewTag("F_INFINITY",
1085 			   new DFloatGDL( std::numeric_limits< DFloat>::infinity()));
1086       }
1087     else
1088       {
1089 #ifndef _MSC_VER // Can be ignored, because the windows version of limit has infinity()
1090 	valuesData->NewTag("F_INFINITY", new DFloatGDL((float)1.0/0.0));
1091 #endif
1092       }
1093 #ifdef NAN
1094     valuesData->NewTag("F_NAN", new DFloatGDL(NAN));
1095 #else
1096     valuesData->NewTag("F_NAN", new DFloatGDL(sqrt((float) -1.0))); //sign depends on the architecture, dangerous way to define a +Nan!
1097 #endif
1098 
1099     if( std::numeric_limits< DDouble>::has_infinity)
1100       {
1101 	valuesData->NewTag("D_INFINITY",
1102 			   new DDoubleGDL( std::numeric_limits< DDouble>::infinity()));
1103       }
1104     else
1105       {
1106 #ifndef _MSC_VER // Can be ignored, because the windows version of limit has infinity()
1107 	valuesData->NewTag("D_INFINITY", new DDoubleGDL( (double)1.0/0.0));
1108 #endif
1109       }
1110 
1111 #ifdef NAN
1112     valuesData->NewTag("D_NAN", new DDoubleGDL(NAN));
1113 #else
1114     valuesData->NewTag("D_NAN", new DDoubleGDL(-sqrt((double) -1.0))); //sign depends on the architecture, dangerous way to define a +Nan!
1115 #endif
1116     DVar *values       = new DVar( "VALUES", valuesData);
1117     valuesIx           = sysVarList.size();
1118     sysVarList.push_back(values);
1119     sysVarRdOnlyList.push_back( values);
1120 
1121     // !JOURNAL hold journal file lun
1122     DLongGDL *journalData = new DLongGDL( 0);
1123     DVar *journal = new DVar( "JOURNAL", journalData);
1124     journalIx     = sysVarList.size();
1125     sysVarList.push_back( journal);
1126     sysVarRdOnlyList.push_back( journal);
1127 
1128     // !EXCEPT
1129     DIntGDL *exceptData = new DIntGDL( 1);
1130     DVar *except = new DVar( "EXCEPT", exceptData);
1131     exceptIx=sysVarList.size();
1132     sysVarList.push_back( except);
1133 
1134     // !MAP
1135     DStructGDL* mapData = new DStructGDL( "!MAP");
1136     mapData->NewTag("PROJECTION", new DLongGDL( 0));
1137     mapData->NewTag("SIMPLE", new DLongGDL( 0));
1138     mapData->NewTag("FILL_METHOD", new DLongGDL( 0));
1139     mapData->NewTag("UP_FLAGS", new DLongGDL( 0));
1140     mapData->NewTag("UP_NAME", new DStringGDL( ""));
1141     mapData->NewTag("P0LON", new DDoubleGDL( 0.0));
1142     mapData->NewTag("P0LAT", new DDoubleGDL( 0.0));
1143     mapData->NewTag("U0", new DDoubleGDL( 0.0));
1144     mapData->NewTag("V0", new DDoubleGDL( 0.0));
1145     mapData->NewTag("SINO", new DDoubleGDL( 0.0));
1146     mapData->NewTag("COSO", new DDoubleGDL( 0.0));
1147     mapData->NewTag("ROTATION", new DDoubleGDL( 0.0));
1148     mapData->NewTag("SINR", new DDoubleGDL( 0.0));
1149     mapData->NewTag("COSR", new DDoubleGDL( 0.0));
1150     mapData->NewTag("A", new DDoubleGDL( 0.0));
1151     mapData->NewTag("E2", new DDoubleGDL( 0.0));
1152     mapData->NewTag("UV", new DDoubleGDL( dimension( 2)));
1153     mapData->NewTag("POLE", new DDoubleGDL( dimension( 7)));
1154     mapData->NewTag("UV_BOX", new DDoubleGDL( dimension( 4)));
1155     mapData->NewTag("LL_BOX", new DDoubleGDL( dimension( 4)));
1156     mapData->NewTag("SEGMENT_LENGTH", new DDoubleGDL( 0.0));
1157     mapData->NewTag("P", new DDoubleGDL( dimension( 16)));
1158     mapData->NewTag("PIPELINE", new DDoubleGDL( dimension( 8, 12)));
1159 
1160     DVar *map=new DVar( "MAP", mapData);
1161     mapIx=sysVarList.size();
1162     sysVarList.push_back( map);
1163 
1164     // !CPU
1165     // init independent of OpenMP usage
1166 #ifdef _OPENMP
1167     CpuTPOOL_NTHREADS = omp_get_num_procs();
1168     omp_set_num_threads(CpuTPOOL_NTHREADS);
1169 #else
1170     CpuTPOOL_NTHREADS = 1;
1171 #endif
1172     CpuTPOOL_MIN_ELTS = DefaultTPOOL_MIN_ELTS;
1173     CpuTPOOL_MAX_ELTS = DefaultTPOOL_MAX_ELTS;
1174 
1175     DStructGDL* cpuData = new DStructGDL( "!CPU");
1176     cpuData->NewTag("HW_VECTOR", new DLongGDL( 0));
1177     cpuData->NewTag("VECTOR_ENABLE", new DLongGDL( 0));
1178 #ifdef _OPENMP
1179     cpuData->NewTag("HW_NCPU", new DLongGDL( omp_get_num_procs()));
1180 #else
1181     cpuData->NewTag("HW_NCPU", new DLongGDL( 1));
1182 #endif
1183     cpuData->NewTag("TPOOL_NTHREADS", new DLongGDL( CpuTPOOL_NTHREADS));
1184 
1185     //if use DLong64 below, please update basic_pro.cpp (function cpu()) and
1186     //add an 'assureLong64Kw()' function in envt.cpp. Otherwise the program will
1187     //crash in cpu(). (should have been done on 2014 March 18 by AC (tested).)
1188     cpuData->NewTag("TPOOL_MIN_ELTS", new DLong64GDL( CpuTPOOL_MIN_ELTS));
1189     cpuData->NewTag("TPOOL_MAX_ELTS", new DLong64GDL( CpuTPOOL_MAX_ELTS));
1190 
1191     DVar *cpu=new DVar( "CPU", cpuData);
1192     cpuIx=sysVarList.size();
1193     sysVarList.push_back( cpu);
1194     sysVarRdOnlyList.push_back( cpu);
1195 
1196 #ifdef _OPENMP
1197     if( omp_get_dynamic())
1198 	omp_set_dynamic( 1);
1199 #endif
1200 #if defined (_WIN32)
1201 
1202 #define realpath(N,R) _fullpath((R),(N),_MAX_PATH)
1203 // ref:http://sourceforge.net/p/mingw/patches/256/ Keith Marshall 2005-12-02
1204 #endif
1205 
1206     // !DIR
1207 #ifndef EXEC_PREFIX
1208 #define EXEC_PREFIX ""
1209 #endif
1210     DStringGDL *dirData = new DStringGDL( EXEC_PREFIX);
1211     string gdlDir=GetEnvString("GDL_DIR");
1212     if( gdlDir == "") gdlDir=GetEnvString("IDL_DIR");
1213     if( gdlDir != "")
1214 	{
1215 	delete dirData;
1216 	dirData = new DStringGDL( gdlDir);
1217 	}
1218     DVar *dir = new DVar( "DIR", dirData);
1219     dirIx=sysVarList.size();
1220     sysVarList.push_back( dir);
1221 
1222     // !GDL_MAPS_DIR
1223     string tmpDir=GetEnvString("GDL_MAPS_DIR");
1224     if( tmpDir == "") tmpDir = string(GDLDATADIR) + "/resource/maps";
1225     char *symlinkpath =const_cast<char*> (tmpDir.c_str());// is the path a true path ?
1226 
1227 #ifdef _MSC_VER
1228 	#define PATH_MAX MAX_PATH
1229 #endif
1230 //patch #90
1231 #ifndef PATH_MAX
1232 #define PATH_MAX 4096
1233 #endif
1234     char actualpath [PATH_MAX+1];
1235     char *ptr;
1236     ptr = realpath(symlinkpath, actualpath);
1237     if( ptr != NULL ) tmpDir=string(ptr)+lib::PathSeparator(); else tmpDir="";
1238     DStringGDL *GdlMapsDataDir =  new DStringGDL( tmpDir);
1239     DVar *GdlMapsDir = new DVar("GDL_MAPS_DIR", GdlMapsDataDir);
1240     sysVarList.push_back(GdlMapsDir);
1241 
1242     // !STIME
1243     DStringGDL *stimeData = new DStringGDL( "");
1244     DVar *stime = new DVar( "STIME", stimeData);
1245     stimeIx=sysVarList.size();
1246     sysVarList.push_back( stime);
1247     sysVarRdOnlyList.push_back( stime); // make it read only
1248 
1249     // !WARN
1250     DStructGDL*  warnData = new DStructGDL( "!WARN");
1251     warnData->NewTag("OBS_ROUTINES", new DByteGDL( 0));
1252     warnData->NewTag("OBS_SYSVARS", new DByteGDL( 0));
1253     warnData->NewTag("PARENS", new DByteGDL( 0));
1254     DVar *warn = new DVar( "WARN", warnData);
1255     warnIx     = sysVarList.size();
1256     sysVarList.push_back(warn);
1257 
1258     //!COLOR
1259     static const int col[]={240,248,255,250,235,215,0,255,255,127,255,212,240,255,255,245,245,220,255,228,196,0,0,0,255,235,205,0,0,255,138,43,
1260 226,165,42,42,222,184,135,95,158,160,127,255,0,210,105,30,255,127,80,100,149,237,255,248,220,220,20,60,0,255,255,0,
1261 0,139,0,139,139,184,134,11,169,169,169,0,100,0,169,169,169,189,183,107,139,0,139,85,107,47,255,140,0,153,50,204,
1262 139,0,0,233,150,122,143,188,143,72,61,139,47,79,79,47,79,79,0,206,209,148,0,211,255,20,147,0,191,255,105,105,
1263 105,105,105,105,30,144,255,178,34,34,255,250,240,34,139,34,255,0,255,220,220,220,248,248,255,255,215,0,218,165,32,127,
1264 127,127,0,127,0,173,255,47,127,127,127,240,255,240,255,105,180,205,92,92,75,0,130,255,255,240,240,230,140,230,230,250,
1265 255,240,245,124,252,0,255,250,205,173,216,230,240,128,128,224,255,255,250,250,210,144,238,144,211,211,211,211,211,211,255,182,
1266 193,255,160,122,32,178,170,135,206,250,119,136,153,119,136,153,176,196,222,255,255,224,0,255,0,50,205,50,250,240,230,255,
1267 0,255,127,0,0,102,205,170,0,0,205,186,85,211,147,112,219,60,179,113,123,104,238,0,250,154,72,209,204,199,21,133,
1268 025,25,112,245,255,250,255,228,225,255,228,181,255,222,173,0,0,128,253,245,230,128,128,0,107,142,35,255,165,0,255,69,
1269 0,218,112,214,238,232,170,152,251,152,175,238,238,219,112,147,255,239,213,255,218,185,205,133,63,255,192,203,221,160,221,176,
1270 224,230,127,0,127,255,0,0,188,143,143,65,105,225,139,69,19,250,128,114,244,164,96,46,139,87,255,245,238,160,82,45,
1271 192,192,192,135,206,235,106,90,205,112,128,144,112,128,144,255,250,250,0,255,127,70,130,180,210,180,140,0,128,128,216,191,
1272 216,255,99,71,64,224,208,238,130,238,245,222,179,255,255,255,245,245,245,255,255,0,154,205,50};
1273     static const string coln[]={"ALICE_BLUE","ANTIQUE_WHITE","AQUA","AQUAMARINE","AZURE","BEIGE","BISQUE","BLACK","BLANCHED_ALMOND",
1274     "BLUE","BLUE_VIOLET","BROWN","BURLYWOOD","CADET_BLUE","CHARTREUSE","CHOCOLATE","CORAL","CORNFLOWER","CORNSILK",
1275     "CRIMSON","CYAN","DARK_BLUE","DARK_CYAN","DARK_GOLDENROD","DARK_GRAY","DARK_GREEN","DARK_GREY","DARK_KHAKI",
1276     "DARK_MAGENTA","DARK_OLIVE_GREEN","DARK_ORANGE","DARK_ORCHID","DARK_RED","DARK_SALMON","DARK_SEA_GREEN",
1277     "DARK_SLATE_BLUE","DARK_SLATE_GRAY","DARK_SLATE_GREY","DARK_TURQUOISE","DARK_VIOLET","DEEP_PINK","DEEP_SKY_BLUE",
1278     "DIM_GRAY","DIM_GREY","DODGER_BLUE","FIREBRICK","FLORAL_WHITE","FOREST_GREEN","FUCHSIA","GAINSBORO","GHOST_WHITE",
1279     "GOLD","GOLDENROD","GRAY","GREEN","GREEN_YELLOW","GREY","HONEYDEW","HOT_PINK","INDIAN_RED","INDIGO","IVORY","KHAKI",
1280     "LAVENDER","LAVENDER_BLUSH","LAWN_GREEN","LEMON_CHIFFON","LIGHT_BLUE","LIGHT_CORAL","LIGHT_CYAN","LIGHT_GOLDENROD",
1281     "LIGHT_GREEN","LIGHT_GRAY","LIGHT_GREY","LIGHT_PINK","LIGHT_SALMON","LIGHT_SEA_GREEN","LIGHT_SKY_BLUE","LIGHT_SLATE_GRAY",
1282     "LIGHT_SLATE_GREY","LIGHT_STEEL_BLUE","LIGHT_YELLOW","LIME","LIME_GREEN","LINEN","MAGENTA","MAROON","MEDIUM_AQUAMARINE",
1283     "MEDIUM_BLUE","MEDIUM_ORCHID","MEDIUM_PURPLE","MEDIUM_SEA_GREEN","MEDIUM_SLATE_BLUE","MEDIUM_SPRING_GREEN","MEDIUM_TURQUOISE",
1284     "MEDIUM_VIOLET_RED","MIDNIGHT_BLUE","MINT_CREAM","MISTY_ROSE","MOCCASIN","NAVAJO_WHITE","NAVY","OLD_LACE","OLIVE",
1285     "OLIVE_DRAB","ORANGE","ORANGE_RED","ORCHID","PALE_GOLDENROD","PALE_GREEN","PALE_TURQUOISE","PALE_VIOLET_RED","PAPAYA_WHIP",
1286     "PEACH_PUFF","PERU","PINK","PLUM","POWDER_BLUE","PURPLE","RED","ROSY_BROWN","ROYAL_BLUE","SADDLE_BROWN","SALMON",
1287     "SANDY_BROWN","SEA_GREEN","SEASHELL","SIENNA","SILVER","SKY_BLUE","SLATE_BLUE","SLATE_GRAY","SLATE_GREY","SNOW","SPRING_GREEN",
1288     "STEEL_BLUE","TAN","TEAL","THISTLE","TOMATO","TURQUOISE","VIOLET","WHEAT","WHITE","WHITE_SMOKE","YELLOW","YELLOW_GREEN"};
1289     int ncol=147;
1290     int i,k;
1291     DStructGDL*  colorData = new DStructGDL( "!COLOR");
1292     for (i=0, k=0; i<ncol; ++i){
1293      colorData->NewTag(coln[i], new DByteGDL( dimension(3)));
1294      for (int j=0; j<3; ++j) (*static_cast<DByteGDL*>( colorData->GetTag( i, 0)))[j] = col[k++];
1295     }
1296     DVar *color = new DVar( "COLOR", colorData);
1297     colorIx     = sysVarList.size();
1298     sysVarList.push_back(color);
1299     sysVarRdOnlyList.push_back( color); //Is Readonly.
1300   }
1301 
1302 }
1303