#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
# CHANGES.TEXT
# DOCS/
# DOCS/README
# DOCS/www/
# DOCS/www/PLAT.html
# DOCS/www/Resumecurrent.ps
# DOCS/www/button.html
# DOCS/www/changes.html
# DOCS/www/checkpointer-interface.html
# DOCS/www/checkpointer-reference.html
# DOCS/www/checksprng.html
# DOCS/www/compilation.html
# DOCS/www/default-interface.html
# DOCS/www/default-reference.html
# DOCS/www/definitions.html
# DOCS/www/examples.html
# DOCS/www/examples/
# DOCS/www/examples/2streams_mpi.c
# DOCS/www/examples/2streamsf_mpi.F
# DOCS/www/examples/checkpoint-simple.c
# DOCS/www/examples/checkpoint.c
# DOCS/www/examples/checkpointf-simple.F
# DOCS/www/examples/checkpointf.F
# DOCS/www/examples/convert.c
# DOCS/www/examples/convertf.F
# DOCS/www/examples/description.html
# DOCS/www/examples/fsprng-simple_mpi.c
# DOCS/www/examples/fsprng_mpi.c
# DOCS/www/examples/fsprngf-simple_mpi.F
# DOCS/www/examples/fsprngf_mpi.F
# DOCS/www/examples/invalid_ID.c
# DOCS/www/examples/invalid_IDf.F
# DOCS/www/examples/message-simple_mpi.c
# DOCS/www/examples/message_mpi.c
# DOCS/www/examples/messagef-simple_mpi.F
# DOCS/www/examples/messagef_mpi.F
# DOCS/www/examples/myrandom.c
# DOCS/www/examples/pi-simple.c
# DOCS/www/examples/pi-simple_mpi.c
# DOCS/www/examples/pif-simple.F
# DOCS/www/examples/seed-simple.c
# DOCS/www/examples/seed-simple_mpi.c
# DOCS/www/examples/seed.c
# DOCS/www/examples/seed_mpi.c
# DOCS/www/examples/seedf-simple.F
# DOCS/www/examples/seedf-simple_mpi.F
# DOCS/www/examples/seedf.F
# DOCS/www/examples/seedf_mpi.F
# DOCS/www/examples/simple-simple.c
# DOCS/www/examples/simplef-simple.F
# DOCS/www/examples/spawn.c
# DOCS/www/examples/spawnf.F
# DOCS/www/examples/sprng-simple.c
# DOCS/www/examples/sprng-simple_mpi.C
# DOCS/www/examples/sprng-simple_mpi.c
# DOCS/www/examples/sprng.C
# DOCS/www/examples/sprng.c
# DOCS/www/examples/sprng_mpi.c
# DOCS/www/examples/sprngf-simple.F
# DOCS/www/examples/sprngf-simple_mpi.F
# DOCS/www/examples/sprngf.F
# DOCS/www/examples/sprngf_mpi.F
# DOCS/www/examples/subroutinef.F
# DOCS/www/frames.html
# DOCS/www/generators.html
# DOCS/www/images/
# DOCS/www/images/energy.ps
# DOCS/www/images/interleave.gif
# DOCS/www/images/msCv.ps
# DOCS/www/images/msE.ps
# DOCS/www/images/msbadCv.ps
# DOCS/www/images/msbadE.ps
# DOCS/www/images/parallel-tests.fig
# DOCS/www/images/parallel-tests.gif
# DOCS/www/images/serial-lcg.gif
# DOCS/www/images/serial-lcg.ppm
# DOCS/www/images/serial-lfg.gif
# DOCS/www/images/serial-lfg.ppm
# DOCS/www/images/specific-heat.ps
# DOCS/www/images/sum.eps
# DOCS/www/images/sum.fig
# DOCS/www/images/sum.gif
# DOCS/www/index.html
# DOCS/www/install.html
# DOCS/www/introduction.html
# DOCS/www/languages.html
# DOCS/www/macros.html
# DOCS/www/makefile.html
# DOCS/www/message-passing.html
# DOCS/www/newgen.html
# DOCS/www/next.gif
# DOCS/www/nextbw.gif
# DOCS/www/nextcol.gif
# DOCS/www/nextcol2.gif
# DOCS/www/nextcol3.gif
# DOCS/www/nextcol4.gif
# DOCS/www/paper/
# DOCS/www/paper/contents_motif.gif
# DOCS/www/paper/cross_ref_motif.gif
# DOCS/www/paper/foot_motif.gif
# DOCS/www/paper/images.aux
# DOCS/www/paper/images.log
# DOCS/www/paper/images.pl
# DOCS/www/paper/images.tex
# DOCS/www/paper/img1.gif
# DOCS/www/paper/img10.gif
# DOCS/www/paper/img11.gif
# DOCS/www/paper/img12.gif
# DOCS/www/paper/img13.gif
# DOCS/www/paper/img14.gif
# DOCS/www/paper/img15.gif
# DOCS/www/paper/img16.gif
# DOCS/www/paper/img17.gif
# DOCS/www/paper/img18.gif
# DOCS/www/paper/img19.gif
# DOCS/www/paper/img2.gif
# DOCS/www/paper/img20.gif
# DOCS/www/paper/img21.gif
# DOCS/www/paper/img22.gif
# DOCS/www/paper/img23.gif
# DOCS/www/paper/img24.gif
# DOCS/www/paper/img25.gif
# DOCS/www/paper/img26.gif
# DOCS/www/paper/img27.gif
# DOCS/www/paper/img28.gif
# DOCS/www/paper/img29.gif
# DOCS/www/paper/img3.gif
# DOCS/www/paper/img30.gif
# DOCS/www/paper/img31.gif
# DOCS/www/paper/img32.gif
# DOCS/www/paper/img33.gif
# DOCS/www/paper/img34.gif
# DOCS/www/paper/img35.gif
# DOCS/www/paper/img36.gif
# DOCS/www/paper/img37.gif
# DOCS/www/paper/img38.gif
# DOCS/www/paper/img39.gif
# DOCS/www/paper/img4.gif
# DOCS/www/paper/img40.gif
# DOCS/www/paper/img41.gif
# DOCS/www/paper/img42.gif
# DOCS/www/paper/img43.gif
# DOCS/www/paper/img44.gif
# DOCS/www/paper/img45.gif
# DOCS/www/paper/img46.gif
# DOCS/www/paper/img46.ppm
# DOCS/www/paper/img47.gif
# DOCS/www/paper/img48.gif
# DOCS/www/paper/img49.gif
# DOCS/www/paper/img49.ppm
# DOCS/www/paper/img5.gif
# DOCS/www/paper/img50.gif
# DOCS/www/paper/img51.gif
# DOCS/www/paper/img52.gif
# DOCS/www/paper/img53.gif
# DOCS/www/paper/img54.gif
# DOCS/www/paper/img55.gif
# DOCS/www/paper/img56.gif
# DOCS/www/paper/img57.gif
# DOCS/www/paper/img58.gif
# DOCS/www/paper/img59.gif
# DOCS/www/paper/img6.gif
# DOCS/www/paper/img60.gif
# DOCS/www/paper/img61.gif
# DOCS/www/paper/img62.gif
# DOCS/www/paper/img63.gif
# DOCS/www/paper/img64.gif
# DOCS/www/paper/img65.gif
# DOCS/www/paper/img66.gif
# DOCS/www/paper/img67.gif
# DOCS/www/paper/img68.gif
# DOCS/www/paper/img69.gif
# DOCS/www/paper/img7.gif
# DOCS/www/paper/img70.gif
# DOCS/www/paper/img71.gif
# DOCS/www/paper/img72.gif
# DOCS/www/paper/img73.gif
# DOCS/www/paper/img74.gif
# DOCS/www/paper/img75.gif
# DOCS/www/paper/img76.gif
# DOCS/www/paper/img77.gif
# DOCS/www/paper/img78.gif
# DOCS/www/paper/img79.gif
# DOCS/www/paper/img8.gif
# DOCS/www/paper/img80.gif
# DOCS/www/paper/img81.gif
# DOCS/www/paper/img81.ppm
# DOCS/www/paper/img82.gif
# DOCS/www/paper/img83.gif
# DOCS/www/paper/img84.gif
# DOCS/www/paper/img85.gif
# DOCS/www/paper/img86.gif
# DOCS/www/paper/img86.ppm
# DOCS/www/paper/img87.gif
# DOCS/www/paper/img9.gif
# DOCS/www/paper/index.html
# DOCS/www/paper/index_motif.gif
# DOCS/www/paper/internals.pl
# DOCS/www/paper/labels.pl
# DOCS/www/paper/next_group_motif.gif
# DOCS/www/paper/next_motif.gif
# DOCS/www/paper/node1.html
# DOCS/www/paper/node10.html
# DOCS/www/paper/node11.html
# DOCS/www/paper/node12.html
# DOCS/www/paper/node13.html
# DOCS/www/paper/node14.html
# DOCS/www/paper/node15.html
# DOCS/www/paper/node16.html
# DOCS/www/paper/node17.html
# DOCS/www/paper/node18.html
# DOCS/www/paper/node19.html
# DOCS/www/paper/node2.html
# DOCS/www/paper/node20.html
# DOCS/www/paper/node3.html
# DOCS/www/paper/node4.html
# DOCS/www/paper/node5.html
# DOCS/www/paper/node6.html
# DOCS/www/paper/node7.html
# DOCS/www/paper/node8.html
# DOCS/www/paper/node9.html
# DOCS/www/paper/paper.css
# DOCS/www/paper/paper.html
# DOCS/www/paper/previous_group_motif.gif
# DOCS/www/paper/previous_motif.gif
# DOCS/www/paper/rng.css
# DOCS/www/paper/up_motif.gif
# DOCS/www/parameters.html
# DOCS/www/physical-model-tests.html
# DOCS/www/platforms.html
# DOCS/www/qr.gif
# DOCS/www/qs.gif
# DOCS/www/quick-default.html
# DOCS/www/quick-reference.html
# DOCS/www/quick-simple.html
# DOCS/www/quick-start.html
# DOCS/www/ref.gif
# DOCS/www/reference.html
# DOCS/www/refs.html
# DOCS/www/simple-interface.html
# DOCS/www/simple-reference.html
# DOCS/www/sprng.html
# DOCS/www/statistical-tests.html
# DOCS/www/test-results.html
# DOCS/www/test-suite.html
# DOCS/www/tests.html
# DOCS/www/testsold.html
# DOCS/www/testwiz/
# DOCS/www/testwiz/CollisionsPanel.java
# DOCS/www/testwiz/CouponPanel.java
# DOCS/www/testwiz/DecParmField.java
# DOCS/www/testwiz/EquidistPanel.java
# DOCS/www/testwiz/GapPanel.java
# DOCS/www/testwiz/IntParmField.java
# DOCS/www/testwiz/LcgPanel.java
# DOCS/www/testwiz/LfgPanel.java
# DOCS/www/testwiz/MaxtPanel.java
# DOCS/www/testwiz/OutputFrame.java
# DOCS/www/testwiz/ParmField.java
# DOCS/www/testwiz/ParmGrpPanel.java
# DOCS/www/testwiz/PermPanel.java
# DOCS/www/testwiz/PokerPanel.java
# DOCS/www/testwiz/PrefDialog.java
# DOCS/www/testwiz/RunsPanel.java
# DOCS/www/testwiz/SerialPanel.java
# DOCS/www/testwiz/StartApplet.java
# DOCS/www/testwiz/SumPanel.java
# DOCS/www/testwiz/TestWizard.java
# DOCS/www/testwiz/cmrgPanel.java
# DOCS/www/testwiz/lcg64Panel.java
# DOCS/www/testwiz/pmlcgPanel.java
# DOCS/www/testwiz/stat_test.html
# DOCS/www/timesprng.html
# DOCS/www/toc.html
# DOCS/www/trouble-shooting.html
# DOCS/www/us.gif
# DOCS/www/usage.html
# DOCS/www/users-guide.html
# DOCS/www/workshop/
# DOCS/www/workshop/WorkshopThankYou.html
# DOCS/www/workshop/details-speakers.html
# DOCS/www/workshop/food.gif
# DOCS/www/workshop/food.html
# DOCS/www/workshop/index.html
# DOCS/www/workshop/registration.html
# DOCS/www/workshop/schedule.html
# DOCS/www/workshop/speakers.html
# DOCS/www/workshop/speakers_old.html
# DOCS/www/workshop/summary.html
# DOCS/www/workshop/topics.html
# EXAMPLES/
# EXAMPLES/2streams_mpi.c
# EXAMPLES/2streamsf_mpi.F
# EXAMPLES/Makefile
# EXAMPLES/README
# EXAMPLES/checkpoint-simple.c
# EXAMPLES/checkpoint.c
# EXAMPLES/checkpointf-simple.F
# EXAMPLES/checkpointf.F
# EXAMPLES/convert.c
# EXAMPLES/convertf.F
# EXAMPLES/displaybytes.c
# EXAMPLES/fsprng-simple_mpi.c
# EXAMPLES/fsprng_mpi.c
# EXAMPLES/fsprngf-simple_mpi.F
# EXAMPLES/fsprngf_mpi.F
# EXAMPLES/invalid_ID.c
# EXAMPLES/invalid_IDf.F
# EXAMPLES/make.test
# EXAMPLES/message-simple_mpi.c
# EXAMPLES/message_mpi.c
# EXAMPLES/messagef-simple_mpi.F
# EXAMPLES/messagef_mpi.F
# EXAMPLES/myrandom.c
# EXAMPLES/pi-simple.c
# EXAMPLES/pi-simple_mpi.c
# EXAMPLES/pif-simple.F
# EXAMPLES/seed-simple.c
# EXAMPLES/seed-simple_mpi.c
# EXAMPLES/seed.c
# EXAMPLES/seed_mpi.c
# EXAMPLES/seedf-simple.F
# EXAMPLES/seedf-simple_mpi.F
# EXAMPLES/seedf.F
# EXAMPLES/seedf_mpi.F
# EXAMPLES/simple-simple.c
# EXAMPLES/simplef-simple.F
# EXAMPLES/spawn.c
# EXAMPLES/spawnf.F
# EXAMPLES/sprng-simple.c
# EXAMPLES/sprng-simple_mpi.C
# EXAMPLES/sprng-simple_mpi.c
# EXAMPLES/sprng.C
# EXAMPLES/sprng.c
# EXAMPLES/sprng_mpi.c
# EXAMPLES/sprngf-simple.F
# EXAMPLES/sprngf-simple_mpi.F
# EXAMPLES/sprngf.F
# EXAMPLES/sprngf_mpi.F
# EXAMPLES/subroutinef.F
# Makefile
# README
# SRC/
# SRC/Makefile
# SRC/README
# SRC/check_gen.c
# SRC/check_gen_ptr.c
# SRC/check_gen_simple.c
# SRC/check_genf.F
# SRC/check_genf_ptr.F
# SRC/check_genf_simple.F
# SRC/checkid.c
# SRC/cmrg/
# SRC/cmrg/Makefile
# SRC/cmrg/cmrg.c
# SRC/cmrg/cmrg.data
# SRC/cmrg/primelist.h
# SRC/cmrg/primes.c
# SRC/cmrg/primes.h
# SRC/communicate.c
# SRC/cputime.c
# SRC/cputime.h
# SRC/drand.c
# SRC/fwrap.h
# SRC/fwrap_.h
# SRC/fwrap_mpi.c
# SRC/insertlib
# SRC/interface.h
# SRC/lcg/
# SRC/lcg/Makefile
# SRC/lcg/lcg.c
# SRC/lcg/lcg.data
# SRC/lcg/primelist.h
# SRC/lcg/primes.c
# SRC/lcg/primes.h
# SRC/lcg64/
# SRC/lcg64/Makefile
# SRC/lcg64/lcg64.c
# SRC/lcg64/lcg64.data
# SRC/lcg64/primelist.h
# SRC/lcg64/primes.c
# SRC/lcg64/primes.h
# SRC/lfg/
# SRC/lfg/Makefile
# SRC/lfg/lfg.c
# SRC/lfg/lfg.data
# SRC/make.CONVEX
# SRC/make.DEC
# SRC/make.GENERIC
# SRC/make.HP
# SRC/make.LINUX
# SRC/make.O2K
# SRC/make.SGI
# SRC/make.SOLARIS
# SRC/make.SP2
# SRC/make.SUN
# SRC/make.T3D
# SRC/make.T3E
# SRC/makeseed.c
# SRC/memory.c
# SRC/memory.h
# SRC/mlfg/
# SRC/mlfg/Makefile
# SRC/mlfg/int64.h
# SRC/mlfg/mlfg.c
# SRC/mlfg/mlfg.data
# SRC/multiply.h
# SRC/pmlcg/
# SRC/pmlcg/Makefile
# SRC/pmlcg/basic.h
# SRC/pmlcg/gmp.h
# SRC/pmlcg/info.h
# SRC/pmlcg/longlong.h
# SRC/pmlcg/pmlcg.c
# SRC/pmlcg/pmlcg.data
# SRC/simple.c
# SRC/simple_.h
# SRC/simple_mpi.c
# SRC/sprng.h
# SRC/sprng_f.h
# SRC/store.c
# SRC/store.h
# SRC/timing.c
# SRC/timingf.F
# TESTS/
# TESTS/Makefile
# TESTS/NEWGEN.TEXT
# TESTS/README
# TESTS/chisquare.c
# TESTS/collisions.c
# TESTS/communicate.c
# TESTS/coupon.c
# TESTS/equidist.c
# TESTS/fft.c
# TESTS/gap.c
# TESTS/init_tests.c
# TESTS/maxt.c
# TESTS/metropolis.c
# TESTS/mytest.c
# TESTS/perm.c
# TESTS/poker.c
# TESTS/random_walk.c
# TESTS/runs.c
# TESTS/serial.c
# TESTS/stirling.c
# TESTS/sum.c
# TESTS/tests.h
# TESTS/util.c
# TESTS/util.h
# TESTS/wolff.c
# VERSION
# include/
# include/interface.h
# include/sprng.h
# include/sprng_f.h
# lib/
# lib/Makefile
# make.CHOICES
# This archive created: Fri Jul 26 10:14:06 2002
export PATH; PATH=/bin:$PATH
if test -f 'CHANGES.TEXT'
then
echo shar: will not over-write existing file "'CHANGES.TEXT'"
else
cat << "SHAR_EOF" > 'CHANGES.TEXT'
Changes in Version 1.0
----------------------
Changes to version 0.5
1. Fortran stream_number in calls to init_sprng now starts from 0
instead of from 1. ****** VERY IMPORTANT ******
--------------
2. A parallel Multiplicative Lagged Fibonacci Generator (mlfg) has
been implemented.
3. Default parameter to init_sprng is called SPRNG_DEFAULT instead of DEFAULT.
4. Several functions inlined, to improve speed.
5. Directory 'include' contains the headers, and 'lib' the SPRNG libraries,
instead of using 'SRC' and '.' respectively. If you have untarred
SPRNG into a location where an old version is present, please remove
your old interface.h, sprng.h, and sprng_f.h files in SRC and either
make links to those in the 'include' directory, or copy them to SRC.
6. SRC/make.GENERIC helps in installation on new machines.
7. 'pack_sprng' now returns the state of a stream in a machine independent
format that can be unpacked with 'unpack_sprng' (except for pmlcg,
which still stores numbers in a machine dependent format). It may
be incompatible with data stored in the beta version's format.
8. lcg64 and cmrg use larger primes as addends. So the random number
sequences will now be different from those in Version 0.5.
Changes to Version 1.0 Beta
---------------------------
1. Fixed a memory leak bug in mlfg.
SHAR_EOF
fi # end of overwriting check
if test ! -d 'DOCS'
then
mkdir 'DOCS'
fi
cd 'DOCS'
if test -f 'README'
then
echo shar: will not over-write existing file "'README'"
else
cat << "SHAR_EOF" > 'README'
SPRNG provides both FORTRAN and C (also C++) interfaces for the use of
the parallel random number generator libraries.
Further documentation is available at the following URL:
http://www.ncsa.uiuc.edu/Apps/CMP/RNG/RNG-home.html
sprng.html.tar too contains similar documentation. Please execute:
zcat tar xvf sprng.html.tar.Z | tar xvof -
and read the file toc.html in the www directory with your web browser.
SHAR_EOF
fi # end of overwriting check
if test ! -d 'www'
then
mkdir 'www'
fi
cd 'www'
if test -f 'PLAT.html'
then
echo shar: will not over-write existing file "'PLAT.html'"
else
cat << "SHAR_EOF" > 'PLAT.html'
SPRNG: Scalable Parallel Pseudo-Random Number Generator Library
PLAT variable for make command
SPRNG libraries can be built by executing the following command:
make PLAT=platform
where platform depends on which SPRNG is to be installed. The specific command on the different
machines that SPRNG has been tested on are as follows:
SHAR_EOF
fi # end of overwriting check
if test -f 'Resumecurrent.ps'
then
echo shar: will not over-write existing file "'Resumecurrent.ps'"
else
cat << "SHAR_EOF" > 'Resumecurrent.ps'
%!PS-Adobe-3.0
%%BoundingBox: (atend)
%%Pages: (atend)
%%PageOrder: (atend)
%%DocumentFonts: (atend)
%%Creator: Frame 5.0
%%DocumentData: Clean7Bit
%%EndComments
%%BeginProlog
%
% Frame ps_prolog 5.0, for use with Frame 5.0 products
% This ps_prolog file is Copyright (c) 1986-1995 Frame Technology
% Corporation. All rights reserved. This ps_prolog file may be
% freely copied and distributed in conjunction with documents created
% using FrameMaker, FrameMaker/SGML and FrameViewer as long as this
% copyright notice is preserved.
%
% FrameMaker users specify the proper paper size for each print job in the
% "Print" dialog's "Printer Paper Size" "Width" and "Height~ fields. If the
% printer that the PS file is sent to does not support the requested paper
% size, or if there is no paper tray of the proper size currently installed,
% then the job will not be printed. The following flag, if set to true, will
% cause the job to print on the default paper in such cases.
/FMAllowPaperSizeMismatch false def
%
% Frame products normally print colors as their true color on a color printer
% or as shades of gray, based on luminance, on a black-and white printer. The
% following flag, if set to true, forces all non-white colors to print as pure
% black. This has no effect on bitmap images.
/FMPrintAllColorsAsBlack false def
%
% Frame products can either set their own line screens or use a printer's
% default settings. Three flags below control this separately for no
% separations, spot separations and process separations. If a flag
% is true, then the default printer settings will not be changed. If it is
% false, Frame products will use their own settings from a table based on
% the printer's resolution.
/FMUseDefaultNoSeparationScreen true def
/FMUseDefaultSpotSeparationScreen true def
/FMUseDefaultProcessSeparationScreen false def
%
% For any given PostScript printer resolution, Frame products have two sets of
% screen angles and frequencies for printing process separations, which are
% recomended by Adobe. The following variable chooses the higher frequencies
% when set to true or the lower frequencies when set to false. This is only
% effective if the appropriate FMUseDefault...SeparationScreen flag is false.
/FMUseHighFrequencyScreens true def
%
% The following is a set of predefined optimal frequencies and angles for various
% common dpi settings. This is taken from "Advances in Color Separation Using
% PostScript Software Technology," from Adobe Systems (3/13/89 P.N. LPS 0043)
% and corrolated with information which is in various PPD (4.0) files.
%
% The "dpiranges" figure is the minimum dots per inch device resolution which
% can support this setting. The "low" and "high" values are controlled by the
% setting of the FMUseHighFrequencyScreens flag above. The "TDot" flags control
% the use of the "Yellow Triple Dot" feature whereby the frequency id divided by
% three, but the dot function is "trippled" giving a block of 3x3 dots per cell.
%
% PatFreq is a compromise pattern frequency for ps Level 2 printers which is close
% to the ideal WYSIWYG pattern frequency of 9 repetitions/inch but does not beat
% (too badly) against the screen frequencies of any separations for that DPI.
/dpiranges [ 2540 2400 1693 1270 1200 635 600 0 ] def
/CMLowFreqs [ 100.402 94.8683 89.2289 100.402 94.8683 66.9349 63.2456 47.4342 ] def
/YLowFreqs [ 95.25 90.0 84.65 95.25 90.0 70.5556 66.6667 50.0 ] def
/KLowFreqs [ 89.8026 84.8528 79.8088 89.8026 84.8528 74.8355 70.7107 53.033 ] def
/CLowAngles [ 71.5651 71.5651 71.5651 71.5651 71.5651 71.5651 71.5651 71.5651 ] def
/MLowAngles [ 18.4349 18.4349 18.4349 18.4349 18.4349 18.4349 18.4349 18.4349 ] def
/YLowTDot [ true true false true true false false false ] def
/CMHighFreqs [ 133.87 126.491 133.843 108.503 102.523 100.402 94.8683 63.2456 ] def
/YHighFreqs [ 127.0 120.0 126.975 115.455 109.091 95.25 90.0 60.0 ] def
/KHighFreqs [ 119.737 113.137 119.713 128.289 121.218 89.8026 84.8528 63.6395 ] def
/CHighAngles [ 71.5651 71.5651 71.5651 70.0169 70.0169 71.5651 71.5651 71.5651 ] def
/MHighAngles [ 18.4349 18.4349 18.4349 19.9831 19.9831 18.4349 18.4349 18.4349 ] def
/YHighTDot [ false false true false false true true false ] def
/PatFreq [ 10.5833 10.0 9.4055 10.5833 10.0 10.5833 10.0 9.375 ] def
%
% PostScript Level 2 printers contain an "Accurate Screens" feature which can
% improve process separation rendering at the expense of compute time. This
% flag is ignored by PostScript Level 1 printers.
/FMUseAcccurateScreens true def
%
% The following PostScript procedure defines the spot function that Frame
% products will use for process separations. You may un-comment-out one of
% the alternative functions below, or use your own.
%
% Dot function
/FMSpotFunction {abs exch abs 2 copy add 1 gt
{1 sub dup mul exch 1 sub dup mul add 1 sub }
{dup mul exch dup mul add 1 exch sub }ifelse } def
%
% Line function
% /FMSpotFunction { pop } def
%
% Elipse function
% /FMSpotFunction { dup 5 mul 8 div mul exch dup mul exch add
% sqrt 1 exch sub } def
%
%
/FMversion (5.0) def
/fMLevel1 /languagelevel where {pop languagelevel} {1} ifelse 2 lt def
/FMPColor
fMLevel1 {
false
/colorimage where {pop pop true} if
} {
true
} ifelse
def
/FrameDict 400 dict def
systemdict /errordict known not {/errordict 10 dict def
errordict /rangecheck {stop} put} if
% The readline in PS 23.0 doesn't recognize cr's as nl's on AppleTalk
FrameDict /tmprangecheck errordict /rangecheck get put
errordict /rangecheck {FrameDict /bug true put} put
FrameDict /bug false put
mark
% Some PS machines read past the CR, so keep the following 3 lines together!
currentfile 5 string readline
00
0000000000
cleartomark
errordict /rangecheck FrameDict /tmprangecheck get put
FrameDict /bug get {
/readline {
/gstring exch def
/gfile exch def
/gindex 0 def
{
gfile read pop
dup 10 eq {exit} if
dup 13 eq {exit} if
gstring exch gindex exch put
/gindex gindex 1 add def
} loop
pop
gstring 0 gindex getinterval true
} bind def
} if
/FMshowpage /showpage load def
/FMquit /quit load def
/FMFAILURE {
dup = flush
FMshowpage
/Helvetica findfont 12 scalefont setfont
72 200 moveto show
72 220 moveto show
FMshowpage
FMquit
} def
/FMVERSION {
FMversion ne {
(Frame product version does not match ps_prolog! Check installation;)
(also check ~/fminit and ./fminit for old versions) FMFAILURE
} if
} def
/FMBADEPSF {
(Adobe's PostScript Language Reference Manual, 2nd Edition, section H.2.4)
(says your EPS file is not valid, as it calls X )
dup dup (X) search pop exch pop exch pop length
5 -1 roll
putinterval
FMFAILURE
} def
/fmConcatProcs
{
/proc2 exch cvlit def/proc1 exch cvlit def/newproc proc1 length proc2 length add array def
newproc 0 proc1 putinterval newproc proc1 length proc2 putinterval newproc cvx
}def
FrameDict begin [
/ALDsave
/FMdicttop
/FMoptop
/FMpointsize
/FMsaveobject
/b
/bitmapsave
/blut
/bpside
/bs
/bstring
/bwidth
/c
/cf
/cs
/cynu
/depth
/edown
/fh
/fillvals
/fw
/fx
/fy
/g
/gfile
/gindex
/grnt
/gryt
/gstring
/height
/hh
/i
/im
/indx
/is
/k
/kk
/landscape
/lb
/len
/llx
/lly
/m
/magu
/manualfeed
/n
/offbits
/onbits
/organgle
/orgbangle
/orgbfreq
/orgbproc
/orgbxfer
/orgfreq
/orggangle
/orggfreq
/orggproc
/orggxfer
/orgmatrix
/orgproc
/orgrangle
/orgrfreq
/orgrproc
/orgrxfer
/orgxfer
/pagesave
/paperheight
/papersizedict
/paperwidth
/pos
/pwid
/r
/rad
/redt
/sl
/str
/tran
/u
/urx
/ury
/val
/width
/width
/ws
/ww
/x
/x1
/x2
/xindex
/xpoint
/xscale
/xx
/y
/y1
/y2
/yelu
/yindex
/ypoint
/yscale
/yy
] { 0 def } forall
/FmBD {bind def} bind def
systemdict /pdfmark known {
/fMAcrobat true def
/FmPD /pdfmark load def
/FmPT /show load def
currentdistillerparams /CoreDistVersion get 2000 ge {
/FmPD2 /pdfmark load def
/FmPA { mark exch /Dest exch 5 3 roll
/View [ /XYZ null 6 -2 roll FmDC exch pop null] /DEST FmPD
}FmBD
} {
/FmPD2 /cleartomark load def
/FmPA {pop pop pop}FmBD
} ifelse
} {
/fMAcrobat false def
/FmPD /cleartomark load def
/FmPD2 /cleartomark load def
/FmPT /pop load def
/FmPA {pop pop pop}FmBD
} ifelse
/FmDC {
transform fMDefaultMatrix itransform cvi exch cvi exch
}FmBD
/FmBx {
dup 3 index lt {3 1 roll exch} if
1 index 4 index lt {4 -1 roll 3 1 roll exch 4 1 roll} if
}FmBD
/FMnone 0 def
/FMcyan 1 def
/FMmagenta 2 def
/FMyellow 3 def
/FMblack 4 def
/FMcustom 5 def
/fMNegative false def
/FrameSepIs FMnone def
/FrameSepBlack 0 def
/FrameSepYellow 0 def
/FrameSepMagenta 0 def
/FrameSepCyan 0 def
/FrameSepRed 1 def
/FrameSepGreen 1 def
/FrameSepBlue 1 def
/FrameCurGray 1 def
/FrameCurPat null def
/FrameCurColors [ 0 0 0 1 0 0 0 ] def
/FrameColorEpsilon .001 def
/eqepsilon {
sub dup 0 lt {neg} if
FrameColorEpsilon le
} bind def
/FrameCmpColorsCMYK {
2 copy 0 get exch 0 get eqepsilon {
2 copy 1 get exch 1 get eqepsilon {
2 copy 2 get exch 2 get eqepsilon {
3 get exch 3 get eqepsilon
} {pop pop false} ifelse
}{pop pop false} ifelse
} {pop pop false} ifelse
} bind def
/FrameCmpColorsRGB {
2 copy 4 get exch 0 get eqepsilon {
2 copy 5 get exch 1 get eqepsilon {
6 get exch 2 get eqepsilon
}{pop pop false} ifelse
} {pop pop false} ifelse
} bind def
/RGBtoCMYK {
1 exch sub
3 1 roll
1 exch sub
3 1 roll
1 exch sub
3 1 roll
3 copy
2 copy
le { pop } { exch pop } ifelse
2 copy
le { pop } { exch pop } ifelse
dup dup dup
6 1 roll
4 1 roll
7 1 roll
sub
6 1 roll
sub
5 1 roll
sub
4 1 roll
} bind def
/CMYKtoRGB {
dup dup 4 -1 roll add
5 1 roll 3 -1 roll add
4 1 roll add
1 exch sub dup 0 lt {pop 0} if 3 1 roll
1 exch sub dup 0 lt {pop 0} if exch
1 exch sub dup 0 lt {pop 0} if exch
} bind def
/FrameSepInit {
1.0 RealSetgray
} bind def
/FrameSetSepColor {
/FrameSepBlue exch def
/FrameSepGreen exch def
/FrameSepRed exch def
/FrameSepBlack exch def
/FrameSepYellow exch def
/FrameSepMagenta exch def
/FrameSepCyan exch def
/FrameSepIs FMcustom def
setCurrentScreen
} bind def
/FrameSetCyan {
/FrameSepBlue 1.0 def
/FrameSepGreen 1.0 def
/FrameSepRed 0.0 def
/FrameSepBlack 0.0 def
/FrameSepYellow 0.0 def
/FrameSepMagenta 0.0 def
/FrameSepCyan 1.0 def
/FrameSepIs FMcyan def
setCurrentScreen
} bind def
/FrameSetMagenta {
/FrameSepBlue 1.0 def
/FrameSepGreen 0.0 def
/FrameSepRed 1.0 def
/FrameSepBlack 0.0 def
/FrameSepYellow 0.0 def
/FrameSepMagenta 1.0 def
/FrameSepCyan 0.0 def
/FrameSepIs FMmagenta def
setCurrentScreen
} bind def
/FrameSetYellow {
/FrameSepBlue 0.0 def
/FrameSepGreen 1.0 def
/FrameSepRed 1.0 def
/FrameSepBlack 0.0 def
/FrameSepYellow 1.0 def
/FrameSepMagenta 0.0 def
/FrameSepCyan 0.0 def
/FrameSepIs FMyellow def
setCurrentScreen
} bind def
/FrameSetBlack {
/FrameSepBlue 0.0 def
/FrameSepGreen 0.0 def
/FrameSepRed 0.0 def
/FrameSepBlack 1.0 def
/FrameSepYellow 0.0 def
/FrameSepMagenta 0.0 def
/FrameSepCyan 0.0 def
/FrameSepIs FMblack def
setCurrentScreen
} bind def
/FrameNoSep {
/FrameSepIs FMnone def
setCurrentScreen
} bind def
/FrameSetSepColors {
FrameDict begin
[ exch 1 add 1 roll ]
/FrameSepColors
exch def end
} bind def
/FrameColorInSepListCMYK {
FrameSepColors {
exch dup 3 -1 roll
FrameCmpColorsCMYK
{ pop true exit } if
} forall
dup true ne {pop false} if
} bind def
/FrameColorInSepListRGB {
FrameSepColors {
exch dup 3 -1 roll
FrameCmpColorsRGB
{ pop true exit } if
} forall
dup true ne {pop false} if
} bind def
/RealSetgray /setgray load def
/RealSetrgbcolor /setrgbcolor load def
/RealSethsbcolor /sethsbcolor load def
end
/setgray {
FrameDict begin
FrameSepIs FMnone eq
{ RealSetgray }
{
FrameSepIs FMblack eq
{ RealSetgray }
{ FrameSepIs FMcustom eq
FrameSepRed 0 eq and
FrameSepGreen 0 eq and
FrameSepBlue 0 eq and {
RealSetgray
} {
1 RealSetgray pop
} ifelse
} ifelse
} ifelse
end
} bind def
/setrgbcolor {
FrameDict begin
FrameSepIs FMnone eq
{ RealSetrgbcolor }
{
3 copy [ 4 1 roll ]
FrameColorInSepListRGB
{
FrameSepBlue eq exch
FrameSepGreen eq and exch
FrameSepRed eq and
{ 0 } { 1 } ifelse
}
{
FMPColor {
RealSetrgbcolor
currentcmykcolor
} {
RGBtoCMYK
} ifelse
FrameSepIs FMblack eq
{1.0 exch sub 4 1 roll pop pop pop} {
FrameSepIs FMyellow eq
{pop 1.0 exch sub 3 1 roll pop pop} {
FrameSepIs FMmagenta eq
{pop pop 1.0 exch sub exch pop } {
FrameSepIs FMcyan eq
{pop pop pop 1.0 exch sub }
{pop pop pop pop 1} ifelse } ifelse } ifelse } ifelse
} ifelse
RealSetgray
}
ifelse
end
} bind def
/sethsbcolor {
FrameDict begin
FrameSepIs FMnone eq
{ RealSethsbcolor }
{
RealSethsbcolor
currentrgbcolor
setrgbcolor
}
ifelse
end
} bind def
FrameDict begin
/setcmykcolor where {
pop /RealSetcmykcolor /setcmykcolor load def
} {
/RealSetcmykcolor {
4 1 roll
3 { 3 index add 0 max 1 min 1 exch sub 3 1 roll} repeat
RealSetrgbcolor pop
} bind def
} ifelse
userdict /setcmykcolor {
FrameDict begin
FrameSepIs FMnone eq
{ RealSetcmykcolor }
{
4 copy [ 5 1 roll ]
FrameColorInSepListCMYK
{
FrameSepBlack eq exch
FrameSepYellow eq and exch
FrameSepMagenta eq and exch
FrameSepCyan eq and
{ 0 } { 1 } ifelse
}
{
FrameSepIs FMblack eq
{1.0 exch sub 4 1 roll pop pop pop} {
FrameSepIs FMyellow eq
{pop 1.0 exch sub 3 1 roll pop pop} {
FrameSepIs FMmagenta eq
{pop pop 1.0 exch sub exch pop } {
FrameSepIs FMcyan eq
{pop pop pop 1.0 exch sub }
{pop pop pop pop 1} ifelse } ifelse } ifelse } ifelse
} ifelse
RealSetgray
}
ifelse
end
} bind put
fMLevel1 {
/patScreenDict 7 dict dup begin
<0f1e3c78f0e1c387> [ 45 { pop } {exch pop} .5 2 sqrt] FmBD
<0f87c3e1f0783c1e> [ 135 { pop } {exch pop} .5 2 sqrt] FmBD
[ 0 { pop } dup .5 2 ] FmBD
[ 90 { pop } dup .5 2 ] FmBD
<8142241818244281> [ 45 { 2 copy lt {exch} if pop} dup .75 2 sqrt] FmBD
<03060c183060c081> [ 45 { pop } {exch pop} .875 2 sqrt] FmBD
<8040201008040201> [ 135 { pop } {exch pop} .875 2 sqrt] FmBD
end def
} {
/patProcDict 5 dict dup begin
<0f1e3c78f0e1c387> { 3 setlinewidth -1 -1 moveto 9 9 lineto stroke
4 -4 moveto 12 4 lineto stroke
-4 4 moveto 4 12 lineto stroke} bind def
<0f87c3e1f0783c1e> { 3 setlinewidth -1 9 moveto 9 -1 lineto stroke
-4 4 moveto 4 -4 lineto stroke
4 12 moveto 12 4 lineto stroke} bind def
<8142241818244281> { 1 setlinewidth -1 9 moveto 9 -1 lineto stroke
-1 -1 moveto 9 9 lineto stroke } bind def
<03060c183060c081> { 1 setlinewidth -1 -1 moveto 9 9 lineto stroke
4 -4 moveto 12 4 lineto stroke
-4 4 moveto 4 12 lineto stroke} bind def
<8040201008040201> { 1 setlinewidth -1 9 moveto 9 -1 lineto stroke
-4 4 moveto 4 -4 lineto stroke
4 12 moveto 12 4 lineto stroke} bind def
end def
/patDict 15 dict dup begin
/PatternType 1 def
/PaintType 2 def
/TilingType 3 def
/BBox [ 0 0 8 8 ] def
/XStep 8 def
/YStep 8 def
/PaintProc {
begin
patProcDict bstring known {
patProcDict bstring get exec
} {
8 8 true [1 0 0 -1 0 8] bstring imagemask
} ifelse
end
} bind def
end def
} ifelse
/combineColor {
FrameSepIs FMnone eq
{
graymode fMLevel1 or not {
[/Pattern [/DeviceCMYK]] setcolorspace
FrameCurColors 0 4 getinterval aload pop FrameCurPat setcolor
} {
FrameCurColors 3 get 1.0 ge {
FrameCurGray RealSetgray
} {
fMAcrobat not FMPColor graymode and and {
0 1 3 {
FrameCurColors exch get
1 FrameCurGray sub mul
} for
RealSetcmykcolor
} {
4 1 6 {
FrameCurColors exch get
graymode {
1 exch sub 1 FrameCurGray sub mul 1 exch sub
} {
1.0 lt {FrameCurGray} {1} ifelse
} ifelse
} for
RealSetrgbcolor
} ifelse
} ifelse
} ifelse
} {
FrameCurColors 0 4 getinterval aload
FrameColorInSepListCMYK {
FrameSepBlack eq exch
FrameSepYellow eq and exch
FrameSepMagenta eq and exch
FrameSepCyan eq and
FrameSepIs FMcustom eq and
{ FrameCurGray } { 1 } ifelse
} {
FrameSepIs FMblack eq
{FrameCurGray 1.0 exch sub mul 1.0 exch sub 4 1 roll pop pop pop} {
FrameSepIs FMyellow eq
{pop FrameCurGray 1.0 exch sub mul 1.0 exch sub 3 1 roll pop pop} {
FrameSepIs FMmagenta eq
{pop pop FrameCurGray 1.0 exch sub mul 1.0 exch sub exch pop } {
FrameSepIs FMcyan eq
{pop pop pop FrameCurGray 1.0 exch sub mul 1.0 exch sub }
{pop pop pop pop 1} ifelse } ifelse } ifelse } ifelse
} ifelse
graymode fMLevel1 or not {
[/Pattern [/DeviceGray]] setcolorspace
FrameCurPat setcolor
} {
graymode not fMLevel1 and {
dup 1 lt {pop FrameCurGray} if
} if
RealSetgray
} ifelse
} ifelse
} bind def
/savematrix {
orgmatrix currentmatrix pop
} bind def
/restorematrix {
orgmatrix setmatrix
} bind def
/fMDefaultMatrix matrix defaultmatrix def
/fMatrix2 matrix def
/dpi 72 0 fMDefaultMatrix dtransform
dup mul exch dup mul add sqrt def
/freq dpi dup 72 div round dup 0 eq {pop 1} if 8 mul div def
/sangle 1 0 fMDefaultMatrix dtransform exch atan def
sangle fMatrix2 rotate
fMDefaultMatrix fMatrix2 concatmatrix
dup 0 get /sflipx exch def
3 get /sflipy exch def
/screenIndex {
0 1 dpiranges length 1 sub { dup dpiranges exch get 1 sub dpi le {exit} {pop} ifelse } for
} bind def
/getCyanScreen {
FMUseHighFrequencyScreens { CHighAngles CMHighFreqs} {CLowAngles CMLowFreqs} ifelse
screenIndex dup 3 1 roll get 3 1 roll get /FMSpotFunction load
} bind def
/getMagentaScreen {
FMUseHighFrequencyScreens { MHighAngles CMHighFreqs } {MLowAngles CMLowFreqs} ifelse
screenIndex dup 3 1 roll get 3 1 roll get /FMSpotFunction load
} bind def
/getYellowScreen {
FMUseHighFrequencyScreens { YHighTDot YHighFreqs} { YLowTDot YLowFreqs } ifelse
screenIndex dup 3 1 roll get 3 1 roll get { 3 div
{2 { 1 add 2 div 3 mul dup floor sub 2 mul 1 sub exch} repeat
FMSpotFunction } } {/FMSpotFunction load } ifelse
0.0 exch
} bind def
/getBlackScreen {
FMUseHighFrequencyScreens { KHighFreqs } { KLowFreqs } ifelse
screenIndex get 45.0 /FMSpotFunction load
} bind def
/getSpotScreen {
getBlackScreen
} bind def
/getCompositeScreen {
getBlackScreen
} bind def
/FMSetScreen
fMLevel1 { /setscreen load
}{ {
8 dict begin
/HalftoneType 1 def
/SpotFunction exch def
/Angle exch def
/Frequency exch def
/AccurateScreens FMUseAcccurateScreens def
currentdict end sethalftone
} bind } ifelse
def
/setDefaultScreen {
FMPColor {
orgrxfer cvx orggxfer cvx orgbxfer cvx orgxfer cvx setcolortransfer
}
{
orgxfer cvx settransfer
} ifelse
orgfreq organgle orgproc cvx setscreen
} bind def
/setCurrentScreen {
FrameSepIs FMnone eq {
FMUseDefaultNoSeparationScreen {
setDefaultScreen
} {
getCompositeScreen FMSetScreen
} ifelse
} {
FrameSepIs FMcustom eq {
FMUseDefaultSpotSeparationScreen {
setDefaultScreen
} {
getSpotScreen FMSetScreen
} ifelse
} {
FMUseDefaultProcessSeparationScreen {
setDefaultScreen
} {
FrameSepIs FMcyan eq {
getCyanScreen FMSetScreen
} {
FrameSepIs FMmagenta eq {
getMagentaScreen FMSetScreen
} {
FrameSepIs FMyellow eq {
getYellowScreen FMSetScreen
} {
getBlackScreen FMSetScreen
} ifelse
} ifelse
} ifelse
} ifelse
} ifelse
} ifelse
} bind def
end
/FMDOCUMENT {
array /FMfonts exch def
/#copies exch def
FrameDict begin
0 ne /manualfeed exch def
/paperheight exch def
/paperwidth exch def
0 ne /fMNegative exch def
0 ne /edown exch def
/yscale exch def
/xscale exch def
fMLevel1 {
manualfeed {setmanualfeed} if
/FMdicttop countdictstack 1 add def
/FMoptop count def
setpapername
manualfeed {true} {papersize} ifelse
{manualpapersize} {false} ifelse
{desperatepapersize} {false} ifelse
{papersizefailure} if
count -1 FMoptop {pop pop} for
countdictstack -1 FMdicttop {pop end} for
}
{2 dict
dup /PageSize [paperwidth paperheight] put
manualfeed {dup /ManualFeed manualfeed put} if
{setpagedevice} stopped {papersizefailure} if
}
ifelse
FMPColor {
currentcolorscreen
cvlit /orgproc exch def
/organgle exch def
/orgfreq exch def
cvlit /orgbproc exch def
/orgbangle exch def
/orgbfreq exch def
cvlit /orggproc exch def
/orggangle exch def
/orggfreq exch def
cvlit /orgrproc exch def
/orgrangle exch def
/orgrfreq exch def
currentcolortransfer
fMNegative {
1 1 4 {
pop { 1 exch sub } fmConcatProcs 4 1 roll
} for
4 copy
setcolortransfer
} if
cvlit /orgxfer exch def
cvlit /orgbxfer exch def
cvlit /orggxfer exch def
cvlit /orgrxfer exch def
} {
currentscreen
cvlit /orgproc exch def
/organgle exch def
/orgfreq exch def
currenttransfer
fMNegative {
{ 1 exch sub } fmConcatProcs
dup settransfer
} if
cvlit /orgxfer exch def
} ifelse
end
} def
/FMBEGINPAGE {
FrameDict begin
/pagesave save def
3.86 setmiterlimit
/landscape exch 0 ne def
landscape {
90 rotate 0 exch dup /pwid exch def neg translate pop
}{
pop /pwid exch def
} ifelse
edown { [-1 0 0 1 pwid 0] concat } if
0 0 moveto paperwidth 0 lineto paperwidth paperheight lineto
0 paperheight lineto 0 0 lineto 1 setgray fill
xscale yscale scale
/orgmatrix matrix def
gsave
} def
/FMENDPAGE {
grestore
pagesave restore
end
showpage
} def
/FMFONTDEFINE {
FrameDict begin
findfont
ReEncode
1 index exch
definefont
FMfonts 3 1 roll
put
end
} def
/FMFILLS {
FrameDict begin dup
array /fillvals exch def
dict /patCache exch def
end
} def
/FMFILL {
FrameDict begin
fillvals 3 1 roll put
end
} def
/FMNORMALIZEGRAPHICS {
newpath
1 setlinewidth
0 setlinecap
0 0 0 sethsbcolor
0 setgray
} bind def
/FMBEGINEPSF {
end
/FMEPSF save def
/showpage {} def
% See Adobe's "PostScript Language Reference Manual, 2nd Edition", page 714.
% "...the following operators MUST NOT be used in an EPS file:" (emphasis ours)
/banddevice {(banddevice) FMBADEPSF} def
/clear {(clear) FMBADEPSF} def
/cleardictstack {(cleardictstack) FMBADEPSF} def
/copypage {(copypage) FMBADEPSF} def
/erasepage {(erasepage) FMBADEPSF} def
/exitserver {(exitserver) FMBADEPSF} def
/framedevice {(framedevice) FMBADEPSF} def
/grestoreall {(grestoreall) FMBADEPSF} def
/initclip {(initclip) FMBADEPSF} def
/initgraphics {(initgraphics) FMBADEPSF} def
/quit {(quit) FMBADEPSF} def
/renderbands {(renderbands) FMBADEPSF} def
/setglobal {(setglobal) FMBADEPSF} def
/setpagedevice {(setpagedevice) FMBADEPSF} def
/setshared {(setshared) FMBADEPSF} def
/startjob {(startjob) FMBADEPSF} def
/lettertray {(lettertray) FMBADEPSF} def
/letter {(letter) FMBADEPSF} def
/lettersmall {(lettersmall) FMBADEPSF} def
/11x17tray {(11x17tray) FMBADEPSF} def
/11x17 {(11x17) FMBADEPSF} def
/ledgertray {(ledgertray) FMBADEPSF} def
/ledger {(ledger) FMBADEPSF} def
/legaltray {(legaltray) FMBADEPSF} def
/legal {(legal) FMBADEPSF} def
/statementtray {(statementtray) FMBADEPSF} def
/statement {(statement) FMBADEPSF} def
/executivetray {(executivetray) FMBADEPSF} def
/executive {(executive) FMBADEPSF} def
/a3tray {(a3tray) FMBADEPSF} def
/a3 {(a3) FMBADEPSF} def
/a4tray {(a4tray) FMBADEPSF} def
/a4 {(a4) FMBADEPSF} def
/a4small {(a4small) FMBADEPSF} def
/b4tray {(b4tray) FMBADEPSF} def
/b4 {(b4) FMBADEPSF} def
/b5tray {(b5tray) FMBADEPSF} def
/b5 {(b5) FMBADEPSF} def
FMNORMALIZEGRAPHICS
[/fy /fx /fh /fw /ury /urx /lly /llx] {exch def} forall
fx fw 2 div add fy fh 2 div add translate
rotate
fw 2 div neg fh 2 div neg translate
fw urx llx sub div fh ury lly sub div scale
llx neg lly neg translate
/FMdicttop countdictstack 1 add def
/FMoptop count def
} bind def
/FMENDEPSF {
count -1 FMoptop {pop pop} for
countdictstack -1 FMdicttop {pop end} for
FMEPSF restore
FrameDict begin
} bind def
FrameDict begin
/setmanualfeed {
%%BeginFeature *ManualFeed True
statusdict /manualfeed true put
%%EndFeature
} bind def
/max {2 copy lt {exch} if pop} bind def
/min {2 copy gt {exch} if pop} bind def
/inch {72 mul} def
/pagedimen {
paperheight sub abs 16 lt exch
paperwidth sub abs 16 lt and
{/papername exch def} {pop} ifelse
} bind def
/setpapername {
/papersizedict 14 dict def
papersizedict begin
/papername /unknown def
/Letter 8.5 inch 11.0 inch pagedimen
/LetterSmall 7.68 inch 10.16 inch pagedimen
/Tabloid 11.0 inch 17.0 inch pagedimen
/Ledger 17.0 inch 11.0 inch pagedimen
/Legal 8.5 inch 14.0 inch pagedimen
/Statement 5.5 inch 8.5 inch pagedimen
/Executive 7.5 inch 10.0 inch pagedimen
/A3 11.69 inch 16.5 inch pagedimen
/A4 8.26 inch 11.69 inch pagedimen
/A4Small 7.47 inch 10.85 inch pagedimen
/B4 10.125 inch 14.33 inch pagedimen
/B5 7.16 inch 10.125 inch pagedimen
end
} bind def
/papersize {
papersizedict begin
/Letter {lettertray letter} def
/LetterSmall {lettertray lettersmall} def
/Tabloid {11x17tray 11x17} def
/Ledger {ledgertray ledger} def
/Legal {legaltray legal} def
/Statement {statementtray statement} def
/Executive {executivetray executive} def
/A3 {a3tray a3} def
/A4 {a4tray a4} def
/A4Small {a4tray a4small} def
/B4 {b4tray b4} def
/B5 {b5tray b5} def
/unknown {unknown} def
papersizedict dup papername known {papername} {/unknown} ifelse get
end
statusdict begin stopped end
} bind def
/manualpapersize {
papersizedict begin
/Letter {letter} def
/LetterSmall {lettersmall} def
/Tabloid {11x17} def
/Ledger {ledger} def
/Legal {legal} def
/Statement {statement} def
/Executive {executive} def
/A3 {a3} def
/A4 {a4} def
/A4Small {a4small} def
/B4 {b4} def
/B5 {b5} def
/unknown {unknown} def
papersizedict dup papername known {papername} {/unknown} ifelse get
end
stopped
} bind def
/desperatepapersize {
statusdict /setpageparams known
{
paperwidth paperheight 0 1
statusdict begin
{setpageparams} stopped
end
} {true} ifelse
} bind def
/papersizefailure {
FMAllowPaperSizeMismatch not
{
(The requested paper size is not available in any currently-installed tray)
(Edit the PS file to "FMAllowPaperSizeMismatch true" to use default tray)
FMFAILURE } if
} def
/DiacriticEncoding [
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /space /exclam /quotedbl
/numbersign /dollar /percent /ampersand /quotesingle /parenleft
/parenright /asterisk /plus /comma /hyphen /period /slash /zero /one
/two /three /four /five /six /seven /eight /nine /colon /semicolon
/less /equal /greater /question /at /A /B /C /D /E /F /G /H /I /J /K
/L /M /N /O /P /Q /R /S /T /U /V /W /X /Y /Z /bracketleft /backslash
/bracketright /asciicircum /underscore /grave /a /b /c /d /e /f /g /h
/i /j /k /l /m /n /o /p /q /r /s /t /u /v /w /x /y /z /braceleft /bar
/braceright /asciitilde /.notdef /Adieresis /Aring /Ccedilla /Eacute
/Ntilde /Odieresis /Udieresis /aacute /agrave /acircumflex /adieresis
/atilde /aring /ccedilla /eacute /egrave /ecircumflex /edieresis
/iacute /igrave /icircumflex /idieresis /ntilde /oacute /ograve
/ocircumflex /odieresis /otilde /uacute /ugrave /ucircumflex
/udieresis /dagger /.notdef /cent /sterling /section /bullet
/paragraph /germandbls /registered /copyright /trademark /acute
/dieresis /.notdef /AE /Oslash /.notdef /.notdef /.notdef /.notdef
/yen /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/ordfeminine /ordmasculine /.notdef /ae /oslash /questiondown
/exclamdown /logicalnot /.notdef /florin /.notdef /.notdef
/guillemotleft /guillemotright /ellipsis /.notdef /Agrave /Atilde
/Otilde /OE /oe /endash /emdash /quotedblleft /quotedblright
/quoteleft /quoteright /.notdef /.notdef /ydieresis /Ydieresis
/fraction /currency /guilsinglleft /guilsinglright /fi /fl /daggerdbl
/periodcentered /quotesinglbase /quotedblbase /perthousand
/Acircumflex /Ecircumflex /Aacute /Edieresis /Egrave /Iacute
/Icircumflex /Idieresis /Igrave /Oacute /Ocircumflex /.notdef /Ograve
/Uacute /Ucircumflex /Ugrave /dotlessi /circumflex /tilde /macron
/breve /dotaccent /ring /cedilla /hungarumlaut /ogonek /caron
] def
/ReEncode {
dup
length
dict begin
{
1 index /FID ne
{def}
{pop pop} ifelse
} forall
0 eq {/Encoding DiacriticEncoding def} if
currentdict
end
} bind def
FMPColor
{
/BEGINBITMAPCOLOR {
BITMAPCOLOR} def
/BEGINBITMAPCOLORc {
BITMAPCOLORc} def
/BEGINBITMAPTRUECOLOR {
BITMAPTRUECOLOR } def
/BEGINBITMAPTRUECOLORc {
BITMAPTRUECOLORc } def
/BEGINBITMAPCMYK {
BITMAPCMYK } def
/BEGINBITMAPCMYKc {
BITMAPCMYKc } def
}
{
/BEGINBITMAPCOLOR {
BITMAPGRAY} def
/BEGINBITMAPCOLORc {
BITMAPGRAYc} def
/BEGINBITMAPTRUECOLOR {
BITMAPTRUEGRAY } def
/BEGINBITMAPTRUECOLORc {
BITMAPTRUEGRAYc } def
/BEGINBITMAPCMYK {
BITMAPCMYKGRAY } def
/BEGINBITMAPCMYKc {
BITMAPCMYKGRAYc } def
}
ifelse
/K {
FMPrintAllColorsAsBlack {
dup 1 eq 2 index 1 eq and 3 index 1 eq and not
{7 {pop} repeat 0 0 0 1 0 0 0} if
} if
FrameCurColors astore
pop combineColor
} bind def
/graymode true def
fMLevel1 {
/fmGetFlip {
fMatrix2 exch get mul 0 lt { -1 } { 1 } ifelse
} FmBD
} if
/setPatternMode {
fMLevel1 {
2 index patScreenDict exch known {
pop pop
patScreenDict exch get aload pop
freq
mul
5 2 roll
fMatrix2 currentmatrix 1 get 0 ne {
3 -1 roll 90 add 3 1 roll
sflipx 1 fmGetFlip sflipy 2 fmGetFlip neg mul
} {
sflipx 0 fmGetFlip sflipy 3 fmGetFlip mul
} ifelse
0 lt {exch pop} {pop} ifelse
fMNegative {
{neg} fmConcatProcs
} if
bind
systemdict /setscreen get exec
/FrameCurGray exch def
} {
/bwidth exch def
/bpside exch def
/bstring exch def
/onbits 0 def /offbits 0 def
freq sangle landscape {90 add} if
{/ypoint exch def
/xpoint exch def
/xindex xpoint 1 add 2 div bpside mul cvi def
/yindex ypoint 1 add 2 div bpside mul cvi def
bstring yindex bwidth mul xindex 8 idiv add get
1 7 xindex 8 mod sub bitshift and 0 ne fMNegative {not} if
{/onbits onbits 1 add def 1}
{/offbits offbits 1 add def 0}
ifelse
}
setscreen
offbits offbits onbits add div fMNegative {1.0 exch sub} if
/FrameCurGray exch def
} ifelse
} {
pop pop
dup patCache exch known {
patCache exch get
} {
dup
patDict /bstring 3 -1 roll put
patDict
9 PatFreq screenIndex get div dup matrix scale
makepattern
dup
patCache 4 -1 roll 3 -1 roll put
} ifelse
/FrameCurGray 0 def
/FrameCurPat exch def
} ifelse
/graymode false def
combineColor
} bind def
/setGrayScaleMode {
graymode not {
/graymode true def
fMLevel1 {
setCurrentScreen
} if
} if
/FrameCurGray exch def
combineColor
} bind def
/normalize {
transform round exch round exch itransform
} bind def
/dnormalize {
dtransform round exch round exch idtransform
} bind def
/lnormalize {
0 dtransform exch cvi 2 idiv 2 mul 1 add exch idtransform pop
} bind def
/H {
lnormalize setlinewidth
} bind def
/Z {
setlinecap
} bind def
/PFill {
graymode fMLevel1 or not {
gsave 1 setgray eofill grestore
} if
} bind def
/PStroke {
graymode fMLevel1 or not {
gsave 1 setgray stroke grestore
} if
stroke
} bind def
/X {
fillvals exch get
dup type /stringtype eq
{8 1 setPatternMode}
{setGrayScaleMode}
ifelse
} bind def
/V {
PFill gsave eofill grestore
} bind def
/Vclip {
clip
} bind def
/Vstrk {
currentlinewidth exch setlinewidth PStroke setlinewidth
} bind def
/N {
PStroke
} bind def
/Nclip {
strokepath clip newpath
} bind def
/Nstrk {
currentlinewidth exch setlinewidth PStroke setlinewidth
} bind def
/M {newpath moveto} bind def
/E {lineto} bind def
/D {curveto} bind def
/O {closepath} bind def
/L {
/n exch def
newpath
normalize
moveto
2 1 n {pop normalize lineto} for
} bind def
/Y {
L
closepath
} bind def
/R {
/y2 exch def
/x2 exch def
/y1 exch def
/x1 exch def
x1 y1
x2 y1
x2 y2
x1 y2
4 Y
} bind def
/rarc
{rad
arcto
} bind def
/RR {
/rad exch def
normalize
/y2 exch def
/x2 exch def
normalize
/y1 exch def
/x1 exch def
mark
newpath
{
x1 y1 rad add moveto
x1 y2 x2 y2 rarc
x2 y2 x2 y1 rarc
x2 y1 x1 y1 rarc
x1 y1 x1 y2 rarc
closepath
} stopped {x1 y1 x2 y2 R} if
cleartomark
} bind def
/RRR {
/rad exch def
normalize /y4 exch def /x4 exch def
normalize /y3 exch def /x3 exch def
normalize /y2 exch def /x2 exch def
normalize /y1 exch def /x1 exch def
newpath
normalize moveto
mark
{
x2 y2 x3 y3 rarc
x3 y3 x4 y4 rarc
x4 y4 x1 y1 rarc
x1 y1 x2 y2 rarc
closepath
} stopped
{x1 y1 x2 y2 x3 y3 x4 y4 newpath moveto lineto lineto lineto closepath} if
cleartomark
} bind def
/C {
grestore
gsave
R
clip
setCurrentScreen
} bind def
/CP {
grestore
gsave
Y
clip
setCurrentScreen
} bind def
/F {
FMfonts exch get
FMpointsize scalefont
setfont
} bind def
/Q {
/FMpointsize exch def
F
} bind def
/T {
moveto show
} bind def
/RF {
rotate
0 ne {-1 1 scale} if
} bind def
/TF {
gsave
moveto
RF
show
grestore
} bind def
/P {
moveto
0 32 3 2 roll widthshow
} bind def
/PF {
gsave
moveto
RF
0 32 3 2 roll widthshow
grestore
} bind def
/S {
moveto
0 exch ashow
} bind def
/SF {
gsave
moveto
RF
0 exch ashow
grestore
} bind def
/B {
moveto
0 32 4 2 roll 0 exch awidthshow
} bind def
/BF {
gsave
moveto
RF
0 32 4 2 roll 0 exch awidthshow
grestore
} bind def
/G {
gsave
newpath
normalize translate 0.0 0.0 moveto
dnormalize scale
0.0 0.0 1.0 5 3 roll arc
closepath
PFill fill
grestore
} bind def
/Gstrk {
savematrix
newpath
2 index 2 div add exch 3 index 2 div sub exch
normalize 2 index 2 div sub exch 3 index 2 div add exch
translate
scale
0.0 0.0 1.0 5 3 roll arc
restorematrix
currentlinewidth exch setlinewidth PStroke setlinewidth
} bind def
/Gclip {
newpath
savematrix
normalize translate 0.0 0.0 moveto
dnormalize scale
0.0 0.0 1.0 5 3 roll arc
closepath
clip newpath
restorematrix
} bind def
/GG {
gsave
newpath
normalize translate 0.0 0.0 moveto
rotate
dnormalize scale
0.0 0.0 1.0 5 3 roll arc
closepath
PFill
fill
grestore
} bind def
/GGclip {
savematrix
newpath
normalize translate 0.0 0.0 moveto
rotate
dnormalize scale
0.0 0.0 1.0 5 3 roll arc
closepath
clip newpath
restorematrix
} bind def
/GGstrk {
savematrix
newpath
normalize translate 0.0 0.0 moveto
rotate
dnormalize scale
0.0 0.0 1.0 5 3 roll arc
closepath
restorematrix
currentlinewidth exch setlinewidth PStroke setlinewidth
} bind def
/A {
gsave
savematrix
newpath
2 index 2 div add exch 3 index 2 div sub exch
normalize 2 index 2 div sub exch 3 index 2 div add exch
translate
scale
0.0 0.0 1.0 5 3 roll arc
restorematrix
PStroke
grestore
} bind def
/Aclip {
newpath
savematrix
normalize translate 0.0 0.0 moveto
dnormalize scale
0.0 0.0 1.0 5 3 roll arc
closepath
strokepath clip newpath
restorematrix
} bind def
/Astrk {
Gstrk
} bind def
/AA {
gsave
savematrix
newpath
3 index 2 div add exch 4 index 2 div sub exch
normalize 3 index 2 div sub exch 4 index 2 div add exch
translate
rotate
scale
0.0 0.0 1.0 5 3 roll arc
restorematrix
PStroke
grestore
} bind def
/AAclip {
savematrix
newpath
normalize translate 0.0 0.0 moveto
rotate
dnormalize scale
0.0 0.0 1.0 5 3 roll arc
closepath
strokepath clip newpath
restorematrix
} bind def
/AAstrk {
GGstrk
} bind def
/BEGINPRINTCODE {
/FMdicttop countdictstack 1 add def
/FMoptop count 7 sub def
/FMsaveobject save def
userdict begin
/showpage {} def
FMNORMALIZEGRAPHICS
3 index neg 3 index neg translate
} bind def
/ENDPRINTCODE {
count -1 FMoptop {pop pop} for
countdictstack -1 FMdicttop {pop end} for
FMsaveobject restore
} bind def
/gn {
0
{ 46 mul
cf read pop
32 sub
dup 46 lt {exit} if
46 sub add
} loop
add
} bind def
/cfs {
/str sl string def
0 1 sl 1 sub {str exch val put} for
str def
} bind def
/ic [
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0223
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0223
0
{0 hx} {1 hx} {2 hx} {3 hx} {4 hx} {5 hx} {6 hx} {7 hx} {8 hx} {9 hx}
{10 hx} {11 hx} {12 hx} {13 hx} {14 hx} {15 hx} {16 hx} {17 hx} {18 hx}
{19 hx} {gn hx} {0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10} {11} {12}
{13} {14} {15} {16} {17} {18} {19} {gn} {0 wh} {1 wh} {2 wh} {3 wh}
{4 wh} {5 wh} {6 wh} {7 wh} {8 wh} {9 wh} {10 wh} {11 wh} {12 wh}
{13 wh} {14 wh} {gn wh} {0 bl} {1 bl} {2 bl} {3 bl} {4 bl} {5 bl} {6 bl}
{7 bl} {8 bl} {9 bl} {10 bl} {11 bl} {12 bl} {13 bl} {14 bl} {gn bl}
{0 fl} {1 fl} {2 fl} {3 fl} {4 fl} {5 fl} {6 fl} {7 fl} {8 fl} {9 fl}
{10 fl} {11 fl} {12 fl} {13 fl} {14 fl} {gn fl}
] def
/ms {
/sl exch def
/val 255 def
/ws cfs
/im cfs
/val 0 def
/bs cfs
/cs cfs
} bind def
400 ms
/ip {
is
0
cf cs readline pop
{ ic exch get exec
add
} forall
pop
} bind def
/rip {
bis ris copy pop
is
0
cf cs readline pop
{ ic exch get exec
add
} forall
pop pop
ris gis copy pop
dup is exch
cf cs readline pop
{ ic exch get exec
add
} forall
pop pop
gis bis copy pop
dup add is exch
cf cs readline pop
{ ic exch get exec
add
} forall
pop
} bind def
/rip4 {
kis cis copy pop
is
0
cf cs readline pop
{ ic exch get exec
add
} forall
pop pop
cis mis copy pop
dup is exch
cf cs readline pop
{ ic exch get exec
add
} forall
pop pop
mis yis copy pop
dup dup add is exch
cf cs readline pop
{ ic exch get exec
add
} forall
pop pop
yis kis copy pop
3 mul is exch
cf cs readline pop
{ ic exch get exec
add
} forall
pop
} bind def
/wh {
/len exch def
/pos exch def
ws 0 len getinterval im pos len getinterval copy pop
pos len
} bind def
/bl {
/len exch def
/pos exch def
bs 0 len getinterval im pos len getinterval copy pop
pos len
} bind def
/s1 1 string def
/fl {
/len exch def
/pos exch def
/val cf s1 readhexstring pop 0 get def
pos 1 pos len add 1 sub {im exch val put} for
pos len
} bind def
/hx {
3 copy getinterval
cf exch readhexstring pop pop
} bind def
/wbytes {
dup dup
8 gt { pop 8 idiv mul }
{ 8 eq {pop} {1 eq {7 add 8 idiv} {3 add 4 idiv} ifelse} ifelse } ifelse
} bind def
/BEGINBITMAPBWc {
1 {} COMMONBITMAPc
} bind def
/BEGINBITMAPGRAYc {
8 {} COMMONBITMAPc
} bind def
/BEGINBITMAP2BITc {
2 {} COMMONBITMAPc
} bind def
/COMMONBITMAPc {
/cvtProc exch def
/depth exch def
gsave
3 index 2 div add exch
4 index 2 div add exch
translate
rotate
1 index 2 div neg
1 index 2 div neg
translate
scale
/height exch def /width exch def
/lb width depth wbytes def
sl lb lt {lb ms} if
/bitmapsave save def
cvtProc
/is im 0 lb getinterval def
ws 0 lb getinterval is copy pop
/cf currentfile def
width height depth [width 0 0 height neg 0 height]
{ip} image
bitmapsave restore
grestore
} bind def
/BEGINBITMAPBW {
1 {} COMMONBITMAP
} bind def
/BEGINBITMAPGRAY {
8 {} COMMONBITMAP
} bind def
/BEGINBITMAP2BIT {
2 {} COMMONBITMAP
} bind def
/COMMONBITMAP {
/cvtProc exch def
/depth exch def
gsave
3 index 2 div add exch
4 index 2 div add exch
translate
rotate
1 index 2 div neg
1 index 2 div neg
translate
scale
/height exch def /width exch def
/bitmapsave save def
cvtProc
/is width depth wbytes string def
/cf currentfile def
width height depth [width 0 0 height neg 0 height]
{cf is readhexstring pop} image
bitmapsave restore
grestore
} bind def
/ngrayt 256 array def
/nredt 256 array def
/nbluet 256 array def
/ngreent 256 array def
fMLevel1 {
/colorsetup {
currentcolortransfer
/gryt exch def
/blut exch def
/grnt exch def
/redt exch def
0 1 255 {
/indx exch def
/cynu 1 red indx get 255 div sub def
/magu 1 green indx get 255 div sub def
/yelu 1 blue indx get 255 div sub def
/kk cynu magu min yelu min def
/u kk currentundercolorremoval exec def
% /u 0 def
nredt indx 1 0 cynu u sub max sub redt exec put
ngreent indx 1 0 magu u sub max sub grnt exec put
nbluet indx 1 0 yelu u sub max sub blut exec put
ngrayt indx 1 kk currentblackgeneration exec sub gryt exec put
} for
{255 mul cvi nredt exch get}
{255 mul cvi ngreent exch get}
{255 mul cvi nbluet exch get}
{255 mul cvi ngrayt exch get}
setcolortransfer
{pop 0} setundercolorremoval
{} setblackgeneration
} bind def
}
{
/colorSetup2 {
[ /Indexed /DeviceRGB 255
{dup red exch get 255 div
exch dup green exch get 255 div
exch blue exch get 255 div}
] setcolorspace
} bind def
} ifelse
/fakecolorsetup {
/tran 256 string def
0 1 255 {/indx exch def
tran indx
red indx get 77 mul
green indx get 151 mul
blue indx get 28 mul
add add 256 idiv put} for
currenttransfer
{255 mul cvi tran exch get 255.0 div}
exch fmConcatProcs settransfer
} bind def
/BITMAPCOLOR {
/depth 8 def
gsave
3 index 2 div add exch
4 index 2 div add exch
translate
rotate
1 index 2 div neg
1 index 2 div neg
translate
scale
/height exch def /width exch def
/bitmapsave save def
fMLevel1 {
colorsetup
/is width depth wbytes string def
/cf currentfile def
width height depth [width 0 0 height neg 0 height]
{cf is readhexstring pop} {is} {is} true 3 colorimage
} {
colorSetup2
/is width depth wbytes string def
/cf currentfile def
7 dict dup begin
/ImageType 1 def
/Width width def
/Height height def
/ImageMatrix [width 0 0 height neg 0 height] def
/DataSource {cf is readhexstring pop} bind def
/BitsPerComponent depth def
/Decode [0 255] def
end image
} ifelse
bitmapsave restore
grestore
} bind def
/BITMAPCOLORc {
/depth 8 def
gsave
3 index 2 div add exch
4 index 2 div add exch
translate
rotate
1 index 2 div neg
1 index 2 div neg
translate
scale
/height exch def /width exch def
/lb width depth wbytes def
sl lb lt {lb ms} if
/bitmapsave save def
fMLevel1 {
colorsetup
/is im 0 lb getinterval def
ws 0 lb getinterval is copy pop
/cf currentfile def
width height depth [width 0 0 height neg 0 height]
{ip} {is} {is} true 3 colorimage
} {
colorSetup2
/is im 0 lb getinterval def
ws 0 lb getinterval is copy pop
/cf currentfile def
7 dict dup begin
/ImageType 1 def
/Width width def
/Height height def
/ImageMatrix [width 0 0 height neg 0 height] def
/DataSource {ip} bind def
/BitsPerComponent depth def
/Decode [0 255] def
end image
} ifelse
bitmapsave restore
grestore
} bind def
/BITMAPTRUECOLORc {
/depth 24 def
gsave
3 index 2 div add exch
4 index 2 div add exch
translate
rotate
1 index 2 div neg
1 index 2 div neg
translate
scale
/height exch def /width exch def
/lb width depth wbytes def
sl lb lt {lb ms} if
/bitmapsave save def
/is im 0 lb getinterval def
/ris im 0 width getinterval def
/gis im width width getinterval def
/bis im width 2 mul width getinterval def
ws 0 lb getinterval is copy pop
/cf currentfile def
width height 8 [width 0 0 height neg 0 height]
{width rip pop ris} {gis} {bis} true 3 colorimage
bitmapsave restore
grestore
} bind def
/BITMAPCMYKc {
/depth 32 def
gsave
3 index 2 div add exch
4 index 2 div add exch
translate
rotate
1 index 2 div neg
1 index 2 div neg
translate
scale
/height exch def /width exch def
/lb width depth wbytes def
sl lb lt {lb ms} if
/bitmapsave save def
/is im 0 lb getinterval def
/cis im 0 width getinterval def
/mis im width width getinterval def
/yis im width 2 mul width getinterval def
/kis im width 3 mul width getinterval def
ws 0 lb getinterval is copy pop
/cf currentfile def
width height 8 [width 0 0 height neg 0 height]
{width rip4 pop cis} {mis} {yis} {kis} true 4 colorimage
bitmapsave restore
grestore
} bind def
/BITMAPTRUECOLOR {
gsave
3 index 2 div add exch
4 index 2 div add exch
translate
rotate
1 index 2 div neg
1 index 2 div neg
translate
scale
/height exch def /width exch def
/bitmapsave save def
/is width string def
/gis width string def
/bis width string def
/cf currentfile def
width height 8 [width 0 0 height neg 0 height]
{ cf is readhexstring pop }
{ cf gis readhexstring pop }
{ cf bis readhexstring pop }
true 3 colorimage
bitmapsave restore
grestore
} bind def
/BITMAPCMYK {
gsave
3 index 2 div add exch
4 index 2 div add exch
translate
rotate
1 index 2 div neg
1 index 2 div neg
translate
scale
/height exch def /width exch def
/bitmapsave save def
/is width string def
/mis width string def
/yis width string def
/kis width string def
/cf currentfile def
width height 8 [width 0 0 height neg 0 height]
{ cf is readhexstring pop }
{ cf mis readhexstring pop }
{ cf yis readhexstring pop }
{ cf kis readhexstring pop }
true 4 colorimage
bitmapsave restore
grestore
} bind def
/BITMAPTRUEGRAYc {
/depth 24 def
gsave
3 index 2 div add exch
4 index 2 div add exch
translate
rotate
1 index 2 div neg
1 index 2 div neg
translate
scale
/height exch def /width exch def
/lb width depth wbytes def
sl lb lt {lb ms} if
/bitmapsave save def
/is im 0 lb getinterval def
/ris im 0 width getinterval def
/gis im width width getinterval def
/bis im width 2 mul width getinterval def
ws 0 lb getinterval is copy pop
/cf currentfile def
width height 8 [width 0 0 height neg 0 height]
{width rip pop ris gis bis width gray} image
bitmapsave restore
grestore
} bind def
/BITMAPCMYKGRAYc {
/depth 32 def
gsave
3 index 2 div add exch
4 index 2 div add exch
translate
rotate
1 index 2 div neg
1 index 2 div neg
translate
scale
/height exch def /width exch def
/lb width depth wbytes def
sl lb lt {lb ms} if
/bitmapsave save def
/is im 0 lb getinterval def
/cis im 0 width getinterval def
/mis im width width getinterval def
/yis im width 2 mul width getinterval def
/kis im width 3 mul width getinterval def
ws 0 lb getinterval is copy pop
/cf currentfile def
width height 8 [width 0 0 height neg 0 height]
{width rip pop cis mis yis kis width cgray} image
bitmapsave restore
grestore
} bind def
/cgray {
/ww exch def
/k exch def
/y exch def
/m exch def
/c exch def
0 1 ww 1 sub { /i exch def c i get m i get y i get k i get CMYKtoRGB
.144 mul 3 1 roll .587 mul 3 1 roll .299 mul add add
c i 3 -1 roll floor cvi put } for
c
} bind def
/gray {
/ww exch def
/b exch def
/g exch def
/r exch def
0 1 ww 1 sub { /i exch def r i get .299 mul g i get .587 mul
b i get .114 mul add add r i 3 -1 roll floor cvi put } for
r
} bind def
/BITMAPTRUEGRAY {
gsave
3 index 2 div add exch
4 index 2 div add exch
translate
rotate
1 index 2 div neg
1 index 2 div neg
translate
scale
/height exch def /width exch def
/bitmapsave save def
/is width string def
/gis width string def
/bis width string def
/cf currentfile def
width height 8 [width 0 0 height neg 0 height]
{ cf is readhexstring pop
cf gis readhexstring pop
cf bis readhexstring pop width gray} image
bitmapsave restore
grestore
} bind def
/BITMAPCMYKGRAY {
gsave
3 index 2 div add exch
4 index 2 div add exch
translate
rotate
1 index 2 div neg
1 index 2 div neg
translate
scale
/height exch def /width exch def
/bitmapsave save def
/is width string def
/yis width string def
/mis width string def
/kis width string def
/cf currentfile def
width height 8 [width 0 0 height neg 0 height]
{ cf is readhexstring pop
cf mis readhexstring pop
cf yis readhexstring pop
cf kis readhexstring pop width cgray} image
bitmapsave restore
grestore
} bind def
/BITMAPGRAY {
8 {fakecolorsetup} COMMONBITMAP
} bind def
/BITMAPGRAYc {
8 {fakecolorsetup} COMMONBITMAPc
} bind def
/ENDBITMAP {
} bind def
end
/ALDmatrix matrix def ALDmatrix currentmatrix pop
/StartALD {
/ALDsave save def
savematrix
ALDmatrix setmatrix
} bind def
/InALD {
restorematrix
} bind def
/DoneALD {
ALDsave restore
} bind def
/I { setdash } bind def
/J { [] 0 setdash } bind def
%%EndProlog
%%BeginSetup
(5.0) FMVERSION
1 1 0 0 612 792 0 1 6 FMDOCUMENT
0 0 /Times-Bold FMFONTDEFINE
1 0 /Times-Roman FMFONTDEFINE
2 0 /Times-Italic FMFONTDEFINE
32 FMFILLS
0 0 FMFILL
1 0.1 FMFILL
2 0.3 FMFILL
3 0.5 FMFILL
4 0.7 FMFILL
5 0.9 FMFILL
6 0.97 FMFILL
7 1 FMFILL
8 <0f1e3c78f0e1c387> FMFILL
9 <0f87c3e1f0783c1e> FMFILL
10 FMFILL
11 FMFILL
12 <8142241818244281> FMFILL
13 <03060c183060c081> FMFILL
14 <8040201008040201> FMFILL
16 1 FMFILL
17 0.9 FMFILL
18 0.7 FMFILL
19 0.5 FMFILL
20 0.3 FMFILL
21 0.1 FMFILL
22 0.03 FMFILL
23 0 FMFILL
24 FMFILL
25 FMFILL
26 <3333333333333333> FMFILL
27 <0000ffff0000ffff> FMFILL
28 <7ebddbe7e7dbbd7e> FMFILL
29 FMFILL
30 <7fbfdfeff7fbfdfe> FMFILL
%%EndSetup
%%Page: "1" 1
%%BeginPaperSize: Letter
%%EndPaperSize
612 792 0 FMBEGINPAGE
[0 0 0 1 0 0 0]
[ 0 1 1 0 1 0 0]
[ 1 0 1 0 0 1 0]
[ 1 1 0 0 0 0 1]
[ 1 0 0 0 0 1 1]
[ 0 1 0 0 1 0 1]
[ 0 0 1 0 1 1 0]
7 FrameSetSepColors
FrameNoSep
0 0 0 1 0 0 0 K
J
0 0 0 1 0 0 0 K
0 0 0 1 0 0 0 K
0 0 0 1 0 0 0 K
0 0 0 1 0 0 0 K
0 0 0 1 0 0 0 K
18 738 540 774 R
7 X
0 0 0 1 0 0 0 K
V
0 16 Q
0 X
( W) 194.03 718.33 T
(illiam McMahon) 249.74 718.33 T
0 12 Q
(T) 90 677 T
(erm Addr) 96.9 677 T
(ess) 147.67 677 T
( Home Addr) 381 677 T
(ess) 483.78 677 T
1 F
(410 Memorial Dri) 90 663 T
(v) 177.02 663 T
(e 121 W) 182.84 663 T
(arwick Road) 447.54 663 T
(Cambridge, MA 02139) 90 649 T
-1.94 ( Haddon\336eld, NJ 08033) 336.66 649 P
2 F
(billmc@mit.edu) 90 635 T
0 11 Q
(OBJECTIVE) 53.43 595.67 T
1 F
(Emplo) 126 595.67 T
(yment in computer aspects of ph) 155.23 595.67 T
(ysics research.) 298.46 595.67 T
0 F
(EDUCA) 50.82 570.67 T
(TION) 88.88 570.67 T
(Massachusetts Institute of T) 126 570.67 T
(echnology) 257.29 570.67 T
1 F
(Cambridge, MA) 467.89 570.67 T
0.8 (Candidate for Bachelor of Science de) 126 557.67 P
0.8 (grees in Ph) 294.49 557.67 P
0.8 (ysics and Electrical Engineering/Computer) 348.48 557.67 P
0.99 (Science, June 1997.Classes include Mechanics 1 and 2, Electricity and Magnetism 1 and 2,) 126 544.67 P
-0.24 (Introduction to Solid State Chemistry) 126 531.67 P
-0.24 (, V) 289.33 531.67 P
-0.24 (ibrations and W) 301.87 531.67 P
-0.24 (a) 370.78 531.67 P
-0.24 (v) 375.44 531.67 P
-0.24 (es, Quantum Ph) 380.78 531.67 P
-0.24 (ysics 1 and 2, Statis-) 450.21 531.67 P
-0.26 (tical Ph) 126 518.67 P
-0.26 (ysics, Circuits and Electronics, Signals and Systems, Softw) 158.99 518.67 P
-0.26 (are Engineering Lab, Junior) 417.98 518.67 P
(Ph) 126 505.67 T
(ysics Lab, Introduction to Design, Japanese 1, 2 , 3, 4.) 137.56 505.67 T
0 F
(Haddon\336eld Memorial High School) 126 486.67 T
1 F
(Haddon\336eld, NJ) 467.89 486.67 T
0.31 (Graduated in top 3% of class, G.P) 126 473.67 P
0.31 (.A. 97%. Acti) 276.31 473.67 P
0.31 (vities included: School debate team \050captain\051,) 337.45 473.67 P
(Academic Challenge team, International Club, V) 126 460.67 T
(arsity T) 340.16 460.67 T
(ennis, Cross Country and T) 373.3 460.67 T
(rack.) 493.61 460.67 T
0 F
(EXPERIENCE) 44.88 435.67 T
(NTT Data Communications Systems, Inc.) 126 435.67 T
1 F
(Ka) 471.24 435.67 T
(w) 483.9 435.67 T
(aski, Japan) 491.73 435.67 T
0.14 (Summer 1996) 126 422.67 P
0 F
0.14 (.) 188.17 422.67 P
1 F
0.14 (P) 193.82 422.67 P
0.14 (art of MIT Japan Program. Designed and coded an interacti) 199.77 422.67 P
0.14 (v) 462.28 422.67 P
0.14 (e application for) 467.62 422.67 P
1.75 (the visualization of English historical data via 3D graphics on an SGI Indigo w) 126 409.67 P
1.75 (orkstation) 496 409.67 P
(using C++ and Open In) 126 396.67 T
(v) 229.01 396.67 T
(entor) 234.35 396.67 T
(.) 256.35 396.67 T
0 F
(MIT Center f) 126 370.67 T
(or Space Resear) 189.26 370.67 T
(ch \050CSR\051) 264.82 370.67 T
1 F
( Cambridge, MA) 316.15 370.67 T
1.16 (Summer 1995. P) 126 357.67 P
1.16 (art of Under) 201.8 357.67 P
1.16 (graduate Research Opportunities Program \050UR) 257.68 357.67 P
1.16 (OP\051. De) 468.4 357.67 P
1.16 (v) 505.34 357.67 P
1.16 (eloped) 510.67 357.67 P
0.76 (softw) 126 344.67 P
0.76 (are for con) 150.33 344.67 P
0.76 (v) 199.05 344.67 P
0.76 (erting data from the ASCII standard to N) 204.38 344.67 P
0.76 (ASA) 389.85 344.67 P
0.76 (\325) 410.63 344.67 P
0.76 (s FITS standard using the C) 413.69 344.67 P
1.35 (Programming language and N) 126 331.67 P
1.35 (ASA) 261.94 331.67 P
1.35 (\325) 282.71 331.67 P
1.35 (s FITSIO routines. Data to be recei) 285.77 331.67 P
1.35 (v) 447.84 331.67 P
1.35 (ed from the X-Ray) 453.18 331.67 P
0.26 (T) 126 318.67 P
0.26 (iming Explorer \050XTE\051 satellite., launched at the end of the summer of \32495. Created data for) 132.34 318.67 P
(image normalizing function.) 126 305.67 T
0 F
(Department of Na) 126 286.67 T
(vy) 210.65 286.67 T
1 F
(Philadelphia, P) 466.45 286.67 T
(A) 532.06 286.67 T
0.09 (Summer 1993. Science and Engineering Apprenticeship Program \050SEAP\051. Aided in establish-) 126 273.67 P
0.15 (ing and troubleshooting computer netw) 126 260.67 P
0.15 (ork on na) 299.43 260.67 P
0.15 (v) 341.06 260.67 P
0.15 (al base. W) 346.28 260.67 P
0.15 (ork included installation of cable,) 391.83 260.67 P
(netw) 126 247.67 T
(ork cards, and softw) 147.27 247.67 T
(are.) 236.36 247.67 T
0 F
(Other Experiences) 126 228.67 T
1 F
0.35 (Re) 126 215.67 P
0.35 (gular maintenance and cleaning of doctor\325) 138.06 215.67 P
0.35 (s of) 325.23 215.67 P
0.35 (\336ce, painting, construction of patio. Member) 341.5 215.67 P
(of MIT Solar Electric V) 126 202.67 T
(ehicle T) 230.48 202.67 T
(eam, Franklin Institute Student Academy) 265.45 202.67 T
(.) 445.91 202.67 T
0 F
(PR) 29.93 177.67 T
(OFICIENCIES) 44.27 177.67 T
1 F
0.47 (Languages: English, Japanese Computer skills: Programming in C, C++, FOR) 126 177.67 P
0.47 (TRAN, UNIX,) 473.85 177.67 P
1.86 (B) 126 164.67 P
1.86 (ASIC, HTML, SCHEME \050dialect of LISP\051, CLU, Open In) 132.95 164.67 P
1.86 (v) 404.61 164.67 P
1.86 (entor pro\336cienc) 409.95 164.67 P
1.86 (y with DOS,) 480.98 164.67 P
4.11 (W) 126 151.67 P
4.11 (indo) 135.94 151.67 P
4.11 (ws, X W) 155.23 151.67 P
4.11 (indo) 201.8 151.67 P
4.11 (ws, W) 221.09 151.67 P
4.11 (ordPerfect, Lotus 123, AutoCAD, ProEngineer) 252.42 151.67 P
4.11 (, Emacs, EZ,) 475.26 151.67 P
(FrameMak) 126 138.67 T
(er) 174.16 138.67 T
(. .) 182.1 138.67 T
1.38 (A) 126 119.67 P
1.38 (w) 132.93 119.67 P
1.38 (ards/Honors: National Merit Scholarship Finalist, Eagle Scout, Co) 140.76 119.67 P
1.38 (v) 442.08 119.67 P
1.38 (enant Bank Scholar-) 447.42 119.67 P
(ship, J. Fithian T) 126 106.67 T
(atem Memorial Scholarship, National Honor Society) 199.38 106.67 T
(.) 430.86 106.67 T
0 F
(B) 37.6 81.67 T
(A) 44.61 81.67 T
(CKGR) 51.95 81.67 T
(OUND) 84.62 81.67 T
1 F
(Raised in Haddon\336eld, NJ in f) 126 81.67 T
(amily of 8.) 259.72 81.67 T
(Acti) 126 68.67 T
(vities/hobbies: tennis, track, bask) 144.67 68.67 T
(etball, v) 290.91 68.67 T
(olle) 326.13 68.67 T
(yball, computers, ph) 342.47 68.67 T
(ysics, piano, reading.) 432.24 68.67 T
FMENDPAGE
%%EndPage: "1" 1
%%Trailer
%%BoundingBox: 0 0 612 792
%%PageOrder: Ascend
%%Pages: 1
%%DocumentFonts: Times-Bold
%%+ Times-Roman
%%+ Times-Italic
%%EOF
SHAR_EOF
fi # end of overwriting check
if test -f 'button.html'
then
echo shar: will not over-write existing file "'button.html'"
else
cat << "SHAR_EOF" > 'button.html'
Button
SHAR_EOF
fi # end of overwriting check
if test -f 'changes.html'
then
echo shar: will not over-write existing file "'changes.html'"
else
cat << "SHAR_EOF" > 'changes.html'
SPRNG: Scalable Parallel Pseudo-Random Number Generator Library
Changes to SPRNG
Changes to version 0.5
- Fortran stream_number in calls to init_sprng now starts from 0
instead of from 1.
- A parallel Multiplicative
Lagged Fibonacci Generator (mlfg) has been implemented.
- lcg64 and cmrg now use larger primes as addends. So the random
number sequences will now be different from those in Version 0.5.
- Default parameter to init_sprng is called SPRNG_DEFAULT instead of DEFAULT.
- Several functions inlined, to improve speed.
- Directory 'include' contains the headers, and 'lib' the SPRNG libraries,
instead of using 'SRC' and '.' respectively. If you have untarred
SPRNG into a location where an old version is present, please remove
your old interface.h, sprng.h, and sprng_f.h files in SRC and either
make links to those in the 'include' directory, or copy them to SRC.
- SRC/make.GENERIC helps in installation on new machines.
- 'pack_sprng' now returns the state of a stream in a machine
independent format that can be unpacked with 'unpack_sprng' (except
for pmlcg, which still stores numbers in a machine dependent
format). It may be incompatible with data stored in the version
0.5 format.
SHAR_EOF
fi # end of overwriting check
if test -f 'checkpointer-interface.html'
then
echo shar: will not over-write existing file "'checkpointer-interface.html'"
else
cat << "SHAR_EOF" > 'checkpointer-interface.html'
SPRNG: Scalable Parallel Pseudo-Random Number Generator Library
Interface with Pointer Checking
In this section, we describe the function calls available in the
SPRNG interface with pointer checking. It is invoked by defining the macro
CHECK_POINTERS before including a SPRNG header file. This interface would typically
be used while debugging a program with
more than one random number stream per
process. The different streams are distinguished by unique ID's, which are implemented as pointers
to memory locations where the states of the respective streams are
stored. Most SPRNG functions take this stream ID as an argument. If the
user passes an invalid ID as an argument, then this can lead to
unpredictable behavior by SPRNG. This interface first checks to see if
the ID is valid before using it, thus detecting the use of
invalid ID's. In case an invalid ID is used, it
responds as explained in the function descriptions below. A determined
user can however subvert this checking system by freeing a stream
directly without invoking the free_sprng function.
Users should note that this interface can slow down the
program moderately. Its use is therefore recommended only while
debugging. The default interface is identical to this interface,
except that it is does not check for the validity of the ID's, and
hence can be used once debugging has been completed.
Further details on each function can be found
in the reference manual.
Pointers for FORTRAN users
The different random number streams available on a
process are distinguished by unique ID's, which are implemented as pointers
to the memory locations where the states of the
respective streams are stored. Since standard FORTRAN 77 does not have
a pointer
type, we can store a pointer as an integer of the same size as a C
pointer. We have defined a macro called SPRNG_POINTER in the file sprng_f.h that
automatically defines an integer of the correct size on the
platforms on which SPRNG is supported. The FORTRAN programmer can then
use the type SPRNG_POINTER just as if it were a FORTRAN data
type. However, this applies only if the FORTRAN program is compiled with the same flags as given in the make file that comes with SPRNG.
SPRNG Functions
We describe below the SPRNG function calls available in the
interface with pointer checking. For each function, the C call is given first, followed by the FORTRAN
call. The data type preceding the function name is the type
returned by the function. The data types preceding the arguments to the
functions are the data types of the corresponding function arguments.
- 1. init_sprng
- int *init_sprng(int
streamnum, int nstreams, int seed, int param)
- SPRNG_POINTER init_sprng(integer
streamnum, integer nstreams, integer seed, integer param)
- init_sprng initializes random number streams.
streamnum
is the generator
number and is typically the process number and must be in
[0,nstreams-1]. nstreams
is the number of different
streams that will be initialized across all the processors and seed is the
seed to the generators. The seed is not the starting state of the
sequence; rather, it is an encoding of the starting state. It
is acceptable (and recommended) to use the
same seed for all the streams. The argument param selects the
appropriate parameters (for example, the multiplier for a Linear
Congruential Generator or the lag for a Lagged Fibonacci
Generator). init_sprng
returns the ID of the stream.
Example
- 2. sprng
- double sprng(int *stream)
- real*8 sprng(SPRNG_POINTER
stream)
-
stream
is the ID of
the stream from which the next random number
in [0,1) is returned by this function. If FORTRAN programmers
wish to obtain real*4 numbers, or C programmers
float numbers, instead of the double precision
default, then they should define the macro
FLOAT_GEN before including a SPRNG header file.
In case stream is an invalid ID, this function returns -1.0.
Example
- 3. isprng
- int isprng(int *stream)
- integer isprng(SPRNG_POINTER
stream)
-
stream
is the ID of
the stream from which the next random integer
in [0,231) is returned by this function. Calling
isprng
is equivalent to multiplying the result of
sprng
by 231 and truncating to an integer. Calls to
sprng
and isprng
can be interleaved.
In case stream is an invalid ID, this function returns -1.
Example
- 4. print_sprng
- int print_sprng(int *stream)
- integer print_sprng(SPRNG_POINTER
stream)
- The user may wish to print information about streams after
initialization or spawning, without printing the entire state This
is typically used when the user wishes to record information which can
later be used to identify the random number stream used in the
computations. This
information can be obtained by a call to print_sprng with
the ID of
the stream as argument.
In case stream is an invalid ID, this function returns 0.
Example
- 5. make_sprng_seed
- int make_sprng_seed()
- integer make_sprng_seed()
- This function produces a new seed using system date and time
information. It will typically be used when the programmer wishes to
initialize with a
different seed every time the program is run. User should note that
both the Lagged Fibonacci
Generators require the use of the same seed for each stream in
order to guarantee their independence. In order to ensure
this on a parallel computer, they should install the MPI version of SPRNG
and define the macro
USE_MPI before including a SPRNG header file. This function
will then
involves some inter-processor
communication.
Example
- 6. pack_sprng
- int pack_sprng(int *stream, char **buffer)
- integer pack_sprng(SPRNG_POINTER stream, SPRNG_POINTER fbuffer)
- This function packs the state of the stream with ID stream into an array and
returns the number of bytes actually required for the storage. fbuffer should be the first element of an array of size MAX_PACKED_LENGTH
bytes, where MAX_PACKED_LENGTH is a macro defined in "sprng_f.h" and
"sprng.h". In the C interface, the programmer need not
allocate memory. SPRNG allocates memory for the
array and has the result stored in *buffer. This
function can be used for check-pointing, where the programmer
packs the state of the stream into an array and then saves it
to a file. This state can later be retrieved by calling
unpack_sprng, which is explained later. pack_sprng can also be
used to pass a stream to another process. That process will
unpack the array to obtain the stream.
In case stream is an invalid ID, this function returns 0.
Example
- 7. unpack_sprng
- int *unpack_sprng(char *buffer)
- SPRNG_POINTER unpack_sprng(SPRNG_POINTER buffer)
- This function recreates a stream given the array
buffer, which was used to store the stream's state through a call to the function pack_sprng. An
ID for the recreated stream is returned. Note that this ID is
unrelated to the previous
ID of the stream before it was packed, though the states are
the same.
Example
- 8. free_sprng
- int free_sprng(int *stream)
- integer free_sprng(SPRNG_POINTER
stream)
- This function frees the memory used to store information
concerning the random number stream identified by the
stream ID
stream
. The stream's
ID is then no longer valid. free_sprng returns the current
number of streams available on the process.
In case stream is an invalid ID, this function returns -1.
Example
- 9. spawn_sprng
- int spawn_sprng(int
*stream, int nspawned, int ***newstreams)
- integer spawn_sprng(SPRNG_POINTER stream,
integer nspawned, SPRNG_POINTER fnewstreams)
- Some times, for example in branching processes, it is necessary
to spawn new streams from an old one. This function creates new
random number streams when given a
stream ID stream and the number of new streams
nspawned to be spawned. fnewstreams is the first element of an array of length
at least nspawned in which the ID's of the new streams will
be stored. In the C interface, SPRNG allocates memory for the array
and makes *newstreams point to this
array. spawn_sprng returns the number of streams
spawned. If the function fails due to an inability to allocate memory, then the value returned is less than nspawned.
In case stream is an invalid ID, this function returns 0.
Example
SHAR_EOF
fi # end of overwriting check
if test -f 'checkpointer-reference.html'
then
echo shar: will not over-write existing file "'checkpointer-reference.html'"
else
cat << "SHAR_EOF" > 'checkpointer-reference.html'
SPRNG: Scalable Parallel Pseudo-Random Number Generator Library
Reference:Interface with Pointer Checking
Previous:Default Reference
Interface with Pointer Checking
In this section, we give detailed descriptions of each SPRNG
function call with the interface with pointer checking. It is invoked by defining the macro
CHECK_POINTERS before including a SPRNG header file. This interface would typically
be used while debugging a program with
more than one random number stream per
process. The different streams are distinguished by unique ID's, which are implemented as pointers
to memory locations where the states of the respective streams are
stored. Most SPRNG functions take this stream ID as an argument. If the
user passes an invalid ID as an argument, then this can lead to
unpredictable behavior by SPRNG. This interface first checks to see if
the ID is valid before using it. In case an invalid ID is used, it
responds as explained in the function descriptions below. A determined
user can however subvert this checking system by freeing a stream
directly without invoking the free_sprng function.
Users should note that this interface can slow down the
program moderately. Its use is therefore recommended only while
debugging. The default interface is identical to this interface,
except that it is does not check for the validity of the ID's, and
hence can be used once debugging has been completed.
Pointers for FORTRAN users
The different random number streams available on a
process are distinguished by unique ID's, which are implemented as pointers
to the memory locations where the states of the
respective streams are stored. Since standard FORTRAN 77 does not have
a pointer
type, we can store a pointer as an integer of the same size as a C
pointer. We have defined a macro called SPRNG_POINTER in the file sprng_f.h that
automatically defines an integer of the correct size on the
platforms on which SPRNG is supported. A FORTRAN programmer can then
use the type SPRNG_POINTER just as if it were a FORTRAN data
type. However, this applies only if the FORTRAN program is compiled with the same flags as given in the make file that comes with SPRNG.
Terminology
In the following description, an argument marked as IN indicates that
the argument, or array elements pointed to by that argument, are
read by the function, but not modified. OUT indicates that the
argument, or array elements pointed to by that argument, are written
into by the function, but that its values are not used by the
function. Arguments that are both read and modified are denoted by INOUT.
SPRNG Functions
We describe below the SPRNG function calls available in the
interface with pointer checking. For each function, the C call is given first, followed by the FORTRAN
call. The data type preceding the function name is the type
returned by the function. The data types preceding the arguments to the
functions are the data types of the corresponding function arguments.
- 1. init_sprng
- int *init_sprng(int
streamnum, int nstreams, int seed, int param)
- SPRNG_POINTER init_sprng(integer
streamnum, integer nstreams, integer seed, integer param)
IN streamnum, IN nstreams, IN seed, IN param.
- init_sprng initializes random number streams.
nstreams is the number of
distinct streams that will be initialized across all
the processes and must be greater than 0. Otherwise it is reset to 1 and a
warning message is sent to stderr stating that the
number of streams has been reset.
streamnum
is the stream
number, typically the process number, and must be in
[0,nstreams-1]. If it is not in the acceptable range,
then an error message is sent to stderr and the function
returns a NULL
pointer. Note that the number of independent streams for each
type of generator is limited (but at least 105). If streamnum
is larger
than this number, then a warning message is sent to stderr
stating that the independence of streams cannot be guaranteed.
seed is the
seed to the random
number generator. It is not the starting state of the
sequence; rather, it is an encoding of the starting state. It
is acceptable (and recommended) to use the
same seed for all the streams. Distinct streams are returned
based on their seed and the stream number. Only the 31 least significant
bits of seed are used in determining the initial
starting state of the stream. Higher order bits
that are set will be ignored. No warning message is printed if
the higher order bits are set.
The argument param selects the
appropriate parameters (for example, the multiplier for a Linear
Congruential Generator or the lag for a Lagged Fibonacci
Generator). The macro
SPRNG_DEFAULT, defined in the
SPRNG header files, can be used to choose the
default parameters. If an invalid parameter is passed to this function,
then a warning message is sent to stderr and the default
parameter is used.
init_sprng
returns the ID of the stream when it completes successfully. If
it fails due to incorrect arguments or inability to allocate
memory, then an error message is sent to stderr and a
NULL pointer is returned.
Example
- 2. sprng
- double sprng(int *stream)
- real*8 sprng(SPRNG_POINTER
stream)
INOUT stream.
- stream is the ID of
the stream from which
the next random number
in [0,1) is returned by this function. This argument must have been
obtained by a prior call to init_sprng, spawn_sprng or
unpack_sprng. In case stream is an invalid ID, this function returns -1.0.
If FORTRAN programmers
wish to obtain real*4 numbers, or C programmers
float numbers, instead of the double precision
default, then they should define the macro
FLOAT_GEN before including a SPRNG header file.
Example
- 3. isprng
- int isprng(int *stream)
- integer isprng(SPRNG_POINTER
stream)
INOUT stream.
- stream is the ID of
the stream from which the next random integer
in [0,231) is returned by this function. This argument must have been
obtained by a prior call to init_sprng, spawn_sprng or
unpack_sprng. In case stream is an invalid ID, this function returns -1.
Calling
isprng
is equivalent to multiplying the result of
sprng
by 231 and truncating to an integer. Calls to
sprng
and isprng
can be interleaved.
Example
- 4. print_sprng
- int print_sprng(int *stream)
- integer print_sprng(SPRNG_POINTER
stream)
IN stream .
- The user may wish to print information about streams without printing the entire state, for example after
initialization. This
is typically done when the user wishes to record information which can
later be used to identify the random number stream used in the
computations. This
information can be obtained by a call to print_sprng with
the ID of
the stream as argument. stream must have been
obtained by a prior call to init_sprng, spawn_sprng or
unpack_sprng. In case stream is an invalid ID, this function returns 0. Otherwise
it returns a non-zero value.
Example
- 5. make_sprng_seed
- int make_sprng_seed()
- integer make_sprng_seed()
- This function produces a new seed using system date and time
information. It will typically be used when the programmer wishes to
initialize with a
different seed every time the program is run. User should note that
both the Lagged Fibonacci
Generators require the use of the same seed for each stream in
order to guarantee their independence. In order to ensure
this on a parallel computer, they should install the MPI version of SPRNG
and define the macro
USE_MPI before including a SPRNG header file. This function
will then
involves some inter-processor
communication.
If the user has installed the MPI version of the library but has not
defined the macro USE_MPI, then the seed could be different
on the different processes. No warning message is printed. If the
user has not installed the MPI version of the library but includes the
macro USE_MPI, then link time errors will be reported by
the compiler.
Note: If users have installed the MPI version of the library and
defined the macro USE_MPI, then they must call
MPI_Init before making calls to
make_sprng_seed. The user should also call
MPI_Finalize later. SPRNG does not make either of these
calls. If any process calls make_sprng_seed, then users
should ensure that all their processes call this function, since
collective MPI operations are performed here.
Example
- 6. pack_sprng
- int pack_sprng(int *stream, char **buffer)
- integer pack_sprng(SPRNG_POINTER stream, character fbuffer)
IN stream, OUT buffer, OUT fbuffer.
- This function packs the state of the stream with ID stream into an array and
returns the number of bytes actually required for the storage. stream must have been
obtained by a prior call to init_sprng, spawn_sprng or
unpack_sprng. In case stream is an invalid ID, this function returns 0.
fbuffer should be the first element of an array of size MAX_PACKED_LENGTH
bytes, where MAX_PACKED_LENGTH is a macro defined in "sprng_f.h" and
"sprng.h". If the memory in the array is insufficient,
undetected errors could occur. It might also lead to segmentation
faults. In the C interface, the programmer need not
allocate memory. SPRNG allocates memory for the
array and has the result stored in *buffer.
Calls to this
function in C or FORTRAN involve memory allocation within this
function. In case of insufficient memory, an error message is sent to
stderr and the value 0 is returned.
This function can be used for check-pointing, where the programmer
packs the state of the stream into an array and then saves it
to a file. This state can later be retrieved by calling
unpack_sprng, which is explained below. pack_sprng can also be
used to pass a stream to another process. That process will
unpack the packed array to obtain the stream.
Note: SPRNG does not free the memory associated with
a stream when it packs it. If users do not plan to use
the stream that has been packed, then they can explicitly call
free_sprng in order to free the memory.
Example
- 7. unpack_sprng
- int *unpack_sprng(char *buffer)
- SPRNG_POINTER unpack_sprng(character fbuffer)
IN buffer, IN fbuffer.
- This function recreates a stream given the array
buffer or fbuffer, which was used to store the stream's state through a call to the function pack_sprng. An
ID for the recreated stream is returned. Note that this ID is
unrelated to the previous
ID of the stream before it was packed, though the states are
the same.
Calls to this function involve memory allocation. In
case sufficient memory was not obtained, an error message is
sent to stderr and the NULL pointer is
returned. The packed string must be the state of a valid
stream. If it is not, the error may not necessarily be
detected by SPRNG. If an error is detected, then an error message
is sent to stderr and a NULL pointer is
returned.
Example
- 8. free_sprng
- int free_sprng(int *stream)
- integer free_sprng(SPRNG_POINTER
stream)
INOUT stream.
- This function frees the memory used to store information
concerning the random number stream identified by the
stream ID
stream
. The stream's
ID is then no longer valid. stream must have been
obtained by a prior call to init_sprng, spawn_sprng or
unpack_sprng. In case stream is an invalid ID, this function returns -1.
free_sprng returns the current
number of streams available on the process.
Example
- 9. spawn_sprng
- int spawn_sprng(int
*stream, int nspawned, int ***newstreams)
- integer spawn_sprng(SPRNG_POINTER stream,
integer nspawned, SPRNG_POINTER fnewstreams)
INOUT stream, IN nspawned, OUT newstreams, OUT fnewstreams .
- Some times, for example in branching processes, it is necessary
to spawn new streams from an old one. This function creates new
random number streams when given a
stream ID stream and the number of new streams
nspawned to be spawned.
stream must have been
obtained by a prior call to init_sprng, spawn_sprng or
unpack_sprng. In case stream is an invalid ID, this function returns 0.
nspawned is the number of
streams that will be spawned and must be greater than
0. Otherwise it is reset to 1 and a
warning message is sent to stderr stating that the
number of streams has been reset. In the unlikely event of an
extremely large number of streams being spawned, SPRNG cannot
guarantee the independence
of the different streams. In this case, a warning message is sent
to stderr. We may also change the seed of the new streams spawned in this case to make it less likely that different streams will overlap.
fnewstreams is the first element of an array of length
at least nspawned in which the ID's of the new streams will
be stored. In the C interface, SPRNG allocates memory for the array
and makes *newstreams point to it.
spawn_sprng returns the number of streams successfully
spawned. If the function fails due to an inability to allocate memory,
then the value returned is less than nspawned. If the
function fails due to an incorrect value of stream, then
the returned value is 0.
Note: If users spawn too often, then the
available set independent streams can get exhausted, depending on the
random number generator used. Therefore some
caution must be used in spawning streams.
Example
SHAR_EOF
fi # end of overwriting check
if test -f 'checksprng.html'
then
echo shar: will not over-write existing file "'checksprng.html'"
else
cat << "SHAR_EOF" > 'checksprng.html'
SPRNG: Scalable Parallel Pseudo-Random Number Generator Library
Checking the SPRNG Libraries
On building the SPRNG library, six executables will also be created
for each SPRNG random number generator
library available. Three of these test the three interfaces in FORTRAN and the other
three repeat the process in C. These tests check, among other things, whether the expected
stream of random numbers is reproduced on the user's machine. They
also check whether SPRNG responds as per its specifications when the
user gives invalid arguments.
We have provided a shell script called checksprng that
calls all the test programs. Since we check the libraries for their
response to erroneous usage by the programmer, the tests make SPRNG print out
ERROR messages to stderr. We redirect
stderr to /dev/null so as not to clutter up the
screen with unnecessary information. checksprng is run in
the Bourne shell since, unlike in the C shell, it is possible here to
redirect standard error without redirecting the standard output.
The programs that check the generators do not make MPI calls, as a default. If users
wish to test them with the MPI calls when the MPI version of SPRNG has been installed, then they should compile these
programs after defining the macro USE_MPI
and test each checking program individually. Users may get several
ERROR and WARNING messages on the screen as SPRNG is checked for its
response to erroneous input. These messages can be ignored. If
SPRNG fails any test, the user will get a FAILED message
rather than an ERROR message.
Please
report any problems in
porting SPRNG.
SHAR_EOF
fi # end of overwriting check
if test -f 'compilation.html'
then
echo shar: will not over-write existing file "'compilation.html'"
else
cat << "SHAR_EOF" > 'compilation.html'
SPRNG: Scalable Parallel Pseudo-Random Number Generator Library
Next:Examples
Previous:Usage
Compilation
Compiling with the Non-MPI version of SPRNG
SPRNG currently consists of five libraries for random number
generation. The library libcmrg.a generates streams from
the Combine Multiple Recursive
Generator, liblcg.a from
the 48 bit Linear Congruential
Generator, liblcg64.a from the 64 bit Linear Congruential Generator,
liblfg.a from the modified Lagged Fibonacci Generator, and libpmlcg.a from
the Prime Modulus Linear Congruential Generator. (The last one is not automatically installed.) In
the current implementation, the user can generate streams only from
one of these libraries in a given program. However, the user can
easily change between different generators in different runs by just
changing the library linked to, and does not need to recompile the code.
In order to use a library, the programmer needs to link the code
to the desired library. This is generally done by using the following
linking option: -Llibdir
-llib where libdir is the path to
the SPRNG libraries, and liblib.a
is the particular SPRNG library from which the user desires to
generate random numbers. We have provided examples for compilation on different platforms.
If
the size of a pointer is 8 bytes, then either the macro
SPRNG_POINTER=8 should be defined before including the header file, or
this should be done through a compiler option (typically
-DSPRNG_POINTER=8). Please take a look at the make.PLAT file of your
platform for the correct setting.
In order to compile programs, the user must also indicate the location of
the SPRNG header files.
This is generally done by passing the -Isrcdir
option to
the compiler, where srcdir is the path to the SPRNG SRC
directory.
The compilation syntax may therefore be one of the following on most compilers:
CC -Isrcdir filename.c -Llibdir
-llib
F77 -Isrcdir filename.F -Llibdir
-llib
where CC is the C compiler and F77 is the
FORTRAN compiler. FORTRAN users may also wish to read the note on
preprocessor directives.
We have
also provided examples for compilation on
different platforms.
Compiling with the MPI version of SPRNG
If the MPI version of SPRNG has
been installed, then the user will have to link to the MPI libraries
too, in addition to the SPRNG libraries mentioned above. Thus the following syntax for the
compilation may be used on most compilers:
CC -Isrcdir filename.c
-Llibdir -llib -Lmpidir -lmpilib
F77 -Isrcdir filename.F -Llibdir -llib -Lmpidir -lmpilib
where mpidir is the path to the MPI library and
libmpilib.a is the name of the
MPI library. The MPI library must be linked after
the SPRNG library. We have
provided examples for compilation on
different platforms.
SHAR_EOF
fi # end of overwriting check
if test -f 'default-interface.html'
then
echo shar: will not over-write existing file "'default-interface.html'"
else
cat << "SHAR_EOF" > 'default-interface.html'
SPRNG: Scalable Parallel Pseudo-Random Number Generator Library
SPRNG Default Interface
In this section, we describe the function calls available in the
default SPRNG interface. This interface would typically be used if
more than one random number stream is needed on any
process.
Further details on each function can be found
in the section in the reference manual.
Pointers for FORTRAN users
The different random number streams available on a
processor are distinguished by unique ID's, which are implemented as pointers
to the memory locations where the states of the
respective streams are stored. Since standard FORTRAN 77 does not have
a pointer
type, we can store a pointer as an integer of the same size as a C
pointer. We have defined a macro called SPRNG_POINTER in the file sprng_f.h that
automatically defines an integer of the correct size on the
platforms on which SPRNG is supported. The FORTRAN programmer can then
use the type SPRNG_POINTER just as if it were a FORTRAN data
type. However, this applies only if the FORTRAN program is compiled with the same flags as given in the make file that comes with SPRNG.
SPRNG Functions
We describe below the SPRNG function calls available in the default
interface. For each function, the C call is given first, followed by the FORTRAN
call. The data type preceding the function name is the type
returned by the function. The data types preceding the arguments to the
functions are the data types of the corresponding function arguments.
- 1. init_sprng
- int *init_sprng(int
streamnum, int nstreams, int seed, int param)
- SPRNG_POINTER init_sprng(integer
streamnum, integer nstreams, integer seed, integer param)
- init_sprng initializes random number streams.
streamnum
is the stream
number and is typically the process number and must be in
[0,nstreams-1]. nstreams
is the number of different
streams that will be initialized across all the processes and seed is the
seed to the generators. The seed is not the starting state of the
sequence; rather, it is an encoding of the starting state. It
is acceptable (and recommended) to use the
same seed for all the streams. The argument param selects the
appropriate parameters (for example, the multiplier for a Linear
Congruential Generator or the lag for a Lagged Fibonacci
Generator). init_sprng
returns the ID of the stream.
Example
- 2. sprng
- double sprng(int *stream)
- real*8 sprng(SPRNG_POINTER
stream)
-
stream
is the ID of
the stream from which the next random number
in [0,1) is returned by this function. If FORTRAN programmers
wish to obtain real*4 numbers, or C programmers
float numbers, instead of the double precision
default, then they should define the macro
FLOAT_GEN before including a SPRNG header file.
Example
- 3. isprng
- int isprng(int *stream)
- integer isprng(SPRNG_POINTER
stream)
-
stream
is the ID of
the stream from which the next random integer
in [0,231) is returned by this function. Calling
isprng
is equivalent to multiplying the result of
sprng
by 231 and truncating to an integer. Calls to
sprng
and isprng
can be interleaved.
Example
- 4. print_sprng
- int print_sprng(int *stream)
- integer print_sprng(SPRNG_POINTER
stream)
- The user may wish to print information about streams after
initialization or spawning, without printing the entire state This
is typically used when the user wishes to record information which can
later be used to identify the random number stream used in the
computations. This
information can be obtained by a call to print_sprng with
the ID of
the stream as argument.
Example
- 5. make_sprng_seed
- int make_sprng_seed()
- integer make_sprng_seed()
- This function produces a new seed using system date and time
information. It will typically be used when the programmer wishes to
initialize with a
different seed every time the program is run. User should note that
both the Lagged Fibonacci
Generators require the use of the same seed for each stream in
order to guarantee their independence. In order to ensure
this on a parallel computer, they should install the MPI version of SPRNG
and define the macro
USE_MPI before including a SPRNG header file. This function
will then
involves some inter-processor
communication.
Example
- 6. pack_sprng
- int _sprng(int *stream, char **buffer)
- integer pack_sprng(SPRNG_POINTER stream, SPRNG_POINTER fbuffer)
- This function packs the state of the stream with ID stream into an array and
returns the number of bytes actually required for the storage. fbuffer should be the first element of an array of size MAX_PACKED_LENGTH
bytes, where MAX_PACKED_LENGTH is a macro defined in "sprng_f.h" and
"sprng.h". If the memory in the array is insufficient,
undetected errors could occur. It might also lead to segmentation
faults. In the C interface, the programmer need not
allocate memory. SPRNG allocates memory for the
array and has the result stored in *buffer. This
function can be used for check-pointing, where the programmer
packs the state of the stream into an array and then saves it
to a file. This state can later be retrieved by calling
unpack_sprng, which is explained later. pack_sprng can also be
used to pass a stream to another process. That process will
unpack the array to obtain the stream.
Example
- 7. unpack_sprng
- int *unpack_sprng(char *buffer)
- SPRNG_POINTER unpack_sprng(SPRNG_POINTER buffer)
- This function recreates a stream given the array
buffer, which was used to store the stream's state through a call to the function pack_sprng. An
ID for the recreated stream is returned. Note that this ID is
unrelated to the previous
ID of the stream before it was packed, though the states are
the same.
Example
- 8. free_sprng
- int free_sprng(int *stream)
- integer free_sprng(SPRNG_POINTER
stream)
- This function frees the memory used to store information
concerning the random number stream identified by the
stream ID
stream
. The stream's
ID is then no longer valid. free_sprng returns the current
number of streams available on the process.
Example
- 9. spawn_sprng
- int spawn_sprng(int
*stream, int nspawned, int ***newstreams)
- integer spawn_sprng(SPRNG_POINTER stream,
integer nspawned, SPRNG_POINTER fnewstreams)
- Some times, for example in branching processes, it is necessary
to spawn new streams from an old one. This function creates new
random number streams when given a
stream ID stream and the number of new streams
nspawned to be spawned. fnewstreams is the first element of an array of length
at least nspawned in which the ID's of the new streams will
be stored. In the C interface, SPRNG allocates memory for the array
and makes *newstreams point to this
array. spawn_sprng returns the number of streams
spawned. If the function fails due to an inability to allocate memory, then the value returned is less than nspawned.
Example
SHAR_EOF
fi # end of overwriting check
if test -f 'default-reference.html'
then
echo shar: will not over-write existing file "'default-reference.html'"
else
cat << "SHAR_EOF" > 'default-reference.html'
SPRNG: Scalable Parallel Pseudo-Random Number Generator Library
Next:Interface with Checkpointing
Previous:Simple Interface
Default Interface
In this section, we give detailed descriptions of each SPRNG
function call with the default interface. This interface would typically be used if
more than one random number stream is needed on any
process.
Pointers for FORTRAN users
The different random number streams available on a
process are distinguished by unique ID's, which are implemented as pointers
to the memory locations where the states of the
respective streams are stored. Since standard FORTRAN 77 does not have
a pointer
type, we can store a pointer as an integer of the same size as a C
pointer. We have defined a macro called SPRNG_POINTER in the file sprng_f.h that
automatically defines an integer of the correct size on the
platforms on which SPRNG is supported. A FORTRAN programmer can then
use the type SPRNG_POINTER just as if it were a FORTRAN data
type. However, this applies only if the FORTRAN program is compiled with the same flags as given in the make file that comes with SPRNG.
Terminology
In the following description, an argument marked as IN indicates that
the argument, or array elements pointed to by that argument, are
read by the function, but not modified. OUT indicates that the
argument, or array elements pointed to by that argument, are written
into by the function, but that its values are not used by the
function. Arguments that are both read and modified are denoted by INOUT.
SPRNG Functions
We describe below the SPRNG function calls available in the default
interface. For each function, the C call is given first, followed by
the FORTRAN
call. The data type preceding the function name is the type
returned by the function. The data types preceding the arguments to the
functions are the data types of the corresponding function arguments.
- 1. init_sprng
- int *init_sprng(int
streamnum, int nstreams, int seed, int param)
- SPRNG_POINTER init_sprng(integer
streamnum, integer nstreams, integer seed, integer param)
IN streamnum, IN nstreams, IN seed, IN param.
- init_sprng initializes random number streams.
nstreams is the number of
distinct streams that will be initialized across all
the processes and must be greater than 0. Otherwise it is reset to 1 and a
warning message is sent to stderr stating that the
number of streams has been reset.
streamnum
is the stream
number, typically the processor number, and must be in
[0,nstreams-1]. If it is not in the acceptable range,
then an error message is sent to stderr and the function
returns a NULL
pointer. Note that the number of independent streams for each
type of generator is limited (but at least 105). If streamnum
is larger
than this number, then a warning message is sent to stderr
stating that the independence of streams cannot be guaranteed.
seed is the
seed to the random
number generator. It is not the starting state of the
sequence; rather, it is an encoding of the starting state. It
is acceptable (and recommended) to use the
same seed for all the streams. Distinct streams are returned
based on their seed and the stream number. Only the 31 least significant
bits of seed are used in determining the initial
starting state of the stream. Higher order bits
that are set will be ignored. No warning message is printed if
the higher order bits are set.
The argument param selects the
appropriate parameters (for example, the multiplier for a Linear
Congruential Generator or the lag for a Lagged Fibonacci
Generator). The macro
SPRNG_DEFAULT, defined in the
SPRNG header files, can be used to choose the
default parameters. If an invalid parameter is passed to this function,
then a warning message is sent to stderr and the default
parameter is used.
init_sprng
returns the ID of the stream when it completes successfully. If
it fails due to incorrect arguments or inability to allocate
memory, then an error message is sent to stderr and a
NULL pointer is returned.
Example
- 2. sprng
- double sprng(int *stream)
- real*8 sprng(SPRNG_POINTER
stream)
INOUT stream.
- stream is the ID of
the stream from which
the next random number
in [0,1) is returned by this function. This argument must have been
obtained by a prior call to init_sprng, spawn_sprng or
unpack_sprng. In the default interface, SPRNG does not check for
the validity of the ID. Incorrect answers or segmentation faults
could occur due to invalid ID's. In case the user wishes SPRNG to check
for the validity of the ID, then the interface with pointer checking must be
used.
If FORTRAN programmers
wish to obtain real*4 numbers, or C programmers
float numbers, instead of the double precision
default, then they should define the macro
FLOAT_GEN before including a SPRNG header file.
Example
- 3. isprng
- int isprng(int *stream)
- integer isprng(SPRNG_POINTER
stream)
INOUT stream.
- stream is the ID of
the stream from which the next random integer
in [0,231) is returned by this function. This argument must have been
obtained by a prior call to init_sprng, spawn_sprng or
unpack_sprng. In this interface, SPRNG does not check for
the validity of the ID. Incorrect answers or segmentation faults
could occur due to invalid ID's. In case the user wishes SPRNG to check
for the validity of the ID, then the interface with pointer checking must be
used.
Calling
isprng
is equivalent to multiplying the result of
sprng
by 231 and truncating to an integer. Calls to
sprng
and isprng
can be interleaved.
Example
- 4. print_sprng
- int print_sprng(int *stream)
- integer print_sprng(SPRNG_POINTER
stream)
IN stream .
- The user may wish to print information about streams without printing the entire state, for example after
initialization. This
is typically done when the user wishes to record information which can
later be used to identify the random number stream used in the
computations. This
information can be obtained by a call to print_sprng with
the ID of
the stream as argument. stream must have been
obtained by a prior call to init_sprng, spawn_sprng or
unpack_sprng. In this interface, SPRNG does not check for
the validity of the ID. Incorrect answers or segmentation faults
could occur due to invalid ID's. In case the user wishes SPRNG to check
for the validity of the ID, then the interface with pointer checking must be
used.
Example
- 5. make_sprng_seed
- int make_sprng_seed()
- integer make_sprng_seed()
- This function produces a new seed using system date and time
information. It will typically be used when the programmer wishes to
initialize with a
different seed every time the program is run. User should note that
both the Lagged Fibonacci
Generators requires the use of the same seed for each stream in
order to guarantee their independence. In order to ensure
this on a parallel computer, they should install the MPI version of SPRNG
and define the macro
USE_MPI before including a SPRNG header file. This function
will then
involves some inter-processor
communication.
If the user has installed the MPI version of the library but has not
defined the macro USE_MPI, then the seed could be different
on the different processes. No warning message is printed. If the
user has not installed the MPI version of the library but includes the
macro USE_MPI, then link time errors will be reported by
the compiler.
Note: If users have installed the MPI version of the
library and defined the macro USE_MPI, then they must
call MPI_Init before making calls to
make_sprng_seed. The user should also call
MPI_Finalize later. SPRNG does not make either of these
calls. If any process calls make_sprng_seed, then users
should ensure that all their processes call this function, since
collective MPI operations are performed here.
Example
- 6. pack_sprng
- int pack_sprng(int *stream, char **buffer)
- integer pack_sprng(SPRNG_POINTER stream, character fbuffer)
IN stream, OUT buffer, OUT fbuffer.
- This function packs the state of the stream with ID stream into an array and
returns the number of bytes actually required for the storage. stream must have been
obtained by a prior call to init_sprng, spawn_sprng or
unpack_sprng. In this interface, SPRNG does not check for
the validity of the ID. Incorrect answers or segmentation faults
could occur due to invalid ID's. In case the user wishes SPRNG to check
for the validity of the ID, then the interface with pointer checking must be
used.
fbuffer should be the first element of an array of size MAX_PACKED_LENGTH
bytes, where MAX_PACKED_LENGTH is a macro defined in "sprng_f.h" and
"sprng.h". If the memory in the array is insufficient,
undetected errors could occur. It might also lead to segmentation
faults. In the C interface, the programmer need not
allocate memory. SPRNG allocates memory for the
array and has the result stored in *buffer.
Calls to this
function in C or FORTRAN involve memory allocation within this
function. In case of insufficient memory, an error message is sent to
stderr and the value 0 is returned.
This function can be used for check-pointing, where the programmer
packs the state of the stream into an array and then saves it
to a file. This state can later be retrieved by calling
unpack_sprng, which is explained below. pack_sprng can also be
used to pass a stream to another process. That process will
unpack the packed array to obtain the stream.
Note: SPRNG does not free the memory associated with
a stream when it packs it. If users do not plan to use
the stream that has been packed, then they can explicitly call
free_sprng in order to free the memory.
Example
- 7. unpack_sprng
- int *unpack_sprng(char *buffer)
- SPRNG_POINTER unpack_sprng(character fbuffer)
IN buffer, IN fbuffer.
- This function recreates a stream given the array
buffer or fbuffer, which was used to store the stream's state through a call to the function pack_sprng. An
ID for the recreated stream is returned. Note that this ID is
unrelated to the previous
ID of the stream before it was packed, though the states are
the same.
Calls to this function involve memory allocation. In
case sufficient memory was not obtained, an error message is
sent to stderr and the NULL pointer is
returned. The packed string must be the state of a valid
stream. If it is not, the error may not necessarily be
detected by SPRNG. If an error is detected, then an error message
is sent to stderr and a NULL pointer is
returned.
Example
- 8. free_sprng
- int free_sprng(int *stream)
- integer free_sprng(SPRNG_POINTER
stream)
INOUT stream.
- This function frees the memory used to store information
concerning the random number stream identified by the
stream ID
stream
. The stream's
ID is then no longer valid. stream must have been
obtained by a prior call to init_sprng, spawn_sprng or
unpack_sprng. In this interface, SPRNG does not check for
the validity of the ID. Incorrect answers or segmentation faults
could occur due to invalid ID's. In case the user wishes SPRNG to check
for the validity of the ID, then the interface with pointer checking must be
used.
free_sprng returns the current
number of streams available on the process.
Example
- 9. spawn_sprng
- int spawn_sprng(int
*stream, int nspawned, int ***newstreams)
- integer spawn_sprng(SPRNG_POINTER stream,
integer nspawned, SPRNG_POINTER fnewstreams)
INOUT stream, IN nspawned, OUT newstreams, OUT fnewstreams .
- Some times, for example in branching processes, it is necessary
to spawn new streams from an old one. This function creates new
random number streams when given a
stream ID stream and the number of new streams
nspawned to be spawned.
stream must have been
obtained by a prior call to init_sprng, spawn_sprng or
unpack_sprng. In this interface, SPRNG does not check for
the validity of the ID. Incorrect answers or segmentation faults
could occur due to invalid ID's. In case the user wishes SPRNG to check
for the validity of the ID, then the interface with pointer checking must be
used.
nspawned is the number of
streams that will be spawned and must be greater than
0. Otherwise it is reset to 1 and a
warning message is sent to stderr stating that the
number of streams has been reset. In the unlikely event of an
extremely large number of streams being spawned, SPRNG cannot
guarantee the independence
of the different streams. In this case, a warning message is sent
to stderr. We may also change the seed of the new streams spawned in this case to make it less likely that different streams will overlap.
fnewstreams is the first element of an array of length
at least nspawned in which the ID's of the new streams will
be stored. In the C interface, SPRNG allocates memory for the array
and makes *newstreams point to this
array.
spawn_sprng returns the number of streams successfully
spawned. If the function fails due to an inability to allocate memory, then the value returned is less than nspawned.
Note: If users spawn too often, then the
available set independent streams can get exhausted, depending on the
random number generator used. Therefore some
caution must be used in spawning streams.
Example
SHAR_EOF
fi # end of overwriting check
if test -f 'definitions.html'
then
echo shar: will not over-write existing file "'definitions.html'"
else
cat << "SHAR_EOF" > 'definitions.html'
SPRNG: Scalable Parallel Pseudo-Random Number Generator Library
Next:References
Previous:Test Suite
Explanation of Terms
- Check-Pointing
- Users may sometimes wish to save the states of random number streams into a file. This is typically done
for the following two reasons:
- In case the system the user is
working on is unreliable, the user may want to save the state of the
calculations into a file, once in a while. If the system crashes, then
the user can recover the state of the calculations from the file and
continue from that point onwards, instead of repeating the entire
calculations.
- Users may not wish to perform the entire
calculations all at one time. This may either be because they are not
sure if the calculations are worth continuing until they have obtained
some intermediate results, or because system time is less expensive
during certain times of the day. In the latter case they may perform
the calculations every day during such cheaper periods.
In both the cases mentioned above, users will need to store the
states of random number streams so that they can start
from where they had left off the previous time. SPRNG
provides a function that returns the state of a random number stream
as an array of characters. Users can store this array into a
file. They can later read the stored information back into a character
array. SPRNG provides a function to obtain the saved state of the
random number stream from this character array, thus enabling users to
continue with their calculations.
Example
- Header Files
- The actual names of the SPRNG functions differ from those given in
the SPRNG interface
descriptions. We have defined certain macros in the files sprng.h and sprng_f.h. If the users include either of those
files (the former file by C users and the latter by FORTRAN users)
in their program, then the correct SPRNG function is automatically
called.
Note to FORTRAN users on preprocessor directives: The header files contain
preprocessing directives which most modern FORTRAN compilers are able
to handle. These compilers typically require special flags and/or the
filename to end in .F instead of .f in order
to preprocess these directives. In case the latter case, users should copy files containing C preprocessor directives to a file with an extension of .F. The user's makefile may need to be changed to give instructions for handling these new files.
Those who are not familiar with the 'make' command can try adding the following lines to their makefile, instead of making any other change:
.SUFFIXES : .f .F
.F.f :
@if [ -f $*.i ] ; then \
rm $*.i ;\
fi
$(CPP) -I$(SRCDIR) $*.F
@if [ -f $*.i ] ; then \
mv $*.i $*.f ;\
fi
Where $(CPP) is identical to that given in the sprng/SRC/make.PLAT file, where PLAT is the user's platform, and $(SRCDIR) is the SPRNG source directory. This same technique can be used in case the user's FORTRAN compiler
does not call the preprocessor. This creates a regular FORTRAN file which the compiler can handle.
On the IBM SP2, please use the following code instead of that given above:
.SUFFIXES : .f .F
.F.f:
$(CPP) -WF,-I$(SRCDIR) $*.F
@if [ -f F$*.f ] ; then \
mv F$*.f $*.f ;\
- Including Header Files
- A C user needs to include the header file
sprng.h and a FORTRAN user
sprng_f.h in order to
use SPRNG. For example, FORTRAN users would type:
#include "sprng_f.h"
in their FORTRAN program files that make SPRNG calls. This statement causes
the contents of the file sprng_f.h to appear instead of
the statement #include "sprng_f.h" once the file has been
preprocessed. This usage is demonstrated in the following examples:
C Example
FORTRAN users can also read the note on header files if they are
not used to the C preprocessor.
- Independence of Random Number Streams
- Users will generally use several random number streams in their
calculations. It is important for these streams to be uncorrelated,
in order for the pseudorandom numbers to be effective at the desired
variance reduction, which is, of course, the point of large Monte
Carlo calculations. We refer to this property of streams being
uncorrelated as the independence of streams. SPRNG provides random number streams that have been
tested for their independence.
- Initialization of Streams
- We store the state of a random number stream in some memory
location. Before we do this, it is necessary to allocate memory space. We then determine the initial state of the stream from the seed and other parameters of
the generator. This process is known as initialization. Before a
random number stream can be used, an initialization call has to be
made. Usually the users need to call init_sprng to perform
the initialization. The exceptions are (i) in the simple interface where
default initialization is performed under certain conditions, (ii)
when the unpack_sprng function is used that creates a
stream with an appropriate state and (iii) when the user calls
spawn_sprng, which performs the initialization itself.
- Locality
- By locality we mean that an operation performed on a
stream should not involve communication between processors. For
example, when we initialize or spawn streams, we need to ensure that
the new streams produced are independent of the
streams available on all other processors. SPRNG produces such
independent streams without performing any communication with other
processors. The only SPRNG function that could involve communication
between processors is make_sprng_seed.
- Macro Substitution
- A SPRNG user may need to use preprocessing directives for
macro substitution, which C users will be familiar with. A statement
of the form:
#define macro replacement
replaces the text macro in the user's file with
replacement. For example, the SPRNG header files define a
macro:
#define SPRNG_DEFAULT 0
If users include a
SPRNG header file and then type the word SPRNG_DEFAULT anywhere
in their program, then this word is replaced by 0 once
the program has been preprocessed. FORTRAN users can read more about
the preprocessing directives in the
note on this topic.
- NULL Pointer
- Certain SPRNG functions return a NULL pointer in case of
error. FORTRAN users can consider a NULL pointer as the integer constant
0.
- Portability
- SPRNG is portable to a variety of serial and parallel
platforms. Exactly the same sequence of random numbers are produced on
all the machines. SPRNG also provides executables to check if the
SPRNG libraries have ported correctly to the platform the user is working
on. The section on installation contains
further details on these executables.
- Quality of Parallel Random Number Streams
- Parallel random number streams must satisfy all
the criteria for an acceptable serial random number stream. For
example, they must be sufficiently uniform, have a large period and
there should be no correlation between the numbers in the sequence. In
addition, parallel streams should be uncorrelated with each other.
- Random Number Streams
- Given a random number generator and its initial state, each call to the
generator produces the next random number in the sequence. We refer to
each such sequence of random numbers as a random number
stream.
- Reproducibility
- SPRNG can be used to produce a totally reproducible stream of
parallel pseudorandom numbers, independent of the number of processors
used in the computation and of the loading produced by sharing of the
parallel computer. Such reproducibility is important during debugging
and also in checking codes ported to new platforms.
- Seed
- We use the term seed with a slightly different meaning
than is conventionally used. This term does not refer to the starting
state of the random
number stream. Rather, it is an encoding of the starting
state. Distinct streams initialized with the same seed will have
different starting states. This provides users the convenience of
being able to use the same seed for distinct streams, and still obtaining
different initial states.
There is a large set of possible starting
states for each stream. We restrict the user to
choosing from 231 of those. The user can specify a particular seed
(which is an integer) based on which SPRNG determines a particular
starting state for the stream. Seeds that are close to each other may
produce very different starting states.
It is recommended that the user use the same seed while initializing
all the streams in one particular computational run. In order to get a
different sequence in a different run, the user can change this common seed.
- Spawning Random Number Streams
- Sometimes it is necessary to create new random number
streams. This situation is best explained with the help of an example.
Consider the following Monte Carlo application in neutronics. Here
independent neutron paths are generated based on the outcome of many
probabilistic events. Statistics are collected along the paths and
estimates for quantities of interest are computed. These estimates
have a standard error that scales with the reciprocal of the square
root of the number of "independent neutron paths". The computational
catch is that during a flight a neutron may collide with a heavy
nucleus thereby producing new neutrons. These new neutrons, along with
their initial conditions, are put into a computational queue for later
processing. An efficient parallel implementation demands that this
queue be distributed. In order to ensure reproducibility,
each neutron in the queue must also have information so that a unique
and deterministic stream of pseudorandom numbers will be used
regardless of which processor it eventually executes on. We also
desire that the pseudorandom numbers streams that are allocated for
each neutron be independent of the stream of any other
neutron.
In order to satisfy the requirements of problems such as the one
above, we provide a SPRNG function that spawns new, independent random number
streams based on the information available from an existing stream. In
the neutron collision problem above, new streams would be spawned for
each neutron that results from the collision based on the stream of
the original neutron that collided. SPRNG further guarantees that the
streams produced are independent of any other stream that exists.
- Standard Error
- SPRNG error and warning messages are sent to the standard
error. Users should note that redirecting the standard output to a
file does not redirect the standard error too. The following example
demonstrates how to redirect standard error to a file
filename in the Bourne and Korn shells:
a.out 2> filename
where a.out is the user's executable. If the user wishes
to redirect standard output and standard error to the same file, they
can issue the following command:
a.out > filename 2>&1
The above can be accomplished in the C shell by the following command:
a.out >& filename
- State of a stream
- In order to generate random numbers from a stream, SPRNG needs to
store information about that stream in memory. This can be considered
the state of that stream. As we progress along the random number
sequence, this state of the stream too keeps changing.
In the simplest
case, we may just need to know the previous random number generated in
order to produce the next. In this case, the state of the stream could
be identical to the integer version of the random number generated. In
order to produce a double precision number, we could divide the state
by an appropriate value to get a floating point number in the range
[0,1). In a more complicated case, for example with the 48 bit Linear
Congruential Generator, the state consists of the multiplier, the
prime addend and a 48 bit integer. We return the 31 high order bits
as the integer random number. This example was given to demonstrate
that the state of a stream is not always identical to the integer random
number generated. The state of the Lagged Fibonacci
Generator, for instance, requires far more memory and consists of several elements of the
sequence.
It should be noted that the state of the stream changes in the same
manner, irrespective of whether the integer or
the double precision generator was called.
- Stream ID
- A single process may have several different random number streams available. These
different streams are distinguished by unique ID's, which are implemented as pointers
to memory locations where states of the
respective streams are stored. Since standard FORTRAN 77 does not have
a pointer
type, we can store a pointer as an integer of the same size as a C
pointer. We have defined a macro called SPRNG_POINTER in the file sprng_f.h that
automatically defines an integer of the correct size on
platforms on which SPRNG is supported. A FORTRAN programmer can then
use the type SPRNG_POINTER just as if it were a FORTRAN data
type. However, if the flag -DPOINTERSIZE was used in
building SPRNG FORTRAN executables, then this flag should also be used
in compiling the user's program for this feature to work correctly.
SHAR_EOF
fi # end of overwriting check
if test ! -d 'examples'
then
mkdir 'examples'
fi
cd 'examples'
if test -f '2streams_mpi.c'
then
echo shar: will not over-write existing file "'2streams_mpi.c'"
else
cat << "SHAR_EOF" > '2streams_mpi.c'
/***************************************************************************/
/* ____Demonstrates use of shared and non-shared streams____ */
/* Each process has two streams. One stream is common to all the */
/* processes. The other stream is different on each process. */
/***************************************************************************/
#include
#include /* MPI header file */
/* Uncomment the following line to get the interface with pointer checking */
/*#define CHECK_POINTERS */
#include "sprng.h" /* SPRNG header file */
#define SEED 985456376
main(int argc, char *argv[])
{
int streamnum, commNum, nstreams, *stream, *commonStream;
double rn;
int i, myid, nprocs;
/************************** MPI calls ***********************************/
MPI_Init(&argc, &argv); /* Initialize MPI */
MPI_Comm_rank(MPI_COMM_WORLD, &myid); /* find process id */
MPI_Comm_size(MPI_COMM_WORLD, &nprocs); /* find number of processes */
/****************** Initialization values *******************************/
streamnum = myid; /*This stream is different on each process*/
commNum = nprocs; /* This stream is common to all processes */
nstreams = nprocs + 1; /* extra stream is common to all processes*/
/*********************** Initialize streams *****************************/
/* This stream is different on each process */
stream = init_sprng(streamnum,nstreams,SEED,SPRNG_DEFAULT);
printf("Process %d: Print information about new stream\n", myid);
print_sprng(stream);
/* This stream is identical on each process */
commonStream = init_sprng(commNum,nstreams,SEED,SPRNG_DEFAULT);
printf("Process %d: This stream is identical on all processes\n", myid);
print_sprng(commonStream);
/*********************** print random numbers ***************************/
for (i=0;i<2;i++) /* random numbers from distinct stream */
{
rn = sprng(stream); /* generate double precision random number*/
printf("Process %d, random number (distinct stream) %d: %f\n",
myid, i+1, rn);
}
for (i=0;i<2;i++) /* random number from common stream */
{
rn = sprng(commonStream); /*generate double precision random number */
printf("Process %d, random number (shared stream) %d: %f\n", myid, i+1, rn);
}
/*************************** free memory ********************************/
free_sprng(stream); /* free memory used to store stream state */
free_sprng(commonStream);
MPI_Finalize(); /* terminate MPI */
}
SHAR_EOF
fi # end of overwriting check
if test -f '2streamsf_mpi.F'
then
echo shar: will not over-write existing file "'2streamsf_mpi.F'"
else
cat << "SHAR_EOF" > '2streamsf_mpi.F'
C
C Demonstrates use of shared and non-shared streams
C Each process has two streams. One stream is common to all the
C processes. The other stream is different on each processor.
C
C Uncomment the following line to get the interface with pointer checking
C #define CHECK_POINTERS
program twostreamsf_mpi
implicit none
#include
#include "sprng_f.h"
integer streamnum,commNum, nstreams, seed
SPRNG_POINTER stream, commonStream
real*8 rn
integer i
integer myid, nprocs, ierror
integer junk
call MPI_INIT(ierror)
call MPI_COMM_SIZE(MPI_COMM_WORLD, nprocs, ierror)
call MPI_COMM_RANK(MPI_COMM_WORLD, myid, ierror)
streamnum = myid !This stream is different on each proces
commNum = nprocs !This stream is common to all processes
nstreams = nprocs +1 !extra stream is common to all processes
seed = 985456376
C This stream is different on each process
stream = init_sprng(streamnum,nstreams,seed,SPRNG_DEFAULT)
write(6, 44) myid
44 format("Process", i2, ": Print information about new stream")
junk = print_sprng(stream)
C This stream is identical on each process
commonStream = init_sprng(commNum,nstreams,seed,SPRNG_DEFAULT)
write (6, 55) myid
55 format ("Process", i2,
& ": This stream is identical on all processes")
junk = print_sprng(commonStream)
do 100 i = 1, 2
rn = sprng(stream)
write(6, 66) myid, i, rn
100 continue
do 200 i = 1, 2
rn = sprng(commonStream)
write(6, 77) myid, i, rn
200 continue
66 format("Process", i2,
& ", random number (distinct stream)",i2,": ", f8.6)
77 format("Process", i2, ", random number (shared stream)",
& i2,": ", f8.6)
junk = free_sprng(stream)
junk = free_sprng(commonStream)
call MPI_FINALIZE(ierror)
end
SHAR_EOF
fi # end of overwriting check
if test -f 'checkpoint-simple.c'
then
echo shar: will not over-write existing file "'checkpoint-simple.c'"
else
cat << "SHAR_EOF" > 'checkpoint-simple.c'
/****************************************************************************/
/* ____Demonstrates checkpointing____ */
/* In a new run, this program initializes a random number stream and prints */
/* a few random numbers. Finally it packs the state of the stream into a */
/* file. In a continuation of an old run this program reads in the state of */
/* a stream from a file, prints a few random numbers, and stores the final */
/* state of the stream into a file. */
/****************************************************************************/
#include
#define SIMPLE_SPRNG /* simple interface */
#include "sprng.h" /* SPRNG header file */
#define SEED 985456376
main(int argc, char *argv[])
{
int i, size;
double rn;
FILE *fp;
char buffer[MAX_PACKED_LENGTH], outfile[80], infile[80], *bytes;
/*********************** Initialize streams *******************************/
printf("Enter name of file to store final state of the stream:\n");
scanf("%s", outfile);
printf("Enter name of file to read from:\n\t(enter 9 for a new run)\n");
scanf("%s", infile);
if(infile[0] == '9') /* initialize stream the first time */
init_sprng(SEED,SPRNG_DEFAULT);
else /* read stream state from file afterwards */
{
fp = fopen(infile,"r");
if(fp == NULL)
{
fprintf(stderr,"Could not open file %s for reading\nCheck path or permissions\n", infile);
exit(1);
}
fread(&size,1,sizeof(int),fp);
fread(buffer,1,size,fp);
unpack_sprng(buffer);
fclose(fp);
}
/*********************** print random numbers *****************************/
printf(" Printing 5 random numbers in [0,1): \n");
for(i=0; i<5; i++)
{
rn = sprng(); /* generate a double precision random number */
printf("%d %f\n", i+1, rn);
}
/************************* store stream state *****************************/
size = pack_sprng(&bytes); /* pack stream state into an array */
fp = fopen(outfile,"w"); /* open file to store stream state */
if(fp == NULL)
{
fprintf(stderr,"Could not open file %s for writing\nCheck path or permissions\n", outfile);
exit(1);
}
fwrite(&size,1,sizeof(int),fp); /* store # of bytes required for storage */
fwrite(bytes,1,size,fp); /* store stream state */
fclose(fp);
free(bytes); /* free memory needed to store stream state */
}
SHAR_EOF
fi # end of overwriting check
if test -f 'checkpoint.c'
then
echo shar: will not over-write existing file "'checkpoint.c'"
else
cat << "SHAR_EOF" > 'checkpoint.c'
/****************************************************************************/
/* ____Demonstrates checkpointing____ */
/* In a new run, this program initializes a random number stream and prints */
/* a few random numbers. Finally it packs the state of the stream into a */
/* file. In a continuation of an old run this program reads in the state of */
/* a stream from a file, prints a few random numbers, and stores the final */
/* state of the stream into a file. */
/****************************************************************************/
#include
/* Uncomment the following line to get the interface with pointer checking */
/*#define CHECK_POINTERS */
#include "sprng.h" /* SPRNG header file */
#define SEED 985456376
main(int argc, char *argv[])
{
int *stream, i, size, nstreams, streamnum;
double rn;
FILE *fp;
char buffer[MAX_PACKED_LENGTH], outfile[80], infile[80], *bytes;
/****************** Initialization values *********************************/
streamnum = 0;
nstreams = 1;
/*********************** Initialize streams *******************************/
printf("Enter name of file to store final state of the stream:\n");
scanf("%s", outfile);
printf("Enter name of file to read from:\n\t(enter 9 for a new run)\n");
scanf("%s", infile);
if(infile[0] == '9') /* initialize stream the first time */
stream = init_sprng(streamnum,nstreams,SEED,SPRNG_DEFAULT);
else /* read stream state from file afterwards */
{
fp = fopen(infile,"r");
fread(&size,1,sizeof(int),fp);
fread(buffer,1,size,fp);
stream = unpack_sprng(buffer);
fclose(fp);
}
/*********************** print random numbers *****************************/
printf(" Printing 5 random numbers in [0,1): \n");
for(i=0; i<5; i++)
{
rn = sprng(stream); /* generate double precision random number */
printf("%d %f\n", i+1, rn);
}
/************************* store stream state *****************************/
size = pack_sprng(stream,&bytes); /* pack stream state into an array */
fp = fopen(outfile,"w"); /* open file to store stream state */
if(fp == NULL)
{
fprintf(stderr,"Could not open file %s for writing\nCheck path or permissions\n", outfile);
exit(1);
}
fwrite(&size,1,sizeof(int),fp); /* store # of bytes required for storage */
fwrite(bytes,1,size,fp); /* store stream state */
fclose(fp);
/*************************** free memory **********************************/
free(bytes); /* free memory needed to store stream state */
free_sprng(stream); /* free memory used to store stream state */
}
SHAR_EOF
fi # end of overwriting check
if test -f 'checkpointf-simple.F'
then
echo shar: will not over-write existing file "'checkpointf-simple.F'"
else
cat << "SHAR_EOF" > 'checkpointf-simple.F'
C
C/****************************************************************************/
C/* ____Demonstrates checkpointing____ */
C/* In a new run, this program initializes a random number stream and prints */
C/* a few random numbers. Finally it packs the state of the stream into a */
C/* file. In a continuation of an old run, this program reads in the state of*/
C/* a stream from a file, prints a few random numbers, and stores the final */
C/* state of the stream into a file. */
C/****************************************************************************/
C
C
program checkpointf_simple
implicit none
#define SIMPLE_SPRNG
#include "sprng_f.h"
integer seed, i, size
SPRNG_POINTER stream
real*8 rn
character buffer1(MAX_PACKED_LENGTH), buffer2(MAX_PACKED_LENGTH)
character outfile*7, infile*7, firstChar*1
seed = 985456376
C/*********************** Initialize streams *******************************/
C===========================================
C outfile -- state.X ; infile -- state.X
C===========================================
print*, 'Enter file name(length 7) to store final state:'
read(*, 111) outfile ! 7 characters please
print*, 'Enter file name(length 7) to read from:'
print*, ' (enter 9 for a new run)'
read(*, 112) infile ! 7 characters please
write(firstChar, 113) infile
111 format(A7)
112 format(A7)
113 format(A1)
if (firstChar .eq. '9') then ! initialize stream the first time
stream = init_sprng(seed,SPRNG_DEFAULT)
else ! read stream state from the old file
open(30, file =infile , status = 'old', form = 'unformatted')
read(30) size
read(30) buffer1
stream = unpack_sprng(buffer1)
close(30)
endif
print *, 'Printing 5 random numbers in [0,1):'
do 100 i = 1, 5
rn = sprng()
write(6,150) i, rn
100 continue
150 format(i1, " ", f8.6)
size = pack_sprng(buffer2)
open(31, file = outfile, status = 'unknown',
& form = 'unformatted')
write(31) size
write(31) buffer2
close(31)
end
SHAR_EOF
fi # end of overwriting check
if test -f 'checkpointf.F'
then
echo shar: will not over-write existing file "'checkpointf.F'"
else
cat << "SHAR_EOF" > 'checkpointf.F'
C/****************************************************************************/
C/* ____Demonstrates checkpointing____ */
C/* In a new run, this program initializes a random number stream and prints */
C/* a few random numbers. Finally it packs the state of the stream into a */
C/* file. In a continuation of an old run, this program reads in the state of*/
C/* a stream from a file, prints a few random numbers, and stores the final */
C/* state of the stream into a file. */
C/****************************************************************************/
C
C Uncomment the following line to get the interface with pointer checking
C #define CHECK_POINTERS
program checkpointf
implicit none
#include "sprng_f.h"
integer streamnum, nstreams, seed
SPRNG_POINTER stream
real*8 rn
integer i, size, junk
character buffer1(MAX_PACKED_LENGTH), buffer2(MAX_PACKED_LENGTH)
character outfile*7, infile*7, firstChar*1
streamnum = 0
nstreams = 1
seed = 985456376
C/*********************** Initialize streams *******************************/
C===========================================
C outfile -- state.X ; infile -- state.X
C===========================================
print*, 'Enter file name(length 7) to store final state:'
read(*, 111) outfile ! 7 characters please
print*, 'Enter file name(length 7) to read from:'
print*, ' (enter 9 for a new run)'
read(*, 112) infile ! 7 characters please
write(firstChar, 113) infile
111 format(A7)
112 format(A7)
113 format(A1)
if (firstChar .eq. '9') then ! initialize stream the first time
stream = init_sprng(streamnum,nstreams,seed,SPRNG_DEFAULT)
else ! read stream state from the old file
open(30, file =infile , status = 'old', form = 'unformatted')
read(30) size
read(30) buffer1
stream = unpack_sprng(buffer1)
close(30)
endif
print *, 'Printing 5 random numbers in [0,1): '
do 100 i = 1, 5
rn = sprng(stream)
write(6,150) i, rn
100 continue
150 format(i1, " ", f8.6)
size = pack_sprng(stream, buffer2)
open(31, file = outfile, status = 'unknown',
& form = 'unformatted')
write(31) size
write(31) buffer2
close(31)
junk = free_sprng(stream)
end
SHAR_EOF
fi # end of overwriting check
if test -f 'convert.c'
then
echo shar: will not over-write existing file "'convert.c'"
else
cat << "SHAR_EOF" > 'convert.c'
/***************************************************************************/
/* ____Demonstrates converting code to SPRNG____ */
/* The original random number call is to 'myrandom'. We change it to call */
/* SPRNG by defining a macro. */
/* The lines between the '#ifdef CONVERT' and the '#else' are the
newly added lines. Those lines between the '#else' and the '#endif'
are theoriginal lines that need to be deleted.
*/
/***************************************************************************/
#include
#ifdef CONVERT
#define SIMPLE_SPRNG /* simple interface */
#include "sprng.h" /* SPRNG header file */
#define myrandom sprng /* we define this macro to make SPRNG calls*/
#endif
#define SEED 985456376
double myrandom();
main()
{
int seed, i;
double rn;
#ifdef CONVERT
/************************** Initialization *******************************/
/******* We add the following optional initialization lines **************/
init_sprng(SEED,SPRNG_DEFAULT); /* initialize stream */
printf("Print information about random number stream:\n");
print_sprng();
#else
/* Old initialization lines*/
#endif
/*********************** print random numbers ****************************/
printf("Printing 3 random numbers in [0,1):\n");
for (i=0;i<3;i++)
{
rn = myrandom(); /* generate double precision random number */
printf("%f\n", rn);
}
}
SHAR_EOF
fi # end of overwriting check
if test -f 'convertf.F'
then
echo shar: will not over-write existing file "'convertf.F'"
else
cat << "SHAR_EOF" > 'convertf.F'
C ____Demonstrates converting code to SPRNG____
C
C The original random number call is to 'myrandom'. We change it to
C call SPRNG by defining a macro.
C
C The lines between the '#ifdef CONVERT' and the '#else' are the
C newly added lines. Those lines between the '#else' and the '#endif'
C are theoriginal lines that need to be deleted.
program sprngf_simple
implicit none
#ifdef CONVERT
#define SIMPLE_SPRNG
#include "sprng_f.h"
#define myrandom sprng
SPRNG_POINTER junkPtr
#else
external myrandom
real*8 myrandom
#endif
real*8 rn
integer seed, irn, i, junk
seed = 985456376
#ifdef CONVERT
C initialization
junkPtr = init_sprng(seed,SPRNG_DEFAULT)
print *, 'Printing information about new stream'
junk = print_sprng()
#else
C Old initialization lines
#endif
print *, 'Printing 3 double precision numbers in [0,1): '
do 100 i = 1, 3
rn = myrandom()
print *,i, rn
100 continue
end
SHAR_EOF
fi # end of overwriting check
if test -f 'description.html'
then
echo shar: will not over-write existing file "'description.html'"
else
cat << "SHAR_EOF" > 'description.html'
SPRNG: Scalable Parallel Pseudo-Random Number Generator Library
Examples
1. simple
This program demonstrates the use of
sprng on one processor without explicit initialization.
Note that we have included the SPRNG header file We
have also defined the macro
SIMPLE_SPRNG before including the SPRNG header file in
order to invoke the simple interface.
When sprng is called the first time, it initializes a
default stream using default parameters, since no explicit
initialization has been performed. It then returns double precision random
numbers in [0,1).
Code:
Simple Interface |
Default/Pointer Checking Interface |
C |
FORTRAN |
Not Available |
Compilation: Example compilation on the SGI Power Challenge
cc -64 -I../include -o simple-simple simple-simple.c -L../lib -llcg
Note: -64 indicates the 64 bit compilation available on the
Power Challenge.
cc is the C compiler.
Output:
sprng/EXAMPLES:sif% simple-simple
Printing 3 random numbers in [0,1):
0.580114
0.740295
0.892874
2. sprng
This program demonstrates the use of sprng,
isprng, init_sprng and print_sprng
on one process.
Note that we have included the SPRNG header file.
First we initialize a random number stream. The value of the seed is defined to be
985456376. We call
print_sprng immediately after initialization so that we
can record the particular stream we obtained, for later reference.
sprng is next called to return double precision random
numbers in [0,1) and then isprng is called to return random
integers in [0,231).
Code:
Compilation: Example compilation on the SGI Power Challenge
f77 -DPOINTER_SIZE=8 -64 -I../include -o sprngf sprngf.F -L../lib -llcg
Note: -DPOINTER_SIZE=8 indicates that the pointer size is 8
bytes, rather than the default 4 bytes assumed by SPRNG.
f77 is the FORTRAN 77 compiler.
Output:
sprng/EXAMPLES:sif% sprngf
Print information about new stream:
Linear Congruential Generator
seed = 985456376, prime = 11863279
multiplier = 44485709377909
Printing 3 random numbers in [0,1):
0.707488
0.664048
0.005616
Printing 3 random integers in [0,2^31):
1873949618
1484742006
602016304
3. sprng_mpi
This program demonstrates the use of sprng
with multiple
processes.
Note that we have included the SPRNG and
MPI header files at the beginning.
First we initialize MPI.
We then initialize a random number stream. The value of the seed is defined to be
985456376. We call
print_sprng immediately after initialization so that we
can record the particular stream we obtained, for later reference.
sprng is next called to return double precision random
numbers in [0,1).
Code:
Compilation: Example compilation on the SGI Power Challenge
CC -64 -I../include -o sprng-simple_mpi sprng-simple_mpi.C -L../lib -llcg -L/usr/lib64 -lmpi
Note: CC is the C++ compiler.
Output:
sprng/EXAMPLES:sif% mpirun -np 2 sprng-simple_mpi
Process 0, print information about stream:
Linear Congruential Generator
seed = 985456376, prime = 11863279
multiplier = 44485709377909
Process 0, random number 1: 0.70748766363408
Process 0, random number 2: 0.66404841879710
Process 0, random number 3: 0.00561565119362
Process 1, print information about stream:
Linear Congruential Generator
seed = 985456376, prime = 11863259
multiplier = 44485709377909
Process 1, random number 1: 0.99144237784703
Process 1, random number 2: 0.15098918187292
Process 1, random number 3: 0.09757740755008
Note that the order in which the output is printed may differ.
4. fsprng_mpi
This program demonstrates the use of the single precision
version of sprng
with one stream per
process.
Note that we have included the SPRNG and
MPI header files sprng.h and
mpi.h respectively at the beginning. Before including the
SPRNG header file, we have defined the macro
FLOAT_GEN, which results in single precision random
numbers being
generated by calls to sprng.
First we initialize MPI.
We then initialize a random number stream. The value of the seed is defined to be
985456376. We call
print_sprng immediately after initialization so that we
can record the particular stream we obtained, for later reference.
sprng is next called to return single precision random
numbers in [0,1).
Code:
Compilation: Example compilation on the SGI Power Challenge
f90 -DPOINTER_SIZE=8 -64 -I../include -o fsprngf_mpi fsprngf_mpi.F -L../lib -llcg -L/usr/lib64 -lmpi
Note: f90 is the FORTRAN 90 compiler.
Output:
sprng/EXAMPLES:sif% mpirun -np 2 fsprngf_mpi
Process 0: Print information about stream:
Linear Congruential Generator
seed = 985456376, prime = 11863279
multiplier = 44485709377909
Process 0, random number 1: 0.707488
Process 0, random number 2: 0.664048
Process 0, random number 3: 0.005616
Process 1: Print information about stream:
Linear Congruential Generator
seed = 985456376, prime = 11863259
multiplier = 44485709377909
Process 1, random number 1: 0.991442
Process 1, random number 2: 0.150989
Process 1, random number 3: 0.097577
Note that the order in which the output is printed may differ.
5. seed
This program demonstrates the use of make_sprng_seed on one
processor.
Note that we have included the SPRNG header file at the beginning.
First we initialize a random number stream. The value of a seed is obtained from a call
to
make_sprng_seed and is based on system date and time information. We call
print_sprng immediately after initialization so that we
can record the particular stream we obtained, for later reference.
sprng is next called to return double precision random
numbers in [0,1).
Code:
Compilation: Example compilation on the SGI Power Challenge
cc -64 -I../include -o seed-simple seed-simple.c -L../lib -llcg
Output:
sprng/EXAMPLES:sif% seed-simple
Printing information about new stream
Linear Congruential Generator
seed = 178783069, prime = 11863279
multiplier = 44485709377909
Printing 3 random numbers in [0,1):
0.856970
0.110647
0.795213
6. seed_mpi
This program demonstrates the use of
make_sprng_seed with the MPI version of SPRNG in order to
obtain the same seed in
each process.
Note that we have included the SPRNG and
MPI header files at the beginning. Before including the
SPRNG header file, we have defined the macro
USE_MPI, which enables SPRNG to make MPI calls to ensure
that the same seed is obtained on each process.
First we initialize MPI.
We then initialize a random number stream. The value of the seed is obtained from a call
to
make_sprng_seed. This function makes MPI calls to ensure
that the same seed is returned in each process, assuming that the MPI
version of SPRNG has been installed. We call
print_sprng immediately after initialization so that we
can record the particular stream we obtained, for later reference.
sprng is next called to return double precision random
numbers in [0,1).
Code:
Compilation: Example compilation on the SGI Power Challenge
cc -64 -I../include -o seed-simple_mpi seed-simple_mpi.c -L../lib -llcg -L/usr/lib64 -lmpi
Output:
sprng/EXAMPLES:sif% mpirun -np 2 seed-simple_mpi
Process 0: seed = 837321565
Process 1: seed = 837321565
Process 0: Print information about stream:
Linear Congruential Generator
seed = 837321565, prime = 11863279
multiplier = 44485709377909
process 0, random number 1: 0.732603
process 0, random number 2: 0.753095
process 0, random number 3: 0.084726
Process 1: Print information about stream:
Linear Congruential Generator
seed = 837321565, prime = 11863259
multiplier = 44485709377909
process 1, random number 1: 0.200456
process 1, random number 2: 0.445652
process 1, random number 3: 0.576297
Note that the order in which the output is printed may differ.
7. checkpoint
This program demonstrates the use of
pack_sprng and unpack_sprng for
check-pointing. This
program prints a few random numbers and then stores the state of the
computation in a file. If users wish to continue their computations
from the previous state, then they can have this program read the
state of the computations from this file. The user is first prompted
for the name of the output file. Then the user is asked for the name
of the input file. If the user wishes to start a new run, then he
should enter 9 at this stage, in which case the program
initializes a
random number stream instead of reading it from a file.
Note that we have included the SPRNG header file sprng.h at the beginning.
First we initialize a random number stream, if this is a new run. The value of the seed is defined to be
985456376. We call
print_sprng immediately after initialization so that we
can record the particular stream we obtained, for later reference.
If this is the continuation of a previous run, then we read in the state
of a stream from the input file, and unpack it to obtain a random
number stream.
sprng is next called to return double precision random
numbers in [0,1).
Finally, we pack the state of the stream into an array and store the
contents of this array into the output file.
Code:
Compilation: Example compilation on the SGI Power Challenge
cc -64 -I../include -o checkpoint-simple checkpoint-simple.c -L../lib -llcg
Output:
sprng/EXAMPLES:sif% checkpoint
Enter name of file to store final state of the stream:
temp
Enter name of file to read from:
(enter 9 for a new run)
9
Printing 5 random numbers in [0,1):
1 0.707488
2 0.664048
3 0.005616
4 0.872626
5 0.691387
sprng/EXAMPLES:sif% checkpoint
Enter name of file to store final state of the stream:
temp
Enter name of file to read from:
(enter 9 for a new run)
temp
Printing 5 random numbers in [0,1):
1 0.280336
2 0.005228
3 0.533545
4 0.710482
5 0.891603
8. message_mpi
This program demonstrates the use of
pack_sprng and unpack_sprng
for passing the state of a stream from one processor to another.
Note that we have included the SPRNG and
MPI header files at the beginning.
First we initialize MPI.
We then initialize a random number stream on process 0. The value of the seed is defined to be
985456376. We call
print_sprng immediately after initialization so that we
can record the particular stream we obtained, for later reference.
sprng is next called by process 0 to return double precision random
numbers in [0,1).
Process 0 then packs the state of the stream into an array and sends it
to process 1, which unpacks it and prints a few more random numbers
from that stream. In this process, the original default stream on
process 1 is over-written by the unpacked stream.
Code:
Compilation: Example compilation on the SGI Power Challenge
cc -64 -I../include -o message-simple_mpi message-simple_mpi.c -L../lib -llcg -L/usr/lib64 -lmpi
Output:
sprng/EXAMPLES:sif% mpirun -np 2 message-simple_mpi
Process 0: Print information about stream:
Linear Congruential Generator
seed = 985456376, prime = 11863279
multiplier = 44485709377909
Process 0: Print 2 random numbers in [0,1):
Process 0: 0.707488
Process 0: 0.664048
Process 0 sends stream to process 1
Process 1 has received the packed stream
Process 1: Print information about stream:
Linear Congruential Generator
seed = 985456376, prime = 11863279
multiplier = 44485709377909
Process 1 prints 2 numbers from received stream:
Process 1: 0.005616
Process 1: 0.872626
Note that the order in which the output is printed may differ.
9. 2streams_mpi
This program demonstrates the use of multiple streams on
each process.
Note that we have included the SPRNG and
MPI header files at the beginning.
First we initialize MPI and determine the number of processes and the
rank of the local process.
We then initialize a random number stream. The value of the seed is defined to be
985456376. We shall have two streams per process, but
is only one of these streams will be distinct. The other stream will be
identical on each process. This is useful in situations in which we
would like all the processes to take the same decision based on a
random number. Thus the number of distinct streams is one more than
the total number of processor, resulting in nstreams = nprocs +
1. For the distinct stream on each
process, we initialize it with stream number as the rank of the local
process, myid. The common stream is initialized with the
stream number nprocs.
sprng is next called for each stream. It returns a double precision random
numbers in [0,1) with the stream ID as its argument.
Finally, we free the memory used to store the states of the two streams by
calls to free_sprng.
Code:
Simple Interface |
Default/Pointer Checking Interface |
Not Available |
C |
FORTRAN |
Compilation: Example compilation on the SGI Power Challenge
cc -64 -I../include -o 2streams_mpi 2streams_mpi.c -L../lib -llcg -L/usr/lib64 -lmpi
Output:
sprng/EXAMPLES:sif% mpirun -np 2 2streams_mpi
Process 0: Print information about new stream
Linear Congruential Generator
seed = 985456376, prime = 11863279
multiplier = 44485709377909
Process 0: This stream is identical on all processes
Linear Congruential Generator
seed = 985456376, prime = 11863253
multiplier = 44485709377909
Process 0, random number (distinct stream) 1: 0.707488
Process 0, random number (distinct stream) 2: 0.664048
Process 0, random number (shared stream) 1: 0.700906
Process 0, random number (shared stream) 2: 0.602204
Process 1: Print information about new stream
Linear Congruential Generator
seed = 985456376, prime = 11863259
multiplier = 44485709377909
Process 1: This stream is identical on all processes
Linear Congruential Generator
seed = 985456376, prime = 11863253
multiplier = 44485709377909
Process 1, random number (distinct stream) 1: 0.991442
Process 1, random number (distinct stream) 2: 0.150989
Process 1, random number (shared stream) 1: 0.700906
Process 1, random number (shared stream) 2: 0.602204
Note that the order in which the output is printed may differ.
10. spawn
This program demonstrates the use of spawn_sprng.
Note that we have included the SPRNG header file at the beginning.
First we initialize a random number stream. The value of the seed is defined to be
985456376. Since there is only one stream,
the number of streams nstreams = 1 and the stream number streamnum =
0. stream stores the returned ID of the initialized stream. We call
print_sprng immediately after initialization so that we
can record the particular stream we obtained, for later reference.
sprng is next called to return double precision random
numbers in [0,1), with the stream ID as its argument.
We next spawn two streams from stream. Their ID's are stored in an array
allocated by sprng. The variable new points to this
array. We print information about the newly spawned streams, and then
print a few random numbers from the second stream spawned.
Finally, we free the memory used to store the states of the streams by
calls to free_sprng.
Code:
Simple Interface |
Default/Pointer Checking Interface |
Not Available |
C |
FORTRAN |
Compilation: Example compilation on the SGI Power Challenge
cc -64 -I../include -o spawn spawn.c -L../lib -llcg
Output:
sprng/EXAMPLES:sif% spawn
Print information about stream:
Linear Congruential Generator
seed = 985456376, prime = 11863279
multiplier = 44485709377909
Printing 2 random numbers in [0,1):
0.707488
0.664048
Spawned two streams
Information on first spawned stream:
Linear Congruential Generator
seed = 985456376, prime = 11863259
multiplier = 44485709377909
Information on second spawned stream:
Linear Congruential Generator
seed = 985456376, prime = 11863253
multiplier = 44485709377909
Printing 2 random numbers from second spawned stream:
0.700906
0.602204
11. invalid_ID
This program demonstrates the handling of invalid pointers in the
interface with pointer checking.
Note that we have included the SPRNG header file sprng.h at the beginning. We
have also defined the macro
CHECK_POINTERS before including the SPRNG header file in
order to invoke the interface with pointer checking.
First we initialize a random number stream. The value of the seed is defined to be
985456376. Since there is only one stream,
the number of streams nstreams = 1 and the stream number streamnum =
0. stream stores the returned ID of the initialized stream. We call
print_sprng immediately after initialization so that we
can record the particular stream we obtained, for later reference.
sprng is next called to return double precision random
numbers in [0,1), with the stream ID as its argument.
Finally, we free the memory used to store the state of the stream by a
call to free_sprng.
we then try to use the freed stream again, which is an incorrect
usage. sprng returns -1.0 due to the invalid
stream being passed as an argument.
Code:
Simple Interface |
Pointer Checking Interface |
Not Available |
C |
FORTRAN |
Compilation: Example compilation on the SGI Power Challenge
cc -64 -I../include -o invalid_ID invalid_ID.c -L../lib -llcg
Output:
sprng/EXAMPLES:sif% invalid_ID
Print information about random number stream:
Linear Congruential Generator
seed = 985456376, prime = 11863279
multiplier = 44485709377909
Printing 3 random numbers in [0,1):
0.707488
0.664048
0.005616
Expect a SPRNG error message on the use of an invalid stream ID
ERROR: Invalid generator ID 10014ed8
sprng returns -1.000000 on being given an invalid stream ID
Note that the incorrect ID, 10017258, may vary.
12. convert
This program demonstrates converting user code to call SPRNG
instead of the original random number generator myrandom.
Note that we have included the SPRNG header file at the beginning. We
have also defined the macro
SIMPLE_SPRNG before including the SPRNG header file in
order to invoke the simple interface. We define the macro
myrandom to sprng after
including the SPRNG header. This replaces the former function call by
calls to SPRNG instead.
We then add statements to initialize SPRNG.
Code:
Simple Interface |
Default/Pointer Checking Interface |
C |
FORTRAN |
Not Available |
Compilation: Example compilation on the SGI Power Challenge
cc -64 -I../include convert.c -L../lib -llcg
Note: In the code provided with SPRNG, users need to define the macro
CONVERT in order to get this converted code.
Output:
sprng/EXAMPLES:sif% a.out
Print information about random number stream:
Linear Congruential Generator
seed = 985456376, prime = 11863279
multiplier = 44485709377909
Printing 3 random numbers in [0,1):
0.707488
0.664048
0.005616
13. subroutine
This program demonstrates the use of SPRNG in
subroutines in FORTRAN programs.
Note that we have included the SPRNG header file sprng_f.h at the
beginning. We have also included this header file in the subroutine
sub1. If we wished to define a macro for use by SPRNG, we
need only do it once in any file, before the first time a SPRNG
header is included.
Subroutine sub1 is then called, which makes calls to sprng.
Code:
Simple Interface |
Default/Pointer Checking Interface |
Not Available |
FORTRAN |
Compilation: Example compilation on the SGI Power Challenge
f77 -64 -I../include -DPOINTER_SIZE=8 subroutinef.F -L../lib -llcg
Output:
sprng/EXAMPLES:sif% a.out
Printing information about new stream
Linear Congruential Generator
seed = 985456376, prime = 11863279
multiplier = 44485709377909
Printing 3 double precision numbers in [0,1):
1 0.7074876636340832
2 0.6640484187971047
3 0.0056156511936152
14. pi-simple
This is a serial program that demonstrates the use of several SPRNG features in a
simple example application involving the computation of PI
through a Monte Carlo method. We generate random points on a square of
side 2 which circumscribes a circle of unit radius. We determine the
proportion of points that fall within this circle. Since the ratio of
the area of the circle to the area of the square is PI/4, the
estimated value of PI is four times the proportion of points
that lie within the circle.
The user specifies the number of samples to be generated on the
square. The final state of the computations is stored in a file
specified by the user. The user can restart the computations by
reading from this file in subsequent runs. The user should also
specify whether the current run is a new one (in which case a new
random number stream is initialized) or an old one (in which case the
state of the random number stream is read from a file).
Note that we have included the SPRNG header file at the beginning. We
have also defined the macro
SIMPLE_SPRNG before including the SPRNG header file in
order to invoke the simple interface.
The function initialize is then called to take suitable
actions based on the information input by the user. A new run involves initializing a random number
stream. In a continuation of a previous run, the state of the random number stream is
read from a file whose name is input by the user. The final state of
the computations is also written into this file. The user should
also input the number of samples to be generated in this run. In a
new run, make_sprng_seed is called to produce a seed
based on system date and time information.
Next the function count_in_circle is called, which
generates points on a square of side 2. The number of
points that fall on a circle of unit radius inscribed within this
square is returned by this function.
We then estimate PI as four times the proportion of points that fall
within the circle inscribed in the square.
Finally we call the function save_state to save the state
of the random number stream, the cumulative number of sample points
generated in all the runs, and the cumulative number of sample points
that lie within the inscribed circle in all the runs.
Code:
Compilation: Example compilation on the SGI Power Challenge
cc -64 -I../include -o pi-simple pi-simple.c -L../lib -llcg
Output:
sprng/EXAMPLES:sif% pi-simple
Enter 9 for a new run, or 2 for the continuation of an old run:
9
Enter name of file to store final state of the stream:
temp
Enter number of new samples:
10000
Linear Congruential Generator
seed = 437891907, prime = 11863279
multiplier = 44485709377909
pi is estimated as 3.1227999999999998 from 10000 samples.
Error = 0.0187927, standard error = 0.0164218
sprng/EXAMPLES:sif% pi-simple
Enter 9 for a new run, or 2 for the continuation of an old run:
2
Enter name of file to store final state of the stream:
temp
Enter number of new samples:
5000
pi is estimated as 3.1165333333333334 from 15000 samples.
Error = 0.0250593, standard error = 0.0134084
Note: Results may vary due to the use of a random seed.
15. pi-simple_mpi
This is a parallel version of is a parallel version of pi-simple in which we divide the work of generating the
samples among the available processes.
First we initialize MPI and call the function initialize
to initialize a random number stream. If this is the continuation of a
previously checkpointed run, then process 0 reads the previous state
and passes to to each process.
Next we divide the number of samples to be generated among all the
processes and then call the function count_in_circle as
in the sequential case. We then sum the number of points that fall within the circle across
all the processes by a call to MPI_REDUCE and estimate PI as four times the proportion of points that fall
within this circle inscribed in the square.
Finally we call the function save_state to save the state
of the random number stream, the cumulative number of sample points
generated in all the runs, and the cumulative number of sample points
that lie within the inscribed circle in all the runs. Each process
passes the state of its stream to process 0, which then saves it to a file.
Code:
Compilation: Example compilation on the SGI Power Challenge
cc -64 -I../include -o pi-simple pi-simple.c -L../lib -llcg
Compilation: Example compilation on the SGI Power Challenge
cc -64 -I../include -o pi-simple_mpi pi-simple_mpi.c -L../lib -llcg -L/usr/lib64 -lmpi
Output:
sprng/EXAMPLES:sif% mpirun -np 2 pi-simple_mpi
Enter 9 for a new run, or 2 for the continuation of an old run:
9
Enter name of file to store final state of the stream:
temp
Enter number of new samples:
5000
Linear Congruential Generator
Linear Congruential Generator
seed = 42578755, prime = 11863279
multiplier = 44485709377909
seed = 42578755, prime = 11863259
multiplier = 44485709377909
pi is estimated as 3.1568000000000001 from 5000 samples.
Error = 0.0152073, standard error = 0.023224
Note: Results may vary due to the use of a random seed.
Ashok Srinivasan
ashoks@ncsa.uiuc.edu
Last modified: 1 Apr, 1997
SHAR_EOF
fi # end of overwriting check
if test -f 'fsprng-simple_mpi.c'
then
echo shar: will not over-write existing file "'fsprng-simple_mpi.c'"
else
cat << "SHAR_EOF" > 'fsprng-simple_mpi.c'
/***************************************************************************/
/* ____Demonstrates use of the single precision generator____ */
/* One stream is maintained per processor. Each processor prints a few */
/* single precision random numbers. */
/***************************************************************************/
#include
#include /* MPI header file */
#define SIMPLE_SPRNG /* simple interface */
#define USE_MPI /* use MPI to find number of processes */
#define FLOAT_GEN /* make 'sprng()' return single precision numbers*/
#include "sprng.h" /* SPRNG header file */
#define SEED 985456376
main(int argc, char *argv[])
{
int i, myid;
float rn;
/************************** MPI calls ***********************************/
MPI_Init(&argc, &argv); /* Initialize MPI */
MPI_Comm_rank(MPI_COMM_WORLD, &myid); /* find process id */
/*********************** Initialize streams *****************************/
init_sprng(SEED,SPRNG_DEFAULT); /* initialize stream */
printf("Process %d: Print information about stream:\n",myid);
print_sprng();
/*********************** print random numbers ***************************/
for (i=0;i<3;i++)
{
rn = sprng(); /*generate single precision random number */
printf("Process %d, random number %d: %f\n", myid, i+1, rn);
}
MPI_Finalize(); /* Terminate MPI */
}
SHAR_EOF
fi # end of overwriting check
if test -f 'fsprng_mpi.c'
then
echo shar: will not over-write existing file "'fsprng_mpi.c'"
else
cat << "SHAR_EOF" > 'fsprng_mpi.c'
/***************************************************************************/
/* ____Demonstrates use of the single precision generator____ */
/* One stream is maintained per processor. Each processor prints a few */
/* single precision random numbers. */
/***************************************************************************/
#include
#include /* MPI header file */
/* Uncomment the following line to get the interface with pointer checking */
/*#define CHECK_POINTERS */
#define FLOAT_GEN /* make 'sprng()' return single precision numbers*/
#include "sprng.h" /* SPRNG header file */
#define SEED 985456376
main(int argc, char *argv[])
{
int streamnum, nstreams, *stream;
float rn;
int i, myid, nprocs;
/************************** MPI calls ************************************/
MPI_Init(&argc, &argv); /* Initialize MPI */
MPI_Comm_rank(MPI_COMM_WORLD, &myid); /* find process id */
MPI_Comm_size(MPI_COMM_WORLD, &nprocs); /* find number of processes */
/************************* Initialization ********************************/
streamnum = myid;
nstreams = nprocs; /* one stream per processor */
stream = init_sprng(streamnum,nstreams,SEED,SPRNG_DEFAULT); /*initialize stream*/
printf("Process %d: Print information about stream:\n",myid);
print_sprng(stream);
/*********************** print random numbers ****************************/
for (i=0;i<3;i++)
{
rn = sprng(stream); /* generate single precision random number */
printf("Process %d, random number %d: %f\n", myid, i+1, rn);
}
/*************************** free memory *********************************/
free_sprng(stream); /* free memory used to store stream state */
MPI_Finalize(); /* Terminate MPI */
}
SHAR_EOF
fi # end of overwriting check
if test -f 'fsprngf-simple_mpi.F'
then
echo shar: will not over-write existing file "'fsprngf-simple_mpi.F'"
else
cat << "SHAR_EOF" > 'fsprngf-simple_mpi.F'
C
C Demonstrates use of the single precision generator
C One stream is maintained per processor. Each processor prints a few
C single precision random numbers.
C
program fsprngf_simple_mpi
implicit none
#define SIMPLE_SPRNG ! simple interface */
#define USE_MPI ! use MPI to find number of processes */
#define FLOAT_GEN 1 ! make 'sprng()' return single precision numbers
#include
#include "sprng_f.h"
SPRNG_POINTER stream
real*4 rn
integer i, seed, myid, ierror, junk
call MPI_INIT(ierror)
call MPI_COMM_RANK(MPI_COMM_WORLD, myid, ierror)
seed = 985456376
C
stream = init_sprng(seed,SPRNG_DEFAULT)
write(*, "('Process',i2,': Print information about stream:')"
& ) myid
junk = print_sprng()
do 100 i = 1, 3
rn = sprng()
write(*, "('Process',i2,', random number',i2,': ',f8.6)")
& myid,i,rn
100 continue
call MPI_FINALIZE(ierror)
end
SHAR_EOF
fi # end of overwriting check
if test -f 'fsprngf_mpi.F'
then
echo shar: will not over-write existing file "'fsprngf_mpi.F'"
else
cat << "SHAR_EOF" > 'fsprngf_mpi.F'
C
C Demonstrates use of the single precision generator
C One stream is maintained per processor. Each processor prints a few
C single precision random numbers.
C
C Uncomment the following line to get the interface with pointer checking
C #define CHECK_POINTERS
program fsprngf_mpi
implicit none
#define FLOAT_GEN 1 ! make 'sprng()' return single precision numbers
#include
#include "sprng_f.h"
integer streamnum, nstreams, seed
SPRNG_POINTER stream
real*4 rn
integer i, myid, nprocs, ierror, junk
call MPI_INIT(ierror)
call MPI_COMM_SIZE(MPI_COMM_WORLD, nprocs, ierror)
call MPI_COMM_RANK(MPI_COMM_WORLD, myid, ierror)
streamnum = myid
nstreams = nprocs
seed = 985456376
C
stream = init_sprng(streamnum,nstreams,seed,SPRNG_DEFAULT)
write(*, "('Process',i2,': Print information about stream:')"
& ) myid
junk = print_sprng(stream)
do 100 i = 1, 3
rn = sprng(stream)
write(*, "('Process',i2,', random number',i2,': ',f8.6)")
& myid,i,rn
100 continue
junk = free_sprng(stream)
call MPI_FINALIZE(ierror)
end
SHAR_EOF
fi # end of overwriting check
if test -f 'invalid_ID.c'
then
echo shar: will not over-write existing file "'invalid_ID.c'"
else
cat << "SHAR_EOF" > 'invalid_ID.c'
/****************************************************************************/
/* ___Demonstrates invalid ID handling in inteface with pointer checking___ */
/* This prorgam prints a few random numbers, frees the stream, and then */
/* tries to use the stream again. */
/****************************************************************************/
#include
#ifndef CHECK_POINTERS
#define CHECK_POINTERS /* do not uncomment this line */
#endif
#include "sprng.h" /* SPRNG header file */
#define SEED 985456376
main()
{
int streamnum, nstreams, *stream;
double rn;
int i;
/**************************** Initialize *********************************/
streamnum = 0;
nstreams = 1;
stream = init_sprng(streamnum,nstreams,SEED,SPRNG_DEFAULT); /*initialize stream */
printf("Print information about random number stream:\n");
print_sprng(stream);
/*********************** print random numbers *****************************/
printf("Printing 3 random numbers in [0,1):\n");
for (i=0;i<3;i++)
{
rn = sprng(stream); /* generate a double precision random number */
printf("%f\n", rn);
}
/**************************** free memory *********************************/
free_sprng(stream); /* free memory used to store stream state */
/********************** Try using freed stream ****************************/
fprintf(stderr,"Expect a SPRNG error message on the use of an invalid stream ID\n");
rn = sprng(stream);
printf("sprng returns %f on being given an invalid stream ID\n", rn);
}
SHAR_EOF
fi # end of overwriting check
if test -f 'invalid_IDf.F'
then
echo shar: will not over-write existing file "'invalid_IDf.F'"
else
cat << "SHAR_EOF" > 'invalid_IDf.F'
C
C Demonstrates invalid ID handling in inteface with pointer checking
C This prorgam prints a few random numbers, frees the stream, and then
C tries to use the stream again.
C
C do not uncomment the following line
#ifndef CHECK_POINTERS
#define CHECK_POINTERS
#endif
program invalid_IDf
implicit none
#include "sprng_f.h"
integer streamnum, nstreams, seed, i, junk
SPRNG_POINTER stream
real*8 rn
streamnum = 0
nstreams = 1
seed = 985456376
C initialize stream
stream = init_sprng(streamnum,nstreams,seed,SPRNG_DEFAULT)
print *, 'Printing information about new stream'
junk = print_sprng(stream)
print *, 'Printing 3 double precision numbers [0,1): '
do 100 i = 1, 3
rn = sprng(stream)
print *, rn
100 continue
junk = free_sprng(stream)
C print *, ' Expect a SPRNG error message on the use of an invalid stream ID '
rn = sprng(stream)
print *, ' sprng returns ', rn,
& ' on being given an invalid stream ID'
end
SHAR_EOF
fi # end of overwriting check
if test -f 'message-simple_mpi.c'
then
echo shar: will not over-write existing file "'message-simple_mpi.c'"
else
cat << "SHAR_EOF" > 'message-simple_mpi.c'
/***************************************************************************/
/* ____Demonstrates passing a stream to another process____ */
/* Process 0 initializes a random number stream and prints a few random */
/* numbers. It then passes this stream to process 1, which recieves it */
/* and prints a few random numbers from this stream. */
/***************************************************************************/
#include
#include
#include /* MPI header file */
#define SIMPLE_SPRNG /* simple interface */
#include "sprng.h" /* SPRNG header file */
#define SEED 985456376
main(int argc, char *argv[])
{
double rn;
int i, myid, len, nprocs;
MPI_Status status;
char *packed;
/************************** MPI calls ************************************/
MPI_Init(&argc, &argv); /* Initialize MPI */
MPI_Comm_rank(MPI_COMM_WORLD, &myid); /* find process id */
MPI_Comm_size(MPI_COMM_WORLD, &nprocs); /* find number of processes */
if(nprocs < 2)
{
fprintf(stderr,"ERROR: At least 2 processes required\n");
MPI_Finalize();
exit(1);
}
if (myid==0) /*********** process 0 sends stream to process 1 ***********/
{
init_sprng(SEED,SPRNG_DEFAULT); /*initialize stream */
printf("Process %d: Print information about stream:\n",myid);
print_sprng();
printf("Process %d: Print 2 random numbers in [0,1):\n", myid);
for (i=0;i<2;i++)
{
rn = sprng(); /* generate double precision random number */
printf("Process %d: %f\n", myid, rn);
}
len = pack_sprng(&packed); /* pack stream into an array */
/* inform process 1 how many bytes process 0 will send. */
MPI_Send(&len, 1, MPI_INT, 1, 0, MPI_COMM_WORLD);
MPI_Send(packed, len, MPI_BYTE, 1, 0, MPI_COMM_WORLD); /* send stream */
free(packed); /* free storage for array */
printf(" Process 0 sends stream to process 1\n");
}
else if(myid == 1) /****** process 1 receives stream from process 0 *****/
{
init_sprng(SEED,SPRNG_DEFAULT); /*initialize stream */
MPI_Recv(&len, 1, MPI_INT, 0, MPI_ANY_TAG,
MPI_COMM_WORLD, &status); /* receive buffer size required */
if ((packed = (char *) malloc(len)) == NULL) /* allocate array */
{
fprintf(stderr,"ERROR: process %d: Cannot allocate memory\n", myid);
MPI_Finalize();
exit(1);
}
MPI_Recv(packed, len, MPI_BYTE, 0, MPI_ANY_TAG,
MPI_COMM_WORLD, &status); /* receive packed stream */
unpack_sprng(packed); /* unpack stream */
printf(" Process 1 has received the packed stream\n");
printf("Process %d: Print information about stream:\n",myid);
print_sprng();
free(packed); /* free array of packed stream */
printf(" Process 1 prints 2 numbers from received stream:\n");
for (i=0;i<2;i++)
{
rn = sprng(); /* generate double precision random number */
printf("Process %d: %f\n", myid, rn);
}
}
MPI_Finalize(); /* terminate MPI */
}
SHAR_EOF
fi # end of overwriting check
if test -f 'message_mpi.c'
then
echo shar: will not over-write existing file "'message_mpi.c'"
else
cat << "SHAR_EOF" > 'message_mpi.c'
/***************************************************************************/
/* ____Demonstrates passing a stream to another process____ */
/* Process 0 initializes a random number stream and prints a few random */
/* numbers. It then passes this stream to process 1, which recieves it */
/* and prints a few random numbers from this stream. */
/***************************************************************************/
#include
#include
#include /* MPI header file */
/* Uncomment the following line to get the interface with pointer checking */
/*#define CHECK_POINTERS */
#include "sprng.h" /* SPRNG header file */
#define SEED 985456376
main(int argc, char *argv[])
{
int streamnum, nstreams, *stream;
double rn;
int i, myid, nprocs, len;
MPI_Status status;
char *packed;
/************************** MPI calls ************************************/
MPI_Init(&argc, &argv); /* Initialize MPI */
MPI_Comm_rank(MPI_COMM_WORLD, &myid); /* find process id */
MPI_Comm_size(MPI_COMM_WORLD, &nprocs); /* find number of processes */
if(nprocs < 2)
{
fprintf(stderr,"ERROR: At least 2 processes required\n");
MPI_Finalize();
exit(1);
}
if (myid==0) /*********** process 0 sends stream to process 1 **********/
{
streamnum = 0;
nstreams = 1;
stream = init_sprng(streamnum,nstreams,SEED,SPRNG_DEFAULT);/*initialize stream*/
printf("Process %d: Print information about stream:\n",myid);
print_sprng(stream);
printf("Process %d: Print 2 random numbers in [0,1):\n", myid);
for (i=0;i<2;i++)
{
rn = sprng(stream); /* generate double precision random number */
printf("Process %d: %f\n", myid, rn);
}
len = pack_sprng(stream, &packed); /* pack stream into an array */
/* inform process 1 how many bytes process 0 will send. */
MPI_Send(&len, 1, MPI_INT, 1, 0, MPI_COMM_WORLD);
MPI_Send(packed, len, MPI_BYTE, 1, 0, MPI_COMM_WORLD); /* send stream */
free(packed); /* free storage for array */
nstreams = free_sprng(stream);
printf(" Process 0 sends stream to process 1\n");
printf(" %d generators now exist on process 0\n", nstreams);
}
else if(myid == 1) /***** process 1 receives stream from process 0 ******/
{
MPI_Recv(&len, 1, MPI_INT, 0, MPI_ANY_TAG,
MPI_COMM_WORLD, &status); /* receive buffer size required */
if ((packed = (char *) malloc(len)) == NULL) /* allocate array */
{
fprintf(stderr,"ERROR: process %d: Cannot allocate memory\n", myid);
MPI_Finalize();
exit(1);
}
MPI_Recv(packed, len, MPI_BYTE, 0, MPI_ANY_TAG,
MPI_COMM_WORLD, &status); /* receive packed stream */
stream = unpack_sprng(packed); /* unpack stream */
printf(" Process 1 has received the packed stream\n");
printf("Process %d: Print information about stream:\n",myid);
print_sprng(stream);
free(packed); /* free array of packed stream */
printf(" Process 1 prints 2 numbers from received stream:\n");
for (i=0;i<2;i++)
{
rn = sprng(stream); /* generate double precision random number */
printf("Process %d: %f\n", myid, rn);
}
free_sprng(stream); /* free memory used to store stream state */
}
MPI_Finalize(); /* terminate MPI */
}
SHAR_EOF
fi # end of overwriting check
if test -f 'messagef-simple_mpi.F'
then
echo shar: will not over-write existing file "'messagef-simple_mpi.F'"
else
cat << "SHAR_EOF" > 'messagef-simple_mpi.F'
C
C Demonstrates passing a stream to another process
C Process 0 initializes a random number stream and prints a few random
C numbers. It then passes this stream to process 1, which recieves it
C and prints a few random numbers from this stream.
program messagef_simple_mpi
implicit none
#define SIMPLE_SPRNG
#include
#include "sprng_f.h"
integer seed,i,myid, nprocs, ierror, len, junk
integer status(MPI_STATUS_SIZE)
SPRNG_POINTER junkPtr
real*8 rn
integer packed(MAX_PACKED_LENGTH)
call MPI_INIT(ierror)
call MPI_COMM_SIZE(MPI_COMM_WORLD, nprocs, ierror)
call MPI_COMM_RANK(MPI_COMM_WORLD, myid, ierror)
if (nprocs .lt. 2) then
print *, 'ERROR: At least 2 processes required'
call MPI_FINALIZE(ierror)
call exit(1)
endif
seed = 985456376
if (myid .eq. 0) then
junkPtr = init_sprng(seed,SPRNG_DEFAULT)
write(6,"('Process',i2,': Print information about stream:')")
& myid
junk = print_sprng()
write(6,"('Process',i2,': Print 2 random numbers in [0,1):')")
& myid
do 100 i = 1, 2
rn = sprng()
write(6, "('Process',i2, ': ', f8.6)") myid, rn
100 continue
len = pack_sprng(packed)
! inform process 1 how many bytes process 0 will send.
call MPI_SEND(len, 1, MPI_INTEGER, 1, 0, MPI_COMM_WORLD,
& ierror)
call MPI_SEND(packed, len, MPI_INTEGER, 1, 0, MPI_COMM_WORLD,
& ierror)
print*, 'Process 0 sends stream to process 1'
elseif (myid .eq. 1) then
junkPtr = init_sprng(seed,SPRNG_DEFAULT)
call MPI_RECV(len, 1, MPI_INTEGER, 0, MPI_ANY_TAG,
& MPI_COMM_WORLD,status, ierror)
call MPI_RECV(packed, len, MPI_INTEGER, 0, MPI_ANY_TAG,
& MPI_COMM_WORLD, status, ierror)
junkPtr = unpack_sprng(packed)
print *, 'Process 1 has received the packed stream'
write(6,"('Process',i2,': Print information about stream:')")
& myid
junk = print_sprng()
print *, 'Process 1 prints 2 numbers from received stream:'
do 200 i = 1, 2
rn = sprng()
write(6, "('Process', i2, ': ', f8.6)") myid, rn
200 continue
endif
call MPI_FINALIZE(ierror)
end
SHAR_EOF
fi # end of overwriting check
if test -f 'messagef_mpi.F'
then
echo shar: will not over-write existing file "'messagef_mpi.F'"
else
cat << "SHAR_EOF" > 'messagef_mpi.F'
C
C Demonstrates passing a stream to another process
C Process 0 initializes a random number stream and prints a few random
C numbers. It then passes this stream to process 1, which recieves it
C and prints a few random numbers from this stream.
C
C Uncomment the following line to get the interface with pointer checking
C #define CHECK_POINTERS
program messagef_mpi
implicit none
#include
#include "sprng_f.h"
integer seed,i,myid, nprocs, len, junk
integer streamnum, nstreams, ierror
SPRNG_POINTER stream
real*8 rn
integer status(MPI_STATUS_SIZE)
integer packed(MAX_PACKED_LENGTH)
call MPI_INIT(ierror)
call MPI_COMM_SIZE(MPI_COMM_WORLD, nprocs, ierror)
call MPI_COMM_RANK(MPI_COMM_WORLD, myid, ierror)
if (nprocs .lt. 2) then
print *, 'ERROR: At least 2 processes required'
call MPI_FINALIZE(ierror)
call exit(1)
endif
if (myid .eq. 0) then
streamnum = 0 ! process 0 sends stream to process 1
nstreams = 1
seed = 985456376
C
stream = init_sprng(streamnum,nstreams,seed,SPRNG_DEFAULT)
write(6,"('Process',i2,': Print information about stream:')")
& myid
junk = print_sprng(stream)
write(6,"('Process',i2,': Print 2 random numbers in [0,1):')")
& myid
do 100 i = 1, 2
rn = sprng(stream)
write(6, "('Process', i2, ': ', f8.6)") myid, rn
100 continue
len = pack_sprng(stream, packed)
! inform process 1 how many bytes process 0 will send.
call MPI_SEND(len,1,MPI_INTEGER,1,0,MPI_COMM_WORLD,ierror)
call MPI_SEND(packed,len,MPI_INTEGER,1,0,
& MPI_COMM_WORLD,ierror)
nstreams = free_sprng(stream)
print*, 'Process 0 sends stream to process 1'
write(6,"(i2,' generators now exist on process 0')")nstreams
elseif (myid .eq. 1) then
call MPI_RECV(len,1,MPI_INTEGER,0,MPI_ANY_TAG,MPI_COMM_WORLD,
& status, ierror)
call MPI_RECV(packed,len,MPI_INTEGER,0,MPI_ANY_TAG,
& MPI_COMM_WORLD,status, ierror)
stream = unpack_sprng(packed)
print *, 'Process 1 has received the packed stream'
write(6, 250) myid
250 format('Process',i2,': Print information about stream:')
junk = print_sprng(stream)
print *, 'Process 1 prints 2 numbers from received stream:'
do 200 i = 1, 2
rn = sprng(stream)
write(6, "('Process', i2, ': ', f8.6)") myid, rn
200 continue
junk = free_sprng(stream)
endif
call MPI_FINALIZE(ierror)
end
SHAR_EOF
fi # end of overwriting check
if test -f 'myrandom.c'
then
echo shar: will not over-write existing file "'myrandom.c'"
else
cat << "SHAR_EOF" > 'myrandom.c'
#include
#include
double myrandom_() /* remove _ before C compilation */
{
return (double) rand()/RAND_MAX;
}
SHAR_EOF
fi # end of overwriting check
if test -f 'pi-simple.c'
then
echo shar: will not over-write existing file "'pi-simple.c'"
else
cat << "SHAR_EOF" > 'pi-simple.c'
/***************************************************************************/
/* ____Demonstrates SPRNG use for Monte Carlo integration____ */
/* Compute pi using Monte Carlo integration. Random points are generated */
/* in a square of size 2. The value of pi is estimated as four times the */
/* the proportion of samples that fall within a circle of unit radius. */
/***************************************************************************/
#include
#include
#include
#define SIMPLE_SPRNG /* simple interface */
#include "sprng.h"
#define EXACT_PI 3.141592653589793238462643
main(argc,argv)
int argc;
char *argv[];
{
int in, n, in_old, n_old;
double pi, error, stderror, p=EXACT_PI/4.0;
char filename[80];
initialize(&n, &in_old, &n_old, filename); /* read args & initialize */
in = count_in_circle(n); /* count samples in circle */
in += in_old; /* # in circle, in all runs */
n += n_old; /* # of samples, in all runs */
pi = (4.0*in)/n; /* estimate pi */
error = fabs(pi - EXACT_PI); /* determine error */
stderror = 4*sqrt(p*(1.0-p)/n); /* standard error */
printf( "pi is estimated as %18.16f from %12d samples.\n", pi, n);
printf( "\tError = %10.8g, standard error = %10.8g\n", error, stderror);
save_state(filename, in, n); /* check-point final state */
}
int count_in_circle(n) /* count # of samples in circle */
int n;
{
int i, in;
double x, y;
for (i=in=0; i 'pi-simple_mpi.c'
/***************************************************************************/
/* ____Demonstrates SPRNG use for Monte Carlo integration____ */
/* Compute pi using Monte Carlo integration. Random points are generated */
/* in a square of size 2. The value of pi is estimated as four times the */
/* the proportion of samples that fall within a circle of unit radius. */
/* The final state of the computations is check-pointed at the end, so the */
/* the calculations can be continued from the previous state. However, the */
/* same number of processors should be used as in the previous run. */
/***************************************************************************/
#include
#include
#include
#include "mpi.h"
#define SIMPLE_SPRNG /* simple interface */
#define USE_MPI /* MPI version of SPRNG */
#include "sprng.h"
#define EXACT_PI 3.141592653589793238462643
#define RECV_STREAM_TAG 1
main(argc,argv)
int argc;
char *argv[];
{
int in, i, seed, n, my_n, in_old, n_old, nprocs, myid, temp;
double pi, error, stderror, p=EXACT_PI/4.0;
char filename[80];
/*************************** Initialization ******************************/
MPI_Init(&argc,&argv); /* Initialize MPI */
MPI_Comm_size(MPI_COMM_WORLD,&nprocs); /* Find number of processes */
MPI_Comm_rank(MPI_COMM_WORLD,&myid); /* Find rank of process */
initialize(&n, &in_old, &n_old, filename); /* read args & initialize */
my_n = n/nprocs; /* number of samples for this process */
if(myid < n%nprocs)
my_n++;
/******************** Count number of samples in circle ******************/
temp = count_in_circle(my_n); /* count samples in circle */
/* sum # in circle over all processes */
MPI_Reduce(&temp, &in, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
/*************************** Determine Pi ********************************/
if(myid == 0)
{
in += in_old; /* # in circle, in all runs */
n += n_old; /* # of samples, in all runs */
pi = (4.0*in)/n; /* estimate pi */
error = fabs(pi - EXACT_PI); /* determine error */
stderror = 4*sqrt(p*(1.0-p)/n); /* standard error */
printf( "pi is estimated as %18.16f from %12d samples.\n", pi, n);
printf( "\tError = %10.8g, standard error = %10.8g\n", error, stderror);
}
/*************************** Save final state ****************************/
save_state(filename,in,n); /* save final state of computation*/
MPI_Finalize(); /* Terminate MPI */
}
int count_in_circle(n) /* count # of samples in circle */
int n;
{
int i, in;
double x, y;
for (i=in=0; i 'pif-simple.F'
C/***************************************************************************/
C/* ____Demonstrates SPRNG use for Monte Carlo integration____ */
C/* Compute pi using Monte Carlo integration. Random points are generated */
C/* in a square of size 2. The value of pi is estimated as four times */
C/* the proportion of samples that fall within a circle of unit radius. */
C/***************************************************************************/
program pif_simple
implicit none
#define SIMPLE_SPRNG ! simple interface
#include "sprng_f.h"
integer in, n, in_old, n_old, count_in_circle
real*8 pi, error, stderror, p, EXACT_PI
character filename*7
EXACT_PI = 3.141592653589793238462643
p = EXACT_PI/4.0
C-- initialization: to initialize n, in_old, n_old, and filename
call initialize(n, in_old, n_old, filename)
in = count_in_circle(n) ! count samples in circle
in = in + in_old ! # in circle, in all runs
n = n + n_old ! # of samples, in all runs
pi = (4.0*in)/n
error = abs(pi - EXACT_PI)
stderror = 4*sqrt(p*(1.0-p)/n)
write(*,114) pi, n
write(*, 115) error, stderror
114 format('pi is estimated as ', f18.16, ' from ', i12, ' samples.')
115 format('Error = ', g18.8, ' standard error = ', g18.8)
call save_state(filename, in, n) !check-point final state
end
C-- count # of samples in cirlce
integer function count_in_circle(n)
implicit none
#include "sprng_f.h"
integer n, i, in
real*8 x, y
in = 0
do 10 i=1, n
x = 2*sprng() - 1.0 ! x coordinate
y = 2*sprng() - 1.0 ! y coordinate
if (x*x + y*y .lt. 1.0) then !check if point (x,y) is in circle
in = in +1
endif
10 continue
count_in_circle = in
return
end
C-- initialization --
subroutine initialize(n, in_old, n_old, filename)
implicit none
#include "sprng_f.h"
integer n, in_old, n_old, seed, size, junk
SPRNG_POINTER junkPtr
character filename*7, firstChar*1, buffer(MAX_PACKED_LENGTH)
print*, 'Enter 9 for a new run, or 2 to continue an old run'
read(*,113) firstChar
print*, 'Enter file name(length 7) to store final state:'
read(*, 111) filename ! 7 characters please
print*, 'Enter number of new samples:'
read(*,*)n
111 format(A7)
113 format(A1)
if (firstChar .eq. '9') then ! new set of runs
seed = make_sprng_seed() ! make seed from date/time information
junkPtr = init_sprng(seed, CRAYLCG) ! initialize stream
junk = print_sprng()
in_old = 0
n_old = 0
else ! continue from previously stored state
open(31, file = filename, status = 'unknown',
& form = 'unformatted')
read(31) in_old, n_old, size, buffer !read previous run info.
junkPtr = unpack_sprng(buffer)
close (31)
endif
return
end
C-- save the final state of the default stream into a file
subroutine save_state(filename, in, n)
implicit none
#include "sprng_f.h"
integer in, n, size
character filename*7, buffer(MAX_PACKED_LENGTH)
open(31, file = filename, status = 'unknown',
& form = 'unformatted')
size = pack_sprng(buffer)
write(31)in,n,size,buffer !write the current run info. for future use
close(31)
return
end
SHAR_EOF
fi # end of overwriting check
if test -f 'seed-simple.c'
then
echo shar: will not over-write existing file "'seed-simple.c'"
else
cat << "SHAR_EOF" > 'seed-simple.c'
/****************************************************************************/
/* ____Demonstrates the use make_sprng_seed____ */
/* 'make_sprng_seed' is used to produce a new seed each time the program is */
/* run. Then a few random numbers are printed. */
/****************************************************************************/
#include
#define SIMPLE_SPRNG /* simple interface */
#include "sprng.h" /* SPRNG header file */
main()
{
int i, seed;
double rn;
seed = make_sprng_seed(); /* make new seed each time program is run */
init_sprng(seed,SPRNG_DEFAULT); /* initialize stream */
printf(" Printing information about new stream\n");
print_sprng();
printf(" Printing 3 random numbers in [0,1):\n");
for (i=0;i<3;i++)
{
rn = sprng(); /* generate double precision random number */
printf("%f\n", rn);
}
}
SHAR_EOF
fi # end of overwriting check
if test -f 'seed-simple_mpi.c'
then
echo shar: will not over-write existing file "'seed-simple_mpi.c'"
else
cat << "SHAR_EOF" > 'seed-simple_mpi.c'
/***************************************************************************/
/* ____Demonstrates the use of make_seed with MPI____ */
/* 'make_sprng_seed' is called to produce a new seed each time the program */
/* is run. The same seed is produced on each process. */
/***************************************************************************/
#include
#include /* MPI header file */
#define SIMPLE_SPRNG /* simple interface */
#define USE_MPI /* SPRNG makes MPI calls */
#include "sprng.h" /* SPRNG header file */
main(int argc, char *argv[])
{
int seed;
double rn;
int myid, i;
/*************************** MPI calls ***********************************/
MPI_Init(&argc, &argv); /* Initialize MPI */
MPI_Comm_rank(MPI_COMM_WORLD, &myid); /* find process id */
/************************** Initialization *******************************/
seed = make_sprng_seed(); /* make new seed each time program is run */
/* Seed should be the same on all processes */
printf("Process %d: seed = %16d\n", myid, seed);
init_sprng(seed,SPRNG_DEFAULT); /* initialize stream */
printf("Process %d: Print information about stream:\n",myid);
print_sprng();
/************************ print random numbers ***************************/
for (i=0;i<3;i++)
{
rn = sprng(); /* generate double precision random number */
printf("process %d, random number %d: %f\n", myid, i+1, rn);
}
MPI_Finalize(); /* Terminate MPI */
}
SHAR_EOF
fi # end of overwriting check
if test -f 'seed.c'
then
echo shar: will not over-write existing file "'seed.c'"
else
cat << "SHAR_EOF" > 'seed.c'
/****************************************************************************/
/* ____Demonstrates the use make_sprng_seed____ */
/* 'make_sprng_seed' is used to produce a new seed each time the program is */
/* run. Then a few random numbers are printed. */
/****************************************************************************/
#include
/* Uncomment the following line to get the interface with pointer checking */
/*#define CHECK_POINTERS */
#include "sprng.h" /* SPRNG header file */
main()
{
int streamnum, nstreams, seed, *stream, i;
double rn;
/************************** Initialization *******************************/
streamnum = 0;
nstreams = 1;
seed = make_sprng_seed(); /* make new seed each time program is run */
stream = init_sprng(streamnum,nstreams,seed,SPRNG_DEFAULT); /*initialize stream*/
printf(" Printing information about new stream\n");
print_sprng(stream);
/************************ print random numbers ***************************/
printf(" Printing 3 random numbers in [0,1):\n");
for (i=0;i<3;i++)
{
rn = sprng(stream); /* generate double precision random number */
printf("%f\n", rn);
}
free_sprng(stream); /* free memory used to store stream state */
}
SHAR_EOF
fi # end of overwriting check
if test -f 'seed_mpi.c'
then
echo shar: will not over-write existing file "'seed_mpi.c'"
else
cat << "SHAR_EOF" > 'seed_mpi.c'
/***************************************************************************/
/* ____Demonstrates the use of make_seed with MPI____ */
/* 'make_sprng_seed' is called to produce a new seed each time the program */
/* is run. The same seed is produced on each process. */
/***************************************************************************/
#include
#include /* MPI header file */
/* Uncomment the following line to get the interface with pointer checking */
/*#define CHECK_POINTERS */
#define USE_MPI /* SPRNG makes MPI calls */
#include "sprng.h" /* SPRNG header file */
main(int argc, char *argv[])
{
int streamnum, nstreams, seed, *stream, i, myid, nprocs;
double rn;
/*************************** MPI calls ***********************************/
MPI_Init(&argc, &argv); /* Initialize MPI */
MPI_Comm_rank(MPI_COMM_WORLD, &myid); /* find process id */
MPI_Comm_size(MPI_COMM_WORLD, &nprocs); /* find number of processes */
/************************** Initialization *******************************/
streamnum = myid;
nstreams = nprocs; /* one stream per processor */
seed = make_sprng_seed(); /* make new seed each time program is run */
/* Seed should be the same on all processes */
printf("Process %d: seed = %16d\n", myid, seed);
stream = init_sprng(streamnum,nstreams,seed,SPRNG_DEFAULT); /*initialize stream*/
printf("Process %d: Print information about stream:\n",myid);
print_sprng(stream);
/************************ print random numbers ***************************/
for (i=0;i<3;i++)
{
rn = sprng(stream); /* generate double precision random number */
printf("process %d, random number %d: %f\n", myid, i+1, rn);
}
free_sprng(stream); /* free memory used to store stream state */
MPI_Finalize(); /* Terminate MPI */
}
SHAR_EOF
fi # end of overwriting check
if test -f 'seedf-simple.F'
then
echo shar: will not over-write existing file "'seedf-simple.F'"
else
cat << "SHAR_EOF" > 'seedf-simple.F'
C
C Demonstrates the use make_sprng_seed
C 'make_sprng_seed' is used to produce a new seed each time the program is
C run. Then a few random numbers are printed.
C
program seedf_simple
implicit none
#define SIMPLE_SPRNG
#include "sprng_f.h"
integer seed, i, junk
SPRNG_POINTER junkPtr
real*8 rn
C generate a new seed each time program is run and initialize stream
seed = make_sprng_seed()
junkPtr = init_sprng(seed,SPRNG_DEFAULT)
print *, 'Printing information about new stream'
junk = print_sprng()
print *, 'Printing 3 random numbers in [0,1):'
do 100 i = 1, 3
rn = sprng()
write(*,"(f8.6)") rn
100 continue
end
SHAR_EOF
fi # end of overwriting check
if test -f 'seedf-simple_mpi.F'
then
echo shar: will not over-write existing file "'seedf-simple_mpi.F'"
else
cat << "SHAR_EOF" > 'seedf-simple_mpi.F'
C
C Demonstrates the use of make_seed with MPI
C'make_sprng_seed' is called to produce a new seed each time the program
C is run. The same seed is produced on each process.
C
program seedf_simple_mpi
implicit none
#define SIMPLE_SPRNG
#define USE_MPI 1
#include
#include "sprng_f.h"
integer seed, i, myid, ierror, junk
SPRNG_POINTER junkPtr
real*8 rn
call MPI_INIT(ierror)
call MPI_COMM_RANK(MPI_COMM_WORLD, myid, ierror)
seed = make_sprng_seed() !produce a new seed each time program is run
C Seed should be the same on all processes
write(6, 911) myid, seed
911 format("Process", i2, ": seed = ", i16)
junkPtr = init_sprng(seed,SPRNG_DEFAULT)
write(6, 922) myid
922 format("Process", i2,
& ": Print information about stream:")
junk = print_sprng()
do 100 i = 1, 3
rn = sprng()
write(6, 933) myid, i, rn
100 continue
933 format("process", i2, ", random number", i2, ": ", f8.6)
call MPI_FINALIZE(ierror)
end
SHAR_EOF
fi # end of overwriting check
if test -f 'seedf.F'
then
echo shar: will not over-write existing file "'seedf.F'"
else
cat << "SHAR_EOF" > 'seedf.F'
C
C Demonstrates the use make_sprng_seed
C 'make_sprng_seed' is used to produce a new seed each time the program is
C run. Then a few random numbers are printed.
C
C Uncomment the following line to get the interface with pointer checking
C #define CHECK_POINTERS
program seedf
implicit none
#include "sprng_f.h"
integer streamnum, nstreams, seed, i, junk
SPRNG_POINTER stream
real*8 rn
streamnum = 0
nstreams = 1
C generate a new seed each time program is run and initialize stream
seed = make_sprng_seed()
stream = init_sprng(streamnum,nstreams,seed,SPRNG_DEFAULT)
print *, 'Printing information about new stream'
junk = print_sprng(stream)
print *, 'Printing 3 random numbers in [0,1):'
do 100 i = 1, 3
rn = sprng(stream)
write(*,"(f8.6)") rn
100 continue
junk = free_sprng(stream)
end
SHAR_EOF
fi # end of overwriting check
if test -f 'seedf_mpi.F'
then
echo shar: will not over-write existing file "'seedf_mpi.F'"
else
cat << "SHAR_EOF" > 'seedf_mpi.F'
C
C Demonstrates the use of make_seed with MPI
C'make_sprng_seed' is called to produce a new seed each time the program
C is run. The same seed is produced on each process.
C
C Uncomment the following line to get the interface with pointer checking
C #define CHECK_POINTERS
program seedf_mpi
implicit none
#define USE_MPI 1
#include
#include "sprng_f.h"
integer streamnum, nstreams, seed, i
SPRNG_POINTER stream
real*8 rn
integer myid, nprocs, ierror, junk
call MPI_INIT(ierror)
call MPI_COMM_SIZE(MPI_COMM_WORLD, nprocs, ierror)
call MPI_COMM_RANK(MPI_COMM_WORLD, myid, ierror)
streamnum = myid
nstreams = nprocs
seed = make_sprng_seed() !produce a new seed each time program is run
C Seed should be the same on all processes
write(6, 911) myid, seed
911 format("Process", i2, ": seed = ", i16)
stream = init_sprng(streamnum,nstreams,seed,SPRNG_DEFAULT)
write(6, 922) myid
922 format("Process", i2,
& ": Print information about stream:")
junk = print_sprng(stream)
do 100 i = 1, 3
rn = sprng(stream)
write(6, 933) myid, i, rn
100 continue
933 format("process", i2, ", random number", i2, ": ", f8.6)
junk = free_sprng(stream)
call MPI_FINALIZE(ierror)
end
SHAR_EOF
fi # end of overwriting check
if test -f 'simple-simple.c'
then
echo shar: will not over-write existing file "'simple-simple.c'"
else
cat << "SHAR_EOF" > 'simple-simple.c'
/****************************************************************************/
/* ____Demonstrates the use of sprng without initialization____ */
/* A few double precision random numbers are generated, without the user */
/* explicitly initializing the streams. SPRNG automatically initializes a */
/* stream with default seed and parameter the first time 'sprng' is called. */
/****************************************************************************/
#include
#define SIMPLE_SPRNG /* simple interface */
#include "sprng.h" /* SPRNG header file */
main()
{
double rn;
int i;
printf(" Printing 3 random numbers in [0,1):\n");
for (i=0;i<3;i++)
{
rn = sprng(); /* generate double precision random number */
printf("%f\n",rn);
}
}
SHAR_EOF
fi # end of overwriting check
if test -f 'simplef-simple.F'
then
echo shar: will not over-write existing file "'simplef-simple.F'"
else
cat << "SHAR_EOF" > 'simplef-simple.F'
C
C ____Demonstrates the use of sprng without initialization____ */
C A few double precision random numbers are generated, without the user */
C explicitly initializing the streams. SPRNG automatically initializes a */
C stream with default seed and parameter the first time 'sprng' is called. */
C
program simplef_simple
implicit none
#define SIMPLE_SPRNG
#include "sprng_f.h"
integer i
real*8 rn
print *, 'Printing 3 random numbers in [0,1):'
do 100 i = 1, 3
rn = sprng()
write(*,"(f8.6)") rn
100 continue
end
SHAR_EOF
fi # end of overwriting check
if test -f 'spawn.c'
then
echo shar: will not over-write existing file "'spawn.c'"
else
cat << "SHAR_EOF" > 'spawn.c'
/***************************************************************************/
/* ____Demonstrates the use of spawn_sprng____ */
/* A random number stream is initialized and a few random numbers are */
/* printed. Then two streams are spawned and a few numbers from one of them*/
/* is printed. */
/***************************************************************************/
#include
/* Uncomment the following line to get the interface with pointer checking */
/*#define CHECK_POINTERS */
#include "sprng.h" /* SPRNG header file */
#define SEED 985456376
main()
{
int streamnum, nstreams, *stream, **new;
double rn;
int i, irn, nspawned;
/****************** Initialization values *******************************/
streamnum = 0;
nstreams = 1;
stream = init_sprng(streamnum,nstreams,SEED,SPRNG_DEFAULT); /* initialize stream */
printf(" Print information about stream:\n");
print_sprng(stream);
/*********************** print random numbers ***************************/
printf(" Printing 2 random numbers in [0,1):\n");
for (i=0;i<2;i++)
{
rn = sprng(stream); /* generate double precision random number*/
printf("%f\n", rn);
}
/**************************** spawn streams *****************************/
printf(" Spawned two streams\n");
nspawned = 2;
nspawned = spawn_sprng(stream,2,&new); /* spawn 2 streams */
if(nspawned != 2)
{
fprintf(stderr,"Error: only %d streams spawned\n", nspawned);
exit(1);
}
printf(" Information on first spawned stream:\n");
print_sprng(new[0]);
printf(" Information on second spawned stream:\n");
print_sprng(new[1]);
printf(" Printing 2 random numbers from second spawned stream:\n");
for (i=0;i<2;i++)
{
rn = sprng(new[1]); /* generate a random number */
printf("%f\n", rn);
}
/*************************** free memory ********************************/
free_sprng(stream); /* free memory used to store stream state */
free_sprng(new[0]); /* free memory used to store stream state */
free_sprng(new[1]); /* free memory used to store stream state */
free(new);
}
SHAR_EOF
fi # end of overwriting check
if test -f 'spawnf.F'
then
echo shar: will not over-write existing file "'spawnf.F'"
else
cat << "SHAR_EOF" > 'spawnf.F'
C
C ____Demonstrates the use of spawn_sprng____
C A random number stream is initialized and a few random numbers are
C printed. Then two streams are spawned and a few numbers from one of them
C is printed
C
C Uncomment the following line to get the interface with pointer checking
C #define CHECK_POINTERS
program sprng_spawnf
implicit none
#include "sprng_f.h"
integer streamnum, nstreams, seed,junk
integer i, nspawned
SPRNG_POINTER stream, new(2)
real*8 rn
streamnum = 0
nstreams = 1
seed = 985456376
C initialize stream
stream = init_sprng(streamnum,nstreams,seed,SPRNG_DEFAULT)
print *, 'Print information about stream:'
junk = print_sprng(stream)
print *, 'Printing 2 random numbers in [0,1):'
do 100 i = 1, 2
rn = sprng(stream)
write(*, "(f8.6)") rn
100 continue
C spawn streams
print*, 'Spawned two streams'
nspawned = 2
nspawned = spawn_sprng(stream, 2, new(1))
if (nspawned .ne. 2) then
write(*, "('Error: only ',i3, ' streams spawned')") nspawned
call exit(1)
endif
print *, 'Information on first spawned stream:'
junk = print_sprng(new(1))
print *, 'Information on second spawned stream:'
junk = print_sprng(new(2))
print *, 'Printing 2 random numbers from second spawned stream:'
do 200 i = 1, 2
rn = sprng(new(2))
write(*, "(f8.6)") rn
200 continue
C free memory
junk = free_sprng(stream)
junk = free_sprng(new(1))
junk = free_sprng(new(2))
end
SHAR_EOF
fi # end of overwriting check
if test -f 'sprng-simple.c'
then
echo shar: will not over-write existing file "'sprng-simple.c'"
else
cat << "SHAR_EOF" > 'sprng-simple.c'
/***************************************************************************/
/* ____Demonstrates the use of sprng and isprng____ */
/* A random number stream is initialized and a few random double precision */
/* numbers and a few integers are printed. */
/***************************************************************************/
#include
#define SIMPLE_SPRNG /* simple interface */
#include "sprng.h" /* SPRNG header file */
#define SEED 985456376
main()
{
int seed, i, irn;
double rn;
/************************** Initialization *******************************/
init_sprng(SEED,SPRNG_DEFAULT); /* initialize stream */
printf(" Print information about new stream:\n");
print_sprng();
/*********************** print random numbers ****************************/
printf(" Printing 3 random numbers in [0,1):\n");
for (i=0;i<3;i++)
{
rn = sprng(); /* generate double precision random number */
printf("%f\n",rn);
}
/*********************** print random integers ***************************/
printf(" Printing 3 random integers in [0,2^31):\n");
for (i=0;i<3;i++)
{
irn = isprng(); /* generate an integer random number */
printf("%16d\n",irn);
}
}
SHAR_EOF
fi # end of overwriting check
if test -f 'sprng-simple_mpi.C'
then
echo shar: will not over-write existing file "'sprng-simple_mpi.C'"
else
cat << "SHAR_EOF" > 'sprng-simple_mpi.C'
/***************************************************************************/
/* Demonstrates sprng use in C++ with MPI */
/* A distinct stream is created on each process, then prints a few */
/* random numbers. */
/***************************************************************************/
#include
#include // MPI header file
#define SIMPLE_SPRNG // simple interface
#define USE_MPI // use MPI to find number of processes
#include "sprng.h" // SPRNG header file
#define SEED 985456376
main(int argc, char *argv[])
{
double rn;
int i, myid;
/*************************** MPI calls ***********************************/
MPI_Init(&argc, &argv); /* Initialize MPI */
MPI_Comm_rank(MPI_COMM_WORLD, &myid); /* find process id */
/************************** Initialization *******************************/
init_sprng(SEED,SPRNG_DEFAULT); /* initialize stream */
printf("Process %d, print information about stream:\n", myid);
print_sprng();
/************************ print random numbers ***************************/
for (i=0;i<3;i++)
{
rn = sprng(); /* generate double precision random number */
printf("Process %d, random number %d: %.14f\n", myid, i+1, rn);
}
MPI_Finalize(); /* Terminate MPI */
}
SHAR_EOF
fi # end of overwriting check
if test -f 'sprng-simple_mpi.c'
then
echo shar: will not over-write existing file "'sprng-simple_mpi.c'"
else
cat << "SHAR_EOF" > 'sprng-simple_mpi.c'
/***************************************************************************/
/* Demonstrates sprng use with one stream per process */
/* A distinct stream is created on each process, then prints a few */
/* random numbers. */
/***************************************************************************/
#include
#include /* MPI header file */
#define SIMPLE_SPRNG /* simple interface */
#define USE_MPI /* use MPI to find number of processes */
#include "sprng.h" /* SPRNG header file */
#define SEED 985456376
main(int argc, char *argv[])
{
double rn;
int i, myid;
/*************************** MPI calls ***********************************/
MPI_Init(&argc, &argv); /* Initialize MPI */
MPI_Comm_rank(MPI_COMM_WORLD, &myid); /* find process id */
/************************** Initialization *******************************/
init_sprng(SEED,SPRNG_DEFAULT); /* initialize stream */
printf("Process %d, print information about stream:\n", myid);
print_sprng();
/************************ print random numbers ***************************/
for (i=0;i<3;i++)
{
rn = sprng(); /* generate double precision random number */
printf("Process %d, random number %d: %.14f\n", myid, i+1, rn);
}
MPI_Finalize(); /* Terminate MPI */
}
SHAR_EOF
fi # end of overwriting check
if test -f 'sprng.C'
then
echo shar: will not over-write existing file "'sprng.C'"
else
cat << "SHAR_EOF" > 'sprng.C'
/***************************************************************************/
/* ____Demonstrates the use of sprng in C++____ */
/* A random number stream is initialized and a few random double precision */
/* numbers are printed. */
/***************************************************************************/
#include
#include
#include "sprng.h" /* SPRNG header file */
#define SEED 985456376
main()
{
int streamnum, nstreams, *stream;
double rn;
int irn;
int i;
/****************** Initialization values *******************************/
streamnum = 0;
nstreams = 1;
stream = init_sprng(streamnum,nstreams,SEED,SPRNG_DEFAULT); /* initialize stream */
cout << " Print information about new stream:\n";
print_sprng(stream);
/*********************** print random numbers ***************************/
cout << " Printing 3 random numbers in [0,1):\n";
for (i=0;i<3;i++)
{
rn = sprng(stream); /* generate a double precision random number */
cout << rn << "\n";
}
free_sprng(stream); /* free memory used to store stream state */
}
SHAR_EOF
fi # end of overwriting check
if test -f 'sprng.c'
then
echo shar: will not over-write existing file "'sprng.c'"
else
cat << "SHAR_EOF" > 'sprng.c'
/***************************************************************************/
/* ____Demonstrates the use of sprng and isprng____ */
/* A random number stream is initialized and a few random double precision */
/* numbers and a few integers are printed. */
/***************************************************************************/
#include
/* Uncomment the following line to get the interface with pointer checking */
/*#define CHECK_POINTERS */
#include "sprng.h" /* SPRNG header file */
#define SEED 985456376
main()
{
int streamnum, nstreams, *stream;
double rn;
int irn;
int i;
/****************** Initialization values *******************************/
streamnum = 0;
nstreams = 1;
stream = init_sprng(streamnum,nstreams,SEED,SPRNG_DEFAULT); /* initialize stream */
printf(" Print information about new stream:\n");
print_sprng(stream);
/*********************** print random numbers ***************************/
printf(" Printing 3 random numbers in [0,1):\n");
for (i=0;i<3;i++)
{
rn = sprng(stream); /* generate a double precision random number */
printf("%f\n",rn);
}
printf(" Printing 3 random integers in [0,2^31):\n");
for (i=0;i<3;i++)
{
irn = isprng(stream); /* generate an integer random number */
printf("%16d\n",irn);
}
/*************************** free memory ********************************/
free_sprng(stream); /* free memory used to store stream state */
}
SHAR_EOF
fi # end of overwriting check
if test -f 'sprng_mpi.c'
then
echo shar: will not over-write existing file "'sprng_mpi.c'"
else
cat << "SHAR_EOF" > 'sprng_mpi.c'
/***************************************************************************/
/* Demonstrates sprng use with one stream per process */
/* A distinct stream is created on each process, then prints a few */
/* random numbers. */
/***************************************************************************/
#include
#include /* MPI header file */
/* Uncomment the following line to get the interface with pointer checking */
/*#define CHECK_POINTERS */
#include "sprng.h" /* SPRNG header file */
#define SEED 985456376
main(int argc, char *argv[])
{
int streamnum, nstreams, *stream;
double rn;
int i, myid, nprocs;
/*************************** MPI calls ***********************************/
MPI_Init(&argc, &argv); /* Initialize MPI */
MPI_Comm_rank(MPI_COMM_WORLD, &myid); /* find process id */
MPI_Comm_size(MPI_COMM_WORLD, &nprocs); /* find number of processes */
/************************** Initialization *******************************/
streamnum = myid;
nstreams = nprocs; /* one stream per processor */
stream = init_sprng(streamnum,nstreams,SEED,SPRNG_DEFAULT); /* initialize stream */
printf("Process %d, print information about stream:\n", myid);
print_sprng(stream);
/*********************** print random numbers ****************************/
for (i=0;i<3;i++)
{
rn = sprng(stream); /* generate double precision random number */
printf("Process %d, random number %d: %.14f\n", myid, i+1, rn);
}
/*************************** free memory *********************************/
free_sprng(stream); /* free memory used to store stream state */
MPI_Finalize(); /* Terminate MPI */
}
SHAR_EOF
fi # end of overwriting check
if test -f 'sprngf-simple.F'
then
echo shar: will not over-write existing file "'sprngf-simple.F'"
else
cat << "SHAR_EOF" > 'sprngf-simple.F'
C
C Demonstrates the use of sprng and isprng
C A random number stream is initialized and a few random double precision
C numbers and a few integers are printed.
C
program sprngf_simple
implicit none
#define SIMPLE_SPRNG
#include "sprng_f.h"
SPRNG_POINTER junkPtr
real*8 rn
integer seed, irn, i, junk
seed = 985456376
C initialization
junkPtr = init_sprng(seed,SPRNG_DEFAULT)
print *, 'Print information about new stream:'
junk = print_sprng()
print *, 'Printing 3 random numbers in [0,1):'
do 100 i = 1, 3
rn = sprng()
write(*,"(f8.6)") rn
100 continue
print *, 'Printing 3 random integers in [0,2^31):'
do 200 i = 1, 3
irn = isprng()
write(*,"(i16)") irn
200 continue
end
SHAR_EOF
fi # end of overwriting check
if test -f 'sprngf-simple_mpi.F'
then
echo shar: will not over-write existing file "'sprngf-simple_mpi.F'"
else
cat << "SHAR_EOF" > 'sprngf-simple_mpi.F'
C
C Demonstrates sprng use with one stream per process
C A distinct stream is created on each process then prints a few
C random numbers.
C
program sprngf_mpi
implicit none
#define SIMPLE_SPRNG ! simple interface
#define USE_MPI ! use MPI to find number of processes
#include
#include "sprng_f.h"
SPRNG_POINTER junkPtr
real*8 rn
integer seed, i, myid, ierror,junk
call MPI_INIT(ierror)
call MPI_COMM_RANK(MPI_COMM_WORLD, myid, ierror)
seed = 985456376
C
junkPtr = init_sprng(seed,SPRNG_DEFAULT)
write(*,"('Process', i2, ', print information about stream:')")
& myid
junk = print_sprng()
do 100 i = 1, 3
rn = sprng()
write(*, "('Process',i2,', random number ',i1,': ',f16.14)")
& myid,i,rn
100 continue
call MPI_FINALIZE(ierror)
end
SHAR_EOF
fi # end of overwriting check
if test -f 'sprngf.F'
then
echo shar: will not over-write existing file "'sprngf.F'"
else
cat << "SHAR_EOF" > 'sprngf.F'
C
C Demonstrates the use of sprng and isprng
C A random number stream is initialized and a few random double precision
C numbers and a few integers are printed.
C
C Uncomment the following line to get the interface with pointer checking
C #define CHECK_POINTERS
program sprngf
implicit none
#include "sprng_f.h"
integer streamnum, nstreams, seed
SPRNG_POINTER stream
real*8 rn
integer irn, i, junk
streamnum = 0
nstreams = 1
seed = 985456376
C initialize stream
stream = init_sprng(streamnum,nstreams,seed,SPRNG_DEFAULT)
print *, 'Print information about new stream:'
junk = print_sprng(stream)
print *, 'Printing 3 random numbers in [0,1):'
do 100 i = 1, 3
rn = sprng(stream)
write(*,"(f8.6)") rn
100 continue
print *, 'Printing 3 random integers in [0,2^31):'
do 200 i = 1, 3
irn = isprng(stream)
write(*,"(i16)") irn
200 continue
junk = free_sprng(stream)
end
SHAR_EOF
fi # end of overwriting check
if test -f 'sprngf_mpi.F'
then
echo shar: will not over-write existing file "'sprngf_mpi.F'"
else
cat << "SHAR_EOF" > 'sprngf_mpi.F'
C
C Demonstrates sprng use with one stream per process
C A distinct stream is created on each process then prints a few
C random numbers.
C
C Uncomment the following line to get the interface with pointer checking
C #define CHECK_POINTERS
program sprngf_mpi
implicit none
#include
#include "sprng_f.h"
integer streamnum, nstreams, seed
SPRNG_POINTER stream
real*8 rn
integer i, myid, nprocs, ierror, junk
call MPI_INIT(ierror)
call MPI_COMM_SIZE(MPI_COMM_WORLD, nprocs, ierror)
call MPI_COMM_RANK(MPI_COMM_WORLD, myid, ierror)
streamnum = myid
nstreams = nprocs
seed = 985456376
C
stream = init_sprng(streamnum,nstreams,seed,SPRNG_DEFAULT)
write(*,"('Process', i2, ', print information about stream:')")
& myid
junk = print_sprng(stream)
do 100 i = 1, 3
rn = sprng(stream)
write(*, "('Process',i2,', random number ',i1,': ',f16.14)")
& myid,i,rn
100 continue
junk = free_sprng(stream)
call MPI_FINALIZE(ierror)
end
SHAR_EOF
fi # end of overwriting check
if test -f 'subroutinef.F'
then
echo shar: will not over-write existing file "'subroutinef.F'"
else
cat << "SHAR_EOF" > 'subroutinef.F'
C
C Demonstrates the use of sprng in subroutines
program sprngf
implicit none
#include "sprng_f.h"
integer streamnum, nstreams, seed,junk
SPRNG_POINTER stream
streamnum = 0
nstreams = 1
seed = 985456376
C initialize stream
stream = init_sprng(streamnum,nstreams,seed,SPRNG_DEFAULT)
print *, 'Printing information about new stream'
junk = print_sprng(stream)
call sub1(stream)
junk = free_sprng(stream)
end
C --- print random numbers in subroutine ---
subroutine sub1(stream)
#include "sprng_f.h"
SPRNG_POINTER stream
real *8 rn
print *, 'Printing 3 double precision numbers in [0,1): '
do 100 i = 1, 3
rn = sprng(stream)
write(*, "(i6, 2H , f19.16)") i, rn
100 continue
return
end
SHAR_EOF
fi # end of overwriting check
cd ..
if test -f 'examples.html'
then
echo shar: will not over-write existing file "'examples.html'"
else
cat << "SHAR_EOF" > 'examples.html'
SPRNG: Scalable Parallel Pseudo-Random Number Generator Library
Next:Generators
Previous:Compilation
- 1. simple
- Use of sprng without explicit
initialization in the simple interface.
- 2. sprng
- Produce random integers and reals: Use of init_sprng, sprng, print_sprng, isprng.
- 3. sprng_mpi
- Use sprng to produce double precision random numbers on multiple processes.
- 4. fsprng_mpi
- Produce single precision random numbers through the use
of the FLOAT_GEN macro.
- 5. seed
- Use make_sprng_seed to produce a seed
using system date and time information on one process.
- 6. seed_mpi
- Use make_sprng_seed to produce seeds on multiple processes.
- 7. checkpoint
- Pack a stream and checkpoint the state of the computation.
- 8. message_mpi
- Pack a stream and pass it to another process with
MPI. Also use free_sprng in the default interface.
- 9. 2streams_mpi
- Use two streams on each process. One stream is common
to all the processes; the other is distinct.
- 10. spawn
- Spawn new streams from an existing one through calls to
spawn_sprng.
- 11. invalidid
- Demonstrates the handling of invalid stream ID's in the interface
with pointer checking.
- 12. convert
- Convert a code that uses a different Random Number Generator to use SPRNG.
- 13. subroutine
- Demonstrates SPRNG use in FORTRAN programs with subroutines.
- 14. pi-simple
- This is a simple Monte Carlo application that estimates the value
of PI based on the proportion of points that fall within a circle
inscribed in a square.
- 15. pi-simple_mpi
- This is a parallel version of pi-simple in
which the work is divided among the available processes.
SHAR_EOF
fi # end of overwriting check
if test -f 'frames.html'
then
echo shar: will not over-write existing file "'frames.html'"
else
cat << "SHAR_EOF" > 'frames.html'
SPRNG User's Guide
Frame stuff not shown