From McGill University Physics Department Technical Services Wiki
Jump to: navigation, search

What is Yorick?

(From its web page): Yorick is an interpreted programming language for scientific simulations or calculations, postprocessing or steering large simulation codes, interactive scientific graphics, and reading, writing, or translating large files of numbers. Yorick includes an interactive graphics package, and a binary file package capable of translating to and from the raw numeric formats of all modern computers. Yorick is written in ANSI C and runs on most operating systems (*nix systems, Windows, MacOS). For a short overview, see the Linux Gazetteand Unix review articles.

Yorick has a compact syntax, similar to C, but with array operators. It is easily expandable through dynamic linking of C libraries, allows efficient manipulation of arbitrary size/dimension arrays, and offers extensive graphic capabilities.

  • http://yorick.sourceforge.net Yorick's homepage. This site contains documentation (manual and FAQ), examples and downloads for yorick. It also has a user forum for questions and discussions.

Yorick at McGill Physics

Since yorick is an interpretive language the source code of its librairies is easy to view. When inside yorick, typing "help,command" will usually give a short description of how the command works. Notice that at the bottom of this description is the line number and the name of the file that contains the definition of the function. Feel free to open that file and look at it in your favourite text editor. This is a good way to learn how to better program in yorick and also to learn tricks to make your programs run better.

Since yorick input has no command editting, you should run yorick under the rlwrap command (readline wrapper). This lets you use the up-arrow and down-arrow keys to recall old commands, edit them and re-execute them. A great time saver. (IE type "rlwrap yorick" at the command prompt.

Here is a short description of some McGill added routines. Looking directly at the files or including them and asking for their help, will give more information. The functions are organized into four directories (folders) according to usage. These are plot/, /fit/, math/ and labs/. Each list has the most useful files first followed by an alphabetic list of other potentially useful files.

Usage is: #include "fit/curfit.i" etc.

For use on your local yorick, download from http://www.ugrad.physics.mcgill.ca/resources/sutton/ug_mar_11_06.tgz. This is a gzipped tar file. The files it contains are meant to be placed in the contrib directory of the yorick installation. A zip file http://www.ugrad.physics.mcgill.ca/resources/sutton/ug_mar_11_06.zip is also available.


  plots.i      includes most common plotting stuff. (sd, lbl, numplots)
  sd.i         screen dump current window to printer
  lbl.i        label a graph (lbl,"top label","X label","Y label).
  multiplot.i  plot a matrix of plots in a window.
  addsys.i     Add new plot system to current window (good for insets etc).
  editstyle.i  Edit the many parameters controlling a plots appearance.
  box.i        draw a box.
  circle.i     draw a circle.
  dlabel.i     label a plot. Each call can be next line of the label
  mousez.i     extended mouse function
  numplots.i   make more than one plot in window (best to use multiplot.i)
  pleb.i       plot with error bars (see fit/fitplot.i).
  plh.i        plot histogram like lines.
  plpixel.i    plot labelled pixels of an image.
  pltstamp.i   put date and time on a plot.
  prfont.i     plot out characters in a font (ie. where is the angstrom?).
  underscore.i convert string to format for plt command.


  curfit.i     non-linear least squares fitting routine.
  curvefit.i   non-linear least squares fitting routine (old syntax).
  simplefit.i  annotated example of using curvefit.i (straight line)
  examplefit.i another annotated example of using curvefit.i using
               more features.
  fitplot.i    nicely plot a fit result.
  fitpeak.i    fit a peak.
  fitpoly.i    fit a straight line (more generally a polynomial).
  get_fwhm.i   estimate peak position and full width at half max (FWHM).

./fit/fns Fitting functions.

  polyfit.i    polynomial for fitpoly.
  erf.i        Error function.
  gauss2d.i    two dimensional Gaussian.
  lorentz.i    many Lorentzian peaks.
  lorentz1.i   one Lorentzian peak.
  voigt1.i     single Voigt peak (convolution of Gaussian and Lorentzian).
  voigt2.i     two Voigt peaks.


  prmat.i      neatly print a matrix.
  fresnel.i    Fresnel functions.
  kummer.i     Kummer functions.
  rotmat.i     calculate a  rotation matrix from Euler angles.
  vecmath.i    some vector functions. dot and cross products, normalize


  rdpca.i      Read PCA-II binary files (rdpca and rdmanypca).


Thursday October 20, 2005


Grab the tar ball from the website and open it up.

zeus:/tmp# wget ftp://ftp-icf.llnl.gov/pub/Yorick/yorick-1.6.02.tgz
zeus:/tmp# tar zxf yorick-1.6.02.tgz 
zeus:/tmp# cd yorick-1.6

Now at this point, things take a slight turn for the worse. The documentation is somewhat sparse regarding the meanings and interrelationships between various variables involved in building the software, and the default configuration is to build executables to be run from the directory in which it was built. Furthermore, there is no mention that changing the variables and building again after a make clean is not the same as performing a build from clean sources. That said, the following incantation worked for me (after a few iterations)

zeus:/tmp/yorick-1.6# make prefix=/usr/local Y_PLATFORM=i686 ysite
zeus:/tmp/yorick-1.6# make
zeus:/tmp/yorick-1.6# make install
zeus:/tmp# ln -s ../yorick/1.6/i686/bin/yorick /usr/local/bin

Porting Labmaster library as a plugin

Here care must be taken because Yorick is very rude, it assumes that you which to build a library with all files with the extension .c or .f, and presumes to be the only entity using the Makefile. To work around this abusive behaviour Yorick will be confined to a subdirectory of the real source code and the build processes controlled by the following script.

# @(#) ganesh:/mnt/gersemi/src/Labmaster/Lib/Yorick/make.sh Thursday October 20, 2005 (11:51)
# Mark Orchard-Webb
# Thursday October 20, 2005 (11:51)
# =================================
# This is a script to build the library as a Yorick plugin

rm *.{c,h,o,so}
cp ../{general,dac,adc,8255,9513}.{c,h} . \
&& yorick -batch make.i \
&& make \
&& make install

Tuesday January 24, 2006

Created install package.

ganesh:/mnt/nfsroot/packages/yorick# ls -lR
total 8
lrwxrwxrwx  1 root root   20 Jan 23 17:08 Makefile -> ../Makefile/Makefile
-rwxr-xr-x  1 root root  422 Jan 23 17:30 post-install.sh
drwxr-xr-x  3 root root 4096 Jan 23 17:08 root

total 4
drwxrwxrwt  2 root root 4096 Jan 23 17:28 tmp

total 2188
-rw-r--r--  1 root root 2234280 Jan 23 17:09 yorick-1.6.02.tgz

Compilation and install are done in post-install.sh:

# @(#) ganesh:/mnt/nfsroot/packages/yorick/post-install.sh Monday January 23, 2006 (17:10)
# Mark Orchard-Webb
# Monday January 23, 2006 (17:10)
# ===============================
cd /tmp \
&& rm -rf yorick-1.6

cd /tmp \
&& tar zxf yorick-1.6.02.tgz \
&& cd yorick-1.6 \
&& make prefix=/usr/local Y_PLATFORM=i686 ysite \
&& make \
&& make install \
&& ln -s ../yorick/1.6/i686/bin/yorick /usr/local/bin