Physics 410: Computational Physics: Software Availability and Usage Hints


This document will be updated throughout the course

Index

General purpose system and programming software Numerical analysis software (see also Course Resources Page) Postscript viewer and plotting software Visualization and related software Scientific word-processing and related software General purpose graphics software and examples Miscellaneous (source code available in ~phys410/util and subdirs). Student requested software

Maple: One of the two major general-purpose "symbolic manipulation" packages (also general-purpose programming environments), and the one that we will study in this course (the other package is Mathematica).

On the lnx machines type

lnx1% xmaple
for the GUI version, or
lnx1% maple
for a terminal-based (text) session. In the latter instance you should see something like this.
lnx1 1> maple
    |\^/|     Maple 6 (IBM INTEL LINUX)
._|\|   |/|_. Copyright (c) 2000 by Waterloo Maple Inc.
 \  MAPLE  /  All rights reserved. Maple is a registered trademark of
 <____ ____>  Waterloo Maple Inc.
      |       Type ? for help.
> 
If there is any sequence of Maple commands that you find yourself typing at the beginning of each session (maple or xmaple) you can put them in a file .mapleinit in your home directory, whereafter they will automatically be executed each time you use Maple.


Fortran 77: A general purpose programming language which is particularly well-suited to numerical (scientific/engineering) applications. On the lnx machines, we will be using the Portland Group (PG) compiler, pgf77

Typical usage:

% pgf77 -g mypgm.f mysubs.f -o mypgm
See the on-line notes describing the use of Fortran and C in the Unix environment for additional information, as well as the Fortran 77 section of the Course Resources page.


Fortran 90: The successor to Fortran 77 which adds powerful capabilities for manipulating array-valued expressions, additional control structures, data structures, pointers, recursion etc.


C: Another general purpose programming language which is also widely-used for scientific and engineering applications. On the lnx machines, I recommend you use the PG compiler, pgcc Typical usage:

% pgcc -g mypgm.c myfcns.c -o mypgm
See the on-line notes describing the use of Fortran and C in the Unix environment for additional information.


libp410fa: Utility library for Fortran 77 programs. Available on the lnx machines. Sample driver for utility routines: p410fsa.f. See source code and course notes for further information.

Typical usage:

% pgf77 pgm.f -L/usr/local/PGI/lib -lp410f -o pgm


SLATEC: The SLATEC package is a large collection of Fortran-callable routines for performing a wide variety of tasks in scientific compuation including evaluation of special functions, solution of nonlinear equations, optimization, differentiation and integration, integral transforms etc.

The following documentation for the package is available:

Typical usage:

% cat tslatec.f
c===========================================================
c     Demonstrates sample use of SLATEC library to evaluate
c     a Bessel function and an Airy function.
c
c     % maple
c     > Digits := 16:
c     > evalf(BesselJ(0,1));
c       .7651976865579666
c     > evalf(AiryAi(1));
c       .1352924163128814
c===========================================================
      program   tslatec

      implicit  none

      real*8    dbesj0,  dai

c-----------------------------------------------------------
c     Compute and output Bessel function of first kind of 
c     order 0.
c-----------------------------------------------------------
      write(0,1000) dbesj0(1.0d0)
1000  format(' dbesj0(1.0d0) = ',1p,E24.16)
c-----------------------------------------------------------
c     Compute and output Airy function.
c-----------------------------------------------------------
      write(0,1100) dai(1.0d0)
1100  format(' dai(1.0d0)    = ',1p,E24.16)

      stop

      end

% pgf77 -g -L/usr/local/PGI/lib tslatec.f -lslatec -o tslatec

% tslatec
 dbesj0(1.0d0) =   7.6519768655796652E-01
 dai(1.0d0)    =   1.3529241631288143E-01


drand48: See Fortran notes, Lecture 4.


fftpack: A library of Fortran callable routines for performing single and double precision Fast Fourier Transforms (FFTs). Available on the lnx machines. Documentation for the double precision routines is available here.

Sample main program tfft.f and Makefile which uses some of the basic routines.


gv: Available on lnx machines as well as physics. Use for viewing Postscript documents. Largely considered an improved (more user friendly) version of the venerable ghostview.

Typical usage:

lnx1% gv somefile.ps
Note: Not all Postscript files will have .ps extensions, but many do by convention.


