r.build

r.build links objects (.o) and create an executable with all the needed options to insure compatibility with the corresponding librmn library for the specified platform. Unless really specific needs, few compilations options (key -opt[f,c]) will have to be specified since the use of the proper keys will adjust the compilers accordingly (paths for libraries and included files, particular flags for the compilers, etc...)

By default, the script will compile for the platform on which the script is called. However, this script is particularly useful for compiling on a Linux box to create objects and executables for the NEC SX6 by using the cross-compiling tools (sxf90 and sxcc). It replaces the f7732-like scripts. It works best in conjonction with r.compile when the latter has been used without the -o flag.

Usage

 
 r.build  
-obj fichier.o objects to link
-opt =-option1 =-option2 Additional options for the compilers (to be used only if certain particular flags are not already included by the script) 
-optc =-option1 =-option2 Additional options for the C compiler (to be used only if certain particular flags are not already included by the script) 
-optf =-option1 =-option2 Additional options for the Fortran compiler (to be used only if certain particular flags are not already included by the script) 
-defines =-Dname1=def1:-Dname2=def2... Additional "defines" (to be used only for particular "defines" needed by the code)
-includes path1 path2 Path to additional directory for include files
-n64 [_o32] Compilation mode: 64 bits (or o32 if -n64 _o32)
-multi multi mode(vs stack)
-mpi [stubs] MPI mode. Using "stubs" argument cause the loading of "fake" mpi calls in order to run a code on a single CPU or on a machine without loading MPI library.
-shared Shared objects
-fast FAST option on NEC SX6
-abi Variable $ABI (preempt on -n64, -multi)
-arch Destination platform (HP-UX, IRIX64, SX6, Linux, Linux_alpha, AIX) of created binaries. If SX6, cross-compilers are used. 
-bidon [lang] If r.makebidon is needed. The generated bidon file will be in fortran or C, depending of the value of the key (fortran by default). (To be used when a program contains only subroutines, no main: r.makebidon creates a "main" who will call a subroutine
-main Name of one or more subroutines to be called by r.makebidon (see examples)
-o  Name of the executable (needed)
-libpath Path to additional directories containing specific libraries (if not already specified by the script) 
-libappl Use of particular application librairies
-libgraph Use of local NCAR library
-libsys Use of a particular system library
-librmn Use of RMN library 
-libpriv Use of priv library (FFT and assembly for NEC)
-O Optimization level (-O 0...4) 
-debug Debugging option
-fstd89 Use of version 89 of standard files instead of current version
-modele Use of model-specific libraries (ANAL, PHY, MC2,etc...)
-version Determine the version of the model to be used (specified previously with -modele) (just type the version number, 4.8.9 for example).
-conly The executable will be build with cc (or sxcc) instead of f90 (sxf90)
-log Redirect error messages and standard output to the specified file.
-liste Product a status file in which all the files processed will be listed with their status (error or ok). Also, a list of user-specified librairies will be printed
-ignorerr Ignore compilation errors (an error won't cause the script to stop)
-codebeta module Load $ARMNLIB/lib/$FULL_ABI/module.o instead of subroutines and/or functions declared in standard libraries.
-ignoreempty If a .ftn (.ftn90) produces an empty .f (.f90), then the latter is ignored with no error returned.
-use_malib
To load all objects in the specified library (to be used with SMALL temporary libraries, this is not a replacement for -libappl)
-prof
Adds proper options to use the profiler
-openmp
Adds proper options to use OpenMP

Localization of libraries and "include" files:

Depending of the value of key -arch and -abi, the script adjusts the compilers in a way that they find the appropriate libraries and "include" files. In the scripts, the keys -arch and -abi are stored in variables $arch and $abi respectively. Those variables are used to build a more global variable, $FULL_ABI. For example:
 
 

Specified keys Corresponding $FULL_ABI
-arch SX6 -multi SX6_multi
-arch IRIX64 -n64 _o32 IRIX64_o32
-arch IRIX64  IRIX64
-arch HP-UX  HP-UX
-arch Linux Linux
-arch SX6 -abi _64_multi SX6_64_multi

The needed libraries are found in those directories, in order:

-$libpath if the -libpath key is specified
-$HOME/userlibs/$FULL_ABI
-$ARMNLIB/modeles/$modele/v_$version/lib/$FULL_ABI if the-modele key and/or the -version key is used
-$ARMNLIB/lib/$FULL_ABI

It it possible to extract all .o from a library in order to force the loading of those .o instead of anything that could be find in another library (useful to create patches). Just create a library with the extension .a.fl (fl stands for force load). For example, using

r.compile -src ... -libpath ici/lib -libappl patch full

will extract the library ici/lib/libpatch.a.fl in a temporary directory (equivalent to r.ar x libpatch.a.fl) and will force those .o to be loaded instead of whatever could be find in libfull.a.

"Include" files are found in:

-$ARMNLIB/include/$FULL_ABI

 Compilations options are read in

 $ARMNLIB/include/$FULL_ABI/Compiler_rules and one can add (or override defaults) personnal options in a file called Compiler_rules in the $HOME/userlibs/$FULL_ABI directory.

By default, the following keys have those values:

-arch : `uname -s` (return the operating system name)
-librmn: rmn (use librmn.a in the appropriate directory)
-libgraph: graph (use libgraph.a in the appropriate directory)
-version: current
-log: compile.log
-liste: compile.liste

 If the -o option is specified (creation of an executable), only existing and readable objects are passed to the compilers. In the case of an unexistant object, a warning will be printed and the compilation continues (this feature permits to use r.build with -obj path/to/objects/*.o even if "ls path/to/objects/*.o" return an exit code different than 0.

The script prints the compilation line generated. If an error occurs during compilation (exit status non-0) , an error message is printed.

This script uses cclargs, but the standard definition separator ":" is inactive. To specify more than one item for a key, the use of double-quote is recommended (for example -libappl "rpn_comm gem mc2 phy" instead of -libappl rpn_comm:gem:mc2:phy)

Selection of a specific cross-compiler

It is now possible to control the crosskit used for the SX6 by using environment variable SX6_OS_REL. (example: export SX6_OS_REL=12.1 before using r.compile will force the use of crosskit 12.1 for the SX6) Default is 12.1 for the SX6.

Examples (see also r.compile )

1. Linking of all objects of the current directory for the IBM, creating an executable called main.exe

r.build -obj *.o -arch AIX -o main.exe


2. Same than 1. for SX6 using librmn and MPI

r.build -obj *.o -arch SX6 -mpi -librmn -o a.out


3. Use of r.makebidon to allow a call to a subroutine called test or test1 (execution of the program with a.out -test or a.out -test1)

r.build -obj test.o  -bidon -main test test1 -o a.out

Author: Luc Corbeil (ARMN-SI) - Fev 15 2003