III.  Environment Variables and Organization of Unix TRANSP Files

As with most unix software systems, TRANSP operates under the context of a user defined environment. This environment defines the location of TRANSP files, and related installation-specific information. It is the user's responsibility to set up this environment correctly. A template is provided in the files

sample.login

which is available via anonymous ftp at ftp.pppl.gov:pub/transp/codata/doc. This file will have been encountered already if the README instructions were followed in order to fetch a copy of the TRANSP source code.

Traditionally, the environment is imbedded directly in the user's .login or .cshrc files in the user's home directory. Alternatively, it may be placed in a file .transprc in the user's home directory. The choice depends on whether the user wants TRANSP definitions automatically upon every login. If TRANSP definitions are desired every time, the .login, .cshrc, or other initialization file for the shell of the user's choice, may be used. If TRANSP definitions are only desired occasionally, then use the .transprc file:

(a) get a copy of `sample.login' (b) edit for local use, following the guidelines below. (c) rename to .transprc in the home directory (d) when you login and desire TRANSP, do (assuming csh):

> source .transprc

to set up the local TRANSP environment.

The exact procedure may be slightly different for non-csh users.

TRANSP files are found in a hierarchical directory tree. The root of this tree and the top level subdirectories of this root are expected to be identified by environment variables that are defined in the user's environment. These root environment variables are:

TRANSPROOT
root of TRANSP directory tree.Each user must select their own TRANSPROOT definition. Then, the following are usually defined in terms of TRANSPROOT:
TMPDIR
a directory for temporary files.
DBGDIR
a directory used for generating debug versions of executable programs.
CONFIGDIR
directory for site specific information, e.g. list of known tokamaks; mail address for code update reports.
PREACTDIR
directory for binary atomic and fusion cross section tables generated by the preact module and used by TRANSP.
DATADIR
root of tree of directories containing Ufile input data for TRANSP. Each known tokamak has a subtree.
WORKDIR
root of tree of working directories for executing TRANSP runs. There is a separate working directory for each known tokamak.
RESULTDIR
root of tree of directories for results of completed TRANSP runs. Subdirectories have names of the form <tok>.<yy>, where <tok> is a tokamak id and <yy> is a two digit shot year code, as in TFTR.88, for analyses of 1988 TFTR shots.
CODESYSDIR
root of tree of directories containing the TRANSP sources.
LOCAL
root of tree containing the TRANSP binaries. On most single user systems, LOCAL and CODESYSDIR point to the same directory.

The definition of CODESYSDIR is $TRANSPROOT/codesys, and most documentation files are in $CODESYSDIR/source/doc (i.e. $TRANSPROOT/codesys/source/doc) with certain specially formatted (VMS legacy) files in $CODESYSDIR/doc

For more detailed information on files and directories, see the document $CODESYSDIR/source/doc/unixdirs.doc This file is $CODESYSDIR/source/doc/unix_transp.doc.

Transp Environment

In setting up the .login environment, the following steps should be attended to. This will be easier if you use the `sample.login' file as a template.

(a) define TRANSPROOT (see discussion, above).

(b) NAG library

The TRANSP dependency on NAG has been removed; NAG_SP and NAG_DP definitions are no longer required.

 (c) f90/C++ mixed language codes

CPP_TRAILER environment variable now required... FTN_TRAILER, FTN_MAIN environment variables  

Several f90 codes, including TRANSP itself, now use C++ based subroutine libraries. In order to link such codes, an environment variable which lists the C++ runtime libraries must be defined. This environment variable is called "CPP_TRAILER".  

To support calling fortran programs from C++ main programs and for those fortran programs which require linking with the C++ linker, the environment variables FTN_TRAILER and FTN_MAIN are required. FTN_TRAILER defines the fortran libraries needed during linking from a C++ program. FTN_MAIN defines the object file containing the fortran main() function -- it is used during linking of a fortran program with the C++ linker. As of 21Jun2004, the four main programs transp,dbtran,toric4_main and key_access_test require C++ linkage.  

