63  character(len=27), 
parameter, 
public :: parser_varname_excluded_characters = 
'|!''"#$%&/\()=?{}+-*^.,;:<> ' 
   66    integer function oct_parse_init(file_out, mpiv_node) 
bind(c) 
   69      character(kind=c_char), 
intent(in) :: file_out(*)
 
   70      integer,                
intent(in) :: mpiv_node
 
   71    end function oct_parse_init
 
   75    integer function oct_parse_input(file_in, set_used) 
bind(c) 
   78      character(kind=c_char), 
intent(in) :: file_in(*)
 
   79      integer,                
intent(in) :: set_used
 
   80    end function oct_parse_input
 
   84    subroutine oct_parse_environment(prefix) 
bind(c) 
   87      character(kind=c_char), 
intent(in) :: prefix(*)
 
   88    end subroutine oct_parse_environment
 
   92    subroutine oct_parse_end()
 
   94    end subroutine oct_parse_end
 
   98    subroutine oct_sym_output_table(only_unused, mpiv_node)
 
  100      integer, 
intent(in) :: only_unused
 
  101      integer, 
intent(in) :: mpiv_node
 
  102    end subroutine oct_sym_output_table
 
  106    integer pure function oct_parse_isdef(name) 
bind(c) 
  109      character(kind=c_char), 
intent(in) :: name(*)
 
  110    end function oct_parse_isdef
 
  116      use, 
intrinsic :: iso_fortran_env
 
  118      character(kind=c_char), 
intent(in)  :: name(*)
 
  119      integer(int64),      
intent(in)  :: def
 
  120      integer(int64),      
intent(out) :: res
 
  125      use, 
intrinsic :: iso_fortran_env
 
  127      character(kind=c_char), 
intent(in)  :: name(*)
 
  128      real(real64),         
intent(in)  :: def
 
  129      real(real64),         
intent(out) :: res
 
  134      use, 
intrinsic :: iso_fortran_env
 
  136      character(kind=c_char), 
intent(in)  :: name(*)
 
  137      complex(real64),      
intent(in)  :: def
 
  138      complex(real64),      
intent(out) :: res
 
  144      character(kind=c_char), 
intent(in)    :: name(*), def(*)
 
  145      character(kind=c_char), 
intent(inout) :: res(*)
 
  146      integer(kind=c_size_t), 
intent(in)    :: res_len 
 
  153      character(kind=c_char), 
intent(in)  :: name(*)
 
  175    subroutine oct_parse_block_end(blk)
 
  178      type(block_t), 
intent(inout) :: blk
 
  179    end subroutine oct_parse_block_end
 
  183    integer function oct_parse_block_n(blk)
 
  186      type(block_t), 
intent(in) :: blk
 
  187    end function oct_parse_block_n
 
  191    integer function oct_parse_block_cols(blk, line)
 
  194      type(
block_t), 
intent(in) :: blk
 
  195      integer,       
intent(in) :: line
 
  196    end function oct_parse_block_cols
 
  200    subroutine oct_parse_block_int(blk, l, c, res)
 
  203      type(
block_t), 
intent(in)  :: blk
 
  204      integer,       
intent(in)  :: l, c
 
  205      integer,       
intent(out) :: res
 
  206    end subroutine oct_parse_block_int
 
  208    subroutine oct_parse_block_int8(blk, l, c, res)
 
  209      use, 
intrinsic :: iso_fortran_env
 
  212      type(
block_t), 
intent(in)    :: blk
 
  213      integer, 
intent(in)          :: l, c
 
  214      integer(int64), 
intent(out)      :: res
 
  215    end subroutine oct_parse_block_int8
 
  219    subroutine oct_parse_block_double(blk, l, c, res)
 
  220      use, 
intrinsic :: iso_fortran_env
 
  223      type(
block_t), 
intent(in)  :: blk
 
  224      integer,       
intent(in)  :: l, c
 
  225      real(real64),      
