All Projects → victorsndvg → FPL

victorsndvg / FPL

Licence: LGPL-3.0 License
Fortran Parameter List. A fortran dictionary where to put the parameters of your application.

Programming Languages

fortran
972 projects
CMake
9771 projects

Projects that are alternatives of or similar to FPL

datastructures-and-algorithms
Repository for studying/practicing Data Structures, Algorithms and Code Interview Problems.
Stars: ✭ 30 (+3.45%)
Mutual labels:  datastructures
prodict
Prodict, what Python dict meant to be.
Stars: ✭ 102 (+251.72%)
Mutual labels:  dictionary
configmanager
Forget about configparser, YAML, or JSON parsers. Focus on configuration. NOT RECOMMENDED FOR USE (2019-01-26)
Stars: ✭ 15 (-48.28%)
Mutual labels:  object-oriented
bloomfilter
Simplistic (but fast) java implementation of a bloom filter.
Stars: ✭ 35 (+20.69%)
Mutual labels:  datastructures
mdict
node.js mdict (*.mdx, *.mdd) file reader
Stars: ✭ 39 (+34.48%)
Mutual labels:  dictionary
Maat
Validation and transformation library powered by deductive ascending parser. Made to be extended for any kind of project.
Stars: ✭ 27 (-6.9%)
Mutual labels:  dictionary
decaf-rs
The Decaf compiler, written in Rust
Stars: ✭ 43 (+48.28%)
Mutual labels:  object-oriented
nebrija
A simple Ruby wrapper for the official Spanish dictionary (RAE)
Stars: ✭ 18 (-37.93%)
Mutual labels:  dictionary
medict
medict a cross platform dictionary application,support mdict (*.mdx/*.mdd) dictionary format
Stars: ✭ 154 (+431.03%)
Mutual labels:  dictionary
tudien
Từ điển tiếng Việt dành cho Kindle
Stars: ✭ 38 (+31.03%)
Mutual labels:  dictionary
Julia
Algorithms implemented in the Julia programming language. We're collaborating with the Humans of Julia community!
Stars: ✭ 216 (+644.83%)
Mutual labels:  datastructures
FPLbot
A bot made for /r/FantasyPL
Stars: ✭ 54 (+86.21%)
Mutual labels:  fpl
RedQuarkTutorials
Code used in all my tutorials on my website - redquark.org
Stars: ✭ 27 (-6.9%)
Mutual labels:  datastructures
Splain
small parser to create more interesting language/sentences
Stars: ✭ 15 (-48.28%)
Mutual labels:  dictionary
star
An experimental programming language that's made to be powerful, productive, and predictable
Stars: ✭ 88 (+203.45%)
Mutual labels:  object-oriented
DictionaryUtils
iOS Dictionary Utilities for Swift - allowing you to pull properties from a dictionary using a string eg. data.readString("field[0].name")
Stars: ✭ 13 (-55.17%)
Mutual labels:  dictionary
Narthex
Modular personalized dictionary generator.
Stars: ✭ 156 (+437.93%)
Mutual labels:  dictionary
oxford-dictionary
A nodeJS wrapper for using the oxforddictionary.com V2 REST API.
Stars: ✭ 28 (-3.45%)
Mutual labels:  dictionary
kwstruct
Struct with keyword arguments support
Stars: ✭ 17 (-41.38%)
Mutual labels:  datastructures
qstardict
A read-only mirror
Stars: ✭ 55 (+89.66%)
Mutual labels:  dictionary

FPL

Fortran Parameter List

Build Status codecov.io

License

License

What is FPL?

FPL is pure fortran 2003 library that can manage the parameters of your program from a single point.

FPL is an extendible container (dictionary) of <Key, Value> pairs, where the Key is a character string and the Value can be, by the default, of the following data types:

  • Integer (kinds 1, 2, 4, 8)
  • Real (kinds 4, 8)
  • Logical
  • String

Value can be a scalar or an array of any dimension.

FPL stores copies of the passed data by assignment.

FPL is based in Teuchos::ParameterList of the Trilinos project.

How to get FPL

git clone --recursive https://github.com/victorsndvg/FPL.git

Compilation

FPL compile with GNU Fortran compiler 5.1 (and newer versions) and Intel Fortran compiler 15.0.1 (and newer versions).

Note: Due to an issue with IBM XLF 14.0.1 Fortran compiler, if you want to use this compiler use the branch XLF_workaround

FPL uses CMake as a portable compilation system.

The easiest way to compile FPL under Linux is:

$ cd FPL
$ mkdir build
$ cd build
$ cmake ../
$ make

To compile FPL under Windows use de equivalent commands

Getting started with FPL

Notes:

  • Source code documentation
  • FPL cannot handle non-allocated variables while calling Set(Key, Value) or Get(Key, Value) procedures.
  • To succesfull get a stored value into your target variable, data type and shape of both variables must agree.

Using FPL in your program

USE FPL

type(ParameterList_t) :: My_List

call FPL_Init()
call My_List%Init()

... [Program body]

call My_List%Free()
call FPL_Finalize()

Setting parameters

FPLError = My_List%Set(Key='Max Iters', Value=1500)
FPLError = My_List%Set(Key='Tolerance', Value=1.e-10)
FPLError = My_List%Set(Key='Solver', Value='GMRES')

Getting parameters

integer :: MaxIters

FPLError = My_List%Get(Key='Max Iters', Value=MaxIters)

Getting parameters as strings

character(len=:), allocatable :: MaxItersString

FPLError = My_List%GetAsString(Key='Max Iters', String=MaxItersString)

Check if you can assign a parameter to your variable

Check if the target variable has the same type and shape as the stored variable ‼️

integer :: MaxIters

if(My_List%isAssignable(Key='Max Iters', Value=MaxIters)) then
    FPLError = My_List%Get(Key='Max Iters', Value=MaxIters)
endif

Deleting parameters

call My_List%Del(Key='Max Iters')

Checking if a parameter is present

logical :: solver_defined

solver_defined = My_List%isPresent(Key='Solver')

Checking if a parameter is of the expected data type

logical :: has_same_type
real    :: Tolerance

has_same_type = My_List%isOfDataType(Key='Tolerance', Mold=Tolerance)

Checking the shape of a parameter

logical :: has_same_type
integer, allocatable :: Shape(:)

FPLError = My_List%GetShape(Key='Tolerance', Shape=Shape)

Working with parameter sublists

Every parameter list can recursively store parameter sublists.

type(ParameterList_t), pointer :: Prec_List

Prec_List => My_List%NewSubList(Key='Preconditioner')

call Prec_List%Set(Key='Type', Value='ILU')
call Prec_List%Set(Key='Drop Tolerance', Value=1.e-3)

Checking if it is a parameter sublist

logical :: prec_defined

prec_defined = My_List%isSubList(Key='Preconditioner')

Print (recursive) the content of a parameter list

call My_List%Print()

Iterate on a ParameterList

ParameterList also includes a derived type that works like an iterator to go through all stored parameters without asking for the key.

ParameterList_Iterator interface is almost the same than ParameterList interface plus some procedures like HasFinished() and Next() to manage the advance of the iterator.

The example below iterates on a ParameterList containing integer vectors and getting the stored values.

type(ParameterListIterator_t) :: Iterator
integer,allocatable :: array(:)
integer,allocatable :: shape(:)

Iterator = Parameters%GetIterator()
do while (.not. Iterator%HasFinished())
    if(Iterator%GetDimensions() /= 1) stop -1
    if(Iterator%GetShape(Shape=shape) /= 0) stop -1
    if(.not. Iterator%IsOfDataType(Mold=array)) stop -1
    if(allocated(array)) deallocate(array)
    allocate(array(shape(1)))
    if(Iterator%Get(array) /= 0) stop -1
    print*, '  Key = '//Iterator%GetKey()
    print*, '  Bytes = ', Iterator%DataSizeInBytes()
    print*, '  Dimensions = ', Iterator%GetDimensions()
    print*, '  Value = ', array)
    call Iterator%Next()
enddo
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].