Monday January 25, 2016
Your challenge is to modify an existing C code to output data using the NetCDF library so it can be visualized.
The starter code for this problem is available below in the "Langton's Ant NetCDF starter zip file." This is a compressed folder that contains C code for two different programs. The first program, "fire.c", models a forest fire in a 20x20 rectangular grid across 50 time steps with a 70 percent chance of a tree catching fire in the next time step if it has a burning neighbor in the current time step. Burning trees stop burning after 2 time steps. The program uses the NetCDF C API to output how long each tree has been burning at each time step. When the program is run, it creates a NetCDF file called "fire.nc". This file can be visualized using the ParaView application by following the steps below.

1. Download and install NetCDF on your system: http://www.unidata.ucar.edu/downloads/netcdf/index.jsp
2. On a command line, change into the folder containing "fire.c" and use the Makefile to create the "fire" executable by entering the command "make fire".
3. Run the fire executable by entering "./fire", and confirm it creates a "fire.nc" file.
4. Download and install the ParaView software from its website: http://www.paraview.org/download/
5. Open ParaView.
6. Choose File -> Open.
7. Find and open the "fire.nc" file.
8. In the window that pops up, choose "NetCDF files generic and CF conventions".
9. In the "Pipeline Browser", click the eyeball icon next to "fire.nc". You should see a blue square with a smaller red square inside it.
10. In the Properties box, under "Display (UniformGridRepresentation)", under "Coloring", click the "Edit" button.
11. In the "Color Map Editor" window, find and click the button for "Rescale to data range over all timesteps". The red square should turn gray.
12. Using the VCR Controls toolbar, you can play, pause, step through, and/or loop the visualization.

Your challenge is to add NetCDF to the second program, "langton.c", which models the Langton's Ant cellular automaton with 10 ants in a 20x20 grid through 1000 time steps. When run, the program should generate a "langton.nc" file, which can be used to visualize the automaton through ParaView in a similar fashion to the fire program as described above.

You may wish to reference the NetCDF C Interface Guide to read about how the various NetCDF functions work:

http://www.unidata.ucar.edu/software/netcdf/netcdf-4/newdocs/netcdf-c/

Some previous challenge problems have involved Langton's Ant. You may wish to take a look at these to familiarize yourself more with the model of Langton's Ant:

http://hpcuniversity.org/students/weeklyChallenge/115/
http://hpcuniversity.org/students/weeklyChallenge/114/
http://hpcuniversity.org/students/weeklyChallenge/113/
http://hpcuniversity.org/students/weeklyChallenge/112/
http://hpcuniversity.org/students/weeklyChallenge/111/
Show solution
Challenge Resources:
©1994-2024   |   Shodor   |   Privacy Policy   |   NSDL   |   XSEDE   |   Blue Waters   |   ACM SIGHPC   |   feedback  |   facebook   |   twitter   |   rss   |   youtube   |   XSEDE Code of Conduct   |   Not Logged In. Login