A Library is a file with a special internal structure, it contains 
 a set of subunits and an index for these subunits, the subunits may 
 be text files, object modules etc.

 The librarian program (or its routines) can be used to create 
 a library, add, delete and list subunits in it. 

 A library can replace a large collection of files of the same type.
 Instead of using many source/object modules, you can insert them all 
 into a single library, that may save I/O operations and disk space. 

 Libraries of routines that perform most routine tasks, e.g. I/O
 operations, number conversions etc are routinely used by the linker 
 when it links user programs.

 You can use a text library to store your source code routines, and
 an object library to store the compiled version. You can include 
 routines from the text library in your programs, or link your
 programs against your object library (faster, recommended method).

 Basic syntax for object libraries commands is:

    VMS object library commands
    LIBRARY /OBJECT /CREATE  Library-name
    LIBRARY /OBJECT /LIST    Library-name
    LIBRARY /OBJECT /REPLACE Library-name Input-file
    LIBRARY /OBJECT /DELETE=Subunit-name  Library-name

    LINK Object-file, Library-name /LIBRARY

    UNIX librarian
    ar cv  Input-file   (to create a library)
    ar rv  Input-file   (to add/replace modules)
    f77 *.o libXXX.a    (to link)

 Do not use ld to link. this will usually involve a lot of platform 
 and release dependent work. 

 Run-time libraries/Shared libraries
 Ordinary linking includes all the linked code into the executable file. 
 It is absurd to have the routines that perform basic tasks like writing 
 to the screen included in every program of every user. 

 Run-Time linking allows you to use at run-time code that is located 
 outside your program, by putting directions for the image activator in 
 the executable file. The directions specify how to find the file that
 contains the auxiliary code, and how to access the code (or data) in it.

 Creating and calling VMS shared images
 To create a run-time/shared library from the object file 
 "SHRLIB.OBJ", you have to use a linker options file:

                   SUB2=PROCEDURE, -

 Your program is linked against the new library using a
 linker options file (assuming it's in the same directory):


 To run the new executable, you have to tell the image
 activator in which directory the shared image resides,
 you can either add the directory to SYS$SHARE logical: 


 or create a new logical:


 Now you can execute your program:

    $  RUN TEST

 Basic Linear Algebra Subroutines (BLAS)
 The BLAS are a vector/matrix oriented routine library distributed 
 by the Netlib organization. Highly optimized versions exists for 
 VMS (DXML), SunOS (Performance library),

 There are 3 sets of BLAS routines:

    Level 1   Vector-vector operations
    Level 2   Vector-matrix operations
    Level 3   Matrix-matrix operations

          A list of some level 1 BLAS: 

    IxAMAX(n, x, incx)
          Index of the first selected element of the array 
          argument which has the maximum absolute value.
    xASUM(n, x, incx)
          Sum of the absolute values of selected elements 
          of the array argument.
    xAXPY(n, a, x, incx, y, incy)
          Multiply an array by a scalar value and add an array.
    xCOPY(n, x, incx, y, incy)
          Copy selected elements of one array to another array.
    xDOTx(n, x, incx, y, incy)
          Inner product of two arrays, conjugated/unconjugated 
          values, depends on suffix (C/U)
    xNRM2(n, x, incx)
          Euclidean norm of a array.  
    xROT(n, x, incx, y, incy, c, s)
          Givens plane rotation to a pair of arrays/a real 
          rotation to a pair of complex arrays.
    xROTG(a, b, c, s)
          Generate the elements for a Givens plane rotation.
    xSCAL(n, a, x, incx)
          Scale the elements of an array by a scalar value.
    xSWAP(n, x, incx, y, incy)
          Swap elements between two arrays.

   Lowercase x in routine name is a  |  Argument list convention:
   data-type code:                   |  -------------------------
   ---------------                   |     n  Number of array elements
    I    Integer                     |     a  A scalar
    S    Single-precision            |     x  First array  (source)
    D    Double-precision            |     y  Second array (target)
    C    Single-precision complex    |  incx  x stride (step)
    Z    Double-precision complex    |  incy  y stride (step)


 Correct use of optimized routines 
 Optimized routined can degrade performance if used carelessly,

Return to contents page