(git:98357aa)
Loading...
Searching...
No Matches
input_restart_rng.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
16 USE input_val_types, ONLY: val_create,&
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
31CONTAINS
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 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 cpassert(ASSOCIATED(rng_section))
56 cpassert(rng_section%ref_count > 0)
57
58 NULLIFY (my_val, old_val, section, vals)
59
60 section => rng_section%section
61
62 ik = section_get_keyword_index(section, "_DEFAULT_KEYWORD_")
63
64 IF (ik == -2) THEN
65 CALL cp_abort(__location__, &
66 "section "//trim(section%name)//" does not contain keyword "// &
67 "_DEFAULT_KEYWORD_")
68 END IF
69
70 DO
71 IF (SIZE(rng_section%values, 2) == 1) EXIT
72 CALL section_vals_add_values(rng_section)
73 END DO
74
75 vals => rng_section%values(ik, 1)%list
76 nlist = 0
77
78 IF (ASSOCIATED(vals)) THEN
79 nlist = cp_sll_val_get_length(vals)
80 END IF
81
82 DO irk = 1, nsize
83
84 CALL ascii_to_string(ascii(:, irk), rng_record)
85 CALL val_create(val=my_val, lc_val=rng_record)
86
87 IF (nlist /= 0) THEN
88 IF (irk == 1) THEN
89 new_pos => vals
90 ELSE
91 new_pos => new_pos%rest
92 END IF
93 old_val => new_pos%first_el
94 CALL val_release(old_val)
95 new_pos%first_el => my_val
96 ELSE
97 IF (irk == 1) THEN
98 NULLIFY (new_pos)
99 CALL cp_sll_val_create(new_pos, first_el=my_val)
100 vals => new_pos
101 ELSE
102 NULLIFY (new_pos%rest)
103 CALL cp_sll_val_create(new_pos%rest, first_el=my_val)
104 new_pos => new_pos%rest
105 END IF
106 END IF
107
108 NULLIFY (my_val)
109
110 END DO
111
112 rng_section%values(ik, 1)%list => vals
113
114 END SUBROUTINE section_rng_val_set
115
116END MODULE input_restart_rng
integer function, public cp_sll_val_get_length(sll)
returns the length of the list
subroutine, public cp_sll_val_create(sll, first_el, rest)
allocates and initializes a single linked list
subroutine, public section_rng_val_set(rng_section, nsize, ascii)
routine to dump rngs.. fast implementation
objects that represent the structure of input sections and the data contained in an input section
integer function, public section_get_keyword_index(section, keyword_name)
returns the index of the requested keyword (or -2 if not found)
subroutine, public section_vals_add_values(section_vals)
adds the place to store the values of a repetition of the section
a wrapper for basic fortran types.
subroutine, public val_create(val, l_val, l_vals, l_vals_ptr, i_val, i_vals, i_vals_ptr, r_val, r_vals, r_vals_ptr, c_val, c_vals, c_vals_ptr, lc_val, lc_vals, lc_vals_ptr, enum)
creates a keyword value
subroutine, public val_release(val)
releases the given val
Parallel (pseudo)random number generator (RNG) for multiple streams and substreams of random numbers.
integer, parameter, public rng_record_length
Utilities for string manipulations.
subroutine, public ascii_to_string(nascii, string)
Convert a sequence of integer numbers (ASCII code) to a string. Blanks are inserted for invalid ASCII...
represent a single linked list that stores pointers to the elements
represent a section of the input file
a type to have a wrapper that stores any basic fortran type