Diagnostic System¶
This section describes the diagnostic system in CATChem, which allows processes to register and manage their own diagnostic outputs at runtime.
Overview¶
The diagnostic system in CATChem is designed to be flexible and extensible. It allows processes to define their own diagnostic variables and to control how and when they are output. The system is built around two key components: the DiagnosticInterface and the DiagnosticManager.
Core Components¶
The Diagnostic Interface¶
The DiagnosticInterface is a module that defines the interface for the diagnostic system. It provides the following key data types:
DiagnosticFieldType: This type is used to define a single diagnostic field. It contains metadata about the field, such as its name, description, and units, as well as the data itself.DiagnosticRegistryType: This type is used to manage a collection of diagnostic fields for a single process. It provides methods for registering, unregistering, and querying diagnostic fields.
The Diagnostic Manager¶
The DiagnosticManager is a module that provides a central manager for the diagnostic system. It is responsible for:
- Managing the diagnostic registries for all processes.
- Collecting diagnostic data from all processes.
- Writing diagnostic data to output files.
- Providing a centralized way to configure the diagnostic system.
Usage¶
To use the diagnostic system, a process must first create a DiagnosticRegistryType object and register it with the DiagnosticManager. Then, the process can create DiagnosticFieldType objects and register them with its diagnostic registry.
Once a diagnostic field is registered, the process can update its value at any time. The DiagnosticManager will then automatically collect the data and write it to an output file at the specified frequency.
Features¶
The diagnostic system in CATChem provides a number of advanced features, including:
- Multiple data types: The system supports a wide range of data types, including scalars, 1D, 2D, and 3D arrays of real, integer, and logical values.
- Flexible metadata: The system allows processes to specify a wide range of metadata for each diagnostic field, including its name, description, units, and output frequency.
- Process-specific diagnostics: Each process has its own diagnostic registry, which allows it to manage its own diagnostic outputs independently of other processes.
- Runtime query and collection: The system allows users to query and collect diagnostic data at runtime, without having to restart the model.
- Optional diagnostic output: The system allows users to enable or disable diagnostic output for each process and for each diagnostic field.