(git:b279b6b)
input_cp2k_read.F
Go to the documentation of this file.
1 !--------------------------------------------------------------------------------------------------!
2 ! CP2K: A general program to perform molecular dynamics simulations !
3 ! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
4 ! !
5 ! SPDX-License-Identifier: GPL-2.0-or-later !
6 !--------------------------------------------------------------------------------------------------!
7 
8 ! **************************************************************************************************
9 !> \brief parse cp2k input files
10 !> \par History
11 !> 06.2004 created [fawzi]
12 !> 03.2014 moved into separate module [Ole Schuett]
13 !> \author fawzi
14 ! **************************************************************************************************
16  USE cp_parser_types, ONLY: cp_parser_type,&
20  USE cp_units, ONLY: cp_unit_set_create,&
22  cp_unit_set_type
24  USE input_section_types, ONLY: section_type,&
26  section_vals_type,&
28  USE message_passing, ONLY: mp_para_env_type
29 #include "./base/base_uses.f90"
30 
31  IMPLICIT NONE
32  PRIVATE
33 
34  LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .true.
35  CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_read'
36 
38 
39 CONTAINS
40 
41 ! **************************************************************************************************
42 !> \brief reads the cp2k input from the given filepath and returns a section_vals
43 !> containing the input
44 !> \param input_declaration ...
45 !> \param file_path path where the input should be read
46 !> \param initial_variables ...
47 !> \param para_env ...
48 !> \return ...
49 !> \author fawzi
50 ! **************************************************************************************************
51  FUNCTION read_input(input_declaration, file_path, initial_variables, para_env) RESULT(res)
52  TYPE(section_type), POINTER :: input_declaration
53  CHARACTER(len=*), INTENT(in) :: file_path
54  CHARACTER(len=*), DIMENSION(:, :) :: initial_variables
55  TYPE(mp_para_env_type), POINTER :: para_env
56  TYPE(section_vals_type), POINTER :: res
57 
58  CHARACTER(len=*), PARAMETER :: routinen = 'read_input'
59 
60  INTEGER :: handle
61  TYPE(cp_parser_type) :: cpparser
62  TYPE(cp_unit_set_type) :: default_units
63 
64  CALL timeset(routinen, handle)
65  NULLIFY (res)
66  CALL section_vals_create(res, input_declaration)
67  CALL parser_create(cpparser, initial_variables=initial_variables, file_name=file_path, &
68  para_env=para_env)
69  CALL cp_unit_set_create(default_units, "OUTPUT")
70  typo_match_section => input_declaration
71  CALL section_vals_parse(res, cpparser, root_section=.false., &
72  default_units=default_units)
73  typo_match_section => null()
74  CALL cp_unit_set_release(default_units)
75  CALL parser_release(cpparser)
76  CALL timestop(handle)
77  END FUNCTION read_input
78 
79 END MODULE input_cp2k_read
Utility routines to read data from files. Kept as close as possible to the old parser because.
character(len=default_path_length), dimension(2, 1:0), public empty_initial_variables
subroutine, public parser_release(parser)
releases the parser
subroutine, public parser_create(parser, file_name, unit_nr, para_env, end_section_label, separator_chars, comment_char, continuation_char, quote_char, section_char, parse_white_lines, initial_variables, apply_preprocessing)
Start a parser run. Initial variables allow to @SET stuff before opening the file.
unit conversion facility
Definition: cp_units.F:30
subroutine, public cp_unit_set_release(unit_set)
releases the given unit set
Definition: cp_units.F:1299
subroutine, public cp_unit_set_create(unit_set, name)
initializes the given unit set
Definition: cp_units.F:1228
parse cp2k input files
type(section_vals_type) function, pointer, public read_input(input_declaration, file_path, initial_variables, para_env)
reads the cp2k input from the given filepath and returns a section_vals containing the input
routines that parse the input
Definition: input_parsing.F:14
recursive subroutine, public section_vals_parse(section_vals, parser, default_units, root_section)
...
Definition: input_parsing.F:67
objects that represent the structure of input sections and the data contained in an input section
recursive subroutine, public section_vals_create(section_vals, section)
creates a object where to store the values of a section
type(section_type), pointer, save, public typo_match_section
Interface to the message passing library MPI.