FORTRAN SOFTWARE CATALOG

Repository owner: Institute of Computing for Climate Science (Cambridge-ICCS)

ftorch

Call PyTorch models from Fortran; checked CPU inference with an embedded affine TorchScript model.

Repository · Pinned source (b1b1bb3b9138) · Try in playground · Checked package example

GAMS classifications

About this package

Category
Machine learning
License
MIT

Topics: deep-learning, fortran, hacktoberfest, inference, interoperability, libtorch, machine-learning, neural-networks, python, pytorch, torch, torchscript

Classification scope and review notes

The original FTorch Fortran and C++ sources are wrapped for FPM, using pinned Debian CPU LibTorch 2.6.0+dfsg-7, the C++20 mode, C++11 ABI and include/definition settings from the upstream CMake target. The operator C++ flag setting is restricted to a current, unshared source-package recipe; public requests cannot set it and previous cache keys are preserved. The self-contained consumer embeds a reproducibly generated 1,766-byte TorchScript model as hexadecimal text, writes tiny.pt in the sandbox and calls the author tensor/model API in REAL64. Two different five-element inputs exercise y=2*x+1, with each output checked independently for finiteness and absolute error below 1e-12. The second call also verifies that the input tensor observes updated Fortran storage. No Python or model download runs in visitor jobs. This is an illustrative affine inference model, not a trained scientific predictor. K covers inference as function approximation; no training or optimization classification is inferred. GPU use, training, autograd, parallel execution and arbitrary external models are not verified. FTorch MIT notices and native Debian dependency notices are retained. APT estimates about 924 MB of additional native dependencies in the isolated FTorch image; these are separate from the catalog logical library-artifact total.

Package dependencies

Resolved GitHub repositories used by the verified playground build, combining direct and indirect dependencies. This list does not describe internal module dependencies or native system libraries.

Required by this build

No additional GitHub package dependencies were recorded for this verified build.

Build record verified 2026-10-30.

Used by (0 selected packages)

No other selected build records this repository as a dependency. This is not a measure of usage outside the catalog.

Reviewed procedures

These mappings have pinned source evidence. A checked package example may exercise only some of them; source review is not a numerical benchmark.

torch_model_load / torch_tensor_from_array / torch_model_forward

Module: ftorch / ftorch_model / ftorch_tensor

K

K: verified

Derivatives / callbacks: not applicable

The original FTorch Fortran and C++ sources are wrapped for FPM, using pinned Debian CPU LibTorch 2.6.0+dfsg-7, the C++20 mode, C++11 ABI and include/definition settings from the upstream CMake target. The operator C++ flag setting is restricted to a current, unshared source-package recipe; public requests cannot set it and previous cache keys are preserved. The self-contained consumer embeds a reproducibly generated 1,766-byte TorchScript model as hexadecimal text, writes tiny.pt in the sandbox and calls the author tensor/model API in REAL64. Two different five-element inputs exercise y=2*x+1, with each output checked independently for finiteness and absolute error below 1e-12. The second call also verifies that the input tensor observes updated Fortran storage. No Python or model download runs in visitor jobs. This is an illustrative affine inference model, not a trained scientific predictor. K covers inference as function approximation; no training or optimization classification is inferred. GPU use, training, autograd, parallel execution and arbitrary external models are not verified. FTorch MIT notices and native Debian dependency notices are retained. APT estimates about 924 MB of additional native dependencies in the isolated FTorch image; these are separate from the catalog logical library-artifact total. Dedicated K driver now checks the same fixed affine model across REAL32/REAL64 tensor ranks 1/2/3, asymmetric dimension permutations, metadata, in-place input updates and replay. It verifies 1742 exact dyadic output entries; nonlinear models, gradients and training remain unverified.

Pinned source: src/ftorch_model.f90 · src/ftorch_tensor.f90 · src/ctorch.cpp

Author examples/tests: examples/02_SimpleNet/simplenet_infer_fortran.f90

Load checked GAMS driver: gams-ftorch-affine-reference