config Module

Reads simulation parameters from a Fortran namelist file (default: input.nml). If the file is absent, built-in Sod shock tube defaults are used so the solver remains immediately runnable without any input file.

Namelist groups (all optional; missing groups keep their defaults):

  • &grid — spatial discretisation
  • &time_ctrl — time-stepping parameters
  • &physics — gas model (gamma)
  • &schemes — algorithm selection strings (incl. MUSCL limiter)
  • &initial_condition — Riemann problem left/right primitive states and BC types
  • &output — result filename, diagnostic frequency, live snapshots
  • &checkpoint — checkpoint write interval and restart path

Example usage in the driver: @code type(config_t) :: cfg call read_config('input.nml', cfg) @endcode



Derived Types

type, public ::  config_t

All runtime-configurable simulation parameters with Sod shock tube defaults.

Components

Type Visibility Attributes Name Initial
integer, public :: n_cell = 500
real(kind=wp), public :: x_left = 0.0_wp
real(kind=wp), public :: x_right = 1.0_wp
real(kind=wp), public :: dt = 1.0e-4_wp
real(kind=wp), public :: time_start = 0.0_wp
real(kind=wp), public :: time_stop = 0.15_wp
real(kind=wp), public :: cfl = 0.0_wp
logical, public :: lapack_solver = .true.

Set to .false. to use the built-in no-pivoting solver instead. Only relevant when time_scheme = 'beuler'.

real(kind=wp), public :: gam = 1.4_wp
character(len=64), public :: flux_scheme = 'lax_friedrichs'

'lax_friedrichs' (default), 'steger_warming', 'van_leer', 'ausm_plus'

character(len=64), public :: recon_scheme = 'weno5'
character(len=64), public :: time_scheme = 'rk3'
character(len=8), public :: char_proj = 'auto'

'auto' (default) — enable per-scheme: on for weno5/weno5z/weno_cu6/weno7/ weno9/weno11/eno3/mp5/teno5, off otherwise. 'yes' — always apply eigensystem decomposition (more accurate for shocks, higher cost). 'no' — always skip eigensystem decomposition (faster; safe for scalar/smooth problems).

character(len=32), public :: limiter = 'minmod'

Valid values: 'minmod' (default), 'superbee', 'mc', 'van_leer', 'koren'. Ignored for all non-MUSCL reconstruction schemes.

logical, public :: use_positivity_limiter = .false.

When .true., reconstructed face states on the FDS path (AUSM+, HLL, HLLC, Roe) are scaled toward the adjacent cell average to ensure density and pressure remain non-negative. Ignored when a FVS flux scheme is active.

logical, public :: use_hybrid_recon = .false.

When .true., each face is classified smooth or non-smooth using the selected sensor (hybrid_sensor). Smooth faces use the linear (optimal-weight) WENO variant — same order as the primary scheme but without nonlinear dissipation. Non-smooth faces fall back to the full nonlinear primary reconstruction scheme.

character(len=32), public :: hybrid_sensor = 'jameson'

Valid values: 'jameson' — Jameson-Schmidt-Turkel pressure second-derivative sensor (JST 1981); physically motivated for compressible flows. Threshold ~ 0.1. 'density_gradient' — Normalised density jump across the face; cheap and robust. Threshold ~ 0.1. 'weno_beta' — Ratio max(β)/min(β) of WENO5 smoothness indicators; only meaningful for 5-point WENO-family schemes; falls back to 'density_gradient' otherwise. Threshold ~ 50.

real(kind=wp), public :: hybrid_sensor_threshold = 0.1_wp

Default 0.1 suits the 'jameson' and 'density_gradient' sensors. Use ~50 for 'weno_beta'.

character(len=64), public :: problem_type = 'sod'

Valid values: 'sod', 'shu_osher', 'smooth_wave', 'linear_advection', 'woodward_colella', 'lax', 'from_file', 'udf'.

character(len=256), public :: ic_file = ''

File must contain whitespace-separated columns: x rho u p (one line per grid point; same format as the solver output file).

logical, public :: ic_interp = .true.

When .false., a grid mismatch causes an error stop.

character(len=256), public :: ic_udf_src = ''

Used when problem_type = 'udf'. The solver compiles this file to a shared library at runtime (requires gfortran on PATH) and calls the subroutine to fill the initial state. See example/udf_sod.f90 for the required interface.

character(len=32), public :: bc_left = 'dirichlet'

Valid values: 'dirichlet' (default), 'inflow', 'outflow', 'reflecting', 'periodic', 'nonreflecting', 'supersonic_inlet', 'subsonic_inlet', 'supersonic_outlet', 'subsonic_outlet', 'neumann', 'neumann_gradient'.

character(len=32), public :: bc_right = 'dirichlet'

Valid values: 'dirichlet' (default), 'inflow', 'outflow', 'reflecting', 'periodic', 'nonreflecting', 'supersonic_inlet', 'subsonic_inlet', 'supersonic_outlet', 'subsonic_outlet', 'neumann', 'neumann_gradient'.

real(kind=wp), public :: p_ref_left = 1.0_wp

Used only when bc_left = 'nonreflecting'.

real(kind=wp), public :: p_ref_right = 1.0_wp

Used only when bc_right = 'nonreflecting'.

real(kind=wp), public :: sigma_nrbc = 0.0_wp

0 = fully non-reflecting; 1 = Dirichlet target pressure p_ref. See Thompson (1987), Poinsot & Lele (1992).

character(len=32), public :: nrbc_mode = 'pressure'

'pressure' (default) = isentropic pressure-relaxation (Thompson 1987). 'characteristic' = full LODI characteristic targeting (Poinsot & Lele 1992, Sec. 3); activates u_ref_, rho_ref_, sigma_nrbc_entropy.

