4.3 BlasterSim source and documentation coding conventions

  • In cva.f90 and BlasterSim’s core simulation procedures otherwise, all variables are in SI units. However, the inputs and outputs may be in other units.

  • Some code comments contain bibliographic keys referring to the BlasterSim documentation’s BibTeX database. The BibTeX database is located at docs/blastersim.bib, and the associated keys can be found there.

  • Some code comments may refer to handwritten notes. I intend to slowly clean up and add these notes to this documentation.

  • Constants (parameters in Fortran terminology) are denoted by capitalizing the variable name. Note that this is different from convention used for intensive and extensive quantities in the typeset math in this documentation as discussed in § 2.1.1. Because each variable in BlasterSim’s source code is given a unit (see § 3.1.3), whether a quantity is extensive or intensive can be determined from the units for that quantity, if unclear.

  • The control volume index for the barrel is I_BARREL, which is set to 1. This convention allows BlasterSim to easily know which control volume is the barrel.

  • integer variables named rc are used for return codes. 0 or negative return codes indicate success, with 0 being normal success and negative numbers having a special context-dependent meaning. The parameter SUCCESS_RC is set to 0 and used to improve readability. Positive return codes indicate failure.

  • The subroutine run is the main simulation loop in BlasterSim. run takes an initial state and runs the simulation until a termination criteria is met. The derived type run_status_type is returned by run. run_status_type contains a return code rc and a time t If rc is not SUCCESS_RC, then run_status_type optionally can set arrays i_cv and data to contain information about particular control volumes to make error and warning messages more meaningful.

  • In the documentation, put no more than one sentence per line of LaTeX code. Breaking up a sentence into clauses may be useful in some contexts as well, and breaking up a mathematical expression into multiple LaTeX lines is also often useful. In LaTeX, a new line does not create a new paragraph if the next line has text. An empty line creates a paragraph. This helps identify changes easier with some diff programs, allows adding comments on a per-sentence basis in LaTeX, and can ease identifying where LaTeX compilation errors are.