February 8, 2016: Diffusion Limited Aggregation NetCDF

SUMMARY

Your challenge is to add NetCDF to an existing simulation such that the result can be visualized using a tool like ParaView.

PROBLEM
This problem deals with a simulation of diffusion limited aggregation (DLA). Your challenge is to modify the starter code found in the “Diffusion Limited Aggregation NetCDF starter zip file“, such that the program creates a “dla.nc” file that can be animated in ParaView.

This is a similar task to the “Langton’s Ant NetCDF” challenge problem. It may be useful to reference the ParaView instructions and solution code for that problem.

SOLUTION
A solution will be posted here on February 15, 2016.

January 25, 2016: Langton’s Ant NetCDF

SUMMARY
Your challenge is to modify an existing C code to output data using the NetCDF library so it can be visualized.

PROBLEM
The starter code for this problem is available 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 20×20 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 20×20 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.

SOLUTION
Download the following file for a solution: langton-netcdf-solution.zip

January 11, 2016: Langton’s Ant CSV

SUMMARY
Your task is to modify an existing C program to output data in comma-separated value (CSV) format.

PROBLEM
The starter code is provided in the “Langton’s Ant CSV starter zip file“. Your task is to modify the code such that it outputs a file in CSV format for each time step of the simulation. Each CSV file should contain the following heading.

X,Y,State

Following the heading, the file should contain corresponding X, Y, and State data for each cell in the automaton, e.g.:

0,0,1
0,1,0
0,2,0

The state of each cell should be written as a 1 if the cell is white and a 0 if the cell is black.

The name of each file should be langtonX.csv, where X is the timestep.

Your program can use the C functions fopen(), fclose(), and fprintf() to handle file I/O; these are all available as part of the stdio.h header file.

SOLUTION
Download the following file for a solution: Langton_CSV_solution.zip

December 14, 2015: Langton’s Ant in MPI

SUMMARY
Your challenge is to use MPI to parallelize a program that models Langton’s Ant.

PROBLEM
You are provided with starter code in the “Langton’s Ant in MPI starter zip file.” Your challenge is to add MPI function calls such that the tasks of turning the ants, updating the cells, and moving the ants are each handled in parallel; i.e. each MPI process is responsible for a subset of the cells and/or ants. Processes should send messages to each other to synchronize data about the cells and ants. Only one process should give the ants random positions. Also, only one process should run the X11 and ASCII visualizations. When the program is run, its ASCII output should be identical to the ASCII output provided when the starter code is run without MPI.

SOLUTION
Download the following file for a solution: Langton_MPI_solution.zip

November 30, 2015: Langton’s Ant in OpenMP

SUMMARY
Your challenge is to parallelize a model of Langton’s Ant using OpenMP.

QUESTION
You are provided with starter code in the “Langton’s Ant in OpenMP starter zip file.” Your challenge is to add OpenMP compiler directives that cause parts of the program to be executed in parallel. When the program is run, its output should be identical to the “langton.out” file provided with the starter code.

SOLUTION
Will be posted December 7, 2015