Fortran Shell
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
doc
scripts
src
.gitignore
.gitmodules
.travis.yml
CONTRIBUTING.md
LICENSE.bsd-2.md
LICENSE.bsd-3.md
LICENSE.gpl3.md
LICENSE.mit.md
README.md
codecov.yml
fobos

README.md

FiNeR GitHub tag

License License License License

Status Build Status Coverage Status

FiNeR, Fortran INI ParseR and generator for FoRtraners

  • FiNeR is a pure Fortran (KISS) library for IO of INI (config) files for modern (2003+) Fortran projects;
  • FiNeR is Fortran 2003+ standard compliant;
  • FiNeR is OOP designed;
  • FiNeR is TDD designed;
  • FiNeR is a Free, Open Source Project.

Issues

GitHub issues Ready in backlog In Progress Open bugs

Compiler Support

Compiler Compiler Compiler Compiler Compiler Compiler


What is FiNeR? | Main features | Copyrights | Documentation | A Taste of FiNeR


What is FiNeR?

Modern Fortran standards (2003+) have introduced better support for strings manipulations. Exploiting such new Fortran capabilities, FiNeR provides an easy to use module library for input (parsing) and output (generating) INI (config) files.

Go to Top

Main features

  • User-friendly methods for IO INI files:
    • parsing files:
      • automatic parsing of all sections (whose number is auto-detected);
      • automatic parsing of all options of each section (whose number is auto-detected);
      • unlimited polymorphic option-values extraction;
    • generating files:
      • user-friendly add/remove sections/options;
      • unlimited polymorphic option-values setting;
    • introspection:
      • self-consistency checks;
      • pretty-printings;
      • loop over options;
      • inquiring the presence of sections/options by name;
  • errors trapping mechanism.

Any feature request is welcome.

Go to Top

Copyrights

FiNeR is an open source project, it is distributed under a multi-licensing system:

Anyone is interest to use, to develop or to contribute to FiNeR is welcome, feel free to select the license that best matches your soul!

More details can be found on wiki.

Go to Top

Documentation

Besides this README file the FiNeR documentation is contained into its own wiki. Detailed documentation of the API is contained into the GitHub Pages that can also be created locally by means of ford tool.

A Taste of FiNeR

Let us assume our goal is to parse a config file. It is as simple as

USE Lib_INI_IO
...
type(Type_File_INI)::           fini     ! INI File.
character(len=:), allocatable:: source   ! Testing string.
real(R4P), allocatable::        array(:) ! Array option.
integer(I4P)::                  error    ! Error code.
...
source='[section-1]'//new_line('A')//    &
       'option-1 = one'//new_line('A')// &
       'option-2 = 2.'//new_line('A')//  &
       '           3.'//new_line('A')//  &
       'option-3 = bar'//new_line('A')// &
       '[section-2]'//new_line('A')//    &
       'option-1 = foo'
call fini%load(source=source)
allocate(array(1:fini%count_values(section='section-1',option='option-2')))
call fini%get(section='section-1',option='option-2',val=array,error=error)
if (error==0) then
  print*,array
else
  ! errors occur...
endif

And what about the generation of an INI file? It is simple as parsing an old one:

USE Lib_INI_IO
...
type(Type_File_INI):: fini ! INI File.
...
call fini%add(section='sec-foo')
call fini%add(section='sec-foo',option='bar',val=-32.1_R8P)
call fini%add(section='sec-foo',option='baz',val=' hello FiNeR! ')
call fini%add(section='sec-foo',option='array',val=[1,2,3,4])
call fini%add(section='sec-bar')
call fini%add(section='sec-bar',option='bools',val=[.true.,.false.,.false.])
call fini%save(filename='foo.ini')

A file named foo.ini is created. It contains something like:

[sec-foo]
bar = -0.321000000000000E+002
baz =  hello FiNeR!
array = +1 +2 +3 +4
[sec-bar]
bools = T F F

Go to Top