CSE logo University of Washington Department of Computer Science & Engineering
 Parallel Computing
  CSE Home     Other Quarters    ZPL  About Us    Search    Contact Info 

 Programming with ZPL
 Assignment 1 (and soln)
 Assignment 2 (html) (pdf) (ppt)
 Assignment 3 

Assignment 3

Due Nov. 18 before class

Submit solution by email to Adam prior to class on Nov. 18

Rain Comes to Seattle

This is intended to suggest a "typical" scientific computation. We are less interested in the exact details of the model than in your solution using ZPL. So, if there are subtle things having to do with how the model works, tell us your assumptions and keep going. Let n be a configuration variable and E be an nXn elevation grid, an array of heights from a reference plane like sea level. Write a ZPL program to plot (print out as an array of 0's and 1's) the drainage map from the highest point to the lowest point in E. Conceptually, the drainage map is that portion of the elevation grid that a raindrop could visit starting from the highest point and descending to the lowest point. (Of course, the drainage map can be empty if it is not possible for a drop to get from the highest to lowest point.) As an example, consider the follwing 5x5 elevation map:
Becomes drainage map
Note that while water can flow to the top right hand corner of the map (where the elevation is 5.0), it can never get out of that area and go to the minimum elevation of 2.0, so those cells are 0. Also notice that in the area of the bottom right hand corner, water can flow diagonally from the 8.0 to the 6.0 and then to the 5.0 and out to the low point, so these are all 1. The elevation map should be read in from a file, use a configuration variable to allow the filename to be set from the command line. (If none is supplied you can programmatically initialize the matrix or read it in from a default file, which you should also supply.) Take a look at matmult.ffm.z in the ZPL examples directory for an idea on how to do this. (You can use as much of the initialization code from that as you want.) The file format you should accept is.
n m
A11 A12 A13 ... A1m
A22 A23 A33 ...
An1 An2 An3 ... Anm
Where n and m are the rows and columns, respectively and the data can be floats. (The assignment calls for square matrices, and we won't take points off if you only handle square matrices, but you should still read both dimensions from the input file. We'll be might run your program against both square and non-square matrices.) While there are a variety of solutions that have an iterative flavor, try to come up with one that uses the parallel features of ZPL.

CSE logo Department of Computer Science & Engineering
University of Washington
Box 352350
Seattle, WA  98195-2350
(206) 543-1695 voice, (206) 543-2969 FAX
[comments to carlson]