Loading...
Searching...
No Matches
Global

Definition

Central global configuration and shared state for the fpx Fortran preprocessor This module defines a single global instance global of type global_settings that holds all persistent, user-configurable state used across the entire preprocessing session:

The design uses a single public variable global so that all fpx modules can access and modify the same configuration without passing arguments everywhere. This is safe in single-threaded use (typical for preprocessing) and allows easy customization from driver programs or interactive sessions.

Examples

  1. Add custom include paths before preprocessing:
    global%includedir = [ './include', '/usr/local/include/fortran', '../common' ]
    call preprocess('main.F90', 'main.f90')
    !#include <file.h> will search these directories
  2. Predefine common macros (e.g. for conditional compilation):
    call add(global%macros, macro('DEBUG', '1'))
    call add(global%macros, macro('MPI_VERSION', '3'))
    call add(global%macros, macro('USE_OPENMP', '1'))
    call preprocess('src/app.F90')
    !> Code can now use #ifdef DEBUG, #if MPI_VERSION >= 3, etc.
  3. Disable macro expansion temporarily (pass-through mode):
    global%expand_macros = .false. ! Only handle #include and conditionals
    call preprocess('raw_source.F90', 'clean.F90')
    ...
  4. Strip all comments from final output:
    global%exclude_comments = .true.
    call preprocess('messy.F90', 'clean_no_comments.f90')
    ...

Data Types

type  global_settings
 Global preprocessor configuration and shared runtime state All components of fpx read from and write to this single instance. Users can safely modify its public components at any time. More...
 

Variables

◆ global

type(global_settings), public global

The single global instance used throughout fpx Initialized automatically with sensible defaults values.

Definition at line 92 of file global.f90.