The choice of linker (see $CODESYSDIR/csh/linkload) is based on the following prescription for a program defined in $CODESYSDIR/source/<name> fortran program - by default linked with f90 with no c++ libraries - if <name>_cpp.inf is defined in <name> directory, link with f90 and include c++ libraries defined in CPP_TRAILER - if <name>_cpp.inf and <name>_ftn.inf are defined in the <name> directory then the environment variables FTN_MAIN and FTN_TRAILER must be set and the program will be linked with g++. FTN_TRAILER should contain the linker switches pointing to the fortran libraries and FTN_MAIN should point to the object file containing the fortran main() symbol. If the environment variable FTN_LINK_WITH_F90 is set, then the f90 linker will be used as though the <name>_ftn.inf file did not exist. c++ programs - by default linked with g++ - if <name>_ftn.inf is defined in <name> directory link with g++ using the fortran libraries in FTN_TRAILER  

The following is a copy of a csh login script for intel linux that is currently being used to support the production system on the PPPL Unix Cluster (rga 20Aug2003). The C++ compiler referenced in the CPP_TRAILER must be consistent with the C++ compiler and library path referenced by the PATH and LD_LIBRARY_PATH environment variables (see setcpp.login)  

Caution-- EXPECT this to CHANGE OFTEN; this document may not be up-to-date. It would be nice if the Linux/gcc folks would clean up their handling of this, someday...  

(this is a copy of the intel linux part of codesys/source/doc/setcpp.login for use with gcc 3.2 and lahey-fujitsu f90 compiler 6.10c -- rga 20Aug2003):  

setenv CPP_TRAILER "-L/usr/local/gcc32/lib -lstdc++" setenv FTN_TRAILER "-lfj9i6 -lfj9f6 -lfj9e6 -lfst -lfccx86_6a" setenv FTN_MAIN "/usr/local/lff95/lib/fj90rt0.o"  

 Several f90 codes, including TRANSP itself, now use C++ based subroutine libraries. In order to link such codes, an environment variable which lists the C++ runtime libraries must be defined. This environment variable is called "CPP_TRAILER". The following is a copy of a csh login script that is currently being used to support all platforms on the PPPL Unix Cluster...

 #! /bin/csh
 if ($WORKSTATION_TYPE == 'SUN') then
 setenv CPP_TRAILER /usr/local/lib/libstdc++.so.2.10.0
> else if ($WORKSTATION_TYPE == 'LINUX') then
 if ($H == 'alpha') then
 setenv CPP_TRAILER -lstdc++
 else
 setenv CPP_TRAILER "-L/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66 -ls
 endif
 else
 setenv CPP_TRAILER "-liostream /usr/local/lib/libstdc++.so.2.10.0"
 endif

(d)  define the LOADER_TRAILER environment variable.

Define environment variables to locate system libraries, such as NetCDF, that can be linked to the code. (But, LOADER_TRAILER can still be used as  before). Here are some sample values:

setenv USRLIB "$CODESYSDIR/other "
#
setenv F2C " -lf2c"                     # libf2c.a, required by
                                        # some lapack builds
setenv BLAS " -lblas"                   # math library libblas.a
setenv LAPACK " -llapack $BLAS $F2C"    # math library liblapack.a
#
setenv FFTW " -lfftw"                   # math library libfftw.a
setenv RFFTW " -lrfftw"
setenv NETCDF " -lnetcdf"               # libnetcdf.a (NetCDF software)
setenv MDSPLUS " -lMdsLib "             # libmdsplus.a ( remote data access
setenv SUPERLU " -L/usr/local/superlu -l superlu $BLAS"
#                                         See bulletin 23Dec2003
setenv LOADER_TRAILER " -L $CODESYSDIR/other"

 


Explanation: -lfftw instructs the loader to include libfftw.a ( or .so ) , which must be located in the library search path ( which includes /usr/lib , /usr/local/lib on unix systems ) Libraries built specifically for transp can conveniently be created in ( or linked from ) $CODESYSDIR/other. The $LOADER_TRAILER environment variable adds this directory to the library search path. $CODESYSDIR/other may contain

>ls -l $CODESYSDIR/other

jclib.a -> libjc.a
libblas.a -> /home/pshare/lib/source/blas/libblas.a
libf2c.a
libf2c.so -> libf2c.so.0.22
libf2c.so.0 -> libf2c.so.0.22
libf2c.so.0.22
libfftw.a -> /home/pshare/lib/source/fftw-2.1.3/fftw/.libs/libfftw.a
libjc.a
liblapack.a -> /home/pshare/lib/source/LAPACK/lf95/liblapack.a
librfftw.a -> /home/pshare/lib/source/fftw-2.1.3/rfftw/.libs/librfftw.a
libsg.a
sglib.a -> libsg.a