real(kind=wp), public :: u_ref_left = 0.0_wp

Used only when bc_left = 'nonreflecting' and nrbc_mode = 'characteristic'.

real(kind=wp), public :: u_ref_right = 0.0_wp

Used only when bc_right = 'nonreflecting' and nrbc_mode = 'characteristic'.

real(kind=wp), public :: rho_ref_left = 1.0_wp

Used only when bc_left = 'nonreflecting' and nrbc_mode = 'characteristic'.

real(kind=wp), public :: rho_ref_right = 1.0_wp

Used only when bc_right = 'nonreflecting' and nrbc_mode = 'characteristic'.

real(kind=wp), public :: sigma_nrbc_entropy = 0.0_wp

0 = fully non-reflecting entropy wave (default); 1 = entropy wave driven to the rho_ref target. Active only when nrbc_mode = 'characteristic'. See Poinsot & Lele (1992), J. Comput. Phys. 101, Sec. 3.

real(kind=wp), public :: p_stag_left = 1.0_wp

Used only when bc_left = 'subsonic_inlet'. Derived from static conditions via p0 = p(1 + (gam-1)/2Ma^2)^(gam/(gam-1)).

real(kind=wp), public :: rho_stag_left = 1.0_wp

Used only when bc_left = 'subsonic_inlet'. Derived from static conditions via rho0 = rho(1 + (gam-1)/2Ma^2)^(1/(gam-1)).

real(kind=wp), public :: p_stag_right = 1.0_wp

Used only when bc_right = 'subsonic_inlet'.

real(kind=wp), public :: rho_stag_right = 1.0_wp

Used only when bc_right = 'subsonic_inlet'.

real(kind=wp), public :: p_back_left = 1.0_wp

Used only when bc_left = 'subsonic_outlet'.

real(kind=wp), public :: p_back_right = 1.0_wp

Used only when bc_right = 'subsonic_outlet'.

real(kind=wp), public :: neumann_grad_left(3) = 0.0_wp

Used only when bc_left = 'neumann_gradient'. Ghost state: q_ghost = q_wall + neumann_grad_left * dx.

real(kind=wp), public :: neumann_grad_right(3) = 0.0_wp

Used only when bc_right = 'neumann_gradient'. Ghost state: q_ghost = q_wall + neumann_grad_right * dx.

real(kind=wp), public :: rho_left = 1.0_wp
real(kind=wp), public :: u_left = 0.0_wp
real(kind=wp), public :: p_left = 1.0_wp
real(kind=wp), public :: rho_right = 0.125_wp
real(kind=wp), public :: u_right = 0.0_wp
real(kind=wp), public :: p_right = 0.1_wp
real(kind=wp), public :: x_diaphragm = 0.5_wp
character(len=256), public :: output_file = 'result.dat'
integer, public :: print_freq = 50
logical, public :: do_timing = .false.

Enable detailed wall-clock timing summary output (default .false.). When .true., compute_resid() and the driver accumulate fine-grained timing and print a performance table after the run. Lightweight per-iteration iter_s / elapsed_s logging is always available. Has no effect on results.

integer, public :: verbosity = 3

Logger verbosity threshold (default 3 = LOGLVL_INFO). 0 = SILENT, 1 = ERROR, 2 = WARN, 3 = INFO, 4 = DEBUG. See module logger for the LOGLVL_* constants.

character(len=256), public :: log_file = 'run.log'

Log file path (default 'run.log'). Empty string disables file logging.

integer, public :: snapshot_freq = 0

Write a live solution snapshot every N iterations (0 = disabled). The snapshot file is overwritten each time, so a GUI app can watch it with inotify/kqueue. Format matches result.dat with a leading comment line: "# iter=NNN t=T".

character(len=256), public :: snapshot_file = 'snapshot.dat'

Path for the live snapshot file (default 'snapshot.dat').

integer, public :: checkpoint_freq = 0

Write a checkpoint every N iterations (0 = disabled). Checkpoint files are named '_NNNNNN.bin' and contain enough state to resume the run exactly: iter, t, ub, and (if BDF2) bdf2_ub_prev. The file 'latest_checkpoint' is also updated to point to the most recent checkpoint so restarts need not know the iteration.

character(len=256), public :: checkpoint_file = 'checkpoint'

Base name for checkpoint files (default 'checkpoint').

character(len=256), public :: restart_file = ''

Path to a checkpoint file to resume from (empty = fresh start). When set, the IC is skipped and iter/t are loaded from the checkpoint.


Functions

private pure function lowercase_token(value) result(normalized)

Return a left-trimmed, lowercased copy of value. Pure: has no side effects; suitable for use in constant expressions.

Arguments

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

Return Value character(len=len)


Subroutines

public subroutine read_config(filename, cfg, is_ok, message)

Read simulation parameters from a namelist file.

Read more…

Arguments

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

Path to the namelist input file.

type(config_t), intent(out) :: cfg

Populated configuration object.

logical, intent(out), optional :: is_ok
character(len=*), intent(out), optional :: message

public subroutine validate_config(cfg, is_valid, message)

Validate that all namelist parameters are physically and numerically sensible.

Read more…

Arguments

Type IntentOptional Attributes Name
type(config_t), intent(inout) :: cfg

Configuration to validate (normalised in-place).

logical, intent(out), optional :: is_valid

.true. on success, .false. on the first violation found.

character(len=*), intent(out), optional :: message

Human-readable description of the first violation, or ''.

private subroutine normalize_config(cfg)

Lowercase all scheme-selection and option string fields in cfg. Called automatically by validate_config before any comparisons so that namelist values are accepted regardless of the case supplied by the user.

Arguments

Type IntentOptional Attributes Name
type(config_t), intent(inout) :: cfg