Correct settings for environment variables

You can set and export a number of environment variables for use with the operating system. The following sections deal with the environment variables that have special significance to the XL Fortran compiler, application programs, or both.

Environment variable basics

You can set the environment variables from shell command lines or from within shell scripts. (For more information about setting environment variables, see the man page help for the shell you are using.) If you are not sure which shell is in use, a quick way to find out is to issue echo $SHELL to show the name of the current shell.

To display the contents of an environment variable, enter the command echo $var_name.

Note:
For the remainder of this document, most examples of shell commands use Bash notation instead of repeating the syntax for all shells.

Environment variables for national language support

Diagnostic messages and the listings from the compiler appear in the default language that was specified at installation of the operating system. If you want the messages and listings to appear in another language, you can set and export the following environment variables before executing the compiler:

LANG
Specifies the locale. A locale is divided into categories. Each category contains a specific aspect of the locale data. Setting LANG may change the national language for all the categories.
NLSPATH
Refers to a list of directory names where the message catalogs may be found.

For example, to specify the Japanese locale, set the LANG environment variable to ja_JP.

Substitute any valid national language code for ja_JP, provided the associated message catalogs are installed.

These environment variables are initialized when the operating system is installed and may be different from the ones that you want to use with the compiler.

Each category has an environment variable associated with it. If you want to change the national language for a specific category but not for other categories, you can set and export the corresponding environment variable.

For example:

LC_MESSAGES
Specifies the national language for the messages that are issued. It affects messages from the compiler and XLF-compiled programs, which may be displayed on the screen or stored in a listing, module, or other compiler output file.
LC_TIME
Specifies the national language for the time format category. It primarily affects the compiler listings.
LC_CTYPE
Defines character classification, case conversion, and other character attributes. For XL Fortran, it primarily affects the processing of multibyte characters.
LC_NUMERIC
Specifies the format to use for input and output of numeric values. Setting this variable in the shell does not affect either the compiler or XLF-compiled programs. The first I/O statement in a program sets the LC_NUMERIC category to POSIX. Therefore, programs that require a different setting must reset it after this point and should restore the setting to POSIX for all I/O statements.

Notes:
  1. Specifying the LC_ALL environment variable overrides the value of the LANG and other LC_ environment variables.
  2. If the XL Fortran compiler or application programs cannot access the message catalogs or retrieve a specific message, the message appears in U.S. English.
  3. The backslash character, \, has the same hexadecimal code, X'5C', as the Yen symbol and can appear as the Yen symbol on the display if the locale is Japanese.

Related information:
Selecting the language for run-time messages.

See the Linux-specific documentation and man page help for more information about National Language Support environment variables and locale concepts.

Setting library search paths

If your executable program is linked with shared libraries, you need to set the run-time library search paths. There are two ways to set run-time library search paths. You can use:

Specifying search paths with the compile/link -R (or -rpath) option has the effect of writing the specified run-time library search paths into the executable program. If you use the -L option, library search paths are searched at link time, but are not written into the executable as run-time library search paths. For example:

# Compile and link
xlf95 -L/usr/lib/mydir1 -R/usr/lib/mydir1 -L/usr/lib/mydir2 -R/usr/lib/mydir2
  -lmylib1 -lmylib2 test.f

# -L directories are searched at link time.
# -R directories are searched at run time.

You can also use the LD_LIBRARY_PATH and LD_RUN_PATH environment variables to specify library search paths. Use LD_RUN_PATH to specify the directories that are to be searched for libraries at run time. Use LD_LIBRARY_PATH to specify the directories that are to be searched for libraries at both link and run time.

For more information on linker options and environment variables, see the man pages for the ld command.

PDFDIR: Specifying the directory for PDF profile information

When you compile a Fortran program with the -qpdf compiler option, you can specify the directory where profiling information is stored by setting the PDFDIR environment variable to the name of the directory. The compiler creates the files to hold the profile information. XL Fortran updates the files when you run an application that is compiled with the -qpdf1 option.

Because problems can occur if the profiling information is stored in the wrong place or is updated by more than one application, you should follow these guidelines:

TMPDIR: Specifying a directory for temporary files

The XL Fortran compiler creates a number of temporary files for use during compilation. An XL Fortran application program creates a temporary file at run time for a file opened with STATUS='SCRATCH'. By default, these files are placed in the directory /tmp.

If you want to change the directory where these files are placed, perhaps because /tmp is not large enough to hold all the temporary files, set and export the TMPDIR environment variable before running the compiler or the application program.

If you explicitly name a scratch file by using the XLFSCRATCH_unit method described below, the TMPDIR environment variable has no effect on that file.

XLFSCRATCH_unit: Specifying names for scratch files

To give a specific name to a scratch file, you can set the run-time option scratch_vars=yes; then set one or more environment variables with names of the form XLFSCRATCH_unit to file names to use when those units are opened as scratch files. See Naming scratch files for examples.

XLFUNIT_unit: Specifying names for implicitly connected files

To give a specific name to an implicitly connected file or a file opened with no FILE= specifier, you can set the run-time option unit_vars=yes; then set one or more environment variables with names of the form XLFUNIT_unit to file names. See Naming files that are connected with no explicit name for examples.