ghostview: Available on all machines. Use for viewing Postscript documents.

Typical usage:

lnx1% ghostview somefile.ps


gnuplot: X-application available on lnx machines and physics. Use for generating X-Y (2D) and some surface plots. Has extensive on-line documentation: type help at the gnuplot prompt for help.

Typical usage:

lnx1% gnuplot
			 .
			 .
			 .
Terminal type set to 'x11'
gnuplot> help
			 .
			 .
			 .
gnuplot> quit


sm: Supermongo plotting package. Available on all course machines. An alternative to gnuplot which is somewhat quirkier but generally produces more professional-looking (i.e. publication-quality) plots. See on-line postscript documentation and on-line help (type help at the the sm command prompt) for further details.

Note: If you are using KDE you should initialize the X11 device with

   : device x11 -bg black
and ignore the error message
   Unknown default colour #000000, using white
Typical usage:
lnx1% sm
Hello Matt, please give me a command
: device x11 -bg black
: help
			 .
			 .
			 .
: quit


xvs (visualization server): An Xforms/OpenGL-based visualization utility developed at UBC, based on previous work at UT Austin/Physics & Toronto/CITA. xvs is a powerful tool for analyzing, among other things, the output of time-dependent PDEs in one spatial dimension (or time dependent cuts of higher-d solutions).

As with other OpenGL applications, xvs is designed to take full advantage of the prodigious hardware of modern PC graphics cards, so must be used at the console of one of the lnx machines (or on any Linux machine with a decent graphics card to which you have access---talk to the instructor for installation help).

Usage information about xvs, though still under development, is available HERE.

PLEASE SEND ME E-MAIL IMMEDIATELY IF YOU HAVE PROBLEMS WITH THIS SOFTWARE.


xvs (API): A Fortran- and C-callable routine that was specifically designed for the output and subsequent visualization (typically via xvs, the visualization server) of data generated in the solution of time-dependent problems in one spatial dimension.

Information concerning this routine can be found HERE.

.sdf files generated via the xvs API can then be sent to the xvs visualization server using the sdftoxvs command, as discussed in more detail below.

Important: Note that .sdf files are not ``human-readable'', so please don't try to edit them or, worse, to print them!


sdftoxvs: Sends data in .sdf files to the xvs server. Here is the full usage for the command

% sdftoxvs
Synopsis:
  Sends .sdf files to the xvs visualization server
 
Usage:
  sdftoxvs [ -c ]
          [ -i ivec ]
          [ -n oname ]
          [ -x xfile ]
          input_file [ input_file [ ... ] ]
 
  -c       -- append coordinate name when naming
              function for output
  -i ivec  -- use ivec (1 based) for output control
  -n oname -- name all data sets oname
  -x xfile -- use y data from xfile for x coordinates
 
  input_file and xfile must be 1D .sdf files 

A typical invocation is

% ls 
wave.sdf

% sdftoxvs wave
Note that you do not have to specify the .sdf extension explicitly, but you can do so if you wish.

If we wanted to send only every second time step of wave.sdf to the server we could use
% sdftoxvs -i '1-*/2' wave
In this example, the construct
1-*/2
is an example of an index-vector (or ivec), which is just a shorthand for a regular sequence of integers:
min-max/step  ===>  min, min + step, min + 2 step, ... min + n step
where n is the largest integer such that
min + n step <= max
Index 1 refers to the first time level of data stored in the file, and an asterisk (*) can be used in place of min and/or max to denote "first time-level" or "last time-level" respectively. When using * in an index-vector specfication, such as in the above example, be sure to enclose the index-vector in single quotes to keep the shell from interpreting * in its own special way.

IMPORTANT NOTE: sdftoxvs needs to know on which machine xvs is running. Often this will be the same machine from which you are sending data, but it need not be so. Thus the utility requires that the environment variable XVSHOST be set to the name of the host which is running xvs. On the lnx machines, XVSHOST will be automatically set at shell start-up to the name of the local host, so normally, you won't have to worry about setting it explicitly. However, if you want to send data from some other machine, say lnx2.physics.ubc.ca, to xvs running on lnx1, for example, then on lnx2 you will need to issue:

   lnx2% setenv XVSHOST lnx1
before you transmit the data.


sdfinfo: Program which dumps summary information about an .sdf file to standard output.

