fpm_module_cache Module

Module-level caching for FPM builds

This module implements a shared cache for compiled Fortran modules (.mod and .o files) that can be reused across different projects. It follows FPM conventions and integrates with the FPM source model.

The cache structure is: ~/.cache/fortran/modules/ / / / module.mod module.o metadata.json


Uses


Derived Types

type, public ::  module_cache_t

Type for managing module-level caching

Components

Type Visibility Attributes Name Initial
character(len=:), public, allocatable :: cache_dir

Base cache directory

character(len=:), public, allocatable :: compiler_id

Compiler identifier for cache segregation

character(len=:), public, allocatable :: compiler_version

Compiler version for cache segregation

logical, public :: enabled = .true.

Whether caching is enabled

Type-Bound Procedures

procedure, public :: init => cache_init
procedure, public :: get_cache_key => cache_get_key
procedure, public :: store_module => cache_store_module
procedure, public :: retrieve_module => cache_retrieve_module
procedure, public :: is_cached => cache_is_cached
procedure, public :: get_module_dir => cache_get_module_dir
procedure, public :: clean_stale => cache_clean_stale
procedure, public :: deep_copy => cache_deep_copy
procedure, public :: assign => cache_assign
generic, public :: assignment(=) => assign

Functions

public function new_module_cache(compiler, compiler_version) result(cache)

Create a new module cache instance

Arguments

Type IntentOptional Attributes Name
type(compiler_t), intent(in) :: compiler
character(len=*), intent(in), optional :: compiler_version

Return Value type(module_cache_t)

public function get_module_cache_dir() result(dir)

Get the default module cache directory

Arguments

None

Return Value character(len=:), allocatable