intent(out) :: res
 
  226    end subroutine oct_parse_block_double
 
  232    subroutine oct_parse_block_complex(blk, l, c, res)
 
  233      use, 
intrinsic :: iso_fortran_env
 
  237      integer,       
intent(in)  :: l, c
 
  238      complex(real64),   
intent(out) :: res
 
  239    end subroutine oct_parse_block_complex
 
  255    character(len=*), 
optional, 
intent(in) :: log_file
 
  258    logical :: file_exists
 
  259    character(len=:), 
allocatable :: log_file_
 
  260    character(len=MAX_PATH_LEN) :: variables
 
  262    if (
present(log_file)) 
then 
  263      log_file_ = trim(log_file)
 
  265      log_file_ = 
'exec/parser.log' 
  268    variables = trim(conf%share)//
'/variables' 
  269    file_exists = .false.
 
  270    inquire(file=variables, exist=file_exists)
 
  271    if (.not. file_exists) 
then 
  272      write(stderr,
'(a)') 
'*** Fatal Error (description follows)' 
  273      write(stderr,
'(a)') 
'Error initializing parser' 
  274      write(stderr,
'(a)') 
'Cannot open variables file: '//trim(conf%share)//
'/variables' 
  279    if (.not. 
present(log_file)) 
then 
  280      if (mpi_world%is_root()) 
call loct_mkdir(
'exec')
 
  287      write(stderr,
'(a)') 
'*** Fatal Error (description follows)' 
  288      write(stderr,
'(a)') 
'Error initializing parser: cannot write to ' // log_file_
 
  289      write(stderr,
'(a)') 
'Do you have write permissions in this directory?' 
  296      write(stderr,
'(a)') 
'*** Fatal Error (description follows)' 
  297      write(stderr,
'(a)') 
'Error initializing parser' 
  298      write(stderr,
'(a)') 
'Cannot open variables file: '//trim(conf%share)//
'/variables' 
  309    logical :: file_exists
 
  313    file_exists = .false.
 
  314    inquire(file=
'inp', exist=file_exists)
 
  315    if (.not. file_exists) 
then 
  316      write(stderr,
'(a)') 
'*** Fatal Error (description follows)' 
  317      write(stderr,
'(a)') 
'Error initializing parser' 
  318      write(stderr,
'(a)') 
'Cannot open input file!' 
  319      write(stderr,
'(a)') 
'Please provide an input file with name inp in the current workdir' 
  325      write(stderr,
'(a)') 
'*** Fatal Error (description follows)' 
  326      write(stderr,
'(a)') 
'Error initializing parser' 
  327      write(stderr,
'(a)') 
'Cannot open input file!' 
  328      write(stderr,
'(a)') 
'Please provide an input file with name inp in the current workdir' 
  339    integer :: parser_log
 
  348    if(mpi_world%is_root()) 
then 
  349      open(newunit=parser_log, file=
'exec/parser.log', status=
'old', action=
'write', position=
'append')
 
  350      write(parser_log, 
'(a)') 
'# Octopus version: '//trim(conf%version)
 
  351      write(parser_log, 
'(a)') 
'# Octopus git_commit: '//trim(conf%git_commit)
 
  360    type(namespace_t), 
intent(in) :: namespace
 
  361    character(len=*),  
intent(in) :: name
 
  363    character(len=MAX_PATH_LEN) :: full_name
 
  373    character(len=*), 
intent(in) :: file_contents
 
  374    integer,          
intent(in) :: set_used
 
  377      integer function oct_parse_input_string(file_contents, set_used) 
bind(c) 
  380        character(kind=c_char), 
intent(in) :: file_contents(*)
 
  381        integer,          
intent(in) :: set_used
 
  382      end function oct_parse_input_string
 
  391    type(namespace_t), 
intent(in)    :: namespace
 
  392    character(len=*),  
intent(in)    :: name
 
  393    integer,           