Other libraries which may be required -

-ldf -lz ... links libdf.a and libz.a (HDF software)
-lsocket ... (SUN only) helps find a necessary systems library
 

Appropriately optimized versions of the standard freeware mathematics libraries LAPACK and BLAS should be built. Sources for these libraries can be found at  http://www.netlib.org if required. The software libfftw.a, "Fastest Fourier Transform in the West",  cf www.fftw.org, is required by ICRF codes and must be provided.

LOADER_TRAILER options ( as from Aug 2004 )

All external libraries were previously defined in LOADER_TRAILER, and so all were searched by the loader for every transp executable. The external libraries are now defined individually for each executable, as variables stored in $CODESYSDIR/source/<name>/<name>_exe.link. See comments in  $SC/uplink for more information.

LOADER_TRAILER may be used to add to the library search path, as shown in  the example above

generic_dummy

This library contains dummy routines, for example to satisfy references  to mdsplus libraries, if these are not available, & a reference to the library  was traditionally included in LOADER_TRAILER. However, most of the external libraries are now required to build a useable version of transp, & so including generic_dummy in all builds is likely to conceal errors in the build process. It is better to add generic_dummy to the .._exe.link file , only for those executables which are known to require it.

Link Errors

Two linux commands to help identify link errors -

a) ldd $XE/<name>

will show the location of all shared libraries used by an executable; Any flagged as 'not found' indicate probable omissions from the setting of
$LD_LIBRARY_PATH

b) Tracing program links

setenv LDFLAGS "-Wl,-t"  produces a list of libraries accessed, and modules loaded from each

MDSplus

A note on MDS+ "include" files (Tina Ludescher May 2001, revised Aug 2004):
-> mdsdescript.h, config.h
by default, these files are in /usr/local/mdsplus/include in this case $SC/System_options is handling it.

If they are somewhere else,  MDSPLUS_DIR must be defined, eg
        MDSPLUS_DIR=$HOME/mymdsplus
(without "include")

Note: The mdsplus library locations are now defined by the variable MDSPLUS ( see previous section ) , rather than in $LOADER_TRAILER as previously. $SC/System_options sets appropriate options based on the presence of MdsLib in LOADER_TRAILER, or the definition of MDSPLUS. If both are absent, mdstransp dummy routines are compiled which don't require mdsplus include files.

Command line editing

This is an option that allows emacs style command line editing to be used within TRANSP's interactive command line oriented fortran programs like rplot and the ufile utilities. To activate this, 3 steps are required:

(1) modify LOADER_TRAILER to pick up the free software foundation (gnu) C libraries needed (LINUX machines find the libraries in the default systems libraries area so a "-L" option won't be needed).

(2) (non-LINUX machines) define an environment variable CCLIB_INCLUDE  to point to the root of the directory tree where gnu's C header  files are located,

(3) define an environment variable GETLINE_EDITOR ...where the values assigned in steps (1) and (2) are site dependent.

 More details:
(1) At PPPL, the appropriate LOADER_TRAILER fragment is:
non-LINUX
"-L/usr/local/lib -lreadline -lhistory -ltermcap"
LINUX:
"-lreadline -lhistory -ltermcap"

These are "gnu" free software foundation libraries for C subprograms (which TRANSP uses). **Whether and where these libraries are installed may vary from system to system**; TRANSP will load without them but then interactive codes won't support command line editing.

(2) Non-LINUX machines Use the environment variable

CCLIB_INCLUDE

to point to the directory where the "gnu" free software foundation C header files are to be found; at PPPL the correct value is

/usr/local/include

but this could vary from site to site. 

(Linux machines have the header files under /usr/include, where gcc looks by default, so, no CCLIB_INCLUDE definition is needed).

(3) Set the GETLINE_EDITOR variable to any value. The build script merely checks whether or not it is defined.--CAUTION-- TRANSP may not build correctly if only a subset of steps (1, 2, 3) are carried out!

Sample segment for login script:

#---------------
# link to readline & history, if available...
# ...assume some of LOADER_TRAILER has already been set.
#
if ( -d /usr/local/include/readline ) then
setenv LOADER_TRAILER \
"$LOADER_TRAILER -L/usr/local/lib -lreadline -lhistory -ltermcap"
setenv CCLIB_INCLUDE /usr/local/include
setenv GETLINE_EDITOR TRUE
else if ( $WORKSTATION_TYPE == "LINUX" ) then
setenv LOADER_TRAILER "$LOADER_TRAILER -lreadline -lhistory -ltermcap"
setenv GETLINE_EDITOR TRUE
endif

e) Set the PATH variable

