Ignore:
Timestamp:
Jan 24, 2018, 10:24:24 PM (7 years ago)
Author:
jvatant
Message:

Making Titan's hazy again - part II
+ Major updates of J.Burgalat YAMMS library and optical coupling, including :
++ Added the routines for haze optics inside YAMMS
++ Calling rad. transf. with interactive haze is plugged
in but should stay unactive as long as the microphysics is
in test phase : cf "uncoupl_optic_haze" flag : true for now !
++ Also some sanity checks for negative tendencies and
some others upkeep of YAMMS model
+ Also added a temporary CPP key USE_QTEST in physiq_mod
that enables to have microphysical tendencies separated
from dynamics for debugging and test phases
-- JVO and JB

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.TITAN/libf/muphytitan/cfgparse.F90

    r1814 r1897  
    1 ! Copyright Jérémie Burgalat (2010-2015)
    2 ! 
    3 ! burgalat.jeremie@gmail.com
    4 ! 
    5 ! This software is a computer program whose purpose is to provide configuration 
     1! Copyright Jérémie Burgalat (2010-2015,2017)
     2!
     3! jeremie.burgalat@univ-reims.fr
     4!
     5! This software is a computer program whose purpose is to provide configuration
    66! file and command line arguments parsing features to Fortran programs.
    7 ! 
     7!
    88! This software is governed by the CeCILL-B license under French law and
    9 ! abiding by the rules of distribution of free software.  You can  use, 
     9! abiding by the rules of distribution of free software.  You can  use,
    1010! modify and/ or redistribute the software under the terms of the CeCILL-B
    1111! license as circulated by CEA, CNRS and INRIA at the following URL
    12 ! "http://www.cecill.info". 
    13 ! 
     12! "http://www.cecill.info".
     13!
    1414! As a counterpart to the access to the source code and  rights to copy,
    1515! modify and redistribute granted by the license, users are provided only
    1616! with a limited warranty  and the software's author,  the holder of the
    1717! economic rights,  and the successive licensors  have only  limited
    18 ! liability. 
    19 ! 
     18! liability.
     19!
    2020! In this respect, the user's attention is drawn to the risks associated
    2121! with loading,  using,  modifying and/or developing or reproducing the
     
    2525! professionals having in-depth computer knowledge. Users are therefore
    2626! encouraged to load and test the software's suitability as regards their
    27 ! requirements in conditions enabling the security of their systems and/or 
    28 ! data to be ensured and,  more generally, to use and operate it in the 
    29 ! same conditions as regards security. 
    30 ! 
     27! requirements in conditions enabling the security of their systems and/or
     28! data to be ensured and,  more generally, to use and operate it in the
     29! same conditions as regards security.
     30!
    3131! The fact that you are presently reading this means that you have had
    3232! knowledge of the CeCILL-B license and that you accept its terms.
    3333
    3434!! file: cfgparse.F90
    35 !! summary: Configuration file parser source file
    36 !! author: burgalat
    37 !! date: 2013-2015, 2017
     35!! summary: Configuration file parser source file.
     36!! author: J. Burgalat
     37!! date: 2013-2015,2017
    3838
    3939#include "defined.h"
     
    4141MODULE CFGPARSE
    4242  !! Configuration file parsing module
    43   !! 
    44   !! This module defines a set of derived types as well as methods to parse configuration files.
     43  !!
     44  !! This module defines a set of derived types as well as methods to parse configuration files.
     45  !!
     46  !! If you only wish to have an overview of cfgparse usage, you'd better go
     47  !! [here](|url|/page/swift/p02_cfgparse.html).
    4548  !! @todo
    46   !! Add interpolation from environment and/or parser options
     49  !! Add interpolation from environment and/or parser options.
    4750  USE, INTRINSIC :: ISO_FORTRAN_ENV
    4851  USE ERRORS
    49   USE STRINGS
     52  USE STRING_OP
    5053  USE FSYSTEM
    5154  IMPLICIT NONE
     
    5659            cfg_get_value, cfg_set_value, cfg_count, cfg_check_name, &
    5760            cfg_has_option, cfg_has_section, &
     61            cfg_option_names,cfg_section_names, &
    5862            cfg_remove_option, cfg_remove_section, &
    5963            cfg_sort_options
     
    6367  ! some public definitions from other modules
    6468  ! from strings
    65   PUBLIC :: str_to_lower,st_slen, st_llen
     69  PUBLIC :: to_lower,st_slen, st_llen
    6670
    6771  PUBLIC :: OPERATOR(==), OPERATOR(/=), ASSIGNMENT(=)
     
    7680  TYPE, PUBLIC :: cfgparser
    7781    !! Define a parser of options
    78     !! 
    79     !! A [[cfgparser(type)]] stores [[option(type)]] objects. 
     82    !!
     83    !! A [[cfgparser(type)]] stores [[option(type)]] objects.
    8084    TYPE(option), DIMENSION(:), ALLOCATABLE  :: options !! list of options.
    8185#if HAVE_FTNPROC
     
    124128    PROCEDURE, PUBLIC :: remove_option  => cfg_remove_option
    125129    !> Remove a section (and all the associated options) from the parser.
    126     PROCEDURE, PUBLIC :: remove_section => cfg_remove_section 
    127     !> Get value(s) of an option in the parser by name 
    128     !! 
     130    PROCEDURE, PUBLIC :: remove_section => cfg_remove_section
     131    !> Get value(s) of an option in the parser by name
     132    !!
    129133    !! ```
    130134    !! FUNCTION cfg_get_value(this,name,output) RESULT(error)
     
    135139    !! On error, __output__ argument is undefined (that is, left unchanged
    136140    !! for scalar versions, **unallocated** for vector version).
    137     !! 
     141    !!
    138142    !! Errors occur in the following situations:
    139143    !! - The option has no value (-6)
    140     !! - The option does not exist (-7) 
     144    !! - The option does not exist (-7)
    141145    !! - The option's value cannot be cast in the desired type (-10)
    142146    GENERIC, PUBLIC :: get_value     => cp_get_rv_sc,cp_get_dv_sc,cp_get_iv_sc, &
     
    144148                                        cp_get_rv_ve,cp_get_dv_ve,cp_get_iv_ve, &
    145149                                        cp_get_lv_ve,cp_get_cv_ve,cp_get_sv_ve
    146     !> Set value(s) of an option in the parser by name 
    147     !! 
     150    !> Set value(s) of an option in the parser by name
     151    !!
    148152    !! ```
    149153    !! FUNCTION cfg_set_value(this,name,input,create) RESULT(error)
     
    167171  END TYPE cfgparser
    168172
    169   !> Get value(s) of an option in the parser by name. 
    170   !! 
     173  !> Get value(s) of an option in the parser by name.
     174  !!
    171175  !! ```
    172176  !! FUNCTION cfg_get_value(parser,name,output) RESULT(error)
     
    177181  !! On error, __output__ argument is undefined (that is, left unchanged
    178182  !! for scalar versions, **unallocated** for vector version).
    179   !! 
     183  !!
    180184  !! Errors occur in the following situations:
    181185  !! - The option has no value (-6)
    182   !! - The option does not exist (-7) 
     186  !! - The option does not exist (-7)
    183187  !! - The option's value cannot be cast in the desired type (-10)
    184188  INTERFACE cfg_get_value
     
    189193  END INTERFACE
    190194
    191     !> Set value(s) of an option in the parser by name 
    192     !! 
     195    !> Set value(s) of an option in the parser by name
     196    !!
    193197    !! ```
    194198    !! FUNCTION set_value(this,name,input,create) RESULT(error)
     
    201205    !! exist in _this_ parser.
    202206    !! @warning
    203     !! In such case, if the given is not valid, an assertion is raised !
     207    !! In such case, if the given __name__ is not valid, an error is raised !
    204208    !!
    205209    !! On error (i.e. no option matches the given _name_), no values are set.
    206     INTERFACE cfg_set_value 
     210    INTERFACE cfg_set_value
    207211      MODULE PROCEDURE :: cp_set_rv_sc,cp_set_dv_sc,cp_set_iv_sc, &
    208212                          cp_set_lv_sc,cp_set_cv_sc,cp_set_sv_sc, &
    209213                          cp_set_rv_ve,cp_set_dv_ve,cp_set_iv_ve, &
    210214                          cp_set_lv_ve,cp_set_cv_ve,cp_set_sv_ve
    211     END INTERFACE 
     215    END INTERFACE
    212216
    213217    !> Derived type assignment operator
     
    230234    this%section = other%section
    231235    this%values = other%values
    232   END SUBROUTINE op_affect_sc 
    233  
     236  END SUBROUTINE op_affect_sc
     237
    234238  FUNCTION op_valid(opt) RESULT(ok)
    235239    !! Check whether or not the option is valid (i.e. has name)
    236     TYPE(option), INTENT(in)      :: opt  !! An option object 
     240    TYPE(option), INTENT(in)      :: opt  !! An option object
    237241    LOGICAL :: ok !! True if the option is valid, false otherwise.
    238242    ok = LEN_TRIM(opt%name) > 0
    239243  END FUNCTION op_valid
    240244
    241   SUBROUTINE op_clear(opt) 
     245  SUBROUTINE op_clear(opt)
    242246    !! Clear and invalid the given option.
    243     TYPE(option), INTENT(inout)      :: opt  !! An option object 
     247    TYPE(option), INTENT(inout)      :: opt  !! An option object
    244248    opt%name = ''
    245249    opt%section = ''
     
    261265    ENDIF
    262266  END FUNCTION op_full_name
    263  
     267
    264268  FUNCTION op_split_name(fname,sname,pname) RESULT(err)
    265269    !> Split a full name in section and option names
    266     !!
    267     !! The method splits a full name into (section,option) names. Output names (if any) are always
    268     !! set to lower case.
     270    !!
     271    !! The method splits a full name into (section,option) names:
     272    !!
     273    !! - Option basename is always set in lower-case.
     274    !! - If any, section name case is left unmodified.
    269275    !!
    270276    !! A full name simply consists in a section name and an option name separated by a single "/".
    271277    !!
    272     !! The method never checks the validity of the output names. Consider using [[cfg_check_name(function)]]
    273     !! to do so.
    274     !! @note
    275     !! If _fname_ does not contains any "/", the method set the special name "\_\_default\_\_" for the output
    276     !! section name.
     278    !! The method never checks the validity of the output names. Consider using [[cfg_check_name(function)]]
     279    !! to do so.
    277280    !! @note
    278     !! On success, option and section names are set to lower case. Otherwise they are set to empty strings.
     281    !! If _fname_ does not contains any "/", the method sets the special name "\_\_default\_\_" for the output
     282    !! section name.
     283    !! @note
     284    !! On failure, output arguments are set to empty strings.
    279285    !! @warning
    280     !! If _fname_ ends with a "/", an error (-6, invalid name) is raised: the method always assumes it can
     286    !! If _fname_ ends with a "/", an error (-9, invalid name) is raised: the method always assumes it can
    281287    !! find an option part in the name.
    282288    CHARACTER(len=*), INTENT(in)               :: fname    !! A name to split
    283289    CHARACTER(len=:), INTENT(out), ALLOCATABLE :: sname, & !! Section part of the name
    284290                                                  pname    !! Option part of the name
    285     TYPE(error) :: err !! Error status of the method
    286     INTEGER     :: idx
     291    TYPE(error)                                :: err      !! Error status of the method
     292    INTEGER                       :: idx
     293    CHARACTER(len=:), ALLOCATABLE :: tfname
    287294    err = noerror ; pname = "" ; sname = ""
     295    tfname = op_format(fname,sname,pname)
     296    IF (LEN_TRIM(tfname) == 0) err = error("Invalid option name ("//TRIM(fname)//")",-9)
     297  END FUNCTION op_split_name
     298
     299  FUNCTION op_format(name,sname,pname) RESULT(oname)
     300    !! Format the input name to be consistent with character case requirements.
     301    !!
     302    !! Given a **name**, the method tries to split in section/option names.
     303    !! Then it converts the option part in lower-case.
     304    !!
     305    !! If no section part is found (not '/' or set as first character of **name**), the
     306    !! special section name `__default__` is set.
     307    !!
     308    !! If **name** ends with a '/', it is an error and the method returns an empty string.
     309    CHARACTER(len=*), INTENT(in)  :: name  !! Name to format.
     310    CHARACTER(len=:), ALLOCATABLE, INTENT(out), OPTIONAL :: sname !! Section part of the name (optional output)
     311    CHARACTER(len=:), ALLOCATABLE, INTENT(out), OPTIONAL :: pname !! Option part of the name (optional output)
     312    CHARACTER(len=:), ALLOCATABLE :: oname                        !! Formatted full option name.
     313    INTEGER                       :: idx
     314    CHARACTER(len=:), ALLOCATABLE :: zsname,zpname
     315    zpname = "" ; zsname = ""
    288316    ! splits input name in sname, pname
    289     idx = INDEX(fname,'/')
    290     IF (idx == LEN_TRIM(fname)) THEN
    291       err = error("Invalid option name ("//TRIM(fname)//")",-9)
     317    idx = INDEX(name,'/')
     318    IF (idx == LEN_TRIM(name)) THEN
     319      oname = ''
     320      IF (PRESENT(sname)) sname = ''
     321      IF (PRESENT(pname)) pname = ''
    292322      RETURN
    293323    ELSE IF (idx <= 1) THEN
    294       sname = "__default__" ; pname = TRIM(fname)
    295       IF (idx == 1) pname=pname(2:)
    296     ELSE
    297       sname = fname(:idx-1)
    298       pname = fname(idx+1:LEN_TRIM(fname))
    299     ENDIF
    300     ! 17/12/2014: set option name to lower
    301     pname = str_to_lower(pname)
    302     sname = str_to_lower(sname)
    303   END FUNCTION op_split_name
     324      zsname = "__default__" ; zpname = to_lower(TRIM(name))
     325      IF (idx == 1) zpname=zpname(2:)
     326    ELSE
     327      zsname = name(:idx-1)
     328      zpname = to_lower(name(idx+1:LEN_TRIM(name)))
     329    ENDIF
     330    oname = zsname//"/"//zpname
     331    IF (PRESENT(sname)) sname = zsname
     332    IF (PRESENT(pname)) pname = zpname
     333  END FUNCTION op_format
    304334
    305335  FUNCTION op_greater_than(left,right) RESULT(ret)
     
    309339    TYPE(option), INTENT(in) :: left  !! LHS option.
    310340    TYPE(option), INTENT(in) :: right !! RHS option.
    311     LOGICAL :: ret 
     341    LOGICAL :: ret
    312342      !! .true. if LHS is _greater_ than RHS (based on section and option name)
    313343    ret = LGT(op_full_name(left),op_full_name(right))
     
    320350    TYPE(option), INTENT(in) :: left  !! LHS option.
    321351    TYPE(option), INTENT(in) :: right !! RHS option.
    322     LOGICAL :: ret 
     352    LOGICAL :: ret
    323353      !! .true. if LHS is _less_ than RHS (based on section and option name)
    324354    ret = LLT(op_full_name(left),op_full_name(right))
     
    327357  FUNCTION op_to_str(opt,num_values) RESULT(str)
    328358    !! Get the string representation of a option object
    329     !! @note 
     359    !! @note
    330360    !! If the object is not valid an empty string is returned.
    331     TYPE(option), INTENT(in) :: opt 
     361    TYPE(option), INTENT(in) :: opt
    332362      !! A option object
    333363    INTEGER, INTENT(in), OPTIONAL :: num_values
     
    343373    str = TRIM(opt%name)//" = " ; np = LEN(str)
    344374    ALLOCATE(CHARACTER(len=np) :: nspcs) ; nspcs(1:) = " "
    345     ! stores the error but do not check... 
     375    ! stores the error but do not check...
    346376    ret = words_to_vector(opt%values,vec)
    347377    IF (.NOT.ALLOCATED(vec)) RETURN
     
    382412
    383413  FUNCTION cfg_check_name(name) RESULT(valid)
    384     !! Check if a name is valid
    385     !!
    386     !! A valid option/section name begins with a letter and is followed by any
    387     !! number of alphanumeric characters and underscore (`[A-Za-z][A-Za-z0-9\_]\*`).
     414    !! Check if a name is valid.
     415    !!
     416    !! If **name** contains a '/' it is assumed to be a full option name. In such case
     417    !! both parts of the name are checked against section/option names requirements (see below).
     418    !!
     419    !! Otherwise it is assumed to be the basename of the option.
     420    !!
     421    !! A valid option (base) name is an alphanumeric sequence in lower-case that always begin by
     422    !! a letter.
     423    !!
     424    !! A valid section name is and alphanumeric sequence (in any case) that always begins by
     425    !! by a letter.
    388426    CHARACTER(len=*), INTENT(in) :: name !! A string with the name to check.
    389427    LOGICAL :: valid                     !! .true. if the name is valid, .false. otherwise
    390428    INTEGER                       :: i
    391     CHARACTER(len=26), PARAMETER  :: alpha = "abcdefghijklmnopqrstuvwxyz"
    392     CHARACTER(len=12), PARAMETER  :: num   = "0123456789_"
     429    CHARACTER(len=26), PARAMETER  :: alpha  = "abcdefghijklmnopqrstuvwxyz"
     430    CHARACTER(len=26), PARAMETER  :: ualpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
     431    CHARACTER(len=12), PARAMETER  :: num    = "0123456789_"
    393432    CHARACTER(len=:), ALLOCATABLE :: pname,sname
    394433    TYPE(error)                   :: err
     
    401440      ENDIF
    402441    ELSE
    403       pname = str_to_lower(TRIM(name))
     442      pname = to_lower(TRIM(name))
    404443      sname = "__default__"
    405444    ENDIF
     
    416455      i = INDEX(sname,CHAR(32))
    417456      IF (i /= 0.OR.LEN_TRIM(sname) <= 0) RETURN
    418       valid = (VERIFY(sname(1:1),alpha) == 0 .AND.VERIFY(TRIM(sname),alpha//"/"//num) == 0)
     457      valid = (VERIFY(sname(1:1),ualpha//alpha) == 0 .AND.VERIFY(TRIM(sname),ualpha//alpha//num) == 0)
    419458    ENDIF
    420459  END FUNCTION cfg_check_name
    421460
    422   FUNCTION cfg_count(this) RESULT(num)
     461  FUNCTION cfg_count(this,section) RESULT(num)
    423462    !! Get the total number of option in the parser.
    424463    !!
     464    !! If a section name is given in argument, the method returns the count for the given section only.
     465    !!
     466    !! To get the number of top-level options (i.e. that belongs to the default section) the keyword \_\_default\_\_
     467    !! should be set for the section argument.
     468    !!
     469    !! If __section__ is not defined in the parser, the method returns 0.
     470    !!
    425471    !! @internal
    426     !! If no options are defined, then it implies that the internal vector of options is 
     472    !! If no options are defined, then it implies that the internal vector of options is
    427473    !! not allocated.
    428     OBJECT(cfgparser), INTENT(in) :: this !! A cfgparser object to search in
    429     INTEGER :: num                        !! Number of current options registered in the parser.
     474    OBJECT(cfgparser), INTENT(in)          :: this    !! A cfgparser object to search in
     475    CHARACTER(len=*), INTENT(in), OPTIONAL :: section !! Optional section name to search in.
     476    INTEGER :: num                                    !! Number of current options registered in the parser.
     477    INTEGER :: i
    430478    num = 0
    431479    IF(.NOT.ALLOCATED(this%options)) RETURN
    432     num = SIZE(this%options)
     480    IF (.NOT.PRESENT(section)) THEN
     481      num = SIZE(this%options) 
     482    ELSE
     483      DO i=1, SIZE(this%options)
     484        IF (this%options(i)%section == section) num = num+1
     485      ENDDO
     486    ENDIF
    433487  END FUNCTION cfg_count
    434488
     
    469523        ! Found a match so start looking again
    470524        found = (tmp(j) == this%options(i)%section .OR. &
    471                  this%options(i)%section == "__default__") 
     525                 this%options(i)%section == "__default__")
    472526        IF (found) EXIT
    473527      ENDDO
     
    482536  END FUNCTION cfg_section_names
    483537
    484   FUNCTION cfg_option_names(this) RESULT(list)
     538  FUNCTION cfg_option_names(this,secname) RESULT(list)
    485539    !! Get the list of option names.
    486540    !!
    487541    !! @note
    488542    !! If the parser does not have options, the vector is still allocated but with 0 elements.
    489     OBJECT(cfgparser), INTENT(in) :: this                     !! A cfgparser object to process.
    490     CHARACTER(len=st_slen), DIMENSION(:), ALLOCATABLE :: list !! List of option names.
    491     INTEGER               :: i,no
     543    OBJECT(cfgparser), INTENT(in)                     :: this    !! A cfgparser object to process.
     544    CHARACTER(len=*), INTENT(in), OPTIONAL            :: secname !! Optional section name to search in.
     545    CHARACTER(len=st_slen), DIMENSION(:), ALLOCATABLE :: list    !! List of option names.
     546    INTEGER               :: j,i,no,nso
    492547    no = cfg_count(this)
    493     ALLOCATE(list(no))
    494     IF (no == 0) RETURN
    495     DO i=1,no
    496       IF (this%options(i)%section == "__default__") THEN
    497         list(i) = TRIM(this%options(i)%name)
    498       ELSE
    499         list(i) = TRIM(this%options(i)%section)//"/"//TRIM(this%options(i)%name)
    500       ENDIF
    501     ENDDO
     548    IF (no == 0) THEN
     549       ALLOCATE(list(no)) ; RETURN
     550    ENDIF
     551    IF (PRESENT(secname)) THEN
     552      IF (.NOT.cfg_has_section(this,TRIM(secname))) THEN
     553        ALLOCATE(list(no)) ; RETURN
     554      ELSE
     555        nso = 0
     556        DO i=1,no ; IF (this%options(i)%section == TRIM(secname)) nso = nso + 1 ; ENDDO
     557        ALLOCATE(list(nso))
     558        IF (nso == 0) RETURN
     559        j = 1
     560        DO i=1,no
     561          IF (this%options(i)%section == TRIM(secname)) THEN
     562            list(j) = TRIM(this%options(i)%section)//"/"//TRIM(this%options(i)%name) ; j=j+1
     563          ENDIF
     564        ENDDO
     565      ENDIF
     566    ELSE
     567      ALLOCATE(list(no))
     568      DO i=1,no
     569        IF (this%options(i)%section == "__default__") THEN
     570          list(i) = TRIM(this%options(i)%name)
     571        ELSE
     572          list(i) = TRIM(this%options(i)%section)//"/"//TRIM(this%options(i)%name)
     573        ENDIF
     574      ENDDO
     575    ENDIF
    502576  END FUNCTION cfg_option_names
    503577
    504578  FUNCTION cfg_has_section(this,name) RESULT(yes)
    505579    !! Check if parser has section by name
     580    !!
     581    !! @note
     582    !! Keep in mind that section name in the configuration are case-sensitive.
    506583    OBJECT(cfgparser), INTENT(in) :: this !! cfgparser object
    507584    CHARACTER(len=*), INTENT(in)  :: name !! Name of the section to search
    508585    LOGICAL :: yes                        !! .true. if the section exists, .false. otherwise
    509     CHARACTER(len=:), ALLOCATABLE :: zname
    510586    INTEGER                       :: i,no
    511587    yes = .false.
    512588    no = cfg_count(this)
    513589    IF (no == 0) RETURN
    514     zname = str_to_lower(name)
    515590    DO i = 1,no
    516       IF (this%options(i)%section == zname) THEN
     591      IF (this%options(i)%section == name) THEN
    517592        yes = .true.
    518593        RETURN
     
    527602    LOGICAL :: yes                        !! .true. if the option is found, .false. otherwise
    528603    CHARACTER(len=:), ALLOCATABLE :: pname,zname
    529     INTEGER                       :: i,no
     604    INTEGER                       :: i,no,iscan
    530605    yes = .false.
    531606    no = cfg_count(this)
    532607    IF (no == 0) RETURN
    533     IF (SCAN(name,"/") <= 0) THEN
    534       zname = "__default__"//"/"//str_to_lower(TRIM(name))
    535     ELSE
    536       zname = str_to_lower(TRIM(name))
    537     ENDIF
     608    zname = op_format(name)
     609    IF (LEN_TRIM(zname) == 0) RETURN
    538610    DO i = 1,no
    539       pname = op_full_name(this%options(i)) 
     611      pname = op_full_name(this%options(i))
    540612      IF (pname == zname) THEN
    541613        yes = .true.
     
    545617  END FUNCTION cfg_has_option
    546618
    547   SUBROUTINE cfg_sort_options(this) 
     619  SUBROUTINE cfg_sort_options(this)
    548620    !! Sort the options in the parser (alphabetiCALLy).
    549621    OBJECT(cfgparser), INTENT(inout) :: this !! A cfgparser object
     
    552624    IF (no == 0) RETURN
    553625    CALL insertionSort(this%options)
    554   END SUBROUTINE cfg_sort_options 
     626  END SUBROUTINE cfg_sort_options
    555627
    556628  SUBROUTINE cfg_remove_option(this,name)
    557629    !! Remove an option from parser by name.
    558     OBJECT(cfgparser), INTENT(inout) :: this !! A cfgparser object to search in 
     630    OBJECT(cfgparser), INTENT(inout) :: this !! A cfgparser object to search in
    559631    CHARACTER(len=*), INTENT(in)     :: name !! The name of the option to remove
    560     CHARACTER(len=:), ALLOCATABLE    :: zname,pname
    561632    INTEGER                                 :: no,idx,i,j
    562633    TYPE(option), DIMENSION(:), ALLOCATABLE :: tmp
    563     IF (SCAN(name,"/") <= 0) THEN
    564       zname = "__default__"//"/"//str_to_lower(TRIM(name))
    565     ELSE
    566       zname = str_to_lower(TRIM(name))
    567     ENDIF
    568     idx = cp_get_opt_idx(this,zname)
     634    idx = cp_get_opt_idx(this,name)
     635    IF (idx == -1) RETURN
    569636    no = cfg_count(this)
    570     IF (idx == -1) RETURN
    571637    ! only one opt
    572638    IF (no == 1) THEN
     
    589655      this%options(i) = tmp(i)
    590656      CALL op_clear(tmp(i))
    591     ENDDO 
     657    ENDDO
    592658    DEALLOCATE(tmp)
    593659  END SUBROUTINE cfg_remove_option
     
    597663    !!
    598664    !! The method removes all the options that belong to the given section name.
    599     OBJECT(cfgparser), INTENT(inout) :: this 
    600       !! A cfgparser object to search in 
     665    OBJECT(cfgparser), INTENT(inout) :: this
     666      !! A cfgparser object to search in
    601667    CHARACTER(len=*), INTENT(in)     :: name
    602668      !! The name of the section to remove
    603     CHARACTER(len=:), ALLOCATABLE           :: zname
    604669    INTEGER                                 :: no,i,j,icount
    605670    INTEGER, DIMENSION(:), ALLOCATABLE      :: idxs,itmp
    606671    TYPE(option), DIMENSION(:), ALLOCATABLE :: tmp
    607      
    608672    no = cfg_count(this)
    609673    IF (no == 0) RETURN
    610     zname = str_to_lower(TRIM(name))
    611674    ALLOCATE(itmp(no))
    612675    itmp(:) = -1
    613676    icount = 0
    614677    DO i=1,no
    615       IF (TRIM(this%options(i)%section) == zname) THEN
     678      IF (TRIM(this%options(i)%section) == TRIM(name)) THEN
    616679        itmp(icount+1) = i
    617680        icount = icount + 1
     
    627690       DEALLOCATE(this%options)
    628691       RETURN
    629     ENDIF 
     692    ENDIF
    630693    ALLOCATE(tmp(icount))
    631694    j = 1
     
    650713    !! Read configuration file
    651714    !!
    652     !! @note 
     715    !! @note
    653716    !! If the library support C bindings, the method can read included files which are defined
    654717    !! by the __#include <...>__ directive (see [p_cfgparse](here) from more details).
     
    662725      !! An error with the first error encountered
    663726    INTEGER                       :: i
    664     LOGICAL                       :: zoverride,ok 
    665     TYPE(words)                   :: incfiles 
     727    LOGICAL                       :: zoverride,ok
     728    TYPE(words)                   :: incfiles
    666729    CHARACTER(len=:), ALLOCATABLE :: name
    667730    CHARACTER(len=st_slen)        :: isec
    668     err = noerror 
     731    err = noerror
    669732    zoverride = .false. ; IF (PRESENT(override)) zoverride = override
    670733    isec = "__default__"
    671734    name = TRIM(path)
    672     i = INDEX(name,'/',.true.) ; IF (i /= 0) name = name(i+1:) 
     735    i = INDEX(name,'/',.true.) ; IF (i /= 0) name = name(i+1:)
    673736    IF (i == 0) THEN
    674737      name = fs_realpath("./"//path)
     
    710773    no = cfg_count(this)
    711774    IF (no == 0) THEN
    712       err = error("No options to write",-7) 
     775      err = error("No options to write",-7)
    713776      RETURN
    714777    ENDIF
     
    728791      WRITE(lu,'(a)') op_to_str(this%options(i),nv)
    729792    ENDDO
    730   END FUNCTION cfg_write_config 
     793  END FUNCTION cfg_write_config
    731794
    732795  ! internal (private methods)
     
    751814  FUNCTION cp_get_opt_idx(this,name) RESULT(idx)
    752815    !! Get the index of an option by name in the parser.
    753     !! 
     816    !!
    754817    !! The method searches in the parser for the option with the given (full) __name__.
    755818    !! If found, it returns the index of the option in the internal vector of options. Otherwise
     
    763826    no = cfg_count(this)
    764827    IF (no == 0) RETURN
    765     IF (SCAN(name,"/") <= 0) THEN
    766       zname = "__default__"//"/"//str_to_lower(TRIM(name))
    767     ELSE
    768       zname = str_to_lower(TRIM(name))
    769     ENDIF
     828    zname = op_format(name) ! prepare the name to search.
     829    IF (LEN_TRIM(zname) == 0) RETURN
    770830    DO i=1,no
    771831      pname = op_full_name(this%options(i))
     
    780840    !! Update an option in the parser.
    781841    !!
    782     !! The attempts to update the option in the parser that matches __opt__ name.
    783     !!
    784     !! If __name__ is given it is used instead of __opt__ name.
    785     !!
    786     !! If no option is found, __opt__ is appended in the parser. Otherwise the matched
    787     !! option is updated (i.e. its values are set to __opt__ values).
    788     !!
    789     !! If the option is not valid, the method does nothing and -X error status is returned.
     842    !! The method attempts to update the option in the parser.
     843    !!
     844    !! If __sname__ is set to empty string, the method searches for the option
     845    !! in the default section.
     846    !!
     847    !! If no option is found, The the option is appended in the parser. Otherwise it is updated
     848    !! with the content of __values__.
     849    !!
     850    !! If the option name is not valid, the method does nothing and -9 error status is returned.
    790851    !!
    791852    !! @internal
    792853    !! The method performs the same kind of operations than the setters except that it
    793     !! expects raw data ([[strings(module):words(type)]]).
     854    !! expects raw data ([[string_op(module):words(type)]]).
    794855    OBJECT(cfgparser), INTENT(inout) :: this   !! cfgparser object to process.
    795856    CHARACTER(len=*), INTENT(in)     :: sname  !! Name of the section.
    796     CHARACTER(len=*), INTENT(in)     :: pname  !! Name of the option.
     857    CHARACTER(len=*), INTENT(in)     :: pname  !! Basename of the option.
    797858    TYPE(words), INTENT(in)          :: values !! Raw values.
    798     TYPE(error) :: err !! Error status.
     859    TYPE(error)                      :: err    !! Error status.
    799860    CHARACTER(len=:), ALLOCATABLE :: zsname,fname
    800861    INTEGER                       :: i
    801862    err = noerror
    802     zsname = str_to_lower(TRIM(sname))
    803     IF (LEN_TRIM(zsname) == 0 ) zsname = "__default__"
    804     fname = zsname//"/"//str_to_lower(TRIM(pname))
     863    zsname = TRIM(sname)
     864    IF (LEN_TRIM(sname) == 0) zsname = "__default__"
     865    fname = zsname//"/"//to_lower(TRIM(pname))
    805866    IF (.NOT.cfg_check_name(fname)) THEN
    806867       err = error("Invalid option (no name)",-9)
     
    816877  END FUNCTION cp_update_opt
    817878
    818 
    819   FUNCTION cp_add_opt(this,sname,pname,values) RESULT(err)
     879  FUNCTION cp_add_opt(this,sname,pname,values) RESULT(err)
    820880    !! Add an option to the parser.
    821881    !!
    822882    !! In order to add an option to the default section, _sname_ should be left empty or set to "\_\_default\_\_".
    823     !!
    824     !! If given, _opt_ points to the new option on output. If an error occured the pointer is null.
    825883    !!
    826884    !! The following error code can be returned:
     
    828886    !!  - -8, the option already exists.
    829887    !!  - -9, option name is not valid.
    830     OBJECT(cfgparser), INTENT(inout) :: this   
     888    OBJECT(cfgparser), INTENT(inout) :: this
    831889      !! A cfgparser object to process.
    832890    CHARACTER(len=*), INTENT(in)     :: sname
    833891      !! Section name.
    834892    CHARACTER(len=*), INTENT(in)     :: pname
    835       !! Option name.
     893      !! Option basename.
    836894    TYPE(words), INTENT(in)          :: values
    837895      !! Values to set.
     
    839897      !! Return error status.
    840898    CHARACTER(len=:), ALLOCATABLE           :: zsname,fname
    841     TYPE(option), DIMENSION(:), ALLOCATABLE :: tmp 
     899    TYPE(option), DIMENSION(:), ALLOCATABLE :: tmp
    842900    INTEGER                                 :: no,i
    843 
    844     TYPE(option) :: sca
     901    TYPE(option)                            :: sca
    845902
    846903    err = noerror
     
    848905    no = cfg_count(this)
    849906    IF (LEN_TRIM(zsname) == 0) zsname = "__default__"
    850     fname = TRIM(zsname)//"/"//TRIM(pname)
     907    fname = TRIM(zsname)//"/"//to_lower(TRIM(pname))
    851908    ! check name
    852909    IF (.NOT.cfg_check_name(fname)) THEN
     
    864921    ! build option
    865922    CALL op_clear(sca)
    866     sca%name = pname
     923    sca%name = to_lower(TRIM(pname))
    867924    sca%section = zsname
    868925    sca%values = values
     
    874931      ! parser has options: increase this%options size (ugly copy).
    875932      ALLOCATE(tmp(no))
    876       DO i =1,no 
    877         tmp(i) = this%options(i) 
     933      DO i =1,no
     934        tmp(i) = this%options(i)
    878935        CALL op_clear(this%options(i))
    879936      ENDDO
    880937      DEALLOCATE(this%options)
    881938      ALLOCATE(this%options(no+1))
    882       DO i =1,no 
    883         this%options(i) = tmp(i) 
     939      DO i =1,no
     940        this%options(i) = tmp(i)
    884941        CALL op_clear(tmp(i))
    885942      ENDDO
     
    898955    !!  - -6, the option does not have value(s).
    899956    !!  - -10, the value cannot be converted in the output type.
    900     OBJECT(cfgparser), INTENT(in) :: this   !! Cfgparser object 
     957    OBJECT(cfgparser), INTENT(in) :: this   !! Cfgparser object
    901958    CHARACTER(len=*), INTENT(in)  :: name   !! (Full) Name of the option to get
    902959    REAL(kind=4), INTENT(out)     :: output !! Output value
    903     TYPE(error) :: err 
     960    TYPE(error) :: err
    904961      !! Error status
    905     INTEGER :: idx 
     962    INTEGER :: idx
    906963    CHARACTER(len=:), ALLOCATABLE :: tmp
    907964    err = noerror
     
    918975        err = error("Option "//TRIM(name)//" has no value",-6)
    919976      ELSE
    920         IF(.NOT.from_string(tmp,output)) & 
     977        IF(.NOT.from_string(tmp,output)) &
    921978        err = error(TRIM(name)//": Cannot convert "//tmp//" to real.",-10)
    922979      ENDIF
     
    931988    !!  - -6, the option does not have value(s).
    932989    !!  - -10, the value cannot be converted in the output type.
    933     OBJECT(cfgparser), INTENT(in) :: this   !! Cfgparser object 
     990    OBJECT(cfgparser), INTENT(in) :: this   !! Cfgparser object
    934991    CHARACTER(len=*), INTENT(in)  :: name   !! (Full) Name of the option to get
    935992    REAL(kind=8), INTENT(out)     :: output !! Output value
    936     TYPE(error) :: err 
     993    TYPE(error) :: err
    937994      !! Error status
    938     INTEGER :: idx 
     995    INTEGER :: idx
    939996    CHARACTER(len=:), ALLOCATABLE :: tmp
    940997    err = noerror
     
    9511008        err = error("Option "//TRIM(name)//" has no value",-6)
    9521009      ELSE
    953         IF(.NOT.from_string(tmp,output)) & 
     1010        IF(.NOT.from_string(tmp,output)) &
    9541011        err = error(TRIM(name)//": Cannot convert "//tmp//" to double.",-10)
    9551012      ENDIF
     
    9641021    !!  - -6, the option does not have value(s).
    9651022    !!  - -10, the value cannot be converted in the output type.
    966     OBJECT(cfgparser), INTENT(in) :: this   !! Cfgparser object 
     1023    OBJECT(cfgparser), INTENT(in) :: this   !! Cfgparser object
    9671024    CHARACTER(len=*), INTENT(in)  :: name   !! (Full) Name of the option to get
    9681025    INTEGER, INTENT(out)          :: output !! Output value
    969     TYPE(error) :: err 
     1026    TYPE(error) :: err
    9701027      !! Error status
    971     INTEGER :: idx 
     1028    INTEGER :: idx
    9721029    CHARACTER(len=:), ALLOCATABLE :: tmp
    9731030    err = noerror
     
    9841041        err = error("Option "//TRIM(name)//" has no value",-6)
    9851042      ELSE
    986         IF(.NOT.from_string(tmp,output)) & 
     1043        IF(.NOT.from_string(tmp,output)) &
    9871044        err = error(TRIM(name)//": Cannot convert "//tmp//" to integer.",-10)
    9881045      ENDIF
     
    9971054    !!  - -6, the option does not have value(s).
    9981055    !!  - -10, the value cannot be converted in the output type.
    999     OBJECT(cfgparser), INTENT(in) :: this   !! Cfgparser object 
     1056    OBJECT(cfgparser), INTENT(in) :: this   !! Cfgparser object
    10001057    CHARACTER(len=*), INTENT(in)  :: name   !! (Full) Name of the option to get
    10011058    LOGICAL, INTENT(out)          :: output !! Output value
    1002     TYPE(error) :: err 
     1059    TYPE(error) :: err
    10031060      !! Error status
    1004     INTEGER :: idx 
     1061    INTEGER :: idx
    10051062    CHARACTER(len=:), ALLOCATABLE :: tmp
    10061063    err = noerror
     
    10171074        err = error("Option "//TRIM(name)//" has no value",-6)
    10181075      ELSE
    1019         IF(.NOT.from_string(tmp,output)) & 
     1076        IF(.NOT.from_string(tmp,output)) &
    10201077        err = error(TRIM(name)//": Cannot convert "//tmp//" to logical.",-10)
    10211078      ENDIF
     
    10301087    !!  - -6, the option does not have value(s).
    10311088    !!  - -10, the value cannot be converted in the output type.
    1032     OBJECT(cfgparser), INTENT(in) :: this   !! Cfgparser object 
     1089    OBJECT(cfgparser), INTENT(in) :: this   !! Cfgparser object
    10331090    CHARACTER(len=*), INTENT(in)  :: name   !! (Full) Name of the option to get
    10341091    COMPLEX, INTENT(out)          :: output !! Output value
    1035     TYPE(error) :: err 
     1092    TYPE(error) :: err
    10361093      !! Error status
    1037     INTEGER :: idx 
     1094    INTEGER :: idx
    10381095    CHARACTER(len=:), ALLOCATABLE :: tmp
    10391096    err = noerror
     
    10501107        err = error("Option "//TRIM(name)//" has no value",-6)
    10511108      ELSE
    1052         IF(.NOT.from_string(tmp,output)) & 
     1109        IF(.NOT.from_string(tmp,output)) &
    10531110        err = error(TRIM(name)//": Cannot convert "//tmp//" to complex.",-10)
    10541111      ENDIF
     
    10621119    !!  - -7, no option matches the given name.
    10631120    !!  - -6, the option does not have value(s).
    1064     OBJECT(cfgparser), INTENT(in) :: this   !! Cfgparser object 
     1121    OBJECT(cfgparser), INTENT(in) :: this   !! Cfgparser object
    10651122    CHARACTER(len=*), INTENT(in)  :: name   !! (Full) Name of the option to get
    10661123    CHARACTER(len=*), INTENT(out) :: output !! Output value
    1067     TYPE(error) :: err 
     1124    TYPE(error) :: err
    10681125      !! Error status
    1069     INTEGER :: idx 
     1126    INTEGER :: idx
    10701127    !CHARACTER(len=:), ALLOCATABLE :: tmp
    10711128    err = noerror
     
    10871144    !!
    10881145    !! On error, the output vector is not allocated.
    1089     OBJECT(cfgparser), INTENT(in)                        :: this   !! Cfgparser object 
     1146    OBJECT(cfgparser), INTENT(in)                        :: this   !! Cfgparser object
    10901147    CHARACTER(len=*), INTENT(in)                         :: name   !! (Full) Name of the option to get
    10911148    REAL(kind=4), INTENT(out), DIMENSION(:), ALLOCATABLE :: output !! Output values
    1092     TYPE(error) :: err                                                 
     1149    TYPE(error) :: err
    10931150      !! Error status of the method (see [[cfgparser(type):get_value(bound)]] documentation)
    10941151    CHARACTER(len=st_slen), DIMENSION(:), ALLOCATABLE :: tmp
     
    11141171        ELSE IF (.NOT.from_string(tmp(i), output(i))) THEN
    11151172          err = error("Cannot convert value #"//TRIM(i2s)//" from option "//TRIM(name),-10)
    1116           DEALLOCATE(output) ; EXIT 
     1173          DEALLOCATE(output) ; EXIT
    11171174        ENDIF
    11181175      ENDDO
    11191176    ENDIF
    11201177    DEALLOCATE(tmp)
    1121     RETURN 
     1178    RETURN
    11221179  END FUNCTION cp_get_rv_ve
    11231180
     
    11261183    !!
    11271184    !! On error, the output vector is not allocated.
    1128     OBJECT(cfgparser), INTENT(in)                        :: this   !! Cfgparser object 
     1185    OBJECT(cfgparser), INTENT(in)                        :: this   !! Cfgparser object
    11291186    CHARACTER(len=*), INTENT(in)                         :: name   !! (Full) Name of the option to get
    11301187    REAL(kind=8), INTENT(out), DIMENSION(:), ALLOCATABLE :: output !! Output values
    1131     TYPE(error) :: err                                                 
     1188    TYPE(error) :: err
    11321189      !! Error status of the method (see [[cfgparser(type):get_value(bound)]] documentation)
    11331190    CHARACTER(len=st_slen), DIMENSION(:), ALLOCATABLE :: tmp
     
    11531210        ELSE IF (.NOT.from_string(tmp(i), output(i))) THEN
    11541211          err = error("Cannot convert value #"//TRIM(i2s)//" from option "//TRIM(name),-10)
    1155           DEALLOCATE(output) ; EXIT 
     1212          DEALLOCATE(output) ; EXIT
    11561213        ENDIF
    11571214      ENDDO
    11581215    ENDIF
    11591216    DEALLOCATE(tmp)
    1160     RETURN 
     1217    RETURN
    11611218  END FUNCTION cp_get_dv_ve
    11621219
     
    11651222    !!
    11661223    !! On error, the output vector is not allocated.
    1167     OBJECT(cfgparser), INTENT(in)                   :: this   !! Cfgparser object 
     1224    OBJECT(cfgparser), INTENT(in)                   :: this   !! Cfgparser object
    11681225    CHARACTER(len=*), INTENT(in)                    :: name   !! (Full) Name of the option to get
    11691226    INTEGER, INTENT(out), DIMENSION(:), ALLOCATABLE :: output !! Output values
    1170     TYPE(error) :: err                                                 
     1227    TYPE(error) :: err
    11711228      !! Error status of the method (see [[cfgparser(type):get_value(bound)]] documentation)
    11721229    CHARACTER(len=st_slen), DIMENSION(:), ALLOCATABLE :: tmp
     
    11921249        ELSE IF (.NOT.from_string(tmp(i), output(i))) THEN
    11931250          err = error("Cannot convert value #"//TRIM(i2s)//" from option "//TRIM(name),-10)
    1194           DEALLOCATE(output) ; EXIT 
     1251          DEALLOCATE(output) ; EXIT
    11951252        ENDIF
    11961253      ENDDO
    11971254    ENDIF
    11981255    DEALLOCATE(tmp)
    1199     RETURN 
     1256    RETURN
    12001257  END FUNCTION cp_get_iv_ve
    12011258
     
    12041261    !!
    12051262    !! On error, the output vector is not allocated.
    1206     OBJECT(cfgparser), INTENT(in)                   :: this   !! Cfgparser object 
     1263    OBJECT(cfgparser), INTENT(in)                   :: this   !! Cfgparser object
    12071264    CHARACTER(len=*), INTENT(in)                    :: name   !! (Full) Name of the option to get
    12081265    LOGICAL, INTENT(out), DIMENSION(:), ALLOCATABLE :: output !! Output values
    1209     TYPE(error) :: err                                                 
     1266    TYPE(error) :: err
    12101267      !! Error status of the method (see [[cfgparser(type):get_value(bound)]] documentation)
    12111268    CHARACTER(len=st_slen), DIMENSION(:), ALLOCATABLE :: tmp
     
    12311288        ELSE IF (.NOT.from_string(tmp(i), output(i))) THEN
    12321289          err = error("Cannot convert value #"//TRIM(i2s)//" from option "//TRIM(name),-10)
    1233           DEALLOCATE(output) ; EXIT 
     1290          DEALLOCATE(output) ; EXIT
    12341291        ENDIF
    12351292      ENDDO
    12361293    ENDIF
    12371294    DEALLOCATE(tmp)
    1238     RETURN 
     1295    RETURN
    12391296  END FUNCTION cp_get_lv_ve
    12401297
     
    12431300    !!
    12441301    !! On error, the output vector is not allocated.
    1245     OBJECT(cfgparser), INTENT(in)                   :: this   !! Cfgparser object 
     1302    OBJECT(cfgparser), INTENT(in)                   :: this   !! Cfgparser object
    12461303    CHARACTER(len=*), INTENT(in)                    :: name   !! (Full) Name of the option to get
    12471304    COMPLEX, INTENT(out), DIMENSION(:), ALLOCATABLE :: output !! Output values
    1248     TYPE(error) :: err                                                 
     1305    TYPE(error) :: err
    12491306      !! Error status of the method (see [[cfgparser(type):get_value(bound)]] documentation)
    12501307    CHARACTER(len=st_slen), DIMENSION(:), ALLOCATABLE :: tmp
     
    12701327        ELSE IF (.NOT.from_string(tmp(i), output(i))) THEN
    12711328          err = error("Cannot convert value #"//TRIM(i2s)//" from option "//TRIM(name),-10)
    1272           DEALLOCATE(output) ; EXIT 
     1329          DEALLOCATE(output) ; EXIT
    12731330        ENDIF
    12741331      ENDDO
    12751332    ENDIF
    12761333    DEALLOCATE(tmp)
    1277     RETURN 
     1334    RETURN
    12781335  END FUNCTION cp_get_cv_ve
    12791336
     
    12821339    !!
    12831340    !! On error, the output vector is not allocated.
    1284     OBJECT(cfgparser), INTENT(in)                            :: this   !! Cfgparser object 
     1341    OBJECT(cfgparser), INTENT(in)                            :: this   !! Cfgparser object
    12851342    CHARACTER(len=*), INTENT(in)                             :: name   !! (Full) Name of the option to get
    12861343    CHARACTER(len=*), INTENT(out), DIMENSION(:), ALLOCATABLE :: output !! Output values
    1287     TYPE(error) :: err                                                 
    1288       !! Error status of the method (see [[cfgparser(type):get_value(bound)]] documentation)
     1344    TYPE(error) :: err                                                 !! Error status of the method (see [[cfgparser(type):get_value(bound)]] documentation)
    12891345    LOGICAL :: ok
    12901346    INTEGER :: idx
     
    13071363    !!
    13081364    !! If _create_ is given to .true., the method will add a new option if it does not exist in
    1309     !! the parser. 
    1310     !! In such case, an error (-6, invalid name) is raised if the option name is not valid.
     1365    !! the parser.
     1366    !! In such case, an error ((-9, invalid name)) is raised if the option name is not valid.
    13111367    !!
    13121368    !! In other case, if the option is not defined in the parser the error status is set to -7.
    1313     OBJECT(cfgparser), INTENT(inout) :: this   !! Cfgparser object 
     1369    OBJECT(cfgparser), INTENT(inout) :: this   !! Cfgparser object
    13141370    CHARACTER(len=*), INTENT(in)     :: name   !! (Full) Name of the option to set
    13151371    REAL(kind=4), INTENT(in)         :: input  !! Input value
    1316     LOGICAL, INTENT(in), OPTIONAL    :: create !! .true. to create option if it does not exist (default to false). 
     1372    LOGICAL, INTENT(in), OPTIONAL    :: create !! .true. to create option if it does not exist (default to false).
    13171373    TYPE(error)                      :: err    !! Error status
    13181374    LOGICAL                       :: zcreate
    1319     INTEGER                       :: idx 
     1375    INTEGER                       :: idx
    13201376    CHARACTER(len=:), ALLOCATABLE :: sname,pname
    13211377    TYPE(words) :: values
     
    13321388      ENDIF
    13331389    ELSE
    1334       this%options(idx)%values = values 
     1390      this%options(idx)%values = values
    13351391    ENDIF
    13361392    CALL words_clear(values)
     
    13411397    !!
    13421398    !! If _create_ is given to .true., the method will add a new option if it does not exist in
    1343     !! the parser. 
    1344     !! In such case, an error (-6, invalid name) is raised if the option name is not valid.
     1399    !! the parser.
     1400    !! In such case, an error ((-9, invalid name)) is raised if the option name is not valid.
    13451401    !!
    13461402    !! In other case, if the option is not defined in the parser the error status is set to -7.
    1347     OBJECT(cfgparser), INTENT(inout) :: this   !! Cfgparser object 
     1403    OBJECT(cfgparser), INTENT(inout) :: this   !! Cfgparser object
    13481404    CHARACTER(len=*), INTENT(in)     :: name   !! (Full) Name of the option to set
    13491405    REAL(kind=8), INTENT(in)         :: input  !! Input value
    1350     LOGICAL, INTENT(in), OPTIONAL    :: create !! .true. to create option if it does not exist (default to false). 
     1406    LOGICAL, INTENT(in), OPTIONAL    :: create !! .true. to create option if it does not exist (default to false).
    13511407    TYPE(error)                      :: err    !! Error status
    13521408    LOGICAL                       :: zcreate
    1353     INTEGER                       :: idx 
     1409    INTEGER                       :: idx
    13541410    CHARACTER(len=:), ALLOCATABLE :: sname,pname
    13551411    TYPE(words) :: values
     
    13661422      ENDIF
    13671423    ELSE
    1368       this%options(idx)%values = values 
     1424      this%options(idx)%values = values
    13691425    ENDIF
    13701426    CALL words_clear(values)
     
    13761432    !! If _create_ is given to .true., the method will add a new option if it does not exist in
    13771433    !! the parser.
    1378     !! In such case, an error (-6, invalid name) is raised if the option name is not valid.
     1434    !! In such case, an error ((-9, invalid name)) is raised if the option name is not valid.
    13791435    !!
    13801436    !! In other case, if the option is not defined in the parser the error status is set to -7.
    1381     OBJECT(cfgparser), INTENT(inout) :: this   !! Cfgparser object 
     1437    OBJECT(cfgparser), INTENT(inout) :: this   !! Cfgparser object
    13821438    CHARACTER(len=*), INTENT(in)     :: name   !! (Full) Name of the option to set
    13831439    INTEGER, INTENT(in)              :: input  !! Input value
    1384     LOGICAL, INTENT(in), OPTIONAL    :: create !! .true. to create option if it does not exist (default to false). 
     1440    LOGICAL, INTENT(in), OPTIONAL    :: create !! .true. to create option if it does not exist (default to false).
    13851441    TYPE(error)                      :: err    !! Error status
    13861442    LOGICAL                       :: zcreate
    1387     INTEGER                       :: idx 
     1443    INTEGER                       :: idx
    13881444    CHARACTER(len=:), ALLOCATABLE :: sname,pname
    13891445    TYPE(words) :: values
     
    13951451      IF (zcreate) THEN
    13961452        err = op_split_name(name,sname,pname)
    1397         !IF (err == 0) err = cp_add_opt(this,sname,pname,values)
    1398         err = cp_add_opt(this,sname,pname,values)
     1453        IF (err == 0) err = cp_add_opt(this,sname,pname,values)
    13991454      ELSE
    14001455        err = error("Option "//TRIM(name)//" does not exist",-7)
    14011456      ENDIF
    14021457    ELSE
    1403       this%options(idx)%values = values 
     1458      this%options(idx)%values = values
    14041459    ENDIF
    14051460    CALL words_clear(values)
     
    14111466    !! If _create_ is given to .true., the method will add a new option if it does not exist in
    14121467    !! the parser.
    1413     !! In such case, an error (-6, invalid name) is raised if the option name is not valid.
     1468    !! In such case, an error ((-9, invalid name)) is raised if the option name is not valid.
    14141469    !!
    14151470    !! In other case, if the option is not defined in the parser the error status is set to -7.
    1416     OBJECT(cfgparser), INTENT(inout) :: this   !! Cfgparser object 
     1471    OBJECT(cfgparser), INTENT(inout) :: this   !! Cfgparser object
    14171472    CHARACTER(len=*), INTENT(in)     :: name   !! (Full) Name of the option to set
    14181473    LOGICAL, INTENT(in)              :: input  !! Input value
    1419     LOGICAL, INTENT(in), OPTIONAL    :: create !! .true. to create option if it does not exist (default to false). 
     1474    LOGICAL, INTENT(in), OPTIONAL    :: create !! .true. to create option if it does not exist (default to false).
    14201475    TYPE(error)                      :: err    !! Error status
    14211476    LOGICAL                       :: zcreate
    1422     INTEGER                       :: idx 
     1477    INTEGER                       :: idx
    14231478    CHARACTER(len=:), ALLOCATABLE :: sname,pname
    14241479    TYPE(words) :: values
     
    14351490      ENDIF
    14361491    ELSE
    1437       this%options(idx)%values = values 
     1492      this%options(idx)%values = values
    14381493    ENDIF
    14391494    CALL words_clear(values)
     
    14451500    !! If _create_ is given to .true., the method will add a new option if it does not exist in
    14461501    !! the parser.
    1447     !! In such case, an error (-6, invalid name) is raised if the option name is not valid.
     1502    !! In such case, an error ((-9, invalid name)) is raised if the option name is not valid.
    14481503    !!
    14491504    !! In other case, if the option is not defined in the parser the error status is set to -7.
    1450     OBJECT(cfgparser), INTENT(inout) :: this   !! Cfgparser object 
     1505    OBJECT(cfgparser), INTENT(inout) :: this   !! Cfgparser object
    14511506    CHARACTER(len=*), INTENT(in)     :: name   !! (Full) Name of the option to set
    14521507    COMPLEX, INTENT(in)              :: input  !! Input value
    1453     LOGICAL, INTENT(in), OPTIONAL    :: create !! .true. to create option if it does not exist (default to false). 
     1508    LOGICAL, INTENT(in), OPTIONAL    :: create !! .true. to create option if it does not exist (default to false).
    14541509    TYPE(error)                      :: err    !! Error status
    14551510    LOGICAL                       :: zcreate
    1456     INTEGER                       :: idx 
     1511    INTEGER                       :: idx
    14571512    CHARACTER(len=:), ALLOCATABLE :: sname,pname
    14581513    TYPE(words) :: values
     
    14691524      ENDIF
    14701525    ELSE
    1471       this%options(idx)%values = values 
     1526      this%options(idx)%values = values
    14721527    ENDIF
    14731528    CALL words_clear(values)
     
    14791534    !! If _create_ is given to .true., the method will add a new option if it does not exist in
    14801535    !! the parser.
    1481     !! In such case, an error (-6, invalid name) is raised if the option name is not valid.
     1536    !! In such case, an error ((-9, invalid name)) is raised if the option name is not valid.
    14821537    !!
    14831538    !! In other case, if the option is not defined in the parser the error status is set to -7.
    1484     OBJECT(cfgparser), INTENT(inout) :: this   !! Cfgparser object 
     1539    OBJECT(cfgparser), INTENT(inout) :: this   !! Cfgparser object
    14851540    CHARACTER(len=*), INTENT(in)     :: name   !! (Full) Name of the option to set
    14861541    CHARACTER(len=*), INTENT(in)     :: input  !! Input value
    1487     LOGICAL, INTENT(in), OPTIONAL    :: create !! .true. to create option if it does not exist (default to false). 
     1542    LOGICAL, INTENT(in), OPTIONAL    :: create !! .true. to create option if it does not exist (default to false).
    14881543    TYPE(error)                      :: err    !! Error status
    14891544    LOGICAL                       :: zcreate
    1490     INTEGER                       :: idx 
     1545    INTEGER                       :: idx
    14911546    CHARACTER(len=:), ALLOCATABLE :: sname,pname
    14921547    TYPE(words) :: values
     
    15031558      ENDIF
    15041559    ELSE
    1505       this%options(idx)%values = values 
     1560      this%options(idx)%values = values
    15061561    ENDIF
    15071562    CALL words_clear(values)
     
    15121567    !!
    15131568    !! If _create_ is given to .true., the method will add a new option if it does not exist in
    1514     !! the parser. 
    1515     !! In such case, an error (-6, invalid name) is raised if the option name is not valid.
     1569    !! the parser.
     1570    !! In such case, an error ((-9, invalid name)) is raised if the option name is not valid.
    15161571    !!
    15171572    !! In other case, if the option is not defined in the parser the error status is set to -7.
    1518     OBJECT(cfgparser), INTENT(inout)       :: this   !! Cfgparser object 
     1573    OBJECT(cfgparser), INTENT(inout)       :: this   !! Cfgparser object
    15191574    CHARACTER(len=*), INTENT(in)           :: name   !! (Full) Name of the option to get
    15201575    REAL(kind=4), INTENT(in), DIMENSION(:) :: input  !! Input values
     
    15371592      ENDIF
    15381593    ELSE
    1539       this%options(idx)%values = values 
     1594      this%options(idx)%values = values
    15401595    ENDIF
    15411596    CALL words_clear(values)
     
    15471602    !! If _create_ is given to .true., the method will add a new option if it does not exist in
    15481603    !! the parser.
    1549     !! In such case, an error (-6, invalid name) is raised if the option name is not valid.
     1604    !! In such case, an error ((-9, invalid name)) is raised if the option name is not valid.
    15501605    !!
    15511606    !! In other case, if the option is not defined in the parser the error status is set to -7.
    1552     OBJECT(cfgparser), INTENT(inout)       :: this   !! Cfgparser object 
     1607    OBJECT(cfgparser), INTENT(inout)       :: this   !! Cfgparser object
    15531608    CHARACTER(len=*), INTENT(in)           :: name   !! (Full) Name of the option to get
    15541609    REAL(kind=8), INTENT(in), DIMENSION(:) :: input  !! Input values
     
    15711626      ENDIF
    15721627    ELSE
    1573       this%options(idx)%values = values 
     1628      this%options(idx)%values = values
    15741629    ENDIF
    15751630    CALL words_clear(values)
     
    15801635    !!
    15811636    !! If _create_ is given to .true., the method will add a new option if it does not exist in
    1582     !! the parser. 
    1583     !! In such case, an error (-6, invalid name) is raised if the option name is not valid.
     1637    !! the parser.
     1638    !! In such case, an error ((-9, invalid name)) is raised if the option name is not valid.
    15841639    !!
    15851640    !! In other case, if the option is not defined in the parser the error status is set to -7.
    1586     OBJECT(cfgparser), INTENT(inout)  :: this   !! Cfgparser object 
     1641    OBJECT(cfgparser), INTENT(inout)  :: this   !! Cfgparser object
    15871642    CHARACTER(len=*), INTENT(in)      :: name   !! (Full) Name of the option to get
    15881643    INTEGER, INTENT(in), DIMENSION(:) :: input  !! Input values
     
    16051660      ENDIF
    16061661    ELSE
    1607       this%options(idx)%values = values 
     1662      this%options(idx)%values = values
    16081663    ENDIF
    16091664    CALL words_clear(values)
     
    16151670    !! If _create_ is given to .true., the method will add a new option if it does not exist in
    16161671    !! the parser.
    1617     !! In such case, an error (-6, invalid name) is raised if the option name is not valid.
     1672    !! In such case, an error ((-9, invalid name)) is raised if the option name is not valid.
    16181673    !!
    16191674    !! In other case, if the option is not defined in the parser the error status is set to -7.
    1620     OBJECT(cfgparser), INTENT(inout)  :: this   !! Cfgparser object 
     1675    OBJECT(cfgparser), INTENT(inout)  :: this   !! Cfgparser object
    16211676    CHARACTER(len=*), INTENT(in)      :: name   !! (Full) Name of the option to get
    16221677    LOGICAL, INTENT(in), DIMENSION(:) :: input  !! Input values
     
    16391694      ENDIF
    16401695    ELSE
    1641       this%options(idx)%values = values 
     1696      this%options(idx)%values = values
    16421697    ENDIF
    16431698    CALL words_clear(values)
     
    16481703    !!
    16491704    !! If _create_ is given to .true., the method will add a new option if it does not exist in
    1650     !! the parser. 
    1651     !! In such case, an error (-6, invalid name) is raised if the option name is not valid.
     1705    !! the parser.
     1706    !! In such case, an error ((-9, invalid name)) is raised if the option name is not valid.
    16521707    !!
    16531708    !! In other case, if the option is not defined in the parser the error status is set to -7.
    1654     OBJECT(cfgparser), INTENT(inout)  :: this   !! Cfgparser object 
     1709    OBJECT(cfgparser), INTENT(inout)  :: this   !! Cfgparser object
    16551710    CHARACTER(len=*), INTENT(in)      :: name   !! (Full) Name of the option to get
    16561711    COMPLEX, INTENT(in), DIMENSION(:) :: input  !! Input values
     
    16731728      ENDIF
    16741729    ELSE
    1675       this%options(idx)%values = values 
     1730      this%options(idx)%values = values
    16761731    ENDIF
    16771732    CALL words_clear(values)
     
    16831738    !! If _create_ is given to .true., the method will add a new option if it does not exist in
    16841739    !! the parser.
    1685     !! In such case, an error (-6, invalid name) is raised if the option name is not valid.
     1740    !! In such case, an error ((-9, invalid name)) is raised if the option name is not valid.
    16861741    !!
    16871742    !! In other case, if the option is not defined in the parser the error status is set to -7.
    1688     OBJECT(cfgparser), INTENT(inout)           :: this   !! Cfgparser object 
     1743    OBJECT(cfgparser), INTENT(inout)           :: this   !! Cfgparser object
    16891744    CHARACTER(len=*), INTENT(in)               :: name   !! (Full) Name of the option to get
    16901745    CHARACTER(len=*), INTENT(in), DIMENSION(:) :: input  !! Input values
     
    17071762      ENDIF
    17081763    ELSE
    1709       this%options(idx)%values = values 
     1764      this%options(idx)%values = values
    17101765    ENDIF
    17111766    CALL words_clear(values)
     
    17341789    LOGICAL                       :: zoverride,ok,has_opt
    17351790    INTEGER                       :: lineno,lu,i
    1736     CHARACTER(len=2), PARAMETER   :: space = CHAR(32)//","    ! check if , is really wanted..
     1791    CHARACTER(len=2), PARAMETER   :: space = CHAR(32)//","    ! check if , is really wanted... A: YES space are the delimiter of the words internal object !
    17371792    CHARACTER(len=2), PARAMETER   :: blanks = CHAR(9)//CHAR(32) ! currently not used because blanks truncate.
    17381793    CHARACTER(len=15)             :: sln
     
    17461801    zoverride = .false. ; IF (PRESENT(override)) zoverride = override
    17471802    ! initialize local variables
    1748     curval = '' ; line   = '' ; name  = '' ; value = '' 
    1749     lineno = 0  ; lu = free_lun() 
     1803    curval = '' ; line   = '' ; name  = '' ; value = ''
     1804    lineno = 0  ; lu = free_lun()
    17501805    IF (LEN_TRIM(isec) == 0) isec = "__default__"
    17511806    i = INDEX(TRIM(path),"/",.true.)
    1752     IF (i == 0) THEN 
     1807    IF (i == 0) THEN
    17531808      fulp = fs_realpath("./"//TRIM(ADJUSTL(path)))
    17541809    ELSE
     
    17631818      RETURN
    17641819    ENDIF
    1765     ! check for lun 
     1820    ! check for lun
    17661821    IF (lu == -1) THEN ; err = error("No available logical unit",-12) ; RETURN ; ENDIF
    17671822    OPEN(lu,FILE=TRIM(path),STATUS='old',ACTION='READ')
     
    17751830          ! 1) get relative path
    17761831          ipath = fs_relpath(ipath,dirp)
    1777           ! 2) compute asbolute path)
     1832          ! 2) compute asbolute path
    17781833          ipath = TRIM(dirp)//"/"//TRIM(ipath)
    17791834          ipath = fs_realpath(ipath)
     
    17931848            CALL op_clear(curopt); curval = ''
    17941849          ENDIF
    1795           err = read_include(parser,ipath,isec,ipaths,zoverride) 
     1850          err = read_include(parser,ipath,isec,ipaths,zoverride)
    17961851          IF (err /= 0) EXIT
    17971852        ENDIF
     
    17991854      ENDIF
    18001855      ! continuation line ?
    1801       IF (SCAN(line(1:1),blanks) /= 0 .AND. op_valid(curopt)) THEN 
     1856      IF (SCAN(line(1:1),blanks) /= 0 .AND. op_valid(curopt)) THEN
    18021857          IF (LEN(curval) == 0) THEN
    18031858            curval = strip_comment(line)
     
    18061861          ENDIF
    18071862      ELSE
    1808        ! 1. Remove comment part and left adjust line 
     1863       ! 1. Remove comment part and left adjust line
    18091864       line = strip_comment(line)
    18101865       ! a section header or option header?
     
    18371892           ! 3. curval is set to value
    18381893           ! 4. update curval
    1839            IF (op_valid(curopt)) THEN 
     1894           IF (op_valid(curopt)) THEN
    18401895              IF (LEN(curval) > 0) &
    18411896              CALL words_extend(curopt%values,TRIM(ADJUSTL(curval)),space,.true.,.true.)
     
    18471902           ENDIF
    18481903           CALL op_clear(curopt) ; curval = ''
    1849            has_opt = cfg_has_option(parser,TRIM(isec)//"/"//TRIM(name)) 
     1904           has_opt = cfg_has_option(parser,TRIM(isec)//"/"//TRIM(name))
    18501905
    18511906           IF (has_opt.AND..NOT.zoverride) THEN
    1852              ! it is an error: no duplicate allowed 
     1907             ! it is an error: no duplicate allowed
    18531908             err = error(basp//'(L'//TRIM(sln)//"): Duplicate option '"//TRIM(name)//"' in "//isec,-8)
    18541909             EXIT
     
    18591914           curval = value
    18601915         CASE(cfg_UNKNOWN)
    1861            ! unknown handles also invalid name: it is a critical error 
     1916           ! unknown handles also invalid name: it is a critical error
    18621917           IF (err == -9) EXIT
    1863        END SELECT 
     1918       END SELECT
    18641919      ENDIF
    18651920    ENDDO
    1866     IF (op_valid(curopt)) THEN 
     1921    IF (op_valid(curopt)) THEN
    18671922      IF (LEN(curval) > 0) &
    18681923      CALL words_extend(curopt%values,TRIM(ADJUSTL(curval)),space,.true.,.true.)
     
    18861941      !!   it is a section header.
    18871942      !! - Otherwise, if line has '=', without '#' before '=', it is an option.
    1888       !! 
    1889       !! Then the method returns an integer with the kind flag of the statement which is one of 
     1943      !!
     1944      !! Then the method returns an integer with the kind flag of the statement which is one of
    18901945      !! -1 (cfg_UNKNOWN), 0 (cfg_SECTION) or 1 (cfg_OPTION).
    18911946      CHARACTER(len=*), INTENT(in)               :: string  !! Input string to process
     
    18981953      kind = cfg_UNKNOWN
    18991954      ! get a trimmed (and left adjusted) copy
    1900       copy = TRIM(string) 
     1955      copy = TRIM(string)
    19011956      ! Is it a section ?
    19021957      !   ---> search for subscripts of '[' and ']'
    19031958      !   ---> check that '[' is 1st char and ']' is last char
    1904       bi = INDEX(copy,'[') ; ei = INDEX(copy,']') 
     1959      bi = INDEX(copy,'[') ; ei = INDEX(copy,']')
    19051960      IF (bi == 1 .AND. ei == LEN(copy) .AND. bi < ei) THEN
    19061961        ! it is a section header
    19071962        kind = cfg_SECTION
    19081963        ! get section name: adjust and trim to remove extra blank spaces
    1909         name = str_to_lower(TRIM(ADJUSTL(copy(bi+1:ei-1))))
    1910         IF (TRIM(name) /= "__default__" .AND. .NOT.cfg_check_name(name)) THEN
     1964        name = TRIM(ADJUSTL(copy(bi+1:ei-1)))
     1965        ! hack cfg_check_name: append '/a' to get a valid option part to test
     1966        IF (TRIM(name) /= "__default__" .AND. .NOT.cfg_check_name(name//"/a")) THEN
    19111967          kind = cfg_UNKNOWN
    19121968          err = error("Invalid section name ("//name//")",-9)
     
    19161972      ELSE
    19171973        ! Is it an option ?
    1918         !   --> search for '=' and check if it is set before 
     1974        !   --> search for '=' and check if it is set before
    19191975        !       1st quote (if any)
    1920         bi = INDEX(copy,"=") 
     1976        bi = INDEX(copy,"=")
    19211977        ! search for quotes
    19221978        ei = SCAN(copy,quotes) ; IF (ei==0) ei = LEN(copy)+1
    19231979        IF (bi /= 0 .AND. bi < ei) THEN
    19241980          kind = cfg_OPTION
    1925           name = str_to_lower(TRIM(copy(1:bi-1)))
    1926           IF (.NOT.cfg_check_name(name)) THEN 
     1981          name = to_lower(TRIM(copy(1:bi-1)))
     1982          IF (.NOT.cfg_check_name(name)) THEN
    19271983            kind = cfg_UNKNOWN
    19281984            err = error("Invalid option name ("//TRIM(name)//")",-9)
     
    19442000    FUNCTION strip_comment(line) RESULT(stripped)
    19452001      !! Replace comments part of a string by blank spaces
    1946       !! The method replaces every characters after '#' (included) by spaces. 
    1947       !! @note 
     2002      !! The method replaces every characters after '#' (included) by spaces.
     2003      !! @note
    19482004      !! Output string is also left adjusted, thus only trailing blank can be present.
    19492005      CHARACTER(len=*), INTENT(in) :: line !! A string to process
    19502006      CHARACTER(len=LEN(line)) :: stripped !! A string of same length than 'line' but without comment(s)
    1951      
     2007
    19522008      INTEGER :: idx
    19532009      stripped = ADJUSTL(line)
     
    19602016      !! Read a complete line
    19612017      !!
    1962       !! Each time it is CALLed, the function reads a complete of the file opened in 'lun' logical 
     2018      !! Each time it is CALLed, the function reads a complete of the file opened in 'lun' logical
    19632019      !! unit and returns .false. if EOF has been reached, .true. otherwise.
    19642020      !!
    19652021      !! The function is intended to read a file line by line:
    1966       !! 
    1967       !! ```fortran
     2022      !!
     2023      !! ```
    19682024      !! lu = 1
    19692025      !! open(lu,file="path/to/the/file/to/read")
     
    19752031      !! CLOSE(1)
    19762032      !! ```
    1977       INTEGER, INTENT(in)                        :: lun     !! Logical unit with the opened file to read. 
    1978       CHARACTER(len=:), INTENT(out), ALLOCATABLE :: string  !! Output processed line 
     2033      INTEGER, INTENT(in)                        :: lun     !! Logical unit with the opened file to read.
     2034      CHARACTER(len=:), INTENT(out), ALLOCATABLE :: string  !! Output processed line
    19792035      LOGICAL                                    :: not_eof !! .true. if EOF has NOT been reached yet, .false. otherwise
    19802036      CHARACTER(len=50) :: buf
    19812037      INTEGER           :: e,sz
    1982       not_eof = .true. ; string = '' 
     2038      not_eof = .true. ; string = ''
    19832039      DO
    19842040        READ(lun,'(a)',ADVANCE="no",SIZE=sz,IOSTAT=e) buf
     
    20062062      CHARACTER(len=:), INTENT(out), ALLOCATABLE :: incpath
    20072063        !! A string with the filepath to be included if '#include' statement is found, empty string otherwise
    2008       LOGICAL :: res 
     2064      LOGICAL :: res
    20092065        !! .true. if line is a comment or an empty string, .false. otherwise
    20102066      CHARACTER(len=:), ALLOCATABLE :: copy
     
    20172073        ! search for include statement
    20182074        ! IMPORTANT: assume that there is only a path after include statement
    2019         IF (INDEX(copy,"#include ") == 1) incpath = TRIM(ADJUSTL(copy(10:)))
     2075        IF (INDEX(copy,"#include ") == 1) incpath = remove_quotes(TRIM(ADJUSTL(copy(10:))))
    20202076      ENDIF
    20212077      RETURN
     
    20462102  SUBROUTINE insertionSort(opts)
    20472103    !! Sort an array of Options using insertion sort algorithm
    2048     TYPE(option), INTENT(inout), DIMENSION(:) :: opts !! Array to sort. 
     2104    TYPE(option), INTENT(inout), DIMENSION(:) :: opts !! Array to sort.
    20492105    TYPE(option) :: temp
    20502106    INTEGER :: i, j
     
    20582114        ELSE
    20592115          EXIT
    2060         ENDIF 
     2116        ENDIF
    20612117      ENDDO
    20622118      opts(j+1) = temp
     
    20652121  END SUBROUTINE insertionSort
    20662122
    2067   FUNCTION free_lun() RESULT(lu)
    2068     !> Get the first free logical unit
    2069     !!
    2070     !! The function loops from 7 to 9999 and returns the first free logical unit.
    2071     !! @note
    2072     !! According to Fortran standard, the maximum value for a lun is processor
    2073     !! dependent. I just assume that [7,9999] is a valid range and I believe that
    2074     !! 9992 files to be opened is far enough for any program !
    2075     !! @note
    2076     !! If you intend to use loggers object from this library, you should keep in
    2077     !! mind that loggers open files with the first free logical unit. Consequently
    2078     !! if you need to perform I/O operations you should use this function to get a
    2079     !! free lun instead of just randomly set a lun !
    2080     INTEGER :: lu
    2081       !! First free logical unit in the range [7,999]  or -1 if no lun is available
    2082     INTEGER, PARAMETER :: mxlu = 9999
    2083     LOGICAL :: notfree
    2084     lu = 6 ; notfree = .true.
    2085     DO WHILE(notfree.AND.lu<=mxlu)
    2086       lu=lu+1 ; INQUIRE(unit=lu,OPENED=notfree)
    2087     ENDDO
    2088     IF (lu >= mxlu) lu = -1
    2089   END FUNCTION free_lun
    2090 
    20912123END MODULE CFGPARSE
    20922124
Note: See TracChangeset for help on using the changeset viewer.