61 character(len=27),
parameter,
public :: parser_varname_excluded_characters =
'|!''"#$%&/\()=?{}+-*^.,;:<> '
64 integer function oct_parse_init(file_out, mpiv_node)
66 character(len=*),
intent(in) :: file_out
67 integer,
intent(in) :: mpiv_node
68 end function oct_parse_init
72 subroutine oct_parse_putsym_int(sym, i)
74 character(len=*),
intent(in) :: sym
75 integer,
intent(in) :: i
76 end subroutine oct_parse_putsym_int
78 subroutine oct_parse_putsym_double(sym, d)
79 use,
intrinsic :: iso_fortran_env
81 character(len=*),
intent(in) :: sym
82 real(real64),
intent(in) :: d
83 end subroutine oct_parse_putsym_double
87 integer function oct_parse_input(file_in, set_used)
89 character(len=*),
intent(in) :: file_in
90 integer,
intent(in) :: set_used
91 end function oct_parse_input
95 integer function oct_parse_input_string(file_contents, set_used)
97 character(len=*),
intent(in) :: file_contents
98 integer,
intent(in) :: set_used
99 end function oct_parse_input_string
103 subroutine oct_parse_environment(prefix)
105 character(len=*),
intent(in) :: prefix
106 end subroutine oct_parse_environment
110 subroutine oct_parse_end()
112 end subroutine oct_parse_end
116 subroutine oct_sym_output_table(only_unused, mpiv_node)
118 integer,
intent(in) :: only_unused
119 integer,
intent(in) :: mpiv_node
120 end subroutine oct_sym_output_table
124 integer pure function oct_parse_isdef(name)
126 character(len=*),
intent(in) :: name
127 end function oct_parse_isdef
132 use,
intrinsic :: iso_fortran_env
134 character(len=*),
intent(in) :: name
135 integer(int64),
intent(in) :: def
136 integer(int64),
intent(out) :: res
140 use,
intrinsic :: iso_fortran_env
142 character(len=*),
intent(in) :: name
143 real(real64),
intent(in) :: def
144 real(real64),
intent(out) :: res
148 use,
intrinsic :: iso_fortran_env
150 character(len=*),
intent(in) :: name
151 complex(real64),
intent(in) :: def
152 complex(real64),
intent(out) :: res
157 character(len=*),
intent(in) :: name, def
158 character(len=*),
intent(out) :: res
164 character(len=*),
intent(in) :: name
181 subroutine oct_parse_block_end(blk)
184 type(
block_t),
intent(inout) :: blk
185 end subroutine oct_parse_block_end
189 integer function oct_parse_block_n(blk)
192 type(
block_t),
intent(in) :: blk
193 end function oct_parse_block_n
197 integer function oct_parse_block_cols(blk, line)
200 type(
block_t),
intent(in) :: blk
201 integer,
intent(in) :: line
202 end function oct_parse_block_cols
206 subroutine oct_parse_block_int(blk, l, c, res)
210 integer,
intent(in) :: l, c
211 integer,
intent(out) :: res
212 end subroutine oct_parse_block_int
214 subroutine oct_parse_block_int8(blk, l, c, res)
215 use,
intrinsic :: iso_fortran_env
218 type(
block_t),
intent(in) :: blk
219 integer,
intent(in) :: l, c
220 integer(int64),
intent(out) :: res
221 end subroutine oct_parse_block_int8
225 subroutine oct_parse_block_double(blk, l, c, res)
226 use,
intrinsic :: iso_fortran_env
229 type(
block_t),
intent(in) :: blk
230 integer,
intent(in) :: l, c
231 real(real64),
intent(out) :: res
232 end subroutine oct_parse_block_double
238 subroutine oct_parse_block_complex(blk, l, c, res)
239 use,
intrinsic :: iso_fortran_env
242 type(
block_t),
intent(in) :: blk
243 integer,
intent(in) :: l, c
244 complex(real64),
intent(out) :: res
245 end subroutine oct_parse_block_complex
249 subroutine oct_parse_block_string(blk, l, c, res)
252 type(
block_t),
intent(in) :: blk
253 integer,
intent(in) :: l, c
254 character(len=*),
intent(out) :: res
255 end subroutine oct_parse_block_string
273 use,
intrinsic :: iso_fortran_env
275 real(real64),
intent(in) :: x, r, t
276 integer,
intent(in) :: ndim
277 real(real64),
intent(out) :: re, im
278 character(len=*),
intent(in) :: pot
283 subroutine oct_parse_expression1(re, im, c, x, string)
284 use,
intrinsic :: iso_fortran_env
286 real(real64),
intent(out) :: re, im
287 character(len=*),
intent(in) :: c
288 real(real64),
intent(in) :: x
289 character(len=*),
intent(in) :: string
290 end subroutine oct_parse_expression1
308 character(len=*),
optional,
intent(in) :: log_file
311 logical :: file_exists
312 character(len=:),
allocatable :: log_file_
314 if (
present(log_file))
then
315 log_file_ = trim(log_file)
317 log_file_ =
'exec/parser.log'
320 inquire(file=trim(conf%share)//
'/variables', exist=file_exists)
321 if (.not. file_exists)
then
322 write(stderr,
'(a)')
'*** Fatal Error (description follows)'
323 write(stderr,
'(a)')
'Error initializing parser'
324 write(stderr,
'(a)')
'Cannot open variables file: '//trim(conf%share)//
'/variables'
329 if (.not.
present(log_file))
then
330 if (mpi_grp_is_root(mpi_world))
call loct_mkdir(
'exec')
337 write(stderr,
'(a)')
'*** Fatal Error (description follows)'
338 write(stderr,
'(a)')
'Error initializing parser: cannot write to ' // log_file_
339 write(stderr,
'(a)')
'Do you have write permissions in this directory?'
346 write(stderr,
'(a)')
'*** Fatal Error (description follows)'
347 write(stderr,
'(a)')
'Error initializing parser'
348 write(stderr,
'(a)')
'Cannot open variables file: '//trim(conf%share)//
'/variables'
359 logical :: file_exists
363 inquire(file=
'inp', exist=file_exists)
364 if (.not. file_exists)
then
365 write(stderr,
'(a)')
'*** Fatal Error (description follows)'
366 write(stderr,
'(a)')
'Error initializing parser'
367 write(stderr,
'(a)')
'Cannot open input file!'
368 write(stderr,
'(a)')
'Please provide an input file with name inp in the current workdir'
374 write(stderr,
'(a)')
'*** Fatal Error (description follows)'
375 write(stderr,
'(a)')
'Error initializing parser'
376 write(stderr,
'(a)')
'Cannot open input file!'
377 write(stderr,
'(a)')
'Please provide an input file with name inp in the current workdir'
388 integer :: parser_log
397 if(mpi_grp_is_root(mpi_world))
then
398 open(newunit=parser_log, file=
'exec/parser.log', status=
'old', action=
'write', position=
'append')
399 write(parser_log,
'(a)')
'# Octopus version: '//trim(conf%version)
400 write(parser_log,
'(a)')
'# Octopus git_commit: '//trim(conf%git_commit)
409 type(namespace_t),
intent(in) :: namespace
410 character(len=*),
intent(in) :: name
419 type(namespace_t),
intent(in) :: namespace
420 character(len=*),
intent(in) :: name
421 integer,
intent(in) :: def
422 integer,
intent(out) :: res
424 integer(int64) :: res8
436 type(namespace_t),
intent(in) :: namespace
437 character(len=*),
intent(in) :: name
438 integer(int64),
intent(in) :: def
439 integer(int64),
intent(out) :: res
449 type(namespace_t),
intent(in) :: namespace
450 character(len=*),
intent(in) :: name
451 integer,
intent(in) :: def
452 integer(int64),
intent(out) :: res
462 type(namespace_t),
intent(in) :: namespace
463 character(len=*),
intent(in) :: name
464 integer(int64),
intent(in) :: def
465 integer,
intent(out) :: res
467 integer(int64) :: res8
479 type(namespace_t),
intent(in) :: namespace
480 character(len=*),
intent(in) :: name
481 character(len=*),
intent(in) :: def
482 character(len=*),
intent(out) :: res
491 type(namespace_t),
intent(in) :: namespace
492 character(len=*),
intent(in) :: name
493 logical,
intent(in) :: def
494 logical,
intent(out) :: res
496 integer(int64) :: idef, ires
512 type(namespace_t),
intent(in) :: namespace
513 character(len=*),
intent(in) :: name
514 complex(real64),
intent(in) :: def
515 complex(real64),
intent(out) :: res
524 integer function parse_block(namespace, name, blk, check_varinfo_)
525 type(namespace_t),
intent(in) :: namespace
526 character(len=*),
intent(in) :: name
527 type(
block_t),
intent(out) :: blk
528 logical,
optional,
intent(in) :: check_varinfo_
530 logical check_varinfo
532 check_varinfo = .
true.
533 if (
present(check_varinfo_)) check_varinfo = check_varinfo_
535 if (check_varinfo)
then
545 type(
block_t),
intent(in) :: blk
546 integer,
intent(in) :: l, c
547 logical,
intent(out) :: res
551 call oct_parse_block_int(blk, l, c, ires)
559 type(namespace_t),
intent(in) :: namespace
560 character(len=*),
intent(in) :: name
561 real(real64),
intent(in) :: def
562 real(real64),
intent(out) :: res
563 type(unit_t),
optional,
intent(in) :: unit
567 if (
present(unit))
then
569 res = units_to_atomic(unit, res)
579 type(
block_t),
intent(in) :: blk
580 integer,
intent(in) :: l, c
581 real(real64),
intent(out) :: res
582 type(unit_t),
intent(in) :: unit
584 call oct_parse_block_double(blk, l, c, res)
585 res = units_to_atomic(unit, res)
591 real(real64),
intent(out) :: re, im
592 integer,
intent(in) :: ndim
593 real(real64),
intent(in) :: x(:), r, t
594 character(len=*),
intent(in) :: pot
607 character(len=*),
intent(inout) :: inp_string
608 real(real64),
intent(in) :: x(:, :)
609 character(len=1),
intent(in) :: arraychar
611 integer :: i, m, n_atom, coord, string_length
612 character (LEN=100) :: v_string
614 string_length = len(inp_string)
615 do i = 1, string_length - 1
616 if (inp_string(i:i+1) == arraychar//
"[")
then
618 if (inp_string(i+3:i+3) ==
",") m = 1
619 if (inp_string(i+4:i+4) ==
",") m = 2
621 write(stderr,
'(a)')
"*** Fatal Error (description follows)"
622 write(stderr,
'(a)')
"Attempting to parse a string with array elements larger than 99"
625 read(inp_string(i+2:i+1+m),*) n_atom
626 read(inp_string(i+3+m:i+3+m),*) coord
627 write(v_string,*) x(n_atom, coord)
628 inp_string = inp_string(:i-1) //
"(" // trim(v_string) //
")" // inp_string(i+5+m:)
637 character(len=*),
intent(in) :: varname
639 if (.not. varinfo_exists(varname))
then
640 write(stderr,
'(a)')
"*** Fatal Internal Error (description follows)"
641 write(stderr,
'(a)')
'Attempting to parse undocumented variable '//trim(varname)//
'.'
675 type(namespace_t),
target,
intent(in) :: namespace
676 character(len=*),
intent(in) :: varname
677 character(len=:),
allocatable :: name
681 type(namespace_t),
pointer :: ancestor
682 character(len=MAX_NAMESPACE_LEN) :: ancestor_name, tmp
687 ancestor => namespace
688 do while (
associated(ancestor) .and. .not. found)
691 ancestor_name = ancestor%get()
693 do while (len_trim(ancestor_name) > 0 .and. is /= 0 .and. .not. found)
695 name = trim(ancestor_name) //
"." // trim(varname)
699 is = index(ancestor_name,
".")
700 tmp = ancestor_name(is+1:)
703 ancestor => ancestor%parent
707 if (.not. found) name = varname
714 call mpi_world%abort()
The public subroutine parse_expression accepts two possible interfaces, one which assumes that the va...
logical function, public parse_is_defined(namespace, name)
subroutine parse_logical(namespace, name, def, res)
subroutine parse_integer(namespace, name, def, res)
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, public parser_end()
End the Octopus parser.
character(len=:) function, allocatable parse_get_full_name(namespace, varname)
Given a namespace and a variable name, this function will iterate over all namespace ancestors contai...
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...
subroutine parse_integer8(namespace, name, def, res)
subroutine oct_parse_double_unit(namespace, name, def, res, unit)
subroutine parse_string(namespace, name, def, res)
subroutine oct_parse_expression_vec(re, im, ndim, x, r, t, pot)
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.