LCOV - code coverage report
Current view: top level - src - input_restart_rng.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:2fce0f8) Lines: 34 35 97.1 %
Date: 2024-12-21 06:28:57 Functions: 1 1 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             : MODULE input_restart_rng
       9             :    USE cp_linked_list_input,            ONLY: cp_sll_val_create,&
      10             :                                               cp_sll_val_get_length,&
      11             :                                               cp_sll_val_type
      12             :    USE input_section_types,             ONLY: section_get_keyword_index,&
      13             :                                               section_type,&
      14             :                                               section_vals_add_values,&
      15             :                                               section_vals_type
      16             :    USE input_val_types,                 ONLY: val_create,&
      17             :                                               val_release,&
      18             :                                               val_type
      19             :    USE parallel_rng_types,              ONLY: rng_record_length
      20             :    USE string_utilities,                ONLY: ascii_to_string
      21             : #include "./base/base_uses.f90"
      22             : 
      23             :    IMPLICIT NONE
      24             : 
      25             :    PRIVATE
      26             : 
      27             :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_restart_rng'
      28             : 
      29             :    PUBLIC :: section_rng_val_set
      30             : 
      31             : CONTAINS
      32             : 
      33             : ! **************************************************************************************************
      34             : !> \brief routine to dump rngs.. fast implementation
      35             : !> \param rng_section ...
      36             : !> \param nsize ...
      37             : !> \param ascii ...
      38             : !> \par History
      39             : !>      02.2006 created [teo]
      40             : !>      - string dump (again) instead of integer ASCII code (07.03.06,MK)
      41             : !> \author Teodoro Laino
      42             : ! **************************************************************************************************
      43         596 :    SUBROUTINE section_rng_val_set(rng_section, nsize, ascii)
      44             : 
      45             :       TYPE(section_vals_type), POINTER                   :: rng_section
      46             :       INTEGER, INTENT(IN)                                :: nsize
      47             :       INTEGER, DIMENSION(:, :)                           :: ascii
      48             : 
      49             :       CHARACTER(LEN=rng_record_length)                   :: rng_record
      50             :       INTEGER                                            :: ik, irk, Nlist
      51             :       TYPE(cp_sll_val_type), POINTER                     :: new_pos, vals
      52             :       TYPE(section_type), POINTER                        :: section
      53             :       TYPE(val_type), POINTER                            :: my_val, old_val
      54             : 
      55         596 :       CPASSERT(ASSOCIATED(rng_section))
      56         596 :       CPASSERT(rng_section%ref_count > 0)
      57             : 
      58         596 :       NULLIFY (my_val, old_val, section, vals)
      59             : 
      60         596 :       section => rng_section%section
      61             : 
      62         596 :       ik = section_get_keyword_index(section, "_DEFAULT_KEYWORD_")
      63             : 
      64         596 :       IF (ik == -2) &
      65             :          CALL cp_abort(__LOCATION__, &
      66             :                        "section "//TRIM(section%name)//" does not contain keyword "// &
      67           0 :                        "_DEFAULT_KEYWORD_")
      68             : 
      69         180 :       DO
      70         776 :          IF (SIZE(rng_section%values, 2) == 1) EXIT
      71         180 :          CALL section_vals_add_values(rng_section)
      72             :       END DO
      73             : 
      74         596 :       vals => rng_section%values(ik, 1)%list
      75         596 :       Nlist = 0
      76             : 
      77         596 :       IF (ASSOCIATED(vals)) THEN
      78         416 :          Nlist = cp_sll_val_get_length(vals)
      79             :       END IF
      80             : 
      81       32112 :       DO irk = 1, nsize
      82             : 
      83       31516 :          CALL ascii_to_string(ascii(:, irk), rng_record)
      84       31516 :          CALL val_create(val=my_val, lc_val=rng_record)
      85             : 
      86       31516 :          IF (Nlist /= 0) THEN
      87       19934 :             IF (irk == 1) THEN
      88         416 :                new_pos => vals
      89             :             ELSE
      90       19518 :                new_pos => new_pos%rest
      91             :             END IF
      92       19934 :             old_val => new_pos%first_el
      93       19934 :             CALL val_release(old_val)
      94       19934 :             new_pos%first_el => my_val
      95             :          ELSE
      96       11582 :             IF (irk == 1) THEN
      97         180 :                NULLIFY (new_pos)
      98         180 :                CALL cp_sll_val_create(new_pos, first_el=my_val)
      99         180 :                vals => new_pos
     100             :             ELSE
     101       11402 :                NULLIFY (new_pos%rest)
     102       11402 :                CALL cp_sll_val_create(new_pos%rest, first_el=my_val)
     103       11402 :                new_pos => new_pos%rest
     104             :             END IF
     105             :          END IF
     106             : 
     107       32112 :          NULLIFY (my_val)
     108             : 
     109             :       END DO
     110             : 
     111         596 :       rng_section%values(ik, 1)%list => vals
     112             : 
     113         596 :    END SUBROUTINE section_rng_val_set
     114             : 
     115             : END MODULE input_restart_rng

Generated by: LCOV version 1.15