Loading...
Searching...
No Matches
Global

Definition

Global configuration and shared runtime state for the fpx preprocessor.

This module defines the central configuration object used throughout the entire preprocessing session. A single public instance, global , stores all persistent settings controlling the behavior of the preprocessor.

The global configuration provides:

  • User-defined macro definitions.
  • Symbols explicitly excluded via #undef.
  • Additional include search directories.
  • Feature switches controlling optional extensions.
  • Behavioural settings affecting parsing and expansion.
  • Runtime flags used by interactive preprocessing sessions.

All fpx components access the same global state, avoiding the need to pass configuration objects through every procedure call.

The design assumes the traditional single-threaded preprocessing model. If multiple preprocessing jobs are executed concurrently, each instance should maintain its own independent configuration object.

Supported configuration options

The following settings are available:

  • macros(:) Collection of predefined macros available before preprocessing begins.
  • undef(:) Symbols protected from future redefinition through #define.
  • includedir(:) Additional directories searched by #include.
  • expand_macros Enables or disables macro expansion globally.
  • exclude_comments Controls whether comments are preserved in the generated output.
  • implicit_continuation Enables implicit continuation during macro expansion.
  • line_break Interprets a double backslash (\\) as an explicit line break.
  • extra_macros Enables non-standard predefined macros such as:
    • __FILE__
    • __LINE__
    • __FUNC__
    • __TIMESTAMP__
  • interactive Enables REPL-style interactive preprocessing.
  • support_forloop Enables support for the non-standard #for / #endfor directives.
  • disable_continuation Disables explicit Fortran continuation handling using trailing &.
  • support_dollar_insert Enables ${NAME} placeholder substitution during macro expansion.
Note
All settings can be modified at any time before invoking preprocess(...).

Examples

  1. Add custom include paths:
    use fpx_global
    global%includedir = [ &
    string('./include'), &
    string('../common'), &
    string('/usr/local/include/fpx') ]
    call preprocess('main.F90')
    type(global_settings), public global
    Global preprocessor configuration instance.
    Definition global.f90:192
  2. Predefine macros:
    use fpx_global
    use fpx_macro
    call add(global%macros, macro('DEBUG','1'))
    call add(global%macros, macro('MPI_VERSION','4'))
    call preprocess('solver.F90')
    Append macros to a macro table.
    Definition macro.f90:175
    Representation of a preprocessor macro.
    Definition macro.f90:135
  3. Disable macro expansion:
    global%expand_macros = .false.
    call preprocess('input.F90', 'output.F90')
  4. Enable fpx extensions:
    global%support_forloop = .true.
    global%support_dollar_insert = .true.
    global%extra_macros = .true.
    call preprocess('templates.F90')
  5. Start an interactive preprocessing session:
    global%interactive = .true.
    call preprocess(stdin, stdout)
See also
macro parser include

Data Types

type  global_settings
 Global preprocessor configuration and shared runtime state. More...

Variables

◆ global

type(global_settings), public global

Global preprocessor configuration instance.

This singleton is automatically initialized with sensible default values and is shared by all fpx modules during preprocessing.

Applications typically customize this object before invoking preprocess(...).

Definition at line 192 of file global.f90.