Skip to content

Debug version of ModelArrayRef

Tim Spain edited this page Feb 9, 2023 · 2 revisions

Debug version of ModelArrayRef

Name: Tim Spain

Affiliation: NERSC

Target/Actual Release Date/Project Milestone (delete as appropriate): ASAP

Reviewers: Alex Smith, Kacper Kornet

GitHub Issue: #240


  1. Introduction
  2. Requirements
  3. Functional
    1. Build
  4. Test Specification
  5. Documentation Impact

Introduction

When writing tests or new code, ModelComponent derived classes of end up missing ModelArrayRefs that they require. The way the model and tests currently signal this is to crash with a SIGSEGV once the missing array is accessed. Having a way of diagnosing this problem with a descriptive message would be a benefit to developers.

The new code will be added in such a way that the final version of the model and of each test will not be impacted at all, since they will compile using the current version of ModelArrayRef.

Requirements

The new code should

  1. provide checked access to ModelArrayRef data and report when access is attempted on a ModelArrayRef that doesn't actually refer to a ModelArray.
  2. This is done by throwing a std::invalid_argument exception with a message describing at least the ModelComponent that should be being referenced.
    • This is not necessarily the best standard exception to use, but it certainly is one.
  3. Once the application in question has all the data it needs the checks can be turned off or replaced with the current ModelArrayRef code.

Functional

A developer uses the new class to check all ModelArrayRefs actually connect to a ModelArray. Once the new class reports no errors and the test runs to completion, the developer replaces the new class with the current ModelArrayRef.

Build

Substitute in the new class until it is not needed any more.

Test Specification

The one place the new class will be used is in a test that it a) can return data exactly as ModelArrayRef when there is data at the other end of the reference and that it throws an appropriate exception with an informative message when there is not.