Classic Computer Magazine Archive COMPUTE! ISSUE 86 / JULY 1987 / PAGE 36

Weather Wizard

John R. Wetsch

This weather forecasting program is written entirely in BASIC and can be adapted to run on virtually any computer with BASIC. The original version is written for the IBM PC/PCjr. We have added translations for the Commodore 64, Amiga, Atari ST, Apple II, and Atari 400, 800, XL, and XE.

"Weather Wizard" is a simple, easily modified BASIC program for forecasting the weather. Because every version is similar, we've published one main program and provided line changes and modifications for each individual machine. Begin by typing in the main program (Program 1). When that's done, add or modify the lines listed for your specific computer. After you have typed the complete program for your computer, save a copy to tape or disk before you run it.

Atari ST users should note that several lines must be deleted from the main program to produce a proper display. See the REM statement in line 1 of Program 6 for details. Amiga users should remember that Amiga BASIC does not automatically arrange numbered program lines in numerical order. Be careful to type the lines of the main program in the order shown. The extra line in Program 7 must be added as the first line of the program.

Entering Data

Weather Wizard is largely self-prompting, so you will not need extensive instructions to use it. The program begins by asking you to enter several items of information about current weather conditions, beginning with the current month, day, and year. Enter a number from 1 to 12 for the month, a number from 1 to 31 for the day, and so on.

The program then displays instructions for entering the next item of information, the wind direction. This is done by typing a number according to the categories shown on the screen.

Next, you must enter the current barometric pressure, expressed in inches of mercury. This will be a number in the range 27–33.

After the barometric pressure, you must enter the barometric activity (whether the barometer is steady, rising fast, and so forth). Again, the computer displays a menu indicating which number to type.

The next item of information is the prevailing cloud type. As prompted by the computer, enter a 1 for cirrus clouds, a 2 for cumulus, and so on. If you are not familiar with the various cloud types, refer to the brief explanations at the end of this article.

Finally, enter the current humidity and temperature when prompted. When you are finished entering data, the computer prints a complete forecast for a 6- to 36-hour period. The period of the forecast depends on what sort of weather is expected. To calculate another forecast, answer Y at the final prompt.

Cloud Types

Cumulus clouds are puffy, white, and cottonlike in appearance with a clearly defined outline. Perhaps the most familiar cloud type, these are usually found at lower altitudes, with cloud tops seldom exceeding 5,000 feet.

Altocumulus clouds are small, semitransparent, cumulus-type cloudlets that appear in layers. This type of cloud evolves from the lifting of lower clouds. They often appear connected, and you can see the sky through them. Rounded and regularly arranged, they are usually found at an altitude of 10,000–17,000 feet.

When a cumulus cloud develops both extreme height and mass, it evolves into a cumulonimbus cloud. Although it makes up the most beautiful cloud mass, sweeping up into a towering column, these are the most dangerous clouds. Capable of producing heavy rain, hail, lightning, and strong, gusty winds, these clouds occasionally mask a tornado. These clouds may be easily identified by their massive appearance, vertical development (often in excess of 20,000 feet), anvil-shaped top, and thunder and lightning. Occasionally the tops of extremely powerful cumulonimbus clouds will exceed 30,000 feet.

Stratus clouds are gray, fea­tureless sheets, sometimes layered in appearance. This type of cloud produces only light precipitation, if any, and may reveal the sun through its thinnest parts. When in contact with the earth (at an altitude of 50 feet or less) this cloud type is called fog. The tops of stratus clouds rarely exceed 10,000 feet, although one variety, nimbostratus, may have cloud tops reaching to 15,000 feet.

The word nimbus is a Latin word which means violent rain or black rain cloud. Nimbostratus clouds produce continous precipitation. This cloud type is often gray and is always thick enough to obscure the sun. Nimbostratus clouds are usually found near weather fronts, and although classified as a middle-altitude cloud, with tops ranging to 15,000 feet, the cloud base may be quite low.

Altostratus clouds are a smooth, uniform, gray sheet of cloud cover, and consist mostly of ice crystals, although the lowest portion may be water droplets. The sun may appear as though seen through ground glass, and objects on the ground will not cast a shadow. Any precipitation associated with this cloud type is continous. Altostratus clouds are considered middle-level clouds, and generally occur between 6,500 and 23,000 feet in altitude.

