ogstools.logparser.log_parser module#
- ogstools.logparser.log_parser.read_mpi_processes(file_name)[source]#
Counts the number of MPI processes started by OpenGeoSys-6 by detecting specific log entries in a given file. It assumes that each MPI process will log two specific messages: “This is OpenGeoSys-6 version” and “OGS started on”. The function counts occurrences of these messages and divides the count by two to estimate the number of MPI processes.
- Parameters:
file_name (str | Path) – The path to the log file, as either a string or a Path object.
- Returns:
An integer representing the estimated number of MPI processes based on the log file’s content.
- Return type:
int
- ogstools.logparser.log_parser.normalize_regex(ogs_res, parallel_log=False)[source]#
Takes regex patterns for serial computation and modify them for parallel Parallel log lines are prepended with the process id, e.g. [0] or [1]
- Return type:
list
- ogstools.logparser.log_parser.parse_line(patterns, line, parallel_log, number_of_lines_read)[source]#
- Return type:
Log | Termination | None
- ogstools.logparser.log_parser.read_version(file)[source]#
Read the version of the OGS log file.
- Parameters:
file (Path) – Path to the OGS log file.
- Returns:
The version number as an integer.
- Return type:
int
- ogstools.logparser.log_parser.parse_file(file_name, maximum_lines=None, force_parallel=False)[source]#
Parses a log file from OGS, applying regex patterns to extract specific information,
The function supports processing files in serial or parallel mode. In parallel mode, a specific regex is used to match log entries from different processes.
- Parameters:
file_name (str | Path) – The path to the log file, as a string or Path object.
maximum_lines (int | None) – Optional maximum number of lines to read from the file. If not provided, the whole file is read.
force_parallel (bool) – Should only be set to True if OGS run with MPI with a single core
- Returns:
A list of extracted records based on the applied regex patterns. The exact type and structure of these records depend on the regex patterns and their associated processing functions.
- Return type:
list[Any]