Typical usage:

   % sdfinfo wave.sdf

   Data set 1
   name=<wave>
   version=1
   time=0
   rank=1
   shape=(10)
   bbox=(0,1)
   csize=10
   dsize=10
   cnames=(r)
   tag=<NULL>
   |data|=0.329628, min(data)=1.38879e-11, max(data)=0.734444
   Data set 2
   name=<wave>
   version=1
   time=0.111111
   rank=1
   shape=(10)
   bbox=(0,1)
   csize=10
   dsize=10
   cnames=(r)
      .
      .
      .
Key to output:

scivis (jser): A package for interactive & collaborative visualization developed at NPAC in Syracuse. Unfortunately, the on-line documentation previously available from the NPAC site no longer exists, so if you have any questions concerning the use of the software, contact the instructor.

For 1-d data, xvs is preferable to this application in most respects. jser does have the advantage that it is an X application which does not require the GLX extension, as does xvs.

Usage information about jser can be found HERE

PLEASE SEND ME E-MAIL IMMEDIATELY IF YOU HAVE PROBLEMS WITH THIS SOFTWARE.


libbbhutil.a: Fortran- and C-callable output utility routines written for the Binary Black Holes Grand Challenge Project. Available on lnx machines. Postscript ``man-style'' documentation for the C routines is available here. Fortran routines have the same names (gft_out_bbox etc.) and can be either calledor invoked as integer functions. For output of 2- and 3-D arrays on uniform finite-difference meshes, the routines

      gft_out_bbox
should suffice. Here is a usage example:
      integer      nx,        ny
      parameter  ( nx = 65,   ny = 33 )

      real*8       gfcn(nx,ny)
      real*8       xmin,      xmax,     ymin,     ymax, 
     &             time

      integer      shape(2),  rank
      real*8       bbox(4)
               .
               .
               .
c------------------------------------------------------
c     'bbox' defines 'bounding box' of coords.
c     associated with the data:
c
c     bbox := ( xmin, xmax, ymin, ymax )
c------------------------------------------------------
      bbox(1) = xmin
      bbox(2) = xmax
      bbox(3) = ymin
      bbox(4) = ymax

      rank = 2
      shape(1) = nx
      shape(2) = ny
 
      do it = 1 , nt
              .
              .
              .
c------------------------------------------------------
c     The first (string) arg. to 'gft_out_bbox'
c     is stripped of non alphanumeric/underscore 
c     characters (including punctuation) if necessary,
c     and then used as the 'stem' for a filename of 
c     the form 'stem.sdf'.  All calls to 'gft_out_bbox'
c     with the same string result in output to the 
c     same file.
c------------------------------------------------------
         time = it * 1.0d0
         call gft_out_bbox('gfcn',time,shape,rank,
     &                      bbox,gfcn)
      end do
              .
              .
              .

The gft_ routines use a machine-independent binary format. On the lnx1 machines, 2- and 3-D data is best visualized using IRIS Explorer. A locally developed module, called ReadSDF_GFT0, is available for Explorer input of data written using the gft_ routines. Here's an image of an Explorer map which uses this module.


IRIS Explorer: A powerful scientific visualization system available on the lnx machines. You need to be logged into a console to use the software.

Complete on-line documentation for the system is available via IRIS Explorer Center and Postscript versions of the User's Guide with graphics and without graphics.


pp2d: OpenGL/GLUT Graphics program for animating two dimensional particle motion. Available on the lnx machines.

Sample usage

   % nbody 2.0 0.01 < nbody_input | pp2d 
   % nbody 2.0 0.01 < nbody_input | pp2d -m
Help is available via
   % pp2d -h
The source code, pp2d.c, pp2d.h and Makefile, may be of interest to those of you interested in using OpenGL for graphics programming.

Sample 6-body input file input6. Use

   % pp2d < input6
to view.

pp3d: OpenGL/GLUT Graphics program for animating three dimensional particle motion. Available on the lnx machines.

Sample usage

   % nbody 2.0 0.01 < nbody_input | pp3d
   % nbody 2.0 0.01 < nbody_input | pp3d -m
Help is available via
   % pp3d -h
Again, the source code, pp3d.c, pp3d.h and Makefile may be of interest to those of you interested in using OpenGL for graphics programming.

Sample 20-body input file input20. Use

   % pp3d < input20
to view.

Warning: This application is still under development. Report any problems to Matt immediately.


