Daniele de Rigo

**ABSTRACT** Computational scientists in the domains of environmental modelling are challenged to cope with data impressively growing in complexity, heterogeneity and size. Computational models are mathematical descriptions which usually try to capture numerically some essential (i.e. in most cases, approximated) relationships between key aspects of observed phenomena. As a consequence, they should in principle be unambiguously deterministic and therefore scientifically reproducible - including unintentional algorithm errors or weaknesses which this way have a chance to be discovered and corrected in a collaborative effort of the involved scientific community.

However, the experience of computational modelling scientists is often quite different: the distance between scientific publications describing research models and the corresponding source code implementations (if publicly available...) can be so remarkable to practically discourage computational models' evolution outside the close group of their original authors, exclusive owners of essential, undisclosed (but also isolated) knowledge.

Reducing this distance is the strategic objective of the semantic array programming paradigm, which is exposed in this book along with its supporting implementation, the Mastrave modelling library.

Array programming was originally conceived for mitigating the gap between mathematical notation and algorithm implementations. Despite programming languages are universal, executable - thus suitable to actually perform extensive experiments - and unambiguous, *"most programming languages are decidedly inferior to mathematical notation and are little used as tools of thought in ways that would be considered significant by, say, an applied mathematician. The thesis [...] is that the advantages of executability and universality found in programming languages can be effectively combined, in a single coherent language, with the advantages offered by mathematical notation."* (Iverson). Array programming promotes as atomic quantities vectors, matrices, tensors and natively provides extremely concise operators for manipulating them. Coherent array-based mathematical description of models can simplify complex algorithm design and prototyping while moving mathematical reasoning directly into the source code – because of its substantial size reduction – where the mathematical description is actually expressed in a completely formalized and reproducible way.

Two additional design concepts define semantic array programming as supported by the Mastrave library:

- modularizing sub-models and autonomous tasks with a strong effort toward their
*most concise*generalization and reusability in other contexts; *semantically*constraining – with terse array-based constraints – the information entered in and returned by each module instead of relying on external assumptions.

Several examples of scientific applications in the field of environmental modelling are provided, along with a comprehensive documentation of the Mastrave modelling library.

**TARGET audience** The book is aimed at research modellers and authors of scientific software in the field of computational modelling. While the examples provided within the book refer to environmental modelling, they are presented paying attention to their general reusability. The possible applications of the semantic array programming paradigm are wider and computational scientists investigating other domains should find at least some of the proposed techniques straightforward to be adapted.

**INDEX of the book** (active links: book parts in the first editon)

- Part 1
- 1. Overview of Mastrave
- 2. Semantic Array Programming
- 3. Data-Transformation Models

- Part 2
- 4. The Mastrave Library
- References

- Appendices
- A GNU Free Documentation License
- B GNU General Public License

**AVAILABILITY** The revision of the first edition is on-going. This new revision significantly expands the first edition, which only referred to the Part 2 of the forthcoming revision. The Part 2 with the function reference of the Mastrave modelling library is constantly updated online so as to reflect the current state of development. You are advised to please periodically check for updates: all new revisions of the book are made freely (under GNU Free Documentation License) available online.

**HOW TO CITE** Please, cite the first edition as:

- de Rigo, D. (2012). Semantic Array Programming with Mastrave - Introduction to Semantic Computational Modelling. The Mastrave Project. (First ed.) http://mastrave.org/doc/MTV-1.012-1