PVT User's Guide Appendix - Examples of Command Procedures

All PVT topics can be found under PHIGS Validation Tests - Overview. All sections of this User's Guide can be accessed from its list of sections or its detailed table of contents.

Below are two examples of a compile, link, and execute procedure for PVT programs. The first is for the VAX/VMS system, the second for UNIX. These are for illustrative purposes only.

 
        ----------------    VAX/VMS   ----------------
 
   Assume the PVT root node is [USER.PVT.V2].  In order to invoke the
following, the user types:
 
$ @PHF  P01    ! run P01, with PVT-defined error handling
    or
$ @PHFE P01    ! run P01, with implementor-defined error handling
 
 
PHF.COM:
$ ! Procedure to invoke DecPHIGS and access PVT libraries.
$ ! Value of variable 'errlib' is set to cause invocation
$ ! of user error handler
$ errlib :== "[user.pvt.v2]errlib/lib, "
$ psource = p1
$ @phfcom
 
 
PHFE.COM
$ ! Procedure to invoke DecPHIGS and access PVT libraries.
$ ! Value of variable 'errlib' is set to prevent invocation
$ ! of system default error handler
$ errlib :== " "
$ psource = p1
$ @phfcom
 
 
PHFCOM.COM
$ ! Procedure to invoke DecPHIGS and access PVT libraries.
$ ! Value of variable 'errlib' controls whether user error
$ ! handling is invoked.  Name of program is passed down
$ ! in variable 'psource'.
$ set nover
$ define sys$input sys$command
$ locsub = " "    ! this'll be string with names of local sublibs
$ curdir = f$directory()     ! name of current directory
$ dirlen = f$length(curdir)  ! length of current directory name
$ stdloc = f$locate(".V2", curdir) ! get root level
$ rootnam = "V2"
$ if (stdloc .lt. dirlen) then goto rootset
$ write sys$output "Cannot find V2 in current directory."
$ goto alldone
$ rootset:
$ numlev = (dirlen - stdloc - 4) / 3  ! number of levels of PVT
$ backup = 0
$ !
$ sub_loop:
$ if (backup .ge. numlev) then goto end_sub_loop
$ seekfile = "[" + f$extract(1,backup,"----------") + "]sublib"
$ gotfile  = f$search(seekfile + ".olb")  ! blank if no sublib at this level
$ if (gotfile .nes. "") then $ locsub = locsub + seekfile + "/lib,"
$ backup = backup + 1
$ goto sub_loop
$ !
$ end_sub_loop:
$ set ver
$ fort/warn=all/standard/float=ieee 'psource'
$ link 'psource','locsub' [user.pvt.'rootnam']trans_sublib/lib, -
   [user.pvt.'rootnam']sublib/lib, 'errlib' -
   sys$library:phigs$for_bnd/lib
$ run 'psource'
$ alldone:
 
 
 
         ----------------    UNIX   ----------------
 
   Assume the PVT root node is /home/user/pvt/v2.  In order to invoke the
following, the user types:
 
$ pvt p01   ! run p01, with PVT-defined error handling
    or
$ pvt p01 e ! run P01, with implementor-defined error handling
 
pvt:
#/usr/bin/csh
 
# This script:
#    Determines the language of the input file (FTN or C)
#    Compiles the source to object code
#    Searches up the directory tree looking for libraries (*.a).
#      Stops searching at a directory called "STD" or root.
#    Links the executable code with all libraries (*.a) found
#      from topdir down.
#    Executes the program.
#
# If any step fails, the script will exit before proceeding.
 
# Test searching of libraries by invoking with an argument
# of "hi".  See usage at bottom for usage instructions.
 
#  Set PRE_PHIGS_LIB to point to your Phigs libraries.  This is
#  the first library listed in the link command.
   set PRE_PHIGS_LIB = " "
 
#  set POST_PHIGS_LIB to your phigs library.  This is listed
#  LAST in the link command.
   set POST_PHIGS_LIB = " -L/usr/phigs-2.0/lib -lphigs77 -lphigs -lxgl -L/usr/openwin/lib -lX11 -lm"
 
if ( $#argv < 1 ) then
   echo "Found < 1 argument"
   goto usage
endif
 
if ( $#argv > 2 ) then
   echo "Found > 2 arguments"
   goto usage
endif
 
if ( $1 == "-v" ) then
    set echocmd = ""
    shift
endif
 
# USER CONFIGURATION VARIABLES
 
# Change libext if libraries have different extensions.
set PVTROOT = ' /home/user/pvt/v2'
set libext = 'sublib.a'
set trans_lib = "$PVTROOT/trans-sublib.a "
 
if ( $#argv < 2) then
   echo "Link to user-defined errlib"
   set global_lib = "$PVTROOT/sublib.a $PVTROOT/errlib.a "
else if ($2 == "e") then
   echo "No link to user-defined errlib"
   set global_lib = "$PVTROOT/sublib.a "
else
   echo "Invalid 2nd argument"
   goto alldone
endif
 
set libs = ""
 
if ( -r $1.f ) then         # Fortran source
# to make call to SECNDS compile correctly, add -lV77
    set CC="f77 -ansi -C -u -g " EXT=.f
else if ( -r $1.c ) then    # C source
    set CC=cc  EXT=.c
else if ( $1 != "hi" ) then
    # if ext. not known & not testing, exit.
    echo ${0}:  Could not read $1.f or \
         $1.c\!  Fix and try again.
    goto alldone
endif
 
if ( $1 != "hi" ) then
    if ( $?echocmd ) echo $CC -c $1$EXT
    $CC -c $1$EXT                   # compile to .o
    if ( $status != 0 ) then        # Bogus compilation?
        echo ${0}:  Fix compilation errors in \
             $1$EXT and try again.
        goto alldone
    endif
endif
 
if ( $?echocmd ) echo -n ${0}: Searching for library archives...
 
set curdir = `pwd`
while ( $curdir != "" )
    if ( $curdir:t == "v2" ) break       # just processed v2 dir?
    if ( -e  $curdir/$libext) then       # found some!
        set libs = ($libs `/bin/ls $curdir/$libext`)
    endif
    set curdir = $curdir:h               # leave head (chop tail)
end
if ( $?echocmd ) echo done.
 
if ( $1 == "hi" || $?echocmd ) then
    echo ${0}:  Libraries found:
    echo $libs
    goto alldone
endif
 
set exec_suffix = 'phigsx'   # distinguish executables
# link with libraries
if ( $?echocmd ) echo $CC $PRE_PHIGS_LIB $1.o \
                      $libs $trans_lib $global_lib $POST_PHIGS_LIB -o $1
$CC $PRE_PHIGS_LIB $1.o  \
    $libs $trans_lib $global_lib $POST_PHIGS_LIB -o $1.$exec_suffix
if ( $status == 0 ) then        # linked OK
    if ( $?echocmd ) echo ./$1
    ./$1.$exec_suffix           # execute
else
    echo ${0}:  Fix link errors and try again.
    goto alldone
endif
 
############
usage:
 
echo Usage:  $0 '[-v] file'
echo Note:  file has no extension, but file.f or file.c exists.
echo '-v' option will echo commands before they are executed.
goto alldone
 
############
 
alldone:
exit