function_parser Module

Modern Fortran function parser.

Original Description

This function parser module is intended for applications where a set of mathematical fortran-style expressions is specified at runtime and is then evaluated for a large number of variable values. This is done by compiling the set of function strings into byte code, which is interpreted efficiently for the various variable values.

History

  • Original code (Fortran 90 function parser v1.1) by: Roland Schmehl roland.schmehl@alumni.uni-karlsruhe.de. The source code is available from http://fparser.sourceforge.net
  • The function parser concept is based on a C++ class library written by Juha Nieminen warp@iki.fi available from http://warp.povusers.org/FunctionParser/
  • Expanded and updated to modern Fortran by Jacob Williams, 2017.

License

  • Copyright (c) 2000-2008, Roland Schmehl. All rights reserved.
  • Copyright (c) 2017, Jacob Williams. All rights reserved.
  • This software is distributable under the BSD license. See the terms of the BSD license in the documentation provided with this software.


Uses

  • module~~function_parser~~UsesGraph module~function_parser function_parser iso_fortran_env iso_fortran_env module~function_parser->iso_fortran_env module~error_module error_module module~function_parser->module~error_module

Contents


Variables

TypeVisibilityAttributesNameInitial
integer, public, parameter:: fparser_rk =real64

real kind used by this module [8 bytes]


Derived Types

type, public :: fparser

The function parser class.

Components

TypeVisibilityAttributesNameInitial
type(stack_func_container), public, dimension(:), allocatable:: bytecode_ops

array of function pointers

integer, public, dimension(:), allocatable:: bytecode

array of integers

integer, public :: bytecodesize =0
real(kind=wp), public, dimension(:), allocatable:: immed
integer, public :: immedsize =0
real(kind=wp), public, dimension(:), allocatable:: stack
integer, public :: stacksize =0
integer, public :: stackptr =0
type(list_of_errors), public :: error_msg

list of error messages

Type-Bound Procedures

procedure, public :: parse => parse_function
procedure, public :: evaluate => evaluate_function
procedure, public :: destroy => destroy_parser
procedure, public :: error
procedure, public :: print_errors
procedure, public :: clear_errors
procedure, public :: compile_substr
procedure, public :: compile
procedure, public :: check_syntax
procedure, public :: add_error

type, public :: fparser_array

A wrapper to fparser to evaluate an array of functions.

Read more…

Components

TypeVisibilityAttributesNameInitial
type(fparser), public, dimension(:), allocatable:: f

An array of parsers. Each one has the same variables.

Type-Bound Procedures

procedure, public :: parse => parse_function_array
procedure, public :: evaluate => evaluate_function_array
procedure, public :: destroy => destroy_parser_array
procedure, public :: error => error_array
procedure, public :: print_errors => print_errors_array
procedure, public :: clear_errors => clear_errors_array