Compiler and runtime environment variables

COBOL for Linux® uses the following environment variables that are common to both the compiler and the run time.

DB2DBDFT
Specifies the database to use for programs that contain embedded SQL statements or that use the Db2® file system.
DBCS_CODEPAGE
Specifies a DBCS code page applicable to DBCS data, including DBCS literals and DBCS data items.
To set the DBCS code page, issue the following command, where codepage is the name of a DBCS code page supported by the International Components for Unicode (ICU) conversion libraries, for example, IBM-943 or IBM-EUCjp:
export DBCS_CODEPAGE=codepage
If DBCS_CODEPAGE is not set, the default DBCS code page associated with the current locale is used.
LANG
Specifies the locale (as described in the related task about using environment variables to specify a locale). LANG also influences the value of the NLSPATH environment variable as described below.

For example, the following command sets the language locale name to U.S. English:


export LANG=en_US
LC_ALL
Specifies the locale. A locale setting that uses LC_ALL overrides any setting that uses LANG or any other LC_xx environment variable (as described in the related task about using environment variables to specify a locale).
LC_COLLATE
Specifies the collation behavior for the locale. This setting is overridden if LC_ALL is specified.
LC_CTYPE
Specifies the code page for the locale. This setting is overridden if LC_ALL is specified.
LC_MESSAGES
Specifies the language for messages for the locale. This setting is overridden if LC_ALL is specified.
LC_TIME
Determines the locale for date and time formatting information. This setting is overridden if LC_ALL is specified.
LD_LIBRARY_PATH
Specifies the directory paths to be used for shared libraries and user-defined compiler exit programs that the EXIT compiler option has identified.
NLSPATH
Specifies the full path name of message catalogs and help files and uses the form directory_name/%L/%N, where %L is substituted by the value specified by the LANG environment variable. %N is substituted by the message catalog name.

COBOL for Linux installs the compiler message catalog in /opt/ibm/cobol/1.2.0/usr/share/locale/xx, and the runtime message catalog in /opt/ibm/cobol/rte/usr/share/locale/xx in where xx is any language that COBOL for Linux supports. The default is en_US.

When you set NLSPATH, be sure to add to NLSPATH rather than replace it. Other programs might use this environment variable. For example:


DIR=xxxx
NLSPATH=$DIR/%L/%N:$NLSPATH
export NLSPATH

xxxx is the directory where COBOL was installed. The directory xxxx must contain a directory xxxx/en_US (in the case of a U.S. English language setup) that contains the COBOL message catalog.

Messages in the following languages are included with the product:

en_US
English
ja_JP
Japanese

You can specify the languages for the messages and for the locale setting differently. For example, you can set the environment variable LANG to en_US and set the environment variable LC_ALL to ja_JP.eucjp. In this example, any COBOL compiler or runtime messages will be in English, whereas native ASCII (DISPLAY or DISPLAY-1) data in the program is treated as encoded in code page ja_JP.eucjp (Japanese EUC code page).

The compiler uses the combination of the NLSPATH and the LANG environment variable values to access the message catalog. If NLSPATH is validly set but LANG is not set to one of the locale values shown above, a warning message is generated and the compiler defaults to the en_US message catalog. If the NLSPATH value is invalid, a terminating error message is generated.

The runtime also library also uses NLSPATH to access the message catalog. If NLSPATH is not set correctly, runtime messages appear in an abbreviated form. The compiler and runtime both automatically manage NLSPATH, so you do not need to handle NLSPATH yourself.

TMPDIR
Specifies the location of temporary work files used by the compiler and runtime. If this value is not set, it defaults to the current directory.

For example:


export TMPDIR=/tmp
TZ
Describes the time-zone information to be used by the locale. TZ has the following format:

export TZ=SSS[+|-]nDDD[,sm,sw,sd,st,em,ew,ed,et,shift]

If TZ is not present, the default is EST5EDT, the default locale value. If only the standard time zone is specified, the default value of n (difference in hours from GMT) is 0 instead of 5.

If you supply values for any of sm, sw, sd, st, em, ew, ed, et, or shift, you must supply values for all of them. If any of these values is not valid, the entire statement is considered invalid and the time-zone information is not changed.

For example, the following statement sets the standard time zone to CST, sets the daylight saving time to CDT, and sets a difference of six hours between CST and UTC. It does not set any values for the start and end of daylight saving time.


export TZ=CST6CDT

Other possible values are PST8PDT for Pacific United States and MST7MDT for Mountain United States.