Skip to content

Tutorials ​

Seven complete programs, one per tutorial, in docs/examples/src/. The code on these pages is that file, included when the site is built, and the output below it is what the program printed: bash scripts/run_examples.sh builds every program, runs it and fails when its output differs from docs/examples/output/<program>.txt.

TutorialYou learnProgram
T1 A derivative on a periodic gridthe window by offset, ghost nodes, the order measured by halving the stepfd_derivative.F90
T2 Finite volumes, conservativelycell averages, face values as fluxes, the cell derivative as their difference, why the sum telescopesfv_flux_difference.F90
T3 Upwind faces and their mirrorright- and left-side stencils, the mirror identity, upwind face values for ut+aux=0upwind.F90
T4 The order at run timethe dispatchers, window bounds as expressions of the order, GIDEON_NAN, the cost of choosing per pointrun_time_order.F90
T5 Gradient, divergence, curlgathering directional stencils from 3-D arrays; the four 3-D operators against exact valuesoperators_3d.F90
T6 On the GPUthe kernels inside !$acc parallel loop, the OpenACC build, the device against the hostgpu.F90
T7 A compact derivative on a periodic linea compact operator as a right-side kernel plus a band solved along the line; its order and accuracy against the explicit onecompact_derivative.F90

Prerequisites ​

  • Fortran arrays with lower bounds other than 1, array sections, explicit-shape dummy arguments.
  • Conventions: the names gideon_<data>_<op>_<bias><order> and the windows by offset. Every tutorial applies them; T1 explains them on one kernel.
  • gfortran (the outputs were produced with gfortran 16.2) and FoBiS. T6 runs on a GPU with nvfortran (-acc, NVIDIA HPC SDK; 26.9 here) and an NVIDIA GPU; without them it runs on the host and prints the same.

Building the examples ​

bash
fobis fetch                        # PENF, into src/third_party/
fobis build --mode examples-gnu    # every program of docs/examples/src, into exe-examples/
./exe-examples/fd_derivative
bash scripts/run_examples.sh       # build, run, compare every output with docs/examples/output/

A program is compiled as your own would be, against the static library (which carries PENF):

bash
fobis build --mode static-gnu      # lib/gnu/static/libgideon.a and its modules
gfortran -I lib/gnu/static/mod docs/examples/src/fd_derivative.F90 lib/gnu/static/libgideon.a -o fd_derivative
./fd_derivative

bash scripts/run_examples.sh fd_derivative upwind checks some programs only; --write rewrites their outputs after a deliberate change. The programs print only what does not depend on the machine: errors to four significant digits, orders to two decimals, counts and logical checks, never a timing. The check is made with the examples-gnu build; another compiler can differ in the last printed digit of an error.

Released under your choice of GPL-3.0-or-later, BSD-2-Clause, BSD-3-Clause or MIT.