Cirrostratus clouds are thin, white clouds that appear in sheets. The sun and moon are hardly ever obscured by these clouds which often indicate severe weather to come. They are typically found high in the atmosphere, usually above 25,000 feet.

Cirrus clouds are wispy and white, generally occurring between 16,500 feet and 45,000 feet. A buildup of cirrus clouds may indicate an approaching warm front.

Before entering this program, carefully read the typing instructions in the article.

Program 1: Weather Wizard—Main Program

For instructions on entering these programs, please refer to "COMPUTEI's Guide to Typing In Programs" elsewhere in this issue.

10 REM Copyright 1987 COMPUTE! Publications, Inc. All rights reserved'
20 GOSUB 1520
30 PRINT "The Weather Wizard"
40 PRINT
30 PRINT "Copyright 1987 COMPUTE! Publications":PRINT"All Rights Reserved
60 FOR J=1 TO 3000: NEXT J
70 GOSUB 1520
80 PRINT "Enter month (use number)";: MIN=1:MAX=12:GOSUB 139 0:M = E
90 PRINT "Enter Day":MIN=1:MAX=31: GOSUB 1390:D = E
100 PRINT "Enter the Year";:MIN=0:MAX=2100:GOSUB 1390:Y = E
110 GOSUB 1520
120 PRINT "Please input numbers when prompted by ?"
130 PRINT
140 PRINT ".From the menu enter the number corres-"
150 PRINT "ponding to the wind direction
160 PRINT
170 PRINT "N= North, S= South, E= East, W= West"
180 PRINT "(Note: The directions are where the"
190 PRINT "wind comes from, not where it is going."
200 PRINT "So, 'NE' means a wind blowing out of"
210 PRINT "the northeast.)"
220 PRINT
230 PRINT "--------- WIND DIRECTION MENU---------"
240 PRINT
250 PRINT "1. N"SPC(4)"2. NE"SPC(3)"3. E"
260 PRINT
270 PRINT "4. SE"SPC(3)"5. S"SPC(4)"6. SW"
280 PRINT
290 PRINT "7. W"SPC(4)"8. NW"SPC(3)"9. NO WIND"
300 PRINT
310 PRINT
320 MIN=1:MAX=9:GOSUB 1390:W =E
330 GOSUB 1520
340 PRINT "Enter barometric pressure":PRINT"in inches of H g (ex. 29.95) ";
350 MIN=27:MAX=33:GOSUB 1480:BP = E
360 GOSUB 1520
370 PRINT "Please enter the number that describes"
380 PRINT "current barometric activity."
390 PRINT "Barometer is: 1. steady"
400 PRINT SPC(14)"2. rising fast"
410 PRINT SPC(14)"3. slowly rising"
420 PRINT SPC(14)"4. falling fast"
430 PRINT SPC(14)"5. slowly falling"
440 PRINT
450 MIN=1:MAX=5:GOSUB 1390:BD = E
460 GOSUB 1520
470 PRINT "Please enter the number for the main"
480 PRINT "cloud type for your location."
490 PRINT
500 PRINT "1. Cirrus"PRINT"2. Cumulonimbus":PRINT"3. Stratus"
510 PRINT "4. Nimbostratus":PRINT"5. Altostratus":PRINT"6. Altocumulus"
520 PRINT "7. Cirrostratus":PRINT"8. Cumulus":PRINT"9. No clouds":PRINT
530 MIN=1:MAX=9:GOSUB 1390:C = E
540 GOSUB 1520
550 PRINT "Input Humidity"PRINT"(ex. input 50 for 50% humidity)";
560 MIN=0:MAX=100:GOSUB 1480:H = E
570 GOSUB 1520
580 PRINT "Input Temperature in Fahrenheit":PRINT"(ex. 63 = 63 deg. F)";
590 MIN=130:MAX=130:GOSUB 1480 :T = E
600 GOSUB 1520
610 REM FORECASTS
620 IF BP > 29.9 THEN 710
630 IF (W>=1 AND W<=5) AND BD=4 AND BP>29.7 THEN 860
640 IF (W>=6 AND W<=8) AND (BD> =1 AND BD<=3) AND T>75 AND H>68 THEN 910
650 IF (W>=6 AND W<=8) AND (BD=2 OR BD=3) THEN 930
660 IF BP > 29.7 THEN 810
670 IF (BD=2 OR BD=3) THEN 1040
680 IF (W>=1 AND W<=5> AND BD=4 THEN 1110
690 IF (W=2 OR W=3) AND BD=5 THEN 1120
700 GOTO 810
710 IF (W>=6 AND W<=8) AND (BD=1 OR BD=3) AND T>75 AND H>70 THEN 950
720 IF (W>=6 AND W<=8) AND (BD=1 OR BD=3) THEN 970
730 IF W=4 AND BD=5 THEN 1000
740 IF W=4 AND BP>30.5 AND <BD=4 OR BD=5) THEN 1020
750 IF (W=4 OR W=5) AND BD=4 THEN 1060
760 IF (W=4 OR W=5) AND BD=5 THEN 1080
770 IF (W=3 OR W=4) AND BD=4 THEN 1090
780 IF W=5 AND (BD=4 OR BD=5) THEN 860
790 IF (W=l OR W=2) AND BD=4 THEN 1140
800 IF (W=l OR W=2) AND BD=5 THEN 1160
810 ON C GOTO 1180, 1210, 1260, 1280, 1300, 820, 1310, 840, 840
820 IF T>75 AND H>68 THEN 950
830 GOTO 1310
840 IF T>73 AND H>68 THEN 1330
850 GOTO 1340
860 PRINT "FORECAST: STRONG WINDS and HEAVY"
870 PRINT "PRECIPITATION CAN BE EXPECTED within"
880 PRINT "the next 6-24 hours. Lower tempera-"
890 PRINT "tures are also forecast."
900 GOTO 1530
910 PRINT "[SMALL CHANCE OF THUNDERSTORMS TODAY]"
920 PRINT
930 PRINT "FORECAST: FAIR weather can be expected"
940 PRINT "for the next 24 to 36 hours": GOTO 1530
950 PRINT "[SLIGHT CHANCE OF THUNDERSTORMS TODAY]"
960 PRINT
970 PRINT "FORECAST: Continued FAIR weather for"
980 PRINT "the next 24 hours. Temperatures will"
990 PRINT "remain nearly constant.":GOT0 1530
1000 PRINT "FORECAST: PRECIPITATION can be expected"
1010 PRINT "in 24 - 48 hrs.":GOTO 1530
1020 PRINT "FORECAST: WARMER temperatures for the"
1030 PRINT "next 24 hours. " : GOTO 1530
1040 PRINT "FORECAST : Clear weather ahead with"
1050 PRINT "cooler temperatures. " : GOTO 1530
1060 PRINT "FORECAST : HIGH WINDS and PRECIPITATION"
1070 PRINT "within 12 hours. " : GOTO 1530
1080 PRINT "FORECAST : PRECIPITATION within 24 hours. " : GOTO 1530
1090 PRINT "FORECAST : HIGH WINDS and PRECIPITATION"
1100 PRINT "within 24 hours. " : GOTO 1530
1110 PRINT "FORECAST : SEVERE weather : stormy with" : PRINT "high winds. " : GOTO 1530
1120 PRINT "FORECAST : Continuing precipitation can"
1130 PRINT "be expected for the next 12 to 24 hours." : GOTO 1530
1140 PRINT "FORECAST : STORMS with HIGH WINDS within"
1150 PRINT "24 hours. Cooler temperatures as well." : GOTO 1530
1160 PRINT "FORECAST : Precipitation within 24–36"
1170 PRINT "hours, slightly cooler temperatures." : GOTO 1530
1180 PRINT "FORECAST : If cirrus clouds are"
1190 PRINT "increasing and becoming more dominant"
1200 PRINT "we can expect warmer weather. " : GOTO 1530
1210 PRINT "FORECAST : 50–80% chance of preci-"
1220 PRINT "pitation within the next 24–36 hours."
1230 PRINT "Chance of precipitation will increase"
1240 PRINT "with the accumulation of more cumulo-"
1250 PRINT "nimbus type clouds. " : GOTO 1530
1260 PRINT "FORECAST : 10–20% chance of " ; : IF T>35 THEN PRINT"showers" : GOTO 1530
1270 PRINT "snow flurries" : GOTO 1530
1280 PRINT "FORECAST : 90% chance of HEAVY precipi-"
1290 PRINT "tation within 12–24 hours. " : GOTO 1530
1300 PRINT "FORECAST : Chance of light precipitation" : GOTO 1530
1310 PRINT "FORECAST : PRECIPITATION with HEAVY"
1320 PRINT "winds in 24–48 hours. " : GOTO 1530
1330 PRINT "[POSSIBILITY OF THUNDERSTORMS TODAY]"
1340 PRINT "FORECAST : FAIR weather today with light"
1350 PRINT "to moderate winds." : GOTO 1530
1360 REM integer input routine
1370 PRINT "enter an integer between" ; MIN; "and"; MAX
1380 PRINT ", try again"
1390 INPUT E * : E = VAL(E$)
1400 IF E = 0 AND LEFT$(E$, 1)<> "0"THEN 1370
1410 IF E <> INT(E) THEN PRINT "please enter an integer"; : GOTO 1380
1420 IF MIN > E THEN PRINT "too low"; : GOTO 1380
1430 IF E > MAX THEN PRINT "too high" ; : GOTO 1380
1440 RETURN
1450 REM real number input routine
1460 PRINT "enter a number between " ; MIN; " and" ; MAX
1470 PRINT ", try again"
1480 INPUT E * : E = VAL(E$) : IF E = 0 AND LEFT$ (E$,1) <> "0" THEN 1460
1490 IF MIN > E THEN PRINT "too low"; : GOTO 1470
1500 IF E > MAX THEN PRINT "too high" ; : GOTO 1470
1510 RETURN
1520 CLS : RETURN
1530 PRINT : PRINT M; "/"D; "/"; Y : PRINT
1540 PRINT "Temperature is : "T;"dog. F" : PRINT
1550 PRINT "Humidity is : ";H; "%" : PRINT
1560 PRINT "Barometric Pressure is : ";BP;" in. Hg"
1570 FOR J = 1 TO 3500 : NEXT J
1580 PRINT : PRINT : PRINT : PRINT : PRINT
1590 PRINT "PRESS <RETURN> to make another forecast
1600 INPUT P$
1610 GOSUB 1520
1620 GOTO 120