The PATH environment variable must be defined to included the directories

$TRANSPROOT/bin $CODESYSDIR/csh $LOCAL/exe

in the search path for executable programs -- use code along the lines of `sample.login'. Also, please make the definitions:

setenv XE $LOCAL/exe setenv SC $CODESYSDIR/csh setenv SB $TRANSPROOT/bin

Some procedures make use of these abbreviated environment variable names.

Note that PATH should include the directories containing the system binaries used for access to client-server source code control, i.e. the cvs, rcs, gzip, diff, gnu make and patch programs. It was already necessary to do this in order to import a copy of the TRANSP source code. Access to the source code control software will similarly be needed for any successful future update of the source code.

Note also that with the advent of XTRANSPIN and SGLIB, one must use the GNU "make" (gmake). The `make' command should point to gmake. If this is not done at the system level it can be done by the user by including the directory $HOME/bin early on the user's PATH and setting up a link $HOME/bin/make to gmake.

(f) Set the WORKSTATION_TYPE 

The environment variable WORKSTATION_TYPE should be defined to identify the type of unix workstation you are running. Use $SC/test_os{_csh} to set it.

Currently known types are:

ALPHA
DEC Alpha (osf/1) workstation
HP
Hewlett Packard Workstation 9000 (HP UX) (work in progress 12/95 tbt)
RS6000
IBM AIX (work in progress 08/98 cal)
SGI
Silicon Graphics Iris workstation
SUN
SUN/SOLARIS systems (SUNOS no longer supported!)
LINUX
LINUX system.

If you are porting TRANSP to a new type of workstation, use its generic name as the definition of WORKSTATION_TYPE, and be prepared for some extra work as described in section III below.

(g) SELECTION OF FORTRAN COMPILER

TRANSP is now a fortran-90 code. There is no longer an option to build the code using fortran-77 only. Generally, the vendor's compiler is used. Switches are set in $CODESYSDIR/csh/Default_options.On Intel LINUX, we recommend the fujitsu compiler. See http://w3.pppl.gov/~dmccune/papers-reports/linux_f90.txt and set the environment variable
                    FORTRAN_VARIANT = "Fujitsu"
so that, for example...
[puffin.pppl.gov|65] printenv FORTRAN_VARIANT
Fujitsu

(h) Set TERMINAL_TYPE

The environment variable TERMINAL_TYPE will have to be defined in a manner appropriate to your hardware environment -- for TRANSP SG graphics to function properly. Most sites: TERMINAL_TYPE=XTERM. Note: on IBM RS-6000, AIXTERM is broken, a "real" XTERM must be used for graphics to work.

[dmc -- last update 18 Oct 1999].

Local build options

Local compiler/link options may be supplied in the file $CONFIGDIR/User_options - eg

#...   config/User_options - sourced from tcomp
#                     set JET user options
#                                                        jconboy  19Sep2000
#----------------------------------------------------------------------------------
#
   set cppargs_f90  = "$cppargs_f90 -D__JET"
#                                                        end User_Options

This appends the flag __JET to the preprocessor command string. See $SC/Default_options, $SC/tcomp for examples & use. 

Miscellaneous

(If this unix copy of TRANSP will be used to update a VMS copy of TRANSP, define the environment variable VAXUPDATE to be TRUE.)

The file `sample.login' also defines the alias names "debug", "nb_debug_on", and "nb_debug_off", which are useful in connection with debugging TRANSP and related software -- these should be defined as well. Some aliases for convenient resetting of the current working directory are also provided, such as:

% alias cdcs "cd $TRANSPROOT/codesys/source"

If the root directory for TRANSP is not the home directory for your account, you may want to define an environment variable or alias to make it easy to change working directory to the TRANSP root directory, i.e. an alias for

% cd $TRANSPROOT

as in:

% alias cdroot "cd $TRANSPROOT"

Alias definitions are a matter of interactive user taste and convenience.