XL Fortran for AIX 8.1

User's Guide


Correct Settings for Environment Variables

You can set and export a number of environment variables for use with the AIX 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 the Bourne shell, Korn shell, or the C shell. If you are not sure which shell is in use, a quick way to find out is to echo $0. This provides a different result in each shell:


$ sh
$ echo $0
sh
$ ksh
$ echo $0
ksh
$ csh
% echo $0
No file for $0.
%

The Bourne shell path is /bin/sh, the Korn shell path is /bin/ksh, and the C shell path is /bin/csh.

To set the environment variables so that everyone on the system has access to them, set the variables in the file /etc/profile (for the Bourne or the Korn shell), or set the variables in the file /etc/csh.login or in the file /etc/csh.cshrc (for the C shell). To set them for a specific user only, add the appropriate commands to the appropriate .profile or .cshrc file in the user's home directory. The variables are set the next time the user logs on.

For more information about setting environment variables, see the following information in the AIX Commands Reference:

The following example shows how to set environment variables from various shells.

From the Bourne or Korn shell:

NLSPATH=/usr/lib/nls/msg/%L/%N:/usr/lib/nls/msg/prime/%N
LANG=en_US
TMPDIR=/home/joe/temp  
export LANG NLSPATH TMPDIR

From the C shell:

setenv LANG en_US
setenv NLSPATH /usr/lib/nls/msg/%L/%N:/usr/lib/nls/msg/prime/%N
setenv TMPDIR /home/joe/temp

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

Note:
Because the Korn shell is the default operating system shell, for the remainder of this book, most examples of shell commands use ksh 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 with the IBM_eucJP code page, use the following commands from the Bourne or Korn shell:

LANG=ja_JP
NLSPATH=/usr/lib/nls/msg/%L/%N:/usr/lib/nls/msg/prime/%N
export LANG NLSPATH

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 General Programming Concepts: Writing and Debugging Programs for more information about National Language Support environment variables and locale concepts.

LIBPATH: Setting Library Search Paths

Under normal circumstances, you only need LIBPATH if libraries are located in different directories at run time from those that they are in at compile time. To use LIBPATH, set it at run time to the names of any directories that contain required user libraries, plus /usr/lib:

   # Compile and link
   xlf95 -L/usr/lib/mydir1 -L/usr/lib/mydir2 -lmylib1 -lmylib2 test.f
 
   # When the libraries are in the same directories as at compile
   # time, the program finds them.
   a.out
 
   # If libmylib1.a and libmylib2.a are moved to /usr/lib/mydir3,
   # you must set the LIBPATH variable:
   export LIBPATH=/usr/lib/mydir3:/usr/lib
   a.out

When running the compiler, ensure that the library libxlf90.a is in /usr/lib or is in a directory named in the LIBPATH setting. Otherwise, you cannot run the compiler, because it is dynamically linked with the libxlf90.a library.

PDFDIR: Specifying the Directory for PDF Profile Information

When you compile a Fortran 90 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.

The AIX system routine tempnam uses the value of TMPDIR for generating unique names for temporary files.

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.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]