LCOV - code coverage report
Current view: top level - src/input - cp_parser_ilist_methods.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:b279b6b) Lines: 24 26 92.3 %
Date: 2024-04-24 07:13:09 Functions: 3 3 100.0 %

          Line data    Source code
       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             : ! **************************************************************************************************
      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         614 :    SUBROUTINE ilist_setup(ilist, token)
      38             :       TYPE(ilist_type), POINTER                          :: ilist
      39             :       CHARACTER(LEN=*)                                   :: token
      40             : 
      41             :       INTEGER                                            :: ind
      42             : 
      43         614 :       CPASSERT(ASSOCIATED(ilist))
      44         614 :       ind = INDEX(token, "..")
      45         614 :       READ (UNIT=token(:ind - 1), FMT=*) ilist%istart
      46         614 :       READ (UNIT=token(ind + 2:), FMT=*) ilist%iend
      47         614 :       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         614 :       ilist%nel_list = ilist%iend - ilist%istart + 1
      53         614 :       ilist%ipresent = ilist%istart
      54         614 :       ilist%in_use = .TRUE.
      55             : 
      56         614 :    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       14276 :    SUBROUTINE ilist_update(ilist)
      65             :       TYPE(ilist_type), POINTER                          :: ilist
      66             : 
      67       14276 :       CPASSERT(ASSOCIATED(ilist))
      68       14276 :       ilist%ipresent = ilist%ipresent + 1
      69       14276 :       IF (ilist%ipresent > ilist%iend) THEN
      70           0 :          CALL ilist_reset(ilist)
      71             :       END IF
      72       14276 :    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       14890 :    SUBROUTINE ilist_reset(ilist)
      81             :       TYPE(ilist_type), POINTER                          :: ilist
      82             : 
      83       14890 :       CPASSERT(ASSOCIATED(ilist))
      84       14890 :       IF (ilist%ipresent == ilist%iend) THEN
      85         614 :          ilist%istart = HUGE(0)
      86         614 :          ilist%iend = HUGE(0)
      87         614 :          ilist%nel_list = HUGE(0)
      88         614 :          ilist%ipresent = HUGE(0)
      89         614 :          ilist%in_use = .FALSE.
      90             :       END IF
      91       14890 :    END SUBROUTINE ilist_reset
      92             : 
      93             : END MODULE cp_parser_ilist_methods

Generated by: LCOV version 1.15