mod_precision Module

Core kind parameters, mathematical constants, and global utility routines.

This module serves as the foundational precision manager for the solver. It centralizes the selection of floating-point precision (real64) and provides a set of universally available mathematical constants to avoid hard-coded magic numbers throughout the codebase.

Additionally, it provides critical infrastructure for: 1. Error Handling: A standardized fatal_error mechanism to ensure consistent error reporting and clean termination. 2. String Manipulation: Utilities like lowercase for case-insensitive namelist and file processing.



Variables

Type Visibility Attributes Name Initial
real(kind=rk), public, parameter :: half = 0.5_rk
integer, public, parameter :: name_len = 64
real(kind=rk), public, parameter :: one = 1.0_rk
integer, public, parameter :: path_len = 256
integer, public, parameter :: rk = real64

Working real precision parameter (Double Precision). All physical fields and numerical coefficients must use this kind.

real(kind=rk), public, parameter :: tiny_safe = 1.0e-300_rk

A very small positive value used for safe divisions and tolerance checks. Designed to be well above the underflow limit of double precision.

real(kind=rk), public, parameter :: two = 2.0_rk
real(kind=rk), public, parameter :: zero = 0.0_rk

Functions

public pure function lowercase(text) result(out)

Converts an input string to all lowercase characters.

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: text

The source string to convert.

Return Value character(len=len)


Subroutines

public subroutine fatal_error(scope, message)

Aborts the simulation with a formatted error message.

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: scope

The name of the module or feature (e.g., "mod_input").

character(len=*), intent(in) :: message

Descriptive message explaining why the simulation failed.