home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume18
/
planet
/
part04
< prev
next >
Wrap
Internet Message Format
|
1991-04-10
|
54KB
From: allen@viewlogic.com (Dave Allen)
Newsgroups: comp.sources.misc
Subject: REPOST: v18i004: planet - planet generation simulator, Part04/04
Message-ID: <1991Apr9.041825.8147@sparky.IMD.Sterling.COM>
Date: 9 Apr 91 04:18:25 GMT
Approved: kent@sparky.imd.sterling.com
X-Checksum-Snefru: b2104cf2 01fc0da8 88f3c561 60378f00
Submitted-by: Dave Allen <allen@viewlogic.com>
Posting-number: Volume 18, Issue 4
Archive-name: planet/part04
Supersedes: tec: Volume 10, Issue 77-78
#! /bin/sh
# into a shell via "sh file" or similar. To overwrite existing files,
# type "sh file -c".
# The tool that generated this appeared in the comp.sources.unix newsgroup;
# send mail to comp-sources-unix@uunet.uu.net if you want that tool.
# Contents: ./README ./doc/params.tec ./doc/readme.clim
# ./doc/readme.globe ./doc/readme.tec ./example/clim.in
# ./example/clim.out ./example/tec.out.1 ./example/tec.out.2
# ./example/tec.out.3 ./src/clim.h ./src/climate.c ./src/const.h
# ./src/globe.c ./src/tec.h ./src/unix.c ./src/wind.c
# Wrapped by kent@sparky on Mon Apr 8 22:39:15 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
echo If this archive is complete, you will see the following message:
echo ' "shar: End of archive 4 (of 4)."'
if test -f './README' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'./README'\"
else
echo shar: Extracting \"'./README'\" \(849 characters\)
sed "s/^X//" >'./README' <<'END_OF_FILE'
XThis is version 1 of a scientific planet generator (as opposed to a
Xdie-rolling planet generator). It is written in C and runs in graphics
Xmode under Xwindows, or in text-only mode under UN*X. There are three
Xprograms:
X
X - tec: a continental drift simulator
X - clim: a climate generator
X - globe: computes and displays a rotating planet
X
XCopyright (c) 1991 by David Allen. You may distribute this freely as long
Xas you leave my name and copyright notice intact.
X
XI'd really like your comments and feedback; send e-mail to
Xallen@viewlogic.com, or send us-mail to David Allen, 10 O'Moore Ave,
XMaynard, MA 01754.
X
XThere are three subdirectories:
X
X - src: contains all source and a UN*X Makefile
X - example: contains some sample input and output files
X - doc: contains details about how to use the programs and how they work.
X
XHave fun!
END_OF_FILE
if test 849 -ne `wc -c <'./README'`; then
echo shar: \"'./README'\" unpacked with wrong size!
fi
# end of './README'
fi
if test -f './doc/params.tec' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'./doc/params.tec'\"
else
echo shar: Extracting \"'./doc/params.tec'\" \(5857 characters\)
sed "s/^X//" >'./doc/params.tec' <<'END_OF_FILE'
XIf you give tec a filename as a command line argument, it will read
Xparameters from that file. If you hand it '-' as an argument, it will
Xread them from stdin. For example, you could type "tec - < foo", or
X"tec foo". The '-' option is handy for pipes.
X
XThe parameter file is optional; all of the parameters you can change
Xhave defaults. Thus, the parameter file need contain only the parameters
Xyou want to change. A parameter file looks like LISP; for example,
Xto change the XSIZE parameter, the file would have the one line
X
X(XSIZE 40)
X
XParameters can also be vectors; for example
X
X(MOVERATE (1 1 1))
X
XThe parameters are either easy or hard. This rating concerns how much
Xyou have to know about the simulation to change the parameters. Easy
Xones just affect run time, resolution, and so on. Hard ones should
Xonly be changed if you understand the code pretty well.
X
XEasy parameters:
XPRINTMODE - 0 produces no output, 1 produces a long text file (default),
X 3 produces a summary text file and 4 produces PostScript
X grayscale drawings.
XDRAWEVERY - How many steps should be iterated for each output. Default 1,
X but this produces an awful lot of text. Reasonable values
X for non-interactive runs are 5 or 10. Supercontinents appear
X every 25 steps or so. A value of zero implies that only the
X final map, at the last timestep, should be output.
XMAXSTEP - How many steps to run before terminating. Default 100.
XXSIZE - Horizontal size of arrays. Default 90. To produce summaries
X that fit on a normal page, I used 72.
XYSIZE - Vertical size of arrays. Default 90. To produce the summaries
X included in tec.out.[1-3], I used 48.
XHYDROPCT - The percentage of the grid that should be covered by water.
X Default is 70. A threshhold is found for the initial blob to meet
X this goal within about 2-3%. If DRAWEVERY is also set to 0 (see
X above), then at the last step the ocean level is forced up or
X down to satisfy the requirement. This may cause a PANIC error if
X there just isn't enough land to do it.
XUNDERSCAN - If a potential rift gets within this many squares of the edge, it
X is thrown away. This keeps new fragments from appearing near the
X edge, which in turn means that far less land falls off the edge
X of the map. This is a hack; the default is 0, which is no change;
X for 100 x 100 maps, 10 is the best choice.
X
XSo to produce a text file with 10 pictures, you could use
X
X(PRINTMODE 2) (DRAWEVERY 10) (XSIZE 72) (YSIZE 48)
X
XTo produce a 20-page PostScript output with a little more detail, use
X
X(PRINTMODE 4) (DRAWEVERY 5)
X
XHard Parameters:
XZINIT - Initial altitude of supercontinent. Default 22.
XZSUBSUME - Altitude added to leading edge of drifting plate. Default 16.
XZCOAST - Sea level. Everything below this is under water. Default 16.
XZSHELF - Minimum altitude for continental shelf. Default 8.
XZMOUNTAIN - Used in PRINTMODE 2; altitude above which a square is counted
X as mountain instead of land. Default 48.
XZERODE - Minimum altitude used in erosion. Default 16. Decrease this
X number and continents grow faster at the margins; increase it
X and they grow more slowly. Increase it too much and weird
X things happen to your mountains.
XMAXBUMP - If two plates overlap on more than this number of squares,
X the plates must be merged together. Default 50.
XBUMPTOL - If the relative velocity of two touching plates is less than this
X value, the plates will be merged together. Default 50.
XMOVERATE - A vector of real numbers describing the rate at which plates
X move apart, slow down, and then drift back together. Each
X plate has an age, measured in steps from its creation. The age
X is used as an offset into the vector. The result is a real
X between -1.0 and +1.0 which is multiplied by the plate's original
X movement vector. The default vector is
X
X (1.0 1.0 1.0 0.7 0.4 0.1 -0.2 -0.5 -0.8 -1.0)
X
X It can be interpreted this way. The first three steps a plate is
X in motion, it moves at its normal velocity. During the 4-6
X steps, it slows down. During the 7-10 steps, it moves the
X opposite way from the way it started, at increasing speeds.
X Thereafter, it keeps moving at its final velocity.
XRIFTPCT - Percent chance that a rift will occur in a given step. Default 40.
XMAXCTRTRY - The number of tries the rift routine will make to find an
X acceptable place to start a rift. Default 50.
XRIFTDIST - The minimum allowable distance between a proposed rift center
X and the nearest coast. Default 5.
XDOERODE - Whether or not to compute erosion. Default 1; if 0, the program
X will run about twice as fast but will generate way too many
X mountains, since the only thing that gets rid of mountains
X is erosion.
XERODERND - The rounding factor used in erosion. Default 4. As this
X parameter goes from 0 to 7, erosion occurs faster.
XBENDEVERY - Each time a rift grows by this many squares, it is allowed to
X bend a little bit. Default 6.
XBENDBY - When a rift bends, it bends by a random angle in the range
X -BENDBY ... +BENDBY multiplied by pi/2000. Default value is 100.
X If BENDBY is too high or BENDEVERY is too low, very curvy rifts
X will be generated, with unrealistic results.
XSPPEDBASE - The minimum speed at which new plates will travel. Default 200.
XSPEEDRNG - The actual speed at which a plate travels is SPEEDBASE +
X rnd (SPEEDRNG). Default value is 300.
END_OF_FILE
if test 5857 -ne `wc -c <'./doc/params.tec'`; then
echo shar: \"'./doc/params.tec'\" unpacked with wrong size!
fi
# end of './doc/params.tec'
fi
if test -f './doc/readme.clim' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'./doc/readme.clim'\"
else
echo shar: Extracting \"'./doc/readme.clim'\" \(3183 characters\)
sed "s/^X//" >'./doc/readme.clim' <<'END_OF_FILE'
XThis is the README file for Version 1 of clim, a program which computes
Xthe climate for a planet: temperature, pressure zones, wind patterns, rain
Xpatterns, and finally climate based on temperature and rain. It is
Xwritten in C and runs on any Xwindows system (X11R4). Copyright (c) 1991
Xby David Allen. You may distribute this freely as long as you leave my
Xname and copyright notice intact.
X
XI'd really like your comments and feedback; send e-mail to
Xallen@viewlogic.com, or send us-mail to David Allen, 10 O'Moore Ave,
XMaynard, MA 01754.
X
XWHAT DOES CLIM DO?
X
XGiven a topographical map, for example, one produced by TEC, this program
Xcomputes temperature, pressure, wind, rain and climate. The information
Xused in these computations comes from any college-level meterology text.
XOutput is produced as an animation on the graphics screen, on in text
Xfiles including PostScript output.
X
XI have included a sample text map showing climate for one world; it is
Xin example/clim.out.
X
XHOW DO I RUN IT?
X
XTo compile clim, go to the src directory and type "make clim". To run it,
Xgo to the example directory and type "../src/clim clim.in". This directs
Xthe program to read the map stored in the file clim.in.
X
XWhen clim runs, it opens a graphics screen. It prints about 40 lines of
Xstatus information to stderr, then begins to animate the results.
X
XAt any time, you can type "q" into the graphics window to end the program.
XYou can flip between the types of display with these keys:
X h: display temperature; default. Temperature is displayed using the
X full spectrum; purple is coldest, then blue, and so on; red is
X hottest. There are about 30 visibly different shades. Black
X lines indicate coastline; white lines surround mountains.
X p: display pressure. Zones of low pressure are surrounded by white
X lines; zones of high pressure are surrounded by black lines. Ocean
X is blue, land is red, and mountains are grey.
X w: display wind patterns. Winds run in circles, especially over the
X ocean. Black horizontal lines are westbound; white horizontals are
X eastbound; black verticals are southbound; white verticals are
X northbound. Ocean is blue, land is red, mountains are grey.
X r: display rainfall. Amount of rainfall is displayed using the full
X spectrum; purple is driest, then blue; red is wettest. Black lines
X indicate coastline; white lines surround mountains.
X c: display climate. The following colors are used:
X dark blue: Ocean orange: Savannah
X light grey: Icebergs dark green: Decidous forest
X dark grey: Tundra bright green: Jungle
X brown: Steppe bright blue: Swamp
X yellow: Desert
X
XTo produce your own maps for use with clim, you can use tec. For example,
Xcreate a tec input file with this single line:
X
X(XSIZE 60) (YSIZE 30) (PRINTMODE 3) (MAXSTEP 20)
X
XThen type "tec filename > tec.out" (where filename is the name of the
Xinput file you just created). Tec should run for a couple of seconds
Xand then produce a file called tec.out. Then type "clim tec.out" and
Xyou will see the climate for your own planet.
END_OF_FILE
if test 3183 -ne `wc -c <'./doc/readme.clim'`; then
echo shar: \"'./doc/readme.clim'\" unpacked with wrong size!
fi
# end of './doc/readme.clim'
fi
if test -f './doc/readme.globe' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'./doc/readme.globe'\"
else
echo shar: Extracting \"'./doc/readme.globe'\" \(1735 characters\)
sed "s/^X//" >'./doc/readme.globe' <<'END_OF_FILE'
XThis is the README file for Version 1 of globe, a program which takes
Xa square map, wraps it around a globe, and displays an animation of the
Xglobe rotating. It is written in C and runs on any Xwindows system (X11R4).
XCopyright (c) 1991 by David Allen. You may distribute this freely as long
Xas you leave my name and copyright notice intact.
X
XI'd really like your comments and feedback; send e-mail to
Xallen@viewlogic.com, or send us-mail to David Allen, 10 O'Moore Ave,
XMaynard, MA 01754.
X
XWHAT DOES THE GLOBE PROGRAM DO?
X
XGiven a square map, for example, one produced by TEC, this program shows
Xwhat the map would look like from space. Since a square is flat, and
Xa sphere is round, some distortion is involved.
X
XHOW DO I RUN IT?
X
XTo compile globe, go to the src directory and type "make globe". To run it,
Xgo to the example directory and type "../src/globe globe.in". This directs
Xthe program to read the map stored in the file globe.in.
X
XWhen globe runs, it opens a graphics screen. After a couple of seconds,
Xa purple globe pops up. There are 18 frames in the animation; the colors
Xindicate altitudes. Unlike tec, the ocean is displayed as bright purple
Xrather than black.
X
XAt any time, you can type "q" into the graphics window to end the program.
XIt will stop automatically after 10000 steps (a fairly long time).
X
XYou can display your own maps created using tec. For example, create
Xa tec input file with this single line:
X
X(MAXSTEP 20) (UNDERSCAN 10) (PRINTMODE 1)
X
XThen type "tec filename > tec.out" (where filename is the name of the
Xinput file you just created). Tec should run for a couple of seconds
Xand then produce a file called tec.out. Then type "globe tec.out" and
Xyou will see your own globe rotating.
END_OF_FILE
if test 1735 -ne `wc -c <'./doc/readme.globe'`; then
echo shar: \"'./doc/readme.globe'\" unpacked with wrong size!
fi
# end of './doc/readme.globe'
fi
if test -f './doc/readme.tec' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'./doc/readme.tec'\"
else
echo shar: Extracting \"'./doc/readme.tec'\" \(3896 characters\)
sed "s/^X//" >'./doc/readme.tec' <<'END_OF_FILE'
XThis is the README file for Version 5 of tec, a plate tectonic simulator.
XIt is written in C and runs on any Xwindows system (X11R4) or any UN*X
Xmachine using text or PostScript output. Copyright (c) 1991 by David Allen.
XYou may distribute this freely as long as you leave my name and copyright
Xnotice intact.
X
XI'd really like your comments and feedback; send e-mail to
Xallen@viewlogic.com, or send us-mail to David Allen, 10 O'Moore Ave,
XMaynard, MA 01754.
X
XVersion history:
X1. Posted to rec.games.frp and rec.games.programmer on 11 / 15 / 89
X - Runs only on Amiga, produces long text summary.
X - Includes PostScript translator for any PostScript printer.
X2. (Unreleased)
X - Added text-only mode so it runs on UN*X machines.
X - Added summary text output mode that fits on 80-character lines.
X - PostScript support merged into main program.
X3. Posted to comp.sources.misc, v10i077-78, on 2 / 15 / 90.
X - Parameters can come from an input file (see params.tec).
X - Ported to Sun workstation by the author.
X - Ported to IBM PC by Peter Lind.
X4. (Unreleased)
X - Ported to Xwindows by George Ferguson.
X - Autoscaling to produce specified hydrographics percentage.
X - Underscan mode to reduce drift "off the edge of the world".
X5. Posted to comp.sources.misc on 3 / 23 / 1991.
X - Merged with globe display and climate generator
X - Scope reduced to Xwindow graphics
X
XCredits:
XBrian Love - conversion to Amiga Lattice C 5.02, Amiga beta tester.
XPeter Lind - port to IBM PC Turbo C with CGA/MCGA/EGA/VGA.
XAndrew Hay - improved random number seeding (now BSD independent).
XFred Smith - added support for IBM PC Hercules mono graphics card.
XHoward Johnson, Dave Pare - bug fixes.
XGeorge Ferguson - port to XWindows.
X
X
XWHAT DOES THE TECTONIC SIMULATOR DO?
X
XTEC draws a map of some imaginary world and puts one big continent on it.
XThe program then graphically simulates the breakup of this supercontinent by
Xrifts and the drifting of the continents. Mountains are built by
Xsubsuming and by continental collision, and are reduced by erosion. As
Xmore time passes, the continents tend to drift back into a supercontinent
Xand split up again, forming what some authors call a "supercontinent cycle."
X
XThe program produces a map of an imaginary world which contains realistic
Xlooking mountain ranges and continents which sometimes look like they fit
Xtogether (like South America and Africa on Earth).
X
XI've included some sample output in the files example/tec.out.[1-3]; they are
Xshort text files. 0's indicate ocean, 1's indicate land, and 2's indicate
Xmountains. Take a look.
X
X
XHOW DO I RUN IT?
X
XTo compile tec, go to the src directory and type "make tec". To run tec,
Xtype "tec". You can provide many optional parameter settings; place them
Xin a file and run tec with "tec filename". Output from tec goes to stdout;
Xredirect it to a file to save it, as in "tec filename > outfile".
X
XWhen tec runs, it opens a graphics screen. A big purple blob pops up.
XThis is the initial supercontinent. Every second or so (depending on
Xmachine speed) another "step" will be computed and drawn.
X
XAltitudes are represented by colors; black is the lowest (ocean), and goes
Xthrough the spectrum from lowest to highest: purple, blue, green, yellow,
Xorange, red and finally white. There are about 30 visibly different altitude
Xranges, since each color has several shades.
X
XAs time passes, you will see the supercontinent split up; green and yellow
Xmountains will appear on the leading edges of drifting continents; when
Xcontinents slow down, reverse course, and collide, higher orange and red
Xmountains will appear. If you watch carefully, you can see erosion on
Xmountains that are not growing; they turn darker and travel down through
Xthe color ranges.
X
XAt any time, you can type "q" into the graphics window to end the program.
XIt will stop automatically after 100 steps.
END_OF_FILE
if test 3896 -ne `wc -c <'./doc/readme.tec'`; then
echo shar: \"'./doc/readme.tec'\" unpacked with wrong size!
fi
# end of './doc/readme.tec'
fi
if test -f './example/clim.in' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'./example/clim.in'\"
else
echo shar: Extracting \"'./example/clim.in'\" \(1840 characters\)
sed "s/^X//" >'./example/clim.in' <<'END_OF_FILE'
X(LAND (
X000000000000000000000011111000000000011111111111100000000000
X000000000000000000000111111100000000011111111111110000000000
X000000000000000000001111111110000000011111111111110000000000
X000000000000000000011111111110000000011111111111110000000000
X000000000000000000111111111110000000011111111111110000000000
X000000000000001111111122111110000000011111111111100000000000
X000000000000011111111222111100000000011111111111100000000000
X000000000000011111112222111100000000001111111111000000000000
X000000000000011111222221111000000000001111111111000000000000
X000000000000111112222211111000000000000111111111000000000000
X000000000000111122222211110000000000000111111111000000000000
X000000000000111222221111100000000000000111111111000000000000
X000000000000111222211111000000000000000111111111000000000000
X000000000000111222111110000000000000000111111110000000000000
X000000000000111221111100000000000000111111111110000000000000
X000000000000111211111100000000000001111111111110000000000000
X000000000000111111111000000000000001111111111110000000000000
X000000000000111111110000000000000011111111111100000000000000
X000000000000111111110000000000000011111111111000000000000000
X000000000000111111100000000000000111111111110000000000000000
X000000000000111111000000000000001111111111110000000000000000
X000000000000111111000000000000001111111111000000000000000000
X000000000000000000000000000000011111111111000000000000000000
X000000000000000000000000000000111111111111000000000000000000
X000000000000000000000000000000111111111111000000000000000000
X000000000000000000000000000001111111111110000000000000000000
X000000000000000000000000000001111111111110000000000000000000
X000000000000000000000000000001111111111100000000000000000000
X000000000000000000000000000000111111111100000000000000000000
X000000000000000000000000000000011111110000000000000000000000))
END_OF_FILE
if test 1840 -ne `wc -c <'./example/clim.in'`; then
echo shar: \"'./example/clim.in'\" unpacked with wrong size!
fi
# end of './example/clim.in'
fi
if test -f './example/clim.out' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'./example/clim.out'\"
else
echo shar: Extracting \"'./example/clim.out'\" \(1830 characters\)
sed "s/^X//" >'./example/clim.out' <<'END_OF_FILE'
X333333333333333333333333333333333333333333333333333333333333
X333333333333333333333333333333333333333333333333333333333333
X333333333333333333333333333334444444444444433333333333333333
X333333333333333333333333333300088885555555550000003333333333
X000000000000000000000000000000008888555555555888000000000000
X000000000000000080000000000000000088555555588888800000000000
X000000000000885550000000000000000000005555555558850000000000
X000000000000887667000000000000000000006655555555557000000000
X000000000000877666780000000000000000006666666667667700000000
X000000000000877666788000000000000000007666666667777880000000
X000000000000876666778800000000000000007766667778887880000000
X000000000000866666777888000000000000006666677778888800000000
X000000000000666666777779900000000000007797900000009000000000
X000000000000666666777777999000000000000000000000000000000000
X000000000000777766777777799990000000000000000000000000000000
X000000000000999777777777779999900000000000000000000000000000
X000000000000A999999999999999999A0000000000000000000000000000
X000000000000A99997777777777777900000000000000000000000000000
X000000000000999979777677777770000000000000000000000000000000
X000000000000988888766677667700000000000000000000000000000000
X000000000000008888876666677800000000000000000000000000000000
X000000000000000088887767677000000000000000000000000000000000
X000000000000000000080007700000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000
X333333333333333333333333333333333333333333333333333333333333
X333333333333333333333333333333333333333333333333333333333333
X333333333333333333333333333333333333333333333333333333333333
END_OF_FILE
if test 1830 -ne `wc -c <'./example/clim.out'`; then
echo shar: \"'./example/clim.out'\" unpacked with wrong size!
fi
# end of './example/clim.out'
fi
if test -f './example/tec.out.1' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'./example/tec.out.1'\"
else
echo shar: Extracting \"'./example/tec.out.1'\" \(3504 characters\)
sed "s/^X//" >'./example/tec.out.1' <<'END_OF_FILE'
X000000000000000000000000000000000000222222221110000000000000000000000000
X000000000000001111110000000000000001222111111100000000000000000000000000
X000000000000011111111000000000000011211111111000000000000000000000000000
X000000000001111111111111000000000111111111110000001110000000000000000000
X000000000011111111111111100000000111111111100000011100000000000000000000
X000000000011111111111111110000001111111111000000011110000000000000000000
X000000000111111111111111111000011111111100000000111110000000000000000000
X000000000111111111111111111100111111111000000001111110000000000000000000
X000000000111111111111111111001111111110000000011111111000000000000000000
X000000000111111111111111111111111111100000000111111111000000000000000000
X000000000111111111111111111111111110000000011111111111000000000000000000
X000000000111111111111111111111111100000000111111111111000000000000000000
X000000000111111111112211111222110000000001111111111110000000000000000000
X000000000111111111122222221111100000000011111221111111000000000000000000
X000000000111111111122222111000000000001111122212221111100000000000000000
X000000000011111111112222100000000000011112222212111111100000000000000000
X000000000011111111111121000000000011111222222211111111110000000000000000
X000000000011111111111010000000000111112222222211111111111000000000000000
X000000000011111111100000000001111111222221112111111111111100000000000000
X000000000011111111000000000112211222222211122111111111111111000000000000
X000000000011111111000000001211111222221111111111111111111110000000000000
X000000000000001110000000011111122222111111111111111111111110000000000000
X000000000000000000000000111111222221111111111111111111100000000000000000
X000000000000000000000001111212222111111111111101111111000000000000000000
X000000000000000000000001222122221111111111111001111111000000000000000000
X000000000000000000000001222222111111111111111101111110000000000000000000
X000000000000000000000001222111111111111111111100110000000000000000000000
X000000000000000000000001211111111111111111111000000000000000000000000000
X000000000000000000000001111111111111111111111000000000000000000000000000
X000000000000000000000000111111111111111111110000000000000000000000000000
X000000000000000000000000111111111111111100000000000000000000000000000000
X000000000000000000000000111111111111111000000000000000000000000000000000
X000000000000000000000000011011111111100000000000000000000000000000000000
X000000000000000000000000000011111111000000000000000000000000000000000000
X000000000000000000000000000000110000000000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000000000000000
END_OF_FILE
if test 3504 -ne `wc -c <'./example/tec.out.1'`; then
echo shar: \"'./example/tec.out.1'\" unpacked with wrong size!
fi
# end of './example/tec.out.1'
fi
if test -f './example/tec.out.2' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'./example/tec.out.2'\"
else
echo shar: Extracting \"'./example/tec.out.2'\" \(3504 characters\)
sed "s/^X//" >'./example/tec.out.2' <<'END_OF_FILE'
X000000000000000000000000000000000000000000000000011111111111221000000000
X000000000000000000000000000000000000000000000000001111111111222000000000
X000000000000000000000000000011000000000000000000001111111111122100000000
X000000000000000000000000011111110000000000000000000111111111111100000000
X000000000000000000000000111111111100000000000000000111111111111100000000
X000000000000000000000000011111111100000000000000000011111111111001100000
X000000000000000000110000000011111100000000000000000011111111111011110000
X000000000000000001110000000001111100000000000000000001111111211121111000
X000000000000000001110110000000011110000000000000000001111111221121111000
X000000000000000001111100000000000111000000000000000000111111221121111000
X000000000000000001111110000000000111000001000000000000111111221121111000
X000000000000000001111111110000000111000001000000000000011111221111111000
X000000000000000001111111111000001111000001000000000000001111211112111000
X000000000000000001211111111100011111000001000000000000001111221112111000
X000000000000000001111111111110111111000001100000000000000111122112111000
X000000000000000001111111111111111111000001110000000000000111122112111000
X000000000000000001111111111111111111000001111000000000000011122112111000
X000000000000000001111111111111111111000001111000000000000011112111210000
X000000000000000000111111111111111111000001111100000000000001112211110000
X000000000000000000111111111111111111000001111110000000000000112211110000
X000000000000000000111111111111111111000001111110000000000000011221110000
X000000000000000000111111111111111111000001111111000000000000001111100000
X000000000000000000121111111111111111000001111111000000000000000111000000
X000000000000000000011111111111111111000001111111000000000000000010000000
X000000000000000000001111111111111111000001111111100000000000000000000000
X000000000000000000000000121111111111000001111111110000000000000000000000
X000000000000000000000000111111111110000001111111111000000000000000000000
X000000000000000000000000121111111100000001111111111100000000000000000000
X000000000000000000000000011111111000000011111111111110000000000000000000
X000000000000000000000000001111111000000011111111111110000000000000000000
X000000000000000011111100000111111000000011111111111111000000000000000000
X000000000000000112222110000000011000000011111111111111000000000000000000
X000000000001011222222210000000001000000011111111111111100000000000000000
X000000000011112221112211000000000000000001111111111111110000000000000000
X000000000012222111111121000000000000000001111111111111110000000000000000
X000000000012211111111121110000000000000001111111111111100000000000000000
X000000000011111111111112211111000000000001111111111111000000000000000000
X000000000001111111111112222221110000000001111111111110000000000000000000
X000000000011111111111112222222221100000000000000000000000000000000000000
X000000000011111111112222222222222110000000000000000000000000000000000000
X000000000011111111112222222222222210000000000000000000000000000000000000
X000000000001111001111111111111111110000000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000000000000000
END_OF_FILE
if test 3504 -ne `wc -c <'./example/tec.out.2'`; then
echo shar: \"'./example/tec.out.2'\" unpacked with wrong size!
fi
# end of './example/tec.out.2'
fi
if test -f './example/tec.out.3' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'./example/tec.out.3'\"
else
echo shar: Extracting \"'./example/tec.out.3'\" \(3504 characters\)
sed "s/^X//" >'./example/tec.out.3' <<'END_OF_FILE'
X000000000000000000000000000000000000000000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000000000000000
X000000000000000000000000000001110000000000000000000011000000000000000000
X000000000000000000000000000001101111111111111111111111000000000000000000
X000000000000000000000000000000001111111111111111111111000000000000000000
X000000000000000000000011000000000111111111111111111111000000000000000000
X000000000000000000000011100000000001111111111111111111110000000000000000
X000000000000000000000011111100000000011111111111111111110000000000000000
X000000000000000000000011111100000000000111111111111111100000000000000000
X000000000000000000000011111110000000000011111111111111100000000000000000
X000000000000000000000011111111110000000001111111111110111111110000000000
X000000000000000000000011111111111000000001111111111101111111111000000000
X000000000000000000000011111111111110000000111111000001111111111110000000
X000000000000000000000011111111111111000000011110000011111111111110000000
X000000000000000000000011111111111110000000111110000111111111111000000000
X000000000000000000000011111111111111100001111110001111111111110000000000
X000000000000000000000011111111111111110011111111111111111111110000000000
X000000000000000000000001111111111111111111111111111111111111111100000000
X000000000000000000000001111111111111111111111111111111111111111110000000
X000000000000000000000001111111111111111111111111111111111111111110000000
X000000000000000000000001111111112221111111111111111111111111111110000000
X000000000000000000000001111111112221111111111111111111111000010000000000
X000000000000000000000000111111112211111111111111111111110000000000000000
X000000000000000000000000000011122111111111111111111111111000000000000000
X000000000000000000000000000111121111111111111111111111111100000000000000
X000000000000000000000000001111111111111011111111111111111100000000000000
X000000000000000000000000011112111111110011111111111111111100000000000000
X000000000000000111111111111122111111110011111111111111111000000000000000
X000000000000000111111111111111111111110011111111111111110000000000000000
X000000000000000111111112222111111111110011111111111111000000000000000000
X000000000000000111111222211111111111110011111111111111100000000000000000
X000000000000000111111221111111111111111001111111111111110000000000000000
X000000000000000111111111111111111111111101111111111111100000000000000000
X000000000000000111111111111111111111111101111111111111000000000000000000
X000000000000000111111111111111111111111001111111111110000000000000000000
X000000000000000111111111111000111111100001111101101100000000000000000000
X000000000000000111111111000000000000000000000000000000000000000000000000
X000000000000000001111110000000000000000000000000000000000000000000000000
X000000000000000000111000000000000000000000000000000000000000000000000000
X000000000000000000010000000000000000000000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000000000000000
X000000000000000000000000000000000000000000000000000000000000000000000000
END_OF_FILE
if test 3504 -ne `wc -c <'./example/tec.out.3'`; then
echo shar: \"'./example/tec.out.3'\" unpacked with wrong size!
fi
# end of './example/tec.out.3'
fi
if test -f './src/clim.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'./src/clim.h'\"
else
echo shar: Extracting \"'./src/clim.h'\" \(675 characters\)
sed "s/^X//" >'./src/clim.h' <<'END_OF_FILE'
X#define MAXB 4
X#define LINE_DIAG 1
X#define LINE_CORN 2
X#define LINE_0V 1
X#define LINE_1V 2
X#define LINE_0H 4
X#define LINE_1H 8
X#define N LINE_0V
X#define S LINE_1V
X#define E LINE_0H
X#define W LINE_1H
X#define PR_LOW 1
X#define PR_HIGH 2
X#define PR_HEQ 3
X#define M_MAIN 0
X#define M_HEAT 1
X#define M_PRESS 2
X#define M_WIND 3
X#define M_RAIN 4
X#define M_CLIM 5
X#define C_OCEAN 0
X#define C_BARELAND 1
X#define C_MOUNTAIN 2
X#define C_OCEANICE 3
X#define C_TUNDRA 4
X#define C_STEPPE 5
X#define C_DESERT 6
X#define C_SAVANA 7
X#define C_DECID 8
X#define C_JUNGLE 9
X#define C_SWAMP 10
END_OF_FILE
if test 675 -ne `wc -c <'./src/clim.h'`; then
echo shar: \"'./src/clim.h'\" unpacked with wrong size!
fi
# end of './src/clim.h'
fi
if test -f './src/climate.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'./src/climate.c'\"
else
echo shar: Extracting \"'./src/climate.c'\" \(4025 characters\)
sed "s/^X//" >'./src/climate.c' <<'END_OF_FILE'
X/* This program is Copyright (c) 1991 David Allen. It may be freely
X distributed as long as you leave my name and copyright notice on it.
X I'd really like your comments and feedback; send e-mail to
X allen@viewlogic.com, or send us-mail to David Allen, 10 O'Moore
X Avenue, Maynard, MA 01754. */
X
X/* This file contains the routines that compute local climate */
X
X#include "const.h"
X#include "clim.h"
X
X
X/* Input arrays are l from main.c, rn from rain.c, and t from heat.c. Note
X that the unscaled temperatures are used. The output array is cl. Array
X lm (from main.c) is used by the drawing routine.*/
X
Xextern unsigned char l[MAXX][MAXY], lm[MAXX][MAXY], rn[MAXB][MAXX][MAXY];
Xextern int tt[MAXB][MAXX][MAXY];
Xunsigned char cl[MAXX][MAXY];
X
X
X/* These parameters are defined in main.c or heat.c */
Xextern int BSIZE, XSIZE, YSIZE, TEMPSCALE, PRINTMODE;
X
X/* These parameters are used here, and are described in params.doc */
Xint tempcut[] = { 0, 40, 90, 120 }, raincut[] = { 40, 60, 110, 160, 180 };
Xint PRINTCLIM = 0, MTDELTA = 20, TCSIZE = 4, RCSIZE = 5;
Xdouble ICEBERGK = 263.0;
X
X
X/* This array is the heart of the climate routine; temperature increases
X going down the array, and rainfall increases going from left to right. */
X
Xstatic unsigned char climkey[4][5] = {
X { C_TUNDRA, C_TUNDRA, C_TUNDRA, C_TUNDRA, C_TUNDRA },
X { C_STEPPE, C_STEPPE, C_DECID, C_DECID, C_DECID },
X { C_DESERT, C_SAVANA, C_DECID, C_JUNGLE, C_SWAMP },
X { C_DESERT, C_SAVANA, C_JUNGLE, C_SWAMP, C_SWAMP } };
X
X
Xclimpar (s) char *s; {
X /* This function is called by mainpar() in main.c; it simply tests input
X parameter names to see if they are defined in this file. Each of the
X above ints are defined in this file. If the input string matches here,
X the function returns true. */
X if (CMP ("ICEBERGK")) getdbl (&ICEBERGK, M_CLIM);
X else if (CMP ("PRINTCLIM")) getlng (&PRINTCLIM, M_CLIM);
X else if (CMP ("TEMPCUT")) getlvec (&TCSIZE, tempcut, M_CLIM);
X else if (CMP ("RAINCUT")) getlvec (&RCSIZE, raincut, M_CLIM);
X else if (CMP ("MTDELTA")) getlng (&MTDELTA, M_CLIM);
X else if (CMP ("PRINTCLIM")) getlng (&PRINTCLIM, M_CLIM);
X else return (0);
X return (1); }
X
X
Xclimdraw () { draw (DRAW_CLIM, LINE_CORN, cl, lm); }
X /* This routine calls draw with the proper arguments to display climate */
X
X
Xclimcomp () {
X /* The outer loop looks at each square. If it is ocean, the climate will
X be ocean unless the temperature is below ICEBREGK degrees all year round.
X If it is land, then the average rainfall and temperature (in Farenheit) are
X computed for the square. If the square is mountain, it is colder; the
X temperature is decreased. These two figures are then turned into array
X indices by using the tempcut and raincut parameter vectors. The climate
X for the square is then simply a table lookup. Finally, the array is printed
X if desired. */
X
X register int i, j, buf;
X int noice, avetemp, averain, ttt, r;
X
X usermessage ("Computing climate"); checkmouse ();
X for (j=0; j<YSIZE; j++) for (i=0; i<XSIZE; i++) {
X if (!l[i][j]) { /* ocean */
X for (noice=0, buf=0; buf<BSIZE; buf++)
X noice |= (tt[buf][i][j] > TEMPSCALE * ICEBERGK);
X cl[i][j] = noice ? C_OCEAN : C_OCEANICE; }
X else { /* land or mountain */
X for (averain=0, avetemp=0, buf=0; buf<BSIZE; buf++) {
X averain += rn[buf][i][j]; avetemp += tt[buf][i][j]; }
X averain /= BSIZE; avetemp /= BSIZE;
X avetemp = ((double) (avetemp / TEMPSCALE) - 273.0) * 1.8 + 32.0;
X if (l[i][j] == 2) avetemp -= MTDELTA;
X ttt = 0; while ((avetemp > tempcut[ttt]) && (ttt < TCSIZE-1)) ttt++;
X r = 0; while ((averain > raincut[r]) && (r < RCSIZE-1)) r++;
X cl[i][j] = climkey[ttt][r]; } }
X if (PRINTCLIM) {
X if (PRINTMODE == PRINTMODE_GREY)
X putmat ("CLIMATE", -1, PRINTMODE_CLIM, cl, lm);
X else putmat ("CLIMATE", -1, PRINTMODE_SHORT, cl, lm); } }
END_OF_FILE
if test 4025 -ne `wc -c <'./src/climate.c'`; then
echo shar: \"'./src/climate.c'\" unpacked with wrong size!
fi
# end of './src/climate.c'
fi
if test -f './src/const.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'./src/const.h'\"
else
echo shar: Extracting \"'./src/const.h'\" \(467 characters\)
sed "s/^X//" >'./src/const.h' <<'END_OF_FILE'
X#define MAXX 100
X#define MAXY 100
X#define PRINTMODE_NONE 0
X#define PRINTMODE_LONG 1
X#define PRINTMODE_SCALE 2
X#define PRINTMODE_SHORT 3
X#define PRINTMODE_GREY 4
X#define PRINTMODE_CLIM 5
X#define DRAW_GREY 1
X#define DRAW_LAND 2
X#define DRAW_CLIM 3
X#define DRAW_TEC 4
X#define LINE_DIAG 1
X#define LINE_CORN 2
X#define LINE_NONE 3
X
X#define ABS(xx) ((xx < 0) ? -xx: xx)
X#define CMP(x) !strcmp (s, x)
X
Xextern double cos(), sin(), sqrt(), atof(), asin(), atan2();
END_OF_FILE
if test 467 -ne `wc -c <'./src/const.h'`; then
echo shar: \"'./src/const.h'\" unpacked with wrong size!
fi
# end of './src/const.h'
fi
if test -f './src/globe.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'./src/globe.c'\"
else
echo shar: Extracting \"'./src/globe.c'\" \(3176 characters\)
sed "s/^X//" >'./src/globe.c' <<'END_OF_FILE'
X/* This program is Copyright (c) 1991 David Allen. It may be freely
X distributed as long as you leave my name and copyright notice on it.
X I'd really like your comments and feedback; send e-mail to
X allen@viewlogic.com, or send us-mail to David Allen, 10 O'Moore
X Avenue, Maynard, MA 01754. */
X
X/* This file contains a spinning globe animation */
X
X#include "const.h"
X#define N ((MAXX / 2) - 1)
X#define AREA (MAXX * MAXX)
X#define RADIUS 45
X#define PI 3.14159
X#define TWOPI (2.0 * PI)
X#define HALFPI (PI / 2.0)
X#define SET(n,x,y,i,j) m[n][(x)+N][(y)+N] = m[0][(i)+N][(j)+N]
X
Xunsigned char m[21][MAXX][MAXY];
Xint rx[] = {0, 0, 0, 0, 0}, ry[] = {0, N, 0, N, 0};
Xint xofs, prime, xflip, sflip, sxflip, change[1], step = 0;
Xint MAXSTEP = 10000, PRINTMODE = PRINTMODE_SCALE, XSIZE = MAXX, YSIZE = MAXX;
Xint ZCOAST = 0;
X
X
Xinit (s) char *s; { int i;
X fileinit ();
X if (!s || !(*s)) panic ("no valid filename"); else getparams (s);
X for (i=1, xofs=45; i<6; xofs-=10, i++) {
X prime = 16-i; xflip = i+5; sflip = 15+i; sxflip = 6-i; compute (); } }
X
X
Xonestep () { static int i = 0;
X draw (DRAW_TEC, LINE_NONE, m[i], 0); i++; step++;
X if (i == 5) i = 6; if (i == 16) i = 17; if (i == 21) i = 1; }
X
X
Xmainpar (s) char *s; { int vec [AREA], index = AREA; register int i, j, k;
X
X if (CMP ("LAND")) {
X getlvec (&index, vec, 0);
X for (k=0, j=0; j<MAXX; j++) for (i=0; i<MAXX; i++, k++)
X m[0][i][j] = (vec[k] > 16) ? vec[k] : 16;
X return (1); }
X return (0); }
X
X
Xcompute () {
X register int i, j, top; int x, y;
X
X rx[0] = xofs + N; rx[4] = rx[0]; rx[2] = xofs - N;
X for (j=0; j<RADIUS; j++) {
X checkmouse ();
X top = sqrt ((double) (RADIUS * RADIUS - j * j + 0.5));
X for (i=1-top; i<top; i++) {
X point (i, j, &x, &y);
X SET (prime, i, j, x, y); SET (prime, i, -j, x, -y);
X SET (xflip, -i, j, -x, y); SET (xflip, -i, -j, -x, -y);
X permute (x, y, &x, &y);
X SET (sxflip, i, -j, -x, y); SET (sxflip, i, j, -x, -y);
X SET (sflip, -i, -j, x, y); SET (sflip, -i, j, x, -y); } } }
X
X
Xpoint (x, y, i, j) int x, y, *i, *j; {
X double r, theta, topx, topy, botx, boty; int bot, top;
X
X r = asin (sqrt ((double)(x * x + y * y)) / RADIUS) * 2.0 / PI;
X if (x || y) theta = atan2 ((double)y, (double)x);
X else theta = 0;
X if (theta <= 0) theta += TWOPI;
X bot = 0; while (theta > HALFPI) { bot++; theta -= HALFPI; }
X top = bot + 1; theta = theta / HALFPI;
X mapr (bot, r, &botx, &boty); mapr (top, r, &topx, &topy);
X *i = botx + theta * (topx - botx) + 0.5;
X *j = boty + theta * (topy - boty) + 0.5;
X if (*i >= N) *i = N-1; if (*j >= N) *j = N-1; }
X
X
Xmapr (n, r, x, y) int n; double r, *x, *y; {
X *x = r * (rx[n] - xofs) + xofs;
X *y = r * ry[n];
X if (*x >= N) { *y = *x - N; *x = N; if (n == 4) *y = -(*y); } }
X
X
Xpermute (x, y, i, j) int x, y, *i, *j; {
X if ((x >= 0) && (y >= 0)) { *i = N - y - 1; *j = x - N + 0; }
X if ((x < 0) && (y >= 0)) { *i = y - N + 0; *j = -N - x - 1; }
X if ((x >= 0) && (y < 0)) { *i = y + N + 0; *j = N - x - 1; }
X if ((x < 0) && (y < 0)) { *i = -N - y - 1; *j = x + N + 0; } }
X
X
Xgreyscale (x) int x; { }
END_OF_FILE
if test 3176 -ne `wc -c <'./src/globe.c'`; then
echo shar: \"'./src/globe.c'\" unpacked with wrong size!
fi
# end of './src/globe.c'
fi
if test -f './src/tec.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'./src/tec.h'\"
else
echo shar: Extracting \"'./src/tec.h'\" \(531 characters\)
sed "s/^X//" >'./src/tec.h' <<'END_OF_FILE'
X#define MAXSPLINTER 10
X#define MAXFRAG 100
X#define MAXPLATE 40
X#define MAXCHANGE 10
X#define REALSCALE 100
X
Xstruct plate { int dx, dy, odx, ody, rx, ry, age, area, id, next; };
X
Xextern int XSIZE, YSIZE, MAXSTEP;
Xextern int MAXLIFE, MAXBUMP, BUMPTOL;
Xextern int DRAWEVERY, HYDROPCT, PRINTMODE;
Xextern int ZINIT, ZSUBSUME, ZCOAST;
Xextern int ZSHELF, ZMOUNTAIN, ZERODE;
Xextern int RIFTPCT, DOERODE, ERODERND;
Xextern int MAXCTRTRY, RIFTDIST, BENDEVERY;
Xextern int BENDBY, SPEEDBASE, SPEEDRNG;
Xextern int UNDERSCAN;
Xextern double MR[];
END_OF_FILE
if test 531 -ne `wc -c <'./src/tec.h'`; then
echo shar: \"'./src/tec.h'\" unpacked with wrong size!
fi
# end of './src/tec.h'
fi
if test -f './src/unix.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'./src/unix.c'\"
else
echo shar: Extracting \"'./src/unix.c'\" \(862 characters\)
sed "s/^X//" >'./src/unix.c' <<'END_OF_FILE'
X/* This program is Copyright (c) 1991 David Allen. It may be freely
X distributed as long as you leave my name and copyright notice on it.
X I'd really like your comments and feedback; send e-mail to
X allen@viewlogic.com, or send us-mail to David Allen, 10 O'Moore Ave,
X Maynard, MA 01754. */
X
X#include "const.h"
Xextern int XSIZE, YSIZE, MAXSTEP, step;
Xint picktype;
X
Xmain (argc,argv) int argc; char **argv; {
X unsigned short seed16v[3];
X
X /* Initialize random number generator */
X srand (time ((long *) 0)); /* initialize rand() */
X seed16v[0] = rand(); seed16v[1] = rand(); seed16v[2] = rand();
X seed48 (seed16v); /* initialize lrand48() */
X
X init (*++argv);
X for (step=0; step<MAXSTEP; step++) onestep();
X return (0); }
X
Xcheckmouse () { }
X
Xpanic (s) char *s; { printf ("PANIC: %s\n", s); exit (1); }
X
Xdraw (ctype, ltype, cra, lra) { }
END_OF_FILE
if test 862 -ne `wc -c <'./src/unix.c'`; then
echo shar: \"'./src/unix.c'\" unpacked with wrong size!
fi
# end of './src/unix.c'
fi
if test -f './src/wind.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'./src/wind.c'\"
else
echo shar: Extracting \"'./src/wind.c'\" \(5268 characters\)
sed "s/^X//" >'./src/wind.c' <<'END_OF_FILE'
X/* This program is Copyright (c) 1991 David Allen. It may be freely
X distributed as long as you leave my name and copyright notice on it.
X I'd really like your comments and feedback; send e-mail to
X allen@viewlogic.com, or send us-mail to David Allen, 10 O'Moore
X Avenue, Maynard, MA 01754. */
X
X/* This file contains the wind computation routines. */
X
X#include "const.h"
X#include "clim.h"
X#define MAXPRESS 255
X
X/* Input arrays are pr, from pressure.c, and l, from main.c. The array
X hl is used as temporary storage for highs and lows, while p is used
X to store the smoothed pressure map. The output array, wd, contains
X an edge map with wind directions. */
X
Xextern unsigned char pr[MAXB][MAXX][MAXY], l[MAXX][MAXY];
Xunsigned char wd[MAXB][MAXX][MAXY];
Xstatic char hl[2][MAXX][MAXY];
Xstatic unsigned char p[MAXX][MAXY];
X
X/* The externs below are parameters defined in main.c. The other two ints
X are parameters described in params.doc. */
X
Xextern int XSIZE, YSIZE, BSIZE, PRINTMODE;
Xint BARSEP = 16, PRINTWIND = 0;
X
X
Xwindpar (s) char *s; {
X /* This function is called by mainpar() in main.c; it simply checks to
X see if the parameter is defined in this file. If so, it returns true. */
X if (CMP ("BARSEP")) getlng (&BARSEP, M_WIND);
X else if (CMP ("PRINTWIND")) getlng (&PRINTWIND, M_WIND);
X else return (0);
X return (1); }
X
X
Xwindcomp () {
X /* This is the main function in this file; it calls getpress() to create
X a smoothed pressure map, then getwind() to put isobars (wind lines) on
X the output map. The last step makes sure that contradictory winds are
X removed, such as N and S winds in the same square. */
X
X register int i, j, x, buf;
X
X for (buf=0; buf<BSIZE; buf++) {
X status (M_WIND, buf); getpress (buf); getwind (buf);
X for (j=0; j<YSIZE; j++) for (i=0; i<XSIZE; i++) {
X x = wd[buf][i][j];
X if (x & N) x &= (~S); if (x & E) x &= (~W);
X wd[buf][i][j] = x; } }
X
X if (PRINTWIND) for (buf=0; buf<BSIZE; buf++) {
X if (PRINTMODE == PRINTMODE_GREY)
X putmat ("WIND", buf, PRINTMODE_SHORT, l, wd[buf]);
X else putmat ("WIND", buf, PRINTMODE_SHORT, wd[buf], 0); } }
X
X
Xwindraw (n) int n; { draw (DRAW_LAND, LINE_DIAG, l, wd[n]); }
X /* This function calls draw with the right arguments to display wind */
X
X
Xgetpress (buf) int buf; {
X /* This function takes the high and low markings from pressure.c and creates
X a smoothed function. Highs turn into MAXPRESS and lows turn into 0. */
X
X register int i, j;
X
X for (j=0; j<YSIZE; j++) for (i=0; i<XSIZE; i++) {
X /* Zero out the arrays to be used */
X wd[buf][i][j] = 0; hl[0][i][j] = 0; hl[1][i][j] = 0;
X
X /* Fill hl[0] with the low pressure zones, and hl[1] with highs */
X if (pr[buf][i][j] == PR_LOW) hl[0][i][j] = -1;
X else if (pr[buf][i][j] == PR_HIGH) hl[1][i][j] = -1;
X else if (pr[buf][i][j] == PR_HEQ) hl[0][i][j] = -1; }
X
X /* Set each square in hl[0] to the distance from that square to the */
X /* nearest low, and each square in hl[1] to the distance to a high. */
X range (hl[0]); range (hl[1]);
X
X /* The final pressure, in array p, is zero if a low is there and */
X /* MAXPRESS if a high is there. Otherwise, the pressure in a square is */
X /* proportional to the ratio of (distance from the square to the nearest */
X /* low) to (total of distance from nearest high and nearest low). This */
X /* gives a smooth curve between the extremes. */
X for (j=0; j<YSIZE; j++) for (i=0; i<XSIZE; i++) {
X if (hl[1][i][j] == -1) p[i][j] = MAXPRESS;
X else if (hl[0][i][j] == -1) p[i][j] = 0;
X else p[i][j] = (MAXPRESS*hl[0][i][j]) / (hl[0][i][j] + hl[1][i][j]); } }
X
X
Xgetwind (buf) int buf; {
X /* This function draws isobars around the pressure map created above. These
X isobars are the directions of wind flow. The isobars are given a direction
X depending on whether the square is above or below the heat equator; north of
X the heat equator, the winds blow counterclockwise out from a low, while
X south of it, the opposite is true. */
X
X register int i, j; int a, b, e, bar;
X
X /* Step from 0 to MAXPRESS by BARSEP; bar is the pressure for which this */
X /* isobar will be drawn. */
X for (bar=BARSEP; bar<=MAXPRESS; bar+=BARSEP) {
X checkmouse ();
X for (i=0; i<XSIZE; i++) for (e=0, j=0; j<YSIZE; j++) {
X
X /* Set e if this square is south of the heat equator */
X a = p[i][j]; if (pr[buf][i][j] == 3) e = 1;
X
X /* Provided the square is not at the top of the array, compare the */
X /* pressure here to the pressure one square up. This gives the */
X /* direction of the wind in terms of east / west flow. */
X if (j) {
X b = p[i][j-1];
X if ((a < bar) && (b >= bar)) wd[buf][i][j] |= (e ? E : W);
X if ((a >= bar) && (b < bar)) wd[buf][i][j] |= (e ? W : E); }
X
X /* Compare the pressure here to the pressure one square to the left */
X /* (including wraparound); this gives the wind direction in terms */
X /* of north / south flow. */
X b = i ? p[i-1][j] : p[XSIZE-1][j];
X if ((a < bar) && (b >= bar)) wd[buf][i][j] |= (e ? N : S);
X if ((a >= bar) && (b < bar)) wd[buf][i][j] |= (e ? S : N); } } }
END_OF_FILE
if test 5268 -ne `wc -c <'./src/wind.c'`; then
echo shar: \"'./src/wind.c'\" unpacked with wrong size!
fi
# end of './src/wind.c'
fi
echo shar: End of archive 4 \(of 4\).
cp /dev/null ark4isdone
MISSING=""
for I in 1 2 3 4 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 4 archives.
rm -f ark[1-9]isdone
else
echo You still must unpack the following archives:
echo " " ${MISSING}
fi
exit 0
exit 0 # Just in case...
--
Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM
Sterling Software, IMD UUCP: uunet!sparky!kent
Phone: (402) 291-8300 FAX: (402) 291-4362
Please send comp.sources.misc-related mail to kent@uunet.uu.net.