Modern Fortran Scientific Build and Verification
Organize, build, and verify a modern Fortran scientific or HPC project. Use for module dependency failures, compiler/profile migrations, numerical regression tests, and reproducible archived results.
Start with a known scientific result and a reproducible build. Produce the compiler and dependency matrix, a minimal numerical fixture and a record that ties reported results to the executable and input bytes. ## Key Points - [GNU Fortran directory and module options](https://gcc.gnu.org/onlinedocs/gfortran/Directory-Options.html) - [GNU Fortran code generation and runtime checks](https://gcc.gnu.org/onlinedocs/gfortran/Code-Gen-Options.html) - [Fortran Package Manager manifest reference](https://fpm.fortran-lang.org/spec/manifest.html)
skilldb get systems-programming-skills/modern-fortran-scientific-projectsFull skill: 39 linesModern Fortran Scientific Build and Verification
Start with a known scientific result and a reproducible build. Produce the compiler and dependency matrix, a minimal numerical fixture and a record that ties reported results to the executable and input bytes.
Inventory the existing contract
Find the supported compiler families, wrapper compilers, language level, preprocessing flags, BLAS/LAPACK or MPI dependencies, and input/output conventions. Locate the build entry point actually used by contributors and CI. Inventory the free-form and legacy fixed-form sources, generated source, modules, submodules and external libraries. Treat project-specific version and publication rules as inputs supplied by the maintainer.
Pick the smallest reference case that exercises the algorithm and the actual normal entry point. Keep the fixture small enough to run in a clean checkout. Record dimensions, units, boundary conditions, seed or initial data, expected outputs, and accepted numerical error. Document whether reproducibility means equal scientific results under tolerances, matching artifacts on one toolchain, or reproducible results across a declared environment matrix.
Build modules in the right dependency order
A compilation unit that uses a module needs the compiler-generated module interface before it compiles. Model that producer-to-consumer dependency explicitly and let the supported build tool schedule it. Separate module output by compiler, target and build profile. GNU Fortran's -J selects the module output/search directory, and -I adds a search path. Match paths for the actual compiler and avoid reusing stale .mod files from another build. Confirm that preprocessor definitions used for dependency discovery match the actual compilation.
Keep the existing supported build system when it works. An fpm manifest can be a good fit for a conventional package with declared dependencies and test executables. Use the project's CMake or other existing build logic when it carries required mixed-language, generated-code or deployment rules. For an external library, verify that headers or module interfaces and linked binaries refer to compatible builds. Preserve integer width, compiler ABI and runtime choices explicitly rather than repairing a link error by adding unrelated search paths.
Run a clean parallel build in each declared profile. Then change a module's public interface and verify its consumers are rebuilt, and touch an unrelated source and check the affected targets. Exercise the build from a fresh directory that has no cached modules. Keep checked and optimized builds separate. For GNU Fortran, use the relevant runtime checks such as -fcheck=all in a checked profile, and confirm the same reference case with release flags.
Verify scientific behavior and preserve provenance
Prefer kinds selected explicitly for the computation and external interface. Assert shape, finite values and conservation or domain-specific invariants as well as selected expected values. For floating-point comparisons use documented absolute and relative tolerances tied to the problem's units and scale. Choose an explicit NaN policy. Include a near-zero case and a deliberately invalid input. Allow order-dependent roundoff only within the stated tolerance. Avoid hiding a systematic drift with a wider tolerance.
Compare serial and parallel outputs when both are supported. Record rank and thread configuration, the compiler/optimization profile and external math library. Treat successful exit, plausible values and scientifically valid output as separate checks. Corrupt a fixture result or inject a known module dependency break to verify the failure is detected. No accepted result should come from an executable built before the changed source.
Archive the source revision, compiler and flags, dependency versions, input hash, machine or container identifier, execution settings, output hash or tolerance report, and exact result schema. Record the smallest command and expected outputs needed to reproduce the run. Use a separate timing study to make performance claims.
References and rights
- GNU Fortran directory and module options
- GNU Fortran code generation and runtime checks
- Fortran Package Manager manifest reference
Original SkillDB instructions under LicenseRef-SkillDB-Content. References were checked 2026-11-13 and used for technical verification.
Install this skill directly: skilldb add systems-programming-skills
Related Skills
Zig Basics
Zig language fundamentals for systems programming including comptime, error handling, and manual memory management
Build Systems
Build systems for systems programming including CMake, Meson, and Zig build with cross-compilation
Cpp Modern
Modern C++ (C++20/23) patterns including concepts, ranges, coroutines, and modules
Ffi
Foreign function interfaces for calling between C, C++, Rust, Zig, Python, and other languages safely
Design and Verify FPGA Logic with Verilog
Verify an FPGA module with self-checking simulation, synthesis, timing constraints, clock-domain review, and board-level acceptance checks.
Memory Safety
Techniques for achieving memory safety without garbage collection including ownership models, arenas, and static analysis