Progarm 2 : IBM PC/PCjr Line Changes

5 KEY OFF : DEF SEG = 0 : POKE 1047, PEEK(1047) OR 64 : WIDTH 40 : LOCATE , , 0

Program 3 : Commodore 64 Line Changes

1390 E$ = " " : INPUT E$ : E = VAL(E$)
1480 E$ = " " : INPUT E$ : E = VAL(E$) : IF E = 0 AND LEFT$ (E$, 1) <> "0" THEN 1460
1520 PRINT CHR$ (147); : RETURN

Program 4 : Atari 400, 800, XL, and XE Line Changes

EJ 5 DIM E$ (10), T$ (14), P$(9) : POKE 82, 0 : POKE 83,39
B8 60 FOR J = 1 TO 999 : NEXT J
KD 250 PRINT "1. N {4 SPACES}2. NE {3 SPACES}3. E"
CI 270 PRINT "4. SE {3 SPACES}5. S {4 SPACES}6. SW"
BJ 290 PRINT "7. W {4 SPACES}8. NW {3 SPACES}9. NO WIND"
KM 395 T$ = "{14 SPACES}" : REM 14 SPACES
HC 400 PRINT T$; "2. RISING FAST"
DA 410 PRINT T$; "3. SLOWLY RISING"
KH 420 PRINT T$; "4. FAILING FAST"
BF 430 PRINT T$; "5. SLOWLY FALLING"
IL 1390 E$ = " " : INPUT E$ : IF e$ > "9" OR E$<"0" THEN 1370
DE 1400 E = VAL(E$)
IL 1480 E$ = " " : INPUT E$ : IF E$ > "9" OR E$<"0" THEN 1460
PB 1485 E = VAL(E$)
AL 1520 ? CHR$ (125) : RETURN
HN 1570 FOR J = 1. TO 999 : NEXT J

Program 5 : Apple II Line Changes

1520 HOME : RETURN

Program 6 : Atari ST Line Changes

1 rem delete 160, 240, 260, 280, 300
5 fullw 2
120 ?"INPUT numbers when prompted by ?"
130 ?
1520 clearw 2 : gotoxy 0, 0 : return
1580 ? : ? : ?

Program 7 : Amiga Line Changes

5 SCREEN 1, 320, 200, 4, 1 : WINDOW 3, " ", (0,0) - (311, 186), 16, 1 : WINDOW OUTPUT 3