intent(in)    :: def
 
  394    integer,           
intent(out)   :: res
 
  396    integer(int64) :: res8
 
  397    character(len=MAX_PATH_LEN) :: full_name
 
  402    call oct_parse_int(string_f_to_c(full_name), int(def, int64), res8)
 
  411    type(namespace_t), 
intent(in)    :: namespace
 
  412    character(len=*),  
intent(in)    :: name
 
  413    integer(int64),       
intent(in)    :: def
 
  414    integer(int64),       
intent(out)   :: res
 
  424    type(namespace_t), 
intent(in)    :: namespace
 
  425    character(len=*),  
intent(in)    :: name
 
  426    integer,           
intent(in)    :: def
 
  427    integer(int64),    
intent(out)   :: res
 
  429    character(len=MAX_PATH_LEN) :: full_name
 
  435    call oct_parse_int(string_f_to_c(full_name), int(def, int64), res)
 
  442    type(namespace_t), 
intent(in)    :: namespace
 
  443    character(len=*),  
intent(in)    :: name
 
  444    integer(int64),    
intent(in)    :: def
 
  445    integer,           
intent(out)   :: res
 
  447    integer(int64) :: res8
 
  448    character(len=MAX_PATH_LEN) :: full_name
 
  462    type(namespace_t), 
intent(in)    :: namespace
 
  463    character(len=*),  
intent(in)    :: name
 
  464    character(len=*),  
intent(in)    :: def
 
  465    character(len=*),  
intent(inout) :: res
 
  467    integer(kind=c_size_t) :: res_len
 
  468    character(len=MAX_PATH_LEN) :: full_name
 
  469    character(kind=c_char) :: c_res(len(res)+1)
 
  477    call oct_parse_string(string_f_to_c(full_name), string_f_to_c(def), c_res, res_len)
 
  478    call string_c_to_f(c_res, res)
 
  484    type(namespace_t), 
intent(in)    :: namespace
 
  485    character(len=*),  
intent(in)    :: name
 
  486    logical,           
intent(in)    :: def
 
  487    logical,           
intent(out)   :: res
 
  489    integer(int64) :: idef, ires
 
  490    character(len=MAX_PATH_LEN) :: full_name
 
  507    type(namespace_t), 
intent(in)    :: namespace
 
  508    character(len=*),  
intent(in)    :: name
 
  509    complex(real64),   
intent(in)    :: def
 
  510    complex(real64),   
intent(out)   :: res
 
  519  integer function parse_block(namespace, name, blk, check_varinfo_)
 
  520    type(namespace_t), 
intent(in)    :: namespace
 
  521    character(len=*),  
intent(in)    :: name
 
  522    type(
block_t),     
intent(out)   :: blk
 
  523    logical, 
optional, 
intent(in)    :: check_varinfo_
 
  525    logical :: check_varinfo
 
  526    character(len=MAX_PATH_LEN) :: full_name
 
  528    check_varinfo = .
true.
 
  529    if (
present(check_varinfo_)) check_varinfo = check_varinfo_
 
  531    if (check_varinfo) 
then 
  544    type(
block_t), 
intent(in)  :: blk
 
  545    integer,       
intent(in)  :: l, c
 
  546    logical,       
intent(out) :: res
 
  550    call oct_parse_block_int(blk, l, c, ires)
 
  558    type(namespace_t),      
intent(in)  :: namespace
 
  559    character(len=*),       
intent(in)  :: name
 
  560    real(real64),           
intent(in)  :: def
 
  561    real(real64),           
intent(out) :: res
 
  562    type(unit_t), 
optional, 
intent(in)  :: unit
 
  564    character(len=MAX_PATH_LEN) :: full_name
 
  570    if (
present(unit)) 
then 
  571      call oct_parse_double(string_f_to_c(full_name), units_from_atomic(unit, def), res)
 
  572      res = units_to_atomic(unit, res)
 
  582    type(
block_t), 
intent(in)  :: blk
 
  583    integer,       
