Examples
Worked examples demonstrating FoBiS.py features from simple to advanced.
Examples in this section
| Example | What it shows |
|---|---|
| Basic Build | Auto-discovery, module dependency resolution, custom directories |
| Library | Building static and shared Fortran libraries |
| Interdependent Projects | Auto-rebuilding dependent libraries with -dependon |
| PreForM Preprocessing | Template preprocessing with PreForM.py |
Structure of each example
Each example follows the same pattern:
- Source tree — the Fortran files involved
- Build — how to invoke FoBiS.py
- fobos — the equivalent fobos file
- Result — what gets built and where
The cumbersome example
Most examples use a deliberately contrived Fortran project called cumbersome. It represents a typical project with multiple levels of module and include dependencies:
src/
├── cumbersome.f90 ← main program, uses module nested_1
└── nested-1/
├── first_dep.f90 ← defines module nested_1, includes second_dep.inc
└── nested-2/
└── second_dep.incThe sources:
fortran
! cumbersome.f90
program cumbersome
use nested_1
implicit none
call print_hello_world
end program cumbersomefortran
! nested-1/first_dep.f90
module nested_1
include 'second_dep.inc'
end module nested_1fortran
! nested-1/nested-2/second_dep.inc
implicit none
character(len=12), parameter :: hello_world = 'Hello World!'
contains
subroutine print_hello_world()
print "(A)", hello_world
end subroutineBuilding this manually requires compiling second_dep.inc (via include), then first_dep.f90, then linking cumbersome.f90 — in exactly that order. FoBiS.py resolves this hierarchy automatically.