LCOV - code coverage report
Current view: top level - src/input - cp_parser_inpp_types.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:11eb9ba) Lines: 29 30 96.7 %
Date: 2022-08-08 21:03:11 Functions: 2 3 66.7 %

          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_inpp_types
      18             : 
      19             :    USE kinds, ONLY: default_path_length
      20             : #include "../base/base_uses.f90"
      21             : 
      22             :    IMPLICIT NONE
      23             :    PRIVATE
      24             : 
      25             :    TYPE inpp_type
      26             :       ! for '@INCLUDE "some_file.inc"'
      27             :       ! currently open include file stack pointer
      28             :       INTEGER                              :: io_stack_level
      29             :       ! include file stack data
      30             :       INTEGER, POINTER, DIMENSION(:)       :: io_stack_channel, &
      31             :                                               io_stack_lineno
      32             :       CHARACTER(len=default_path_length), &
      33             :          POINTER, DIMENSION(:)             :: io_stack_filename
      34             :       ! for '@SET VAR value' and '${VAR}'
      35             :       ! table size
      36             :       INTEGER                              :: num_variables
      37             :       ! table entries
      38             :       CHARACTER(len=default_path_length), &
      39             :          POINTER, DIMENSION(:)       :: variable_name
      40             :       CHARACTER(len=default_path_length), &
      41             :          POINTER, DIMENSION(:)       :: variable_value
      42             :    END TYPE inpp_type
      43             : 
      44             :    PUBLIC :: inpp_type, create_inpp_type, release_inpp_type
      45             :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'cp_parser_inpp_types'
      46             : 
      47             : CONTAINS
      48             : 
      49             : ! ****************************************************************************
      50             : !> \brief creates the internal preprocessing type
      51             : !> \param inpp ...
      52             : !> \param initial_variables ...
      53             : !> \date  22.02.2008
      54             : !> \author Teodoro Laino [tlaino] - University of Zurich
      55             : ! **************************************************************************************************
      56       47083 :    SUBROUTINE create_inpp_type(inpp, initial_variables)
      57             :       TYPE(inpp_type), POINTER                           :: inpp
      58             :       CHARACTER(len=default_path_length), &
      59             :          DIMENSION(:, :), POINTER                        :: initial_variables
      60             : 
      61       47083 :       CPASSERT(.NOT. ASSOCIATED(inpp))
      62       47083 :       ALLOCATE (inpp)
      63             : 
      64       47083 :       inpp%io_stack_level = 0
      65             :       NULLIFY (inpp%io_stack_channel, &
      66       47083 :                inpp%io_stack_lineno, &
      67       47083 :                inpp%io_stack_filename)
      68             : 
      69       47083 :       inpp%num_variables = 0
      70             :       NULLIFY (inpp%variable_name, &
      71       47083 :                inpp%variable_value)
      72             : 
      73       47083 :       IF (ASSOCIATED(initial_variables)) THEN
      74          86 :          inpp%num_variables = SIZE(initial_variables, 2)
      75         258 :          ALLOCATE (inpp%variable_name(inpp%num_variables))
      76         516 :          inpp%variable_name = initial_variables(1, :)
      77         258 :          ALLOCATE (inpp%variable_value(inpp%num_variables))
      78         516 :          inpp%variable_value = initial_variables(2, :)
      79             :       END IF
      80             : 
      81       47083 :    END SUBROUTINE create_inpp_type
      82             : 
      83             : ! ****************************************************************************
      84             : !> \brief releases the internal preprocessing type
      85             : !> \param inpp ...
      86             : !> \date  22.02.2008
      87             : !> \author Teodoro Laino [tlaino] - University of Zurich
      88             : ! **************************************************************************************************
      89       47083 :    SUBROUTINE release_inpp_type(inpp)
      90             :       TYPE(inpp_type), POINTER                           :: inpp
      91             : 
      92       47083 :       CPASSERT(ASSOCIATED(inpp))
      93             : 
      94       47083 :       IF (ASSOCIATED(inpp%io_stack_channel)) THEN
      95         177 :          DEALLOCATE (inpp%io_stack_channel)
      96             :       END IF
      97       47083 :       IF (ASSOCIATED(inpp%io_stack_lineno)) THEN
      98         177 :          DEALLOCATE (inpp%io_stack_lineno)
      99             :       END IF
     100       47083 :       IF (ASSOCIATED(inpp%io_stack_filename)) THEN
     101         177 :          DEALLOCATE (inpp%io_stack_filename)
     102             :       END IF
     103             : 
     104       47083 :       IF (ASSOCIATED(inpp%variable_name)) THEN
     105         422 :          DEALLOCATE (inpp%variable_name)
     106             :       END IF
     107       47083 :       IF (ASSOCIATED(inpp%variable_value)) THEN
     108         422 :          DEALLOCATE (inpp%variable_value)
     109             :       END IF
     110             : 
     111       47083 :       DEALLOCATE (inpp)
     112       47083 :    END SUBROUTINE release_inpp_type
     113             : 
     114           0 : END MODULE cp_parser_inpp_types

Generated by: LCOV version 1.15