Skip to content

An equation parser class for Modern Fortran

License

Notifications You must be signed in to change notification settings

jacobwilliams/feq-parse

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fortran Equation Parser

Copyright 2020 Fluid Numerics LLC

feqparse is an equation parser Fortran class that is used to interpret and evaluate functions provided as strings.

Learn how to contribute to this repository

Installation

For a quick installation to /usr/local/feqparse,

cd build/
cmake ../
make
sudo make install

If you'd like to run the provided tests to verify your installation,

  1. Navigate to the test/ directory underneath the build/ directory.
cd test/
  1. Use ctest to run the provided tests
ctest .

The above steps install

/opt/feqparse/lib/libfeqparse.a
/opt/feqparse/include/FEQParse.mod

Fortran Package Manager

A Fortran Package Manager manifest file is also included, so that the library and test cases can be compiled with FPM. For example:

fpm build --profile release
fpm test --profile release

To use feq-parse within your fpm project, add the following to your fpm.toml file:

[dependencies]
feq-parse = { git="https://github.com/FluidNumerics/feq-parse.git" }

Or, to use a specific version:

[dependencies]
feq-parse = { git="https://github.com/FluidNumerics/feq-parse.git", tag = "v1.1.0" }

Usage

Demo Program

Example Makefile

FC = gfortran
FLIBS += -L/opt/feqparse/lib -lfeqparse
FFLAGS += -I/opt/feqparse/include

demo : FEqParseDemo.f90
	${FC} -c FEqParseDemo.f90 ${FFLAGS}
	${FC} FEqParseDemo.o ${FFLAGS} ${FLIBS} -o $@

Example program

PROGRAM FEqParseDemo

USE FEQParse

IMPLICIT NONE

  TYPE(EquationParser) :: f
  CHARACTER(LEN=1), DIMENSION(1:3) :: independentVars
  CHARACTER(LEN=30) :: eqChar
  REAL :: x(1:3)

    ! Specify the independent variables
    independentVars = (/ 'x', 'y', 'z' /)

    ! Specify an equation string that we want to evaluate
    eqChar = 'f = exp( -(x^2 + y^2 + z^2) )'

    ! Create the EquationParser object
    f = EquationParser(eqChar, independentVars)

    ! Evaluate the equation
    x = (/ 0.0, 0.0, 0.0 /)
    PRINT*, f % evaluate( x )

    ! Clean up memory
    CALL f % Destruct()


END PROGRAM FEqParseDemo

Contributors

  • (Maintainer) Joe Schoonover, Fluid Numerics LLC

About

An equation parser class for Modern Fortran

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Fortran 91.0%
  • CMake 9.0%