ogstools.logparser.log_parser module#

ogstools.logparser.log_parser.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.parse_file(file_name, maximum_lines=None, force_parallel=False, ogs_res=None)[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

  • ogs_res (list | None)

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]