xfpp3d: Version of pp3d which incorporates a GUI created using the XForms package.

Must be used via the console on the lnx machines.

Help is available via

   % xfpp3d -h 

Sample usage

   % nbody 2.0 0.01 < nbody_input | xfpp3d

Refer to the above link for the help message, which includes a description of the expected formats for input to the utility.

Documentation describing the creation of mpeg animations using this utility is available HERE

The following source code files may be of interest to those of you interested in using OpenGL and XForms for graphics programming:

Warning: This application is still under development. Report any problems to Matt immediately.


xflat2d: XForms-based GUI for visualization of two-dimensional, binary valued lattices.

Must be used via the console on the lnx machines.

This utility can be used to visualize the output of simulations of, e.g. the Game of Life, the 2-d Ising model, diffusion limited aggregation etc.

Help is available via

   % xflat2d -h
Refer to the above link for the help message, which includes a description of the expected format.

Documentation describing the creation of mpeg animations using this utility is available HERE

Sample usage

  % xflat2d < input


Warning: This application is still under development.  Report 
any problems to Matt immediately.




latex and tex: Available on all course machines. Scientific typesetting software. Converts .tex source files to .dvi files which can then be previewed using xdvi, or converted to postscript using dvips.

Typical usage:
   % ls 
   document.tex

   % latex document.tex
   This is TeX, Version 3.14159 (C version 6.1)
   (document.tex
   LaTeX2e <1996/06/01>
   Hyphenation patterns for english, german, loaded.
             .
             .
             .
   No file document.aux.
   [1] (document.aux) )
   Output written on document.dvi (1 page, 696 bytes).
   Transcript written on document.log.

   % ls
   document.aux   document.dvi   document.log   document.tex
You can easily include Encapsulated Postscript files in a TeX/LaTeX document, using the epsf package. Here is a sample tex source file, here is the figure file which is included, and here is the final postscript file.

Additional Information


xdvi: X-application for previewing .dvi files (output from Latex-ing or tex-ing of .tex files). You don't have to explicitly specify the .dvi extension.

Typical usage:

   % ls
   document.aux   document.dvi   document.log   document.tex

   % xdvi document


dvips: Utility for converting .dvi files to postscript.

Typical usage:

   % ls
   document.aux   document.dvi   document.log   document.tex

   % dvips document
   Got a new papersize
   This is dvips 5.58 Copyright 1986, 1994 Radical Eye Software
   ' TeX output 1997.01.22:1442' -> document.ps
   . [1] 

   % ls 
   document.aux   document.dvi   document.log   document.ps    document.tex


Open GL: A widely used software interface to graphics hardware, consisting of about 120 commands which are used to specify the objects and operations needed to produce interactive 2- and 3-dimensional applications.

This software is available on the lnx machines.

Available PS documentation:

GLUT: OpenGL Utility Toolkit Programming Interface. Facilitates construction of OpenGL programs which manipulate windows, handle user-initiated events etc.

Available PS documentation:

See pp2d below for sample application including a Makefile which can be modified for use on the lnx machines.

Note that the Makefile requires the following environment variables to be set as documented HERE.

CC
CCFLAGS
CCCFLAGS
CCLFLAGS
LIBGL
On the lnx machines, these variables should be set properly by default, for all users.


Open Inventor: An object-oriented toolkit (written in C++) that simplifies and abstracts the task of writing graphics programming into a set of easy to use objects.

This software is available on the lnx machines.

Available documentation: Under construction, in the meantime, start with man inventor.

Part of the Open Inventor environment is ivview, a fast interactive 3D viewer of Inventor files. The source code for this application, ivview.C and ivviewMenus.h may be of interest to those of you interested in using Open Inventor for graphics programming. Makefile for ivview. Sample Inventor File (ASCII format) engine.iv.

Note that the Makefile requires the followinng environment variables to be set as documented HERE.

CXX
CXXFLAGS
CXXCFLAGS
CXXLFLAGS
LIBINVENTOR
On the lnx machines, these variables should be set properly by default, for all users.


XForms: A software package consisting of

  1. A C-callable library, libforms.a
  2. A GUI, fdesign
which, together, facilitate the construction of other X- and OpenGL-based GUIs.

This software is available on the lnx machines.

Available PS documentation:

See xfpp3d above for sample application including a Makefile which can be modified for use on the lnx machines.