LCOV - code coverage report
Current view: top level - src/input - cp_parser_ilist_methods.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:f515968) Lines: 24 26 92.3 %
Date: 2022-07-03 19:52:34 Functions: 3 3 100.0 %

          Line data    Source code
       1             : !--------------------------------------------------------------------------------------------------!
       2             : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3             : !   Copyright 2000-2022 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             : ! **************************************************************************************************
      17             : MODULE cp_parser_ilist_methods
      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             : 
      25             :    PUBLIC :: ilist_setup, ilist_update, ilist_reset
      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         598 :    SUBROUTINE ilist_setup(ilist, token)
      38             :       TYPE(ilist_type), POINTER                          :: ilist
      39             :       CHARACTER(LEN=*)                                   :: token
      40             : 
      41             :       INTEGER                                            :: ind
      42             : 
      43         598 :       CPASSERT(ASSOCIATED(ilist))
      44         598 :       ind = INDEX(token, "..")
      45         598 :       READ (UNIT=token(:ind - 1), FMT=*) ilist%istart
      46         598 :       READ (UNIT=token(ind + 2:), FMT=*) ilist%iend
      47         598 :       IF (ilist%istart > ilist%iend) &
      48             :          CALL cp_abort(__LOCATION__, &
      49             :                        "Invalid list range specified: "// &
      50             :                        TRIM(ADJUSTL(cp_to_string(ilist%istart)))//".."// &
      51           0 :                        TRIM(ADJUSTL(cp_to_string(ilist%iend))))
      52         598 :       ilist%nel_list = ilist%iend - ilist%istart + 1
      53         598 :       ilist%ipresent = ilist%istart
      54         598 :       ilist%in_use = .TRUE.
      55             : 
      56         598 :    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       14162 :    SUBROUTINE ilist_update(ilist)
      65             :       TYPE(ilist_type), POINTER                          :: ilist
      66             : 
      67       14162 :       CPASSERT(ASSOCIATED(ilist))
      68       14162 :       ilist%ipresent = ilist%ipresent + 1
      69       14162 :       IF (ilist%ipresent > ilist%iend) THEN
      70           0 :          CALL ilist_reset(ilist)
      71             :       END IF
      72       14162 :    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       14760 :    SUBROUTINE ilist_reset(ilist)
      81             :       TYPE(ilist_type), POINTER                          :: ilist
      82             : 
      83       14760 :       CPASSERT(ASSOCIATED(ilist))
      84       14760 :       IF (ilist%ipresent == ilist%iend) THEN
      85         598 :          ilist%istart = HUGE(0)
      86         598 :          ilist%iend = HUGE(0)
      87         598 :          ilist%nel_list = HUGE(0)
      88         598 :          ilist%ipresent = HUGE(0)
      89         598 :          ilist%in_use = .FALSE.
      90             :       END IF
      91       14760 :    END SUBROUTINE ilist_reset
      92             : 
      93             : END MODULE cp_parser_ilist_methods

Generated by: LCOV version 1.15