(git:ccc2433)
cp_parser_ilist_methods.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 a module to allow simple internal preprocessing in input files.
10 !> \par History
11 !> - standalone proof-of-concept implementation (20.02.2008,AK)
12 !> - integration into cp2k (22.02.2008,tlaino)
13 !> - variables added (25.02.2008,AK)
14 !> \author Axel Kohlmeyer [AK] - CMM/UPenn Philadelphia
15 !> \date 25.02.2008
16 ! **************************************************************************************************
18  USE cp_log_handling, ONLY: cp_to_string
19  USE cp_parser_ilist_types, ONLY: ilist_type
20 #include "../base/base_uses.f90"
21 
22  IMPLICIT NONE
23  PRIVATE
24 
26  CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'cp_parser_ilist_methods'
27 
28 CONTAINS
29 
30 ! ****************************************************************************
31 !> \brief setup the integer listing type
32 !> \param ilist ...
33 !> \param token ...
34 !> \date 08.2008
35 !> \author Teodoro Laino [tlaino] - University of Zurich
36 ! **************************************************************************************************
37  SUBROUTINE ilist_setup(ilist, token)
38  TYPE(ilist_type), POINTER :: ilist
39  CHARACTER(LEN=*) :: token
40 
41  INTEGER :: ind
42 
43  cpassert(ASSOCIATED(ilist))
44  ind = index(token, "..")
45  READ (unit=token(:ind - 1), fmt=*) ilist%istart
46  READ (unit=token(ind + 2:), fmt=*) ilist%iend
47  IF (ilist%istart > ilist%iend) &
48  CALL cp_abort(__location__, &
49  "Invalid list range specified: "// &
50  trim(adjustl(cp_to_string(ilist%istart)))//".."// &
51  trim(adjustl(cp_to_string(ilist%iend))))
52  ilist%nel_list = ilist%iend - ilist%istart + 1
53  ilist%ipresent = ilist%istart
54  ilist%in_use = .true.
55 
56  END SUBROUTINE ilist_setup
57 
58 ! ****************************************************************************
59 !> \brief updates the integer listing type
60 !> \param ilist ...
61 !> \date 08.2008
62 !> \author Teodoro Laino [tlaino] - University of Zurich
63 ! **************************************************************************************************
64  SUBROUTINE ilist_update(ilist)
65  TYPE(ilist_type), POINTER :: ilist
66 
67  cpassert(ASSOCIATED(ilist))
68  ilist%ipresent = ilist%ipresent + 1
69  IF (ilist%ipresent > ilist%iend) THEN
70  CALL ilist_reset(ilist)
71  END IF
72  END SUBROUTINE ilist_update
73 
74 ! ****************************************************************************
75 !> \brief updates the integer listing type
76 !> \param ilist ...
77 !> \date 08.2008
78 !> \author Teodoro Laino [tlaino] - University of Zurich
79 ! **************************************************************************************************
80  SUBROUTINE ilist_reset(ilist)
81  TYPE(ilist_type), POINTER :: ilist
82 
83  cpassert(ASSOCIATED(ilist))
84  IF (ilist%ipresent == ilist%iend) THEN
85  ilist%istart = huge(0)
86  ilist%iend = huge(0)
87  ilist%nel_list = huge(0)
88  ilist%ipresent = huge(0)
89  ilist%in_use = .false.
90  END IF
91  END SUBROUTINE ilist_reset
92 
93 END MODULE cp_parser_ilist_methods
various routines to log and control the output. The idea is that decisions about where to log should ...
a module to allow simple internal preprocessing in input files.
subroutine, public ilist_update(ilist)
updates the integer listing type
subroutine, public ilist_setup(ilist, token)
setup the integer listing type
subroutine, public ilist_reset(ilist)
updates the integer listing type
a module to allow simple internal preprocessing in input files.