1!--------------------------------------------------------------------------------------------------! 2! CP2K: A general program to perform molecular dynamics simulations ! 3! Copyright (C) 2000 - 2019 CP2K developers group ! 4!--------------------------------------------------------------------------------------------------! 5 6! ************************************************************************************************** 7!> \brief a module to allow simple internal preprocessing in input files. 8!> \par History 9!> - standalone proof-of-concept implementation (20.02.2008,AK) 10!> - integration into cp2k (22.02.2008,tlaino) 11!> - variables added (25.02.2008,AK) 12!> \author Axel Kohlmeyer [AK] - CMM/UPenn Philadelphia 13!> \date 25.02.2008 14! ************************************************************************************************** 15MODULE cp_parser_ilist_methods 16 USE cp_log_handling, ONLY: cp_to_string 17 USE cp_parser_ilist_types, ONLY: ilist_type 18#include "../base/base_uses.f90" 19 20 IMPLICIT NONE 21 PRIVATE 22 23 PUBLIC :: ilist_setup, ilist_update, ilist_reset 24 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'cp_parser_ilist_methods' 25 26CONTAINS 27 28! **************************************************************************** 29!> \brief setup the integer listing type 30!> \param ilist ... 31!> \param token ... 32!> \date 08.2008 33!> \author Teodoro Laino [tlaino] - University of Zurich 34! ************************************************************************************************** 35 SUBROUTINE ilist_setup(ilist, token) 36 TYPE(ilist_type), POINTER :: ilist 37 CHARACTER(LEN=*) :: token 38 39 CHARACTER(len=*), PARAMETER :: routineN = 'ilist_setup', routineP = moduleN//':'//routineN 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 CHARACTER(len=*), PARAMETER :: routineN = 'ilist_update', routineP = moduleN//':'//routineN 68 69 CPASSERT(ASSOCIATED(ilist)) 70 ilist%ipresent = ilist%ipresent + 1 71 IF (ilist%ipresent > ilist%iend) THEN 72 CALL ilist_reset(ilist) 73 END IF 74 END SUBROUTINE ilist_update 75 76! **************************************************************************** 77!> \brief updates the integer listing type 78!> \param ilist ... 79!> \date 08.2008 80!> \author Teodoro Laino [tlaino] - University of Zurich 81! ************************************************************************************************** 82 SUBROUTINE ilist_reset(ilist) 83 TYPE(ilist_type), POINTER :: ilist 84 85 CHARACTER(len=*), PARAMETER :: routineN = 'ilist_reset', routineP = moduleN//':'//routineN 86 87 CPASSERT(ASSOCIATED(ilist)) 88 IF (ilist%ipresent == ilist%iend) THEN 89 ilist%istart = HUGE(0) 90 ilist%iend = HUGE(0) 91 ilist%nel_list = HUGE(0) 92 ilist%ipresent = HUGE(0) 93 ilist%in_use = .FALSE. 94 END IF 95 END SUBROUTINE ilist_reset 96 97END MODULE cp_parser_ilist_methods 98