PGPLOT is no longer necessary in SPLASH 2.0. This FAQ is kept for historical interest and as a resource for other people on the internet still using PGPLOT.
giza is a modern, drop-in replacement for PGPLOT I have written with a nearly feature-complete implementation of the PGPLOT API. It provides link-time compatible replacements for both libpgplot and libcpgplot. Download giza here. |
PGPLOT is a library of Fortran (77) routines for plotting applications. It can be downloaded from http://www.astro.caltech.edu/~tjp/pgplot/. The PGPLOT libraries were widely used in Astronomy in particular.
Mac OS/X: PGPLOT and gfortran (Fortran compiler) are available via Macports.
ld: Undefined symbols: _fprintf$LDBLStub _printf$LDBLStub _sprintf$LDBLStubsolution: add -lSystemStubs to the F90FLAGS= in the Makefile
%PGPLOT, Unable to read font file: grfont.dat %PGPLOT, Use environment variable PGPLOT_FONT to specify the location of the PGPLOT grfont.dat file. Graphics device/type (? to see list, default /NULL): /xw PGPLOT /xw: Couldn't find program "pgxwin_server" in the directory named PGPLOT /xw: in your PGPLOT_DIR environment variable, or in any directory PGPLOT /xw: listed in your PATH environment variable.
solution: Set the PGPLOT_DIR environment variable to the
install directory (e.g. /sw/lib/pgplot). This should solve both problems (although see below for
problems with the font file on 64 bit machines).
In tcsh this means something like
setenv PGPLOT_DIR /sw/lib/pgplotin bash this means
export PGPLOT_DIR='/sw/lib/pgplot'
Problems with PGPLOT fonts on 64-bit machines
solution: the PGPLOT font file (grfont.dat) is a binary file which by default comes pre-compiled as a 32-bit binary which may not be read properly in a 64-bit installation. The solution is to re-build the grfont.dat file using the compiler you have used to build PGPLOT by typing, in the PGPLOT directory:
rm grfont.dat make grfont.datassuming of course that you have the permissions to do so (try "sudo rm grfont.dat" and "sudo make grfont.dat").
Problems with PGPLOT fonts and runtime endian changing
solution: the PGPLOT font file (grfont.dat, see above question) is an unformatted binary file read when PGPLOT is first called. With gfortran-compiled PGPLOT (and SPLASH), changing the endian-ness in SPLASH (either with a compile time flag or using the GFORTRAN_CONVERT_UNIT environment variable) also affects the grfont.dat file, making it unreadable. One solution is to compile a grfont.dat file for each endian-ness, using the endian-changing flags for gfortran in the PGPLOT makefile (ie. add -fconvert=little-endian or -fconvert=big-endian to the flags in the PGPLOT makefile), then remake the grfont.dat file:
rm grfont.dat make grfont.dat
(see above problem also). Then make a copy (e.g. mv grfont.dat grfont.dat_little) and use the environment variable PGPLOT_FONT to point to this file instead of the default grfont.dat
setenv PGPLOT_FONT /mypgplotdir/pgplot/grfont.dat_littlewhenever you are trying to read in little-endian.
When selecting the option /xw the program complains that it can't find the "pgxwin_server" program in the directory specified in the PGPLOT_DIR environment variable.
solution: "pgxwin_server" is just a program which is run the first time you launch a PGPLOT X-window. So if you can find where it is (e.g. try "locate pgxwin_server"), then you can just launch it (ie. "cd whereveritis; ./pgxwin_server") before running splash, then the /xw plots will work. Better still, you don't even have to be running the pgxwin_server on the same machine as you are plotting on. For example, you can run a local version of pgxwin_server (e.g. from your own PGPLOT installation) which takes the place of a broken version running on a remote machine.
Everything compiles correctly, but when I try to run splash, I get an error like:
splash: error while loading shared libraries: libpgplot.so: cannot open shared object file: No such file or directory
solution: This means that the shared PGPLOT library file (libpgplot.so) cannot be found, most likely because the directory which contains it is not in the LD_LIBRARY_PATH. To fix this amend the LD_LIBRARY_PATH environment variable appropriately, ie. insert the following line into your .tcshrc file:
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/home/me/pgplot (or wherever you installed pgplot)
or the bash equivalent (in ~/.profile):
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/home/me/pgplot
Another possibility is that the shared libraries (ie. libpgplot.so) have not been compiled in your PGPLOT installation. The simplest solution in this case is to link to the static libraries instead (ie. libpgplot.a). In the Makefile the easiest way is to modify the SYSTEMFILE variable to include the static libraries, e.g.
SYSTEMFILE = system_unix.f90 /usr/local/lib/pgplot/libpgplot.a
or something similar. Note that for static linking you do not need the -lpgplot in the LDFLAGS.