- 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.
What is FiNeR? | Main features | Copyrights | Documentation | A Taste of 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
- 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;
- parsing files:
- errors trapping mechanism.
Any feature request is welcome.
Go to Top
FiNeR is an open source project, it is distributed under a multi-licensing system:
- for FOSS projects:
- for closed source/commercial projects:
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
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.
Let us assume our goal is to parse a config file. It is as simple as
use finer
...
type(file_ini) :: fini !< INI file handler.
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 finer
...
type(file_ini) :: fini !< INI file handler.
...
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