62 character(len=27),
parameter,
public :: parser_varname_excluded_characters =
'|!''"#$%&/\()=?{}+-*^.,;:<> '
65 integer function oct_parse_init(file_out, mpiv_node)
67 character(len=*),
intent(in) :: file_out
68 integer,
intent(in) :: mpiv_node
69 end function oct_parse_init
73 subroutine oct_parse_putsym_int(sym, i)
75 character(len=*),
intent(in) :: sym
76 integer,
intent(in) :: i
77 end subroutine oct_parse_putsym_int
79 subroutine oct_parse_putsym_double(sym, d)
80 use,
intrinsic :: iso_fortran_env
82 character(len=*),
intent(in) :: sym
83 real(real64),
intent(in) :: d
84 end subroutine oct_parse_putsym_double
88 integer function oct_parse_input(file_in, set_used)
90 character(len=*),
intent(in) :: file_in
91 integer,
intent(in) :: set_used
92 end function oct_parse_input
96 integer function oct_parse_input_string(file_contents, set_used)
98 character(len=*),
intent(in) :: file_contents
99 integer,
intent(in) :: set_used
100 end function oct_parse_input_string
104 subroutine oct_parse_environment(prefix)
106 character(len=*),
intent(in) :: prefix
107 end subroutine oct_parse_environment
111 subroutine oct_parse_end()
113 end subroutine oct_parse_end
117 subroutine oct_sym_output_table(only_unused, mpiv_node)
119 integer,
intent(in) :: only_unused
120 integer,
intent(in) :: mpiv_node
121 end subroutine oct_sym_output_table
125 integer pure function oct_parse_isdef(name)
127 character(len=*),
intent(in) :: name
128 end function oct_parse_isdef
133 use,
intrinsic :: iso_fortran_env
135 character(len=*),
intent(in) :: name
136 integer(int64),
intent(in) :: def
137 integer(int64),
intent(out) :: res
141 use,
intrinsic :: iso_fortran_env
143 character(len=*),
intent(in) :: name
144 real(real64),
intent(in) :: def
145 real(real64),
intent(out) :: res
149 use,
intrinsic :: iso_fortran_env
151 character(len=*),
intent(in) :: name
152 complex(real64),
intent(in) :: def
153 complex(real64),
intent(out) :: res
158 character(len=*),
intent(in) :: name, def
159 character(len=*),
intent(out) :: res
165 character(len=*),
intent(in) :: name
166 type(
block_t),
intent(out) :: blk
182 subroutine oct_parse_block_end(blk)
185 type(
block_t),
intent(inout) :: blk
186 end subroutine oct_parse_block_end
190 integer function oct_parse_block_n(blk)
193 type(
block_t),
intent(in) :: blk
194 end function oct_parse_block_n
198 integer function oct_parse_block_cols(blk, line)
201 type(
block_t),
intent(in) :: blk
202 integer,
intent(in) :: line
203 end function oct_parse_block_cols
207 subroutine oct_parse_block_int(blk, l, c, res)
210 type(
block_t),
intent(in) :: blk
211 integer,
intent(in) :: l, c
212 integer,
intent(out) :: res
213 end subroutine oct_parse_block_int
215 subroutine oct_parse_block_int8(blk, l, c, res)
216 use,
intrinsic :: iso_fortran_env
219 type(block_t),
intent(in) :: blk
220 integer,
intent(in) :: l, c
221 integer(int64),
intent(out) :: res
222 end subroutine oct_parse_block_int8
226 subroutine oct_parse_block_double(blk, l, c, res)
227 use,
intrinsic :: iso_fortran_env
230 type(
block_t),
intent(in) :: blk
231 integer,
intent(in) :: l, c
232 real(real64),
intent(out) :: res
233 end subroutine oct_parse_block_double
239 subroutine oct_parse_block_complex(blk, l, c, res)
240 use,
intrinsic :: iso_fortran_env
244 integer,
intent(in) :: l, c
245 complex(real64),
intent(out) :: res
246 end subroutine oct_parse_block_complex
250 subroutine oct_parse_block_string(blk, l, c, res)
253 type(
block_t),
intent(in) :: blk
254 integer,
intent(in) :: l, c
255 character(len=*),
intent(out) :: res
256 end subroutine oct_parse_block_string
274 use,
intrinsic :: iso_fortran_env
276 real(real64),
intent(in) :: x, r, t
277 integer,
intent(in) :: ndim
278 real(real64),
intent(out) :: re, im
279 character(len=*),
intent(in) :: pot
284 subroutine oct_parse_expression1(re, im, c, x, string)
285 use,
intrinsic :: iso_fortran_env
287 real(real64),
intent(out) :: re, im
288 character(len=*),
intent(in) :: c
289 real(real64),
intent(in) :: x
290 character(len=*),
intent(in) :: string
291 end subroutine oct_parse_expression1
309 character(len=*),
optional,
intent(in) :: log_file
312 logical :: file_exists
313 character(len=:),
allocatable :: log_file_
315 if (
present(log_file))
then
316 log_file_ = trim(log_file)
318 log_file_ =
'exec/parser.log'
321 inquire(file=trim(conf%share)//
'/variables', exist=file_exists)
322 if (.not. file_exists)
then
323 write(stderr,
'(a)')
'*** Fatal Error (description follows)'
324 write(stderr,
'(a)')
'Error initializing parser'
325 write(stderr,
'(a)')
'Cannot open variables file: '//trim(conf%share)//
'/variables'
330 if (.not.
present(log_file))
then
331 if (mpi_world%is_root())
call loct_mkdir(
'exec')
338 write(stderr,
'(a)')
'*** Fatal Error (description follows)'
339 write(stderr,
'(a)')
'Error initializing parser: cannot write to ' // log_file_
340 write(stderr,
'(a)')
'Do you have write permissions in this directory?'
347 write(stderr,
'(a)')
'*** Fatal Error (description follows)'
348 write(stderr,
'(a)')
'Error initializing parser'
349 write(stderr,
'(a)')
'Cannot open variables file: '//trim(conf%share)//
'/variables'
360 logical :: file_exists
364 inquire(file=
'inp', exist=file_exists)
365 if (.not. file_exists)
then
366 write(stderr,
'(a)')
'*** Fatal Error (description follows)'
367 write(stderr,
'(a)')
'Error initializing parser'
368 write(stderr,
'(a)')
'Cannot open input file!'
369 write(stderr,
'(a)')
'Please provide an input file with name inp in the current workdir'
375 write(stderr,
'(a)')
'*** Fatal Error (description follows)'
376 write(stderr,
'(a)')
'Error initializing parser'
377 write(stderr,
'(a)')
'Cannot open input file!'
378 write(stderr,
'(a)')
'Please provide an input file with name inp in the current workdir'
389 integer :: parser_log
398 if(mpi_world%is_root())
then
399 open(newunit=parser_log, file=
'exec/parser.log', status=
'old', action=
'write', position=
'append')
400 write(parser_log,
'(a)')
'# Octopus version: '//trim(conf%version)
401 write(parser_log,
'(a)')
'# Octopus git_commit: '//trim(conf%git_commit)
410 type(namespace_t),
intent(in) :: namespace
411 character(len=*),
intent(in) :: name
420 type(namespace_t),
intent(in) :: namespace
421 character(len=*),
intent(in) :: name
422 integer,
intent(in) :: def
423 integer,
intent(out) :: res
425 integer(int64) :: res8
437 type(namespace_t),
intent(in) :: namespace
438 character(len=*),
intent(in) :: name
439 integer(int64),
intent(in) :: def
440 integer(int64),
intent(out) :: res
450 type(namespace_t),
intent(in) :: namespace
451 character(len=*),
intent(in) :: name
452 integer,
intent(in) :: def
453 integer(int64),
intent(out) :: res
463 type(namespace_t),
intent(in) :: namespace
464 character(len=*),
intent(in) :: name
465 integer(int64),
intent(in) :: def
466 integer,
intent(out) :: res
468 integer(int64) :: res8
480 type(namespace_t),
intent(in) :: namespace
481 character(len=*),
intent(in) :: name
482 character(len=*),
intent(in) :: def
483 character(len=*),
intent(out) :: res
492 type(namespace_t),
intent(in) :: namespace
493 character(len=*),
intent(in) :: name
494 logical,
intent(in) :: def
495 logical,
intent(out) :: res
497 integer(int64) :: idef, ires
513 type(namespace_t),
intent(in) :: namespace
514 character(len=*),
intent(in) :: name
515 complex(real64),
intent(in) :: def
516 complex(real64),
intent(out) :: res
525 integer function parse_block(namespace, name, blk, check_varinfo_)
526 type(namespace_t),
intent(in) :: namespace
527 character(len=*),
intent(in) :: name
528 type(
block_t),
intent(out) :: blk
529 logical,
optional,
intent(in) :: check_varinfo_
531 logical check_varinfo
533 check_varinfo = .
true.
534 if (
present(check_varinfo_)) check_varinfo = check_varinfo_
536 if (check_varinfo)
then
546 type(
block_t),
intent(in) :: blk
547 integer,
intent(in) :: l, c
548 logical,
intent(out) :: res
552 call oct_parse_block_int(blk, l, c, ires)
560 type(namespace_t),
intent(in) :: namespace
561 character(len=*),
intent(in) :: name
562 real(real64),
intent(in) :: def
563 real(real64),
intent(out) :: res
564 type(unit_t),
optional,
intent(in) :: unit
568 if (
present(unit))
then
570 res = units_to_atomic(unit, res)
580 type(
block_t),
intent(in) :: blk
581 integer,
intent(in) :: l, c
582 real(real64),
intent(out) :: res
583 type(unit_t),
intent(in) :: unit
585 call oct_parse_block_double(blk, l, c, res)
586 res = units_to_atomic(unit, res)
592 real(real64),
intent(out) :: re, im
593 integer,
intent(in) :: ndim
594 real(real64),
intent(in) :: x(:), r, t
595 character(len=*),
intent(in) :: pot
608 character(len=*),
intent(inout) :: inp_string
609 real(real64),
intent(in) :: x(:, :)
610 character(len=1),
intent(in) :: arraychar
612 integer :: i, m, n_atom, coord, string_length
613 character (LEN=100) :: v_string
615 string_length = len(inp_string)
616 do i = 1, string_length - 1
617 if (inp_string(i:i+1) == arraychar//
"[")
then
619 if (inp_string(i+3:i+3) ==
",") m = 1
620 if (inp_string(i+4:i+4) ==
",") m = 2
622 write(stderr,
'(a)')
"*** Fatal Error (description follows)"
623 write(stderr,
'(a)')
"Attempting to parse a string with array elements larger than 99"
626 read(inp_string(i+2:i+1+m),*) n_atom
627 read(inp_string(i+3+m:i+3+m),*) coord
628 write(v_string,*) x(n_atom, coord)
629 inp_string = inp_string(:i-1) //
"(" // trim(v_string) //
")" // inp_string(i+5+m:)
638 character(len=*),
intent(in) :: varname
640 if (.not. varinfo_exists(varname))
then
641 write(stderr,
'(a)')
"*** Fatal Internal Error (description follows)"
642 write(stderr,
'(a)')
'Attempting to parse undocumented variable '//trim(varname)//
'.'
676 type(namespace_t),
target,
intent(in) :: namespace
677 character(len=*),
intent(in) :: varname
678 character(len=:),
allocatable :: name
682 type(namespace_t),
pointer :: ancestor
683 character(len=MAX_NAMESPACE_LEN) :: ancestor_name, tmp
688 ancestor => namespace
689 do while (
associated(ancestor) .and. .not. found)
692 ancestor_name = ancestor%get()
694 do while (len_trim(ancestor_name) > 0 .and. is /= 0 .and. .not. found)
696 name = trim(ancestor_name) //
"." // trim(varname)
700 is = index(ancestor_name,
".")
701 tmp = ancestor_name(is+1:)
704 ancestor => ancestor%parent
708 if (.not. found) name = varname
715 call mpi_world%abort()
The public subroutine parse_expression accepts two possible interfaces, one which assumes that the va...
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 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.
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.