GDX (GAMS) files


[note: see end of this topic for GDX read errors]

GDX files are used by the GAMS modelling system to store data. ViewHAR can translate between HAR and GDX formats -- subject to several provisos:

The translation facilities will only be available if the file GDXIOMH.DLL is in the same folder as VIEWHAR.EXE.

When writing GDX files note that:

Integer arrays and character arrays in HAR files (other than sets) are ignored.

You have a choice whether GAMS names are based on (a) the HAR coefficient names; or (b) the HAR header names.

When reading GDX files note that:

Multi-dimensional sets, variables and equations in GDX files are ignored.

You cannot extract individual parameters -- you must read in the whole GDX.

Various differences between GEMPACK and GAMS can cause translation problems. To avoid these:

(A) if you are using GAMS to prepare a GDX file for translation to HAR, remember that GDX files do not naturally contain information about array domains -- the sets over which the array is defined. To assist translation, you should store associated sets in the GDX file and include domain information and a suggested header key in the "explicit text'' description of each GAMS array declaration, as in the example below:

PARAMETER OUTPUT(i,r) Base year production [[Y:I*R]]

The information enclosed in double square brackets tells ViewHAR to use the header " Y'' and that the dimensions of OUTPUT are the sets I and R. If there is no such information enclosed in double square brackets, ViewHAR has to invent sets for each matrix. Because GDX uses a sparse format to save data, the invented sets might have fewer elements than you expect (corresponding to zero rows or columns).

(B) if you are using GEMPACK to prepare a HAR file for translation to GDX, avoid creating sets which share common elements that are ordered differently. If you follow this rule, the GAMS user can use GlobalSet (prepared by HAR2GDX) to ensure that GAMS orders set elements in the same way as GEMPACK.

(C) Try to use names (for arrays, sets and set elements) which are legal in both GEMPACK and GAMS. Identifiers of maximum length 10 with first character one of [A..Z,a..z] and remaining characters in [A..Z,a..z,0..9] will translate most smoothly.

The translation system is the same as that used by the command line programs GDX2HAR and HAR2GDX. The help file GDXHAR.CHM explains the above points in greater detail.

You may already have the command line programs GDX2HAR and HAR2GDX in the same folder as ViewHAR. If not, download them from:

http://www.copsmodels.com/webjmh.htm

Other methods of Saving Data to file are:

GEMPACK Text Files

Excel (XLS) format

Database text files

Since October 2010 the file gdxiomh.dll distributed with ViewHAR is in fact a copy of the file gdxdclib.dll (size 167,936 date 15-12-2009) distributed with GAMS23.3.

This should mean that ViewHAR and GDX2HAR can read any GDX files compatible with GAMS23.3 or earlier.

ViewHAR and HAR2GDX create GDX files of the V7 uncompressed type (they ignore any setting of the Windows environment variable GDXCONVERT -- see below).

 

See also this webpage

 

 

GDX FORMAT CHANGE PROBLEM

GAMS changed its GDX format for GAMS Version 22.6.

Prior to October 2010, ViewHAR could read only the older V5 GDX format.

The following advice applies to these older versions of ViewHAR and GDX2HAR.

As described by Erwin Kalvelagen:

Users may encounter the following error message when using ViewHar or GDX2HAR:

Cannot open input file C:\delgams\tmp2.gdx

Perhaps it is not really a GDX file !

**** Fatal GDX I/O Error = -100033

This happens when a new GAMS system (22.6 or newer) is used with an old GDX2HAR (or ViewHar) tool. The tools included in GEMPACK work with GAMS 22.5 or older. To increase the confusion, GAMS also distributes GDX2HAR and then it depends on the PATH order which version of GDX2HAR will be executed. Make sure you actually use the GAMS version of GDX2HAR and things should be ok. ViewHar is not distributed by GAMS so you need to convert the GDX to an older format first. You can use GDXCOPY for this.

Remedies

If you have a full modern GAMS installation you should be able to read old or new formats of GDX files easily. ViewHAR will only read the older "V5" format, but you can use the GAMS GDXCOPY utility to convert GDX files to the older format.

There are two ways to cause GAMS to write the older, ViewHAR-compatible V5 format:

1: Set the Windows environment variable

GDXCONVERT to V5

via Control Panel..System..Advanced. Then, after you next start up the GAMSIDE, GAMS will automatically produce the ViewHAR-compatible V5 format.

2: Alternatively include the following line in your GMS file

$SetEnv GDXCONVERT "v5"

before your EXECUTE_UNLOAD statement.



URL of this topic: www.copsmodels.com/webhelp/viewhar/hc_gdx.htm

Link to full GEMPACK Manual

Link to GEMPACK homepage