(git:374b731)
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-2024 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) &
65 CALL cp_abort(__location__, &
66 "section "//trim(section%name)//" does not contain keyword "// &
67 "_DEFAULT_KEYWORD_")
68
69 DO
70 IF (SIZE(rng_section%values, 2) == 1) EXIT
71 CALL section_vals_add_values(rng_section)
72 END DO
73
74 vals => rng_section%values(ik, 1)%list
75 nlist = 0
76
77 IF (ASSOCIATED(vals)) THEN
78 nlist = cp_sll_val_get_length(vals)
79 END IF
80
81 DO irk = 1, nsize
82
83 CALL ascii_to_string(ascii(:, irk), rng_record)
84 CALL val_create(val=my_val, lc_val=rng_record)
85
86 IF (nlist /= 0) THEN
87 IF (irk == 1) THEN
88 new_pos => vals
89 ELSE
90 new_pos => new_pos%rest
91 END IF
92 old_val => new_pos%first_el
93 CALL val_release(old_val)
94 new_pos%first_el => my_val
95 ELSE
96 IF (irk == 1) THEN
97 NULLIFY (new_pos)
98 CALL cp_sll_val_create(new_pos, first_el=my_val)
99 vals => new_pos
100 ELSE
101 NULLIFY (new_pos%rest)
102 CALL cp_sll_val_create(new_pos%rest, first_el=my_val)
103 new_pos => new_pos%rest
104 END IF
105 END IF
106
107 NULLIFY (my_val)
108
109 END DO
110
111 rng_section%values(ik, 1)%list => vals
112
113 END SUBROUTINE section_rng_val_set
114
115END 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