# tomofast/tomofast-x architecture

> Architecture diagram of the GitHub repository tomofast/tomofast-x, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tomofast/tomofast-x
- Repository: https://github.com/tomofast/tomofast-x

## Overview

Tomofast-x is a parallel 3D geophysical inversion application for gravity and magnetic data. Users launch it with a parameter file; its documented capabilities include joint and constrained inversion, gravity gradiometry, multiple-component magnetics, petrophysical constraints, topography, and parallel wavelet compression. The tree identifies corresponding source areas, but the supplied excerpts do not show their runtime call relationships, so those links are marked unverified. The separately sampled Python utility splits model-grid geometry and values; no connection to the inversion runtime is evidenced.

Main entry points: [`src/problem_joint_gravmag.F90`](https://github.com/tomofast/tomofast-x/blob/master/src/problem_joint_gravmag.F90) (Joint problem), [`src/program_tomofastx.F90`](https://github.com/tomofast/tomofast-x/blob/master/src/program_tomofastx.F90) (Tomofast-x), [`src/forward/gravmag/data_gravmag.f90`](https://github.com/tomofast/tomofast-x/blob/master/src/forward/gravmag/data_gravmag.f90) (Forward data), [`parfiles`](https://github.com/tomofast/tomofast-x/tree/master/parfiles) (Parameter files)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime entry"]
  node_parameters["Parameter files"]
  node_app["Tomofast-x"]
  node_joint_problem["Joint problem"]
end

subgraph group_forward["Forward modelling"]
  node_forward_data["Forward data<br/>[data_gravmag.f90]"]
  node_gravity["Gravity fields<br/>[gravity_field.f90]"]
  node_magnetic["Magnetic fields<br/>[magnetic_field.f90]"]
  node_sensitivity["Sensitivity kernels"]
end

subgraph group_inversion["Inversion"]
  node_model["Model state<br/>[model.F90]"]
  node_solver["LSQR solver<br/>[lsqr_solver2.F90]"]
  node_admm["ADMM method<br/>[admm_method.F90]"]
  node_constraints["Geological constraints"]
  node_cross_gradient["Cross-gradient<br/>[cross_gradient.F90]"]
  node_topography["Topography grids<br/>[grid.F90]"]
end

subgraph group_parallel["Parallel capabilities"]
  node_wavelet["Wavelet compression"]
  node_mpi["MPI parallelism<br/>[mpi_tools.F90]"]
  node_shared_parallel["Parallel tools<br/>[parallel_tools.f90]"]
end

subgraph group_utilities["Grid utilities"]
  node_converter["Grid splitter"]
end

node_user(("Geophysicist"))

node_user -->|"runs"| node_app
node_user -->|"selects"| node_parameters
node_parameters -->|"configures"| node_app
node_app -.->|"performs inversion"| node_joint_problem
node_joint_problem -.->|"uses"| node_forward_data
node_forward_data -.->|"models gravity"| node_gravity
node_forward_data -.->|"models magnetics"| node_magnetic
node_joint_problem -.->|"uses kernels"| node_sensitivity
node_joint_problem -.->|"updates model"| node_model
node_joint_problem -.->|"solves system"| node_solver
node_joint_problem -.->|"supports ADMM"| node_admm
node_joint_problem -.->|"supports constraints"| node_constraints
node_constraints -.->|"includes"| node_cross_gradient
node_joint_problem -.->|"supports topography"| node_topography
node_sensitivity -.->|"compresses kernels"| node_wavelet
node_app -.->|"runs in parallel"| node_mpi
node_app -.->|"uses parallelism"| node_shared_parallel

click node_parameters "https://github.com/tomofast/tomofast-x/tree/master/parfiles"
click node_app "https://github.com/tomofast/tomofast-x/blob/master/src/program_tomofastx.F90"
click node_joint_problem "https://github.com/tomofast/tomofast-x/blob/master/src/problem_joint_gravmag.F90"
click node_forward_data "https://github.com/tomofast/tomofast-x/blob/master/src/forward/gravmag/data_gravmag.f90"
click node_gravity "https://github.com/tomofast/tomofast-x/blob/master/src/forward/gravmag/grav/gravity_field.f90"
click node_magnetic "https://github.com/tomofast/tomofast-x/blob/master/src/forward/gravmag/mag/magnetic_field.f90"
click node_sensitivity "https://github.com/tomofast/tomofast-x/blob/master/src/forward/gravmag/sensitivity_gravmag.F90"
click node_model "https://github.com/tomofast/tomofast-x/blob/master/src/inversion/model.F90"
click node_solver "https://github.com/tomofast/tomofast-x/blob/master/src/inversion/lsqr_solver2.F90"
click node_admm "https://github.com/tomofast/tomofast-x/blob/master/src/inversion/admm_method.F90"
click node_constraints "https://github.com/tomofast/tomofast-x/tree/master/src/inversion"
click node_cross_gradient "https://github.com/tomofast/tomofast-x/blob/master/src/inversion/cross_gradient.F90"
click node_topography "https://github.com/tomofast/tomofast-x/blob/master/src/inversion/grid.F90"
click node_wavelet "https://github.com/tomofast/tomofast-x/blob/master/src/utils/wavelet_transform.F90"
click node_mpi "https://github.com/tomofast/tomofast-x/blob/master/src/utils/mpi_tools.F90"
click node_shared_parallel "https://github.com/tomofast/tomofast-x/blob/master/src/utils/parallel_tools.f90"
click node_converter "https://github.com/tomofast/tomofast-x/blob/master/data/convert_to_new_model_grid_format.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_parameters,node_app,node_joint_problem toneBlue
class node_forward_data,node_gravity,node_magnetic,node_sensitivity toneAmber
class node_model,node_solver,node_admm,node_constraints,node_cross_gradient,node_topography toneMint
class node_wavelet,node_mpi,node_shared_parallel toneRose
class node_converter,node_user toneIndigo
```

## Components

### Runtime entry

- [Parameter files](https://github.com/tomofast/tomofast-x/tree/master/parfiles): `parfiles`
- [Tomofast-x](https://github.com/tomofast/tomofast-x/blob/master/src/program_tomofastx.F90): `src/program_tomofastx.F90`
- [Joint problem](https://github.com/tomofast/tomofast-x/blob/master/src/problem_joint_gravmag.F90): `src/problem_joint_gravmag.F90`

### Forward modelling

- [Forward data](https://github.com/tomofast/tomofast-x/blob/master/src/forward/gravmag/data_gravmag.f90): `src/forward/gravmag/data_gravmag.f90`
- [Gravity fields](https://github.com/tomofast/tomofast-x/blob/master/src/forward/gravmag/grav/gravity_field.f90): `src/forward/gravmag/grav/gravity_field.f90`
- [Magnetic fields](https://github.com/tomofast/tomofast-x/blob/master/src/forward/gravmag/mag/magnetic_field.f90): `src/forward/gravmag/mag/magnetic_field.f90`
- [Sensitivity kernels](https://github.com/tomofast/tomofast-x/blob/master/src/forward/gravmag/sensitivity_gravmag.F90): `src/forward/gravmag/sensitivity_gravmag.F90`

### Inversion

- [Model state](https://github.com/tomofast/tomofast-x/blob/master/src/inversion/model.F90): `src/inversion/model.F90`
- [LSQR solver](https://github.com/tomofast/tomofast-x/blob/master/src/inversion/lsqr_solver2.F90): `src/inversion/lsqr_solver2.F90`
- [ADMM method](https://github.com/tomofast/tomofast-x/blob/master/src/inversion/admm_method.F90): `src/inversion/admm_method.F90`
- [Geological constraints](https://github.com/tomofast/tomofast-x/tree/master/src/inversion): `src/inversion`
- [Cross-gradient](https://github.com/tomofast/tomofast-x/blob/master/src/inversion/cross_gradient.F90): `src/inversion/cross_gradient.F90`
- [Topography grids](https://github.com/tomofast/tomofast-x/blob/master/src/inversion/grid.F90): `src/inversion/grid.F90`

### Parallel capabilities

- [Wavelet compression](https://github.com/tomofast/tomofast-x/blob/master/src/utils/wavelet_transform.F90): `src/utils/wavelet_transform.F90`
- [MPI parallelism](https://github.com/tomofast/tomofast-x/blob/master/src/utils/mpi_tools.F90): `src/utils/mpi_tools.F90`
- [Parallel tools](https://github.com/tomofast/tomofast-x/blob/master/src/utils/parallel_tools.f90): `src/utils/parallel_tools.f90`

### Grid utilities

- [Grid splitter](https://github.com/tomofast/tomofast-x/blob/master/data/convert_to_new_model_grid_format.py): `data/convert_to_new_model_grid_format.py`

### Other components

- **Geophysicist**

## Connections

- Geophysicist → Tomofast-x: runs (evidence: `README.md`)
- Geophysicist → Parameter files: selects (evidence: `README.md`)
- Parameter files → Tomofast-x: configures (evidence: `README.md`)
- Tomofast-x → Joint problem: performs inversion
- Joint problem → Forward data: uses
- Forward data → Gravity fields: models gravity
- Forward data → Magnetic fields: models magnetics
- Joint problem → Sensitivity kernels: uses kernels
- Joint problem → Model state: updates model
- Joint problem → LSQR solver: solves system
- Joint problem → ADMM method: supports ADMM
- Joint problem → Geological constraints: supports constraints
- Geological constraints → Cross-gradient: includes
- Joint problem → Topography grids: supports topography
- Sensitivity kernels → Wavelet compression: compresses kernels
- Tomofast-x → MPI parallelism: runs in parallel
- Tomofast-x → Parallel tools: uses parallelism