intent(in)  :: l, c
 
  584    real(real64),  
intent(out) :: res
 
  585    type(unit_t),  
intent(in)  :: unit
 
  587    call oct_parse_block_double(blk, l, c, res)
 
  588    res = units_to_atomic(unit, res)
 
  594    real(real64),     
intent(out) :: re, im
 
  595    integer,          
intent(in)  :: ndim
 
  596    real(real64),     
intent(in)  :: x(:), r, t
 
  597    character(len=*), 
intent(in)  :: pot
 
  610    character(len=*), 
intent(inout) :: inp_string
 
  611    real(real64),     
intent(in)    :: x(:, :)
 
  612    character(len=1), 
intent(in)    :: arraychar
 
  614    integer              :: i, m, n_atom, coord, string_length
 
  615    character (LEN=100)  :: v_string
 
  617    string_length = len(inp_string)
 
  618    do i = 1, string_length - 1
 
  619      if (inp_string(i:i+1) == arraychar//
"[") 
then 
  621        if (inp_string(i+3:i+3) == 
",") m = 1
 
  622        if (inp_string(i+4:i+4) == 
",") m = 2
 
  624          write(stderr, 
'(a)') 
"*** Fatal Error (description follows)" 
  625          write(stderr, 
'(a)') 
"Attempting to parse a string with array elements larger than 99" 
  628        read(inp_string(i+2:i+1+m),*) n_atom
 
  629        read(inp_string(i+3+m:i+3+m),*) coord
 
  630        write(v_string,*) x(n_atom, coord)
 
  631        inp_string = inp_string(:i-1) // 
"(" // trim(v_string) // 
")" // inp_string(i+5+m:)
 
  640    character(len=*), 
intent(in) :: varname
 
  642    if (.not. varinfo_exists(varname)) 
then 
  643      write(stderr,
'(a)') 
"*** Fatal Internal Error (description follows)" 
  644      write(stderr,
'(a)') 
'Attempting to parse undocumented variable '//trim(varname)//
'.' 
  678    type(namespace_t), 
target, 
intent(in)  :: namespace
 
  679    character(len=*),          
intent(in)  :: varname
 
  680    character(len=:),          
allocatable :: name
 
  684    type(namespace_t), 
pointer :: ancestor
 
  685    character(len=MAX_NAMESPACE_LEN) :: ancestor_name, tmp
 
  690    ancestor => namespace
 
  691    do while (
associated(ancestor) .and. .not. found)
 
  694      ancestor_name = ancestor%get()
 
  696      do while (len_trim(ancestor_name) > 0 .and. is /= 0 .and. .not. found)
 
  698        name = trim(ancestor_name) // 
"." // trim(varname)
 
  699        found = 
parse_isdef(string_f_to_c(trim(name))) /= 0
 
  702        is = index(ancestor_name, 
".")
 
  703        tmp = ancestor_name(is+1:)
 
  706      ancestor => ancestor%parent
 
  710    if (.not. found) name = varname
 
  715    type(
block_t),    
intent(in)     :: blk
 
  716    integer,          
intent(in)     :: l, c
 
  717    character(len=*), 
intent(inout)  :: res
 
  718    logical, 
optional,
intent(in)     :: convert_to_c
 
  720    character(kind=c_char) :: c_res(len(res)+1)
 
  722    interface oct_parse_block_string
 
  723      subroutine oct_parse_block_string(blk, l, c, res)
 
  727        type(
block_t),    
intent(in)  :: blk
 
  728        integer,          
intent(in)  :: l, c
 
  729        character(kind=c_char), 
intent(out) :: res(*)
 
  730      end subroutine oct_parse_block_string
 
  731    end interface oct_parse_block_string
 
  734    call oct_parse_block_string(blk, l, c, c_res)
 
  735    call string_c_to_f(c_res, res)
 
  737    if(optional_default(convert_to_c, .false.)) 
then 
  738      call conv_to_c_string(res)
 
  757    real(real64),           
intent(in)  :: x, r, t
 
  758    integer,                
intent(in)  :: ndim
 
  759    real(real64),           
intent(out) :: re, im
 
  760    character(len=*),       
intent(in)  :: pot
 
  762    interface oct_parse_expression_low
 
  763      subroutine oct_parse_expression_low(re, im, ndim, x, r, t, pot) bind(c, name='oct_parse_expression')
 
  765        use, 
intrinsic :: iso_fortran_env
 
  767        real(real64),           
intent(in)  :: x, r, t
 
  768        integer,                
intent(in)  :: ndim
 
  769        real(real64),           
intent(out) :: re, im
 
  770        character(kind=c_char), 
intent(in)  :: pot(*)
 
  771      end subroutine oct_parse_expression_low
 
  772    end interface oct_parse_expression_low
 
  774    call oct_parse_expression_low(re, im, ndim, x, r, t, string_f_to_c(pot))
 
  778    real(real64),     
intent(out) :: re, im
 
  779    character(len=*), 
intent(in)  :: c
 
  780    real(real64),     
intent(in)  :: x
 
  781    character(len=*), 
intent(in)  :: string
 
  783    interface oct_parse_expression1
 
  784      subroutine oct_parse_expression1(re, im, c, x, string) 
bind(c) 
  786        use, 
intrinsic :: iso_fortran_env
 
  788        real(real64),           
intent(out) :: re, im
 
  789        character(kind=c_char), 
intent(in)  :: c(*)
 
  790        real(real64),           
intent(in)  :: x
 
  791        character(kind=c_char), 
intent(in)  :: string(*)
 
  792      end subroutine oct_parse_expression1
 
  793    end interface oct_parse_expression1
 
  795    call oct_parse_expression1(re, im, string_f_to_c(c), x, string_f_to_c(string))
 
  804    call mpi_world%abort()
 
System information (time, memory, sysname)
 
character(len=:) function, allocatable, public parse_get_full_name(namespace, varname)
Given a namespace and a variable name, this function will iterate over all namespace ancestors contai...
 
logical function, public parse_is_defined(namespace, name)
 
subroutine parse_logical(namespace, name, def, res)
 
subroutine parse_integer(namespace, name, def, res)
 
subroutine, public parse_block_string(blk, l, c, res, convert_to_c)
 
subroutine parse_integer48(namespace, name, def, res)
 
subroutine, public parser_init()
Initialise the Octopus parser.
 
subroutine, public parse_block_logical(blk, l, c, res)
 
subroutine oct_parse_expression(re, im, ndim, x, r, t, pot)
The public subroutine parse_expression accepts two possible interfaces, one which assumes that the va...
 
subroutine, public parser_end()
End the Octopus parser.
 
subroutine oct_parse_block_double_unit(blk, l, c, res, unit)
 
subroutine parse_integer84(namespace, name, def, res)
 
subroutine, public parse_array(inp_string, x, arraychar)
A very primitive way to "preprocess" a string that contains reference to the elements of a two-dimens...
 
integer function, public parse_input_string(file_contents, set_used)
 
subroutine parse_integer8(namespace, name, def, res)
 
subroutine oct_parse_double_unit(namespace, name, def, res, unit)
 
subroutine oct_parse_expression_vec1(re, im, c, x, string)
 
subroutine oct_parse_expression_vec0(re, im, ndim, x, r, t, pot)
 
subroutine parse_string(namespace, name, def, res)
 
subroutine parse_check_varinfo(varname)
 
subroutine parse_cmplx(namespace, name, def, res)
 
integer function, public parse_block(namespace, name, blk, check_varinfo_)
 
subroutine, public parser_initialize_symbol_table(log_file)
Initialise the Octopus parser symbol table from file of keys.
 
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.