Devoir
4. Binary I/O
Conditions d'achèvement
Ouvert le : jeudi 4 février 2021, 23:59
À rendre : jeudi 11 février 2021, 23:59
In this assignment, we are going to add binary and netcdf output as well as command line arguments to the modular version of antsontable. You are expected to do this on the Teach cluster, where netcdf has already been installed. The netcdf module requires another module, hdf5, so you'll need to type
Copy the resulting zip file off of the teach cluster and submit the zip file, by February 11th, 2021 at 23:55 PM to the dropbox on the course website. The late policy can be found in the syllabus.
$ module load gcc rarray hdf5 netcdfto get started.
Note: Your submission for this assignment will be shared, in an anonymized form, with another student of the class for a subsequent assignment.
For this assignment, you should take the modularized, rarray-ized code of last week's assignment and:
- Add a module to write out the number_of_ants rarray in raw binary every 1000 time steps to a file named ants.bin.
Use this new capability in the antsontable application to produce ants.bin.
Hint: look up the write member function of std::ofstream and remember that an rarray can be converted to a pointer to its first element with the .data() method, while the number of elements in it can be found with the .size() method. - Add a second module to write out the number_of_ants array in a netcdf file every 1000 time steps to a file named ants.nc.
Hint: Continuously appending to this file will require you to create a netcdf file with a variable that has a so-called unlimited dimension. To give you an idea how this is done, check out this example code. - Make the main function accept a command line argument which controls whether the output is in text format (if the argument is -t), in binary (if the argument is -b), or in netcdf format (if the argument is -n). Compile it with a Makefile and run it for all three cases.
- Write a separate program (which should still be part of the same repository) that can read any of these files, depending a similar the command line argument, and computes for each saved time step the total number of ants, the minimum and the maximum. Compare this to the output of the antsontable application.
- As in the previous assignment, you should use git and there should be several meaningful commits.
- Because this code will be seen (anonymized) by another student, comment it well and describe each function and file with doxygen-type comments.
git2zip REPODIR(with REPODIR replaced by the directory where your code and the git repo lives).
Copy the resulting zip file off of the teach cluster and submit the zip file, by February 11th, 2021 at 23:55 PM to the dropbox on the course website. The late policy can be found in the syllabus.
- 14 août 2023, 15:45