Line data Source code
1 : !--------------------------------------------------------------------------------------------------!
2 : ! CP2K: A general program to perform molecular dynamics simulations !
3 : ! Copyright 2000-2025 CP2K developers group <https://cp2k.org> !
4 : ! !
5 : ! SPDX-License-Identifier: GPL-2.0-or-later !
6 : !--------------------------------------------------------------------------------------------------!
7 :
8 : ! **************************************************************************************************
9 : !> \brief Routine for sorting an array
10 : !> \note
11 : !> CP2K:
12 : !> Please use the interface defined in util.F for calling sort().
13 : !>
14 : !> DBCSR:
15 : !> Please use the interface defined in dbcsr_toollib.F for calling sort().
16 : !> \par History
17 : !> 12.2012 first version [ole]
18 : !> \author Ole Schuett
19 : ! **************************************************************************************************
20 : MODULE cp_array_sort
21 :
22 : USE kinds, ONLY: sp, dp, int_4, int_8
23 :
24 : #include "../base/base_uses.f90"
25 :
26 : #:include 'array_sort.fypp'
27 :
28 : IMPLICIT NONE
29 : PRIVATE
30 :
31 : PUBLIC :: cp_1d_s_sort, cp_1d_r_sort, cp_1d_i4_sort, cp_1d_i8_sort
32 :
33 : CONTAINS
34 :
35 0 : #:call array_sort(prefix='cp_1d_s', type='REAL(kind=sp)')
36 : #:endcall
37 :
38 0 : PURE FUNCTION cp_1d_s_less_than(a, b) RESULT(res)
39 : REAL(kind=sp), INTENT(IN) :: a, b
40 : LOGICAL :: res
41 0 : res = a < b
42 0 : END FUNCTION cp_1d_s_less_than
43 :
44 34909044609 : #:call array_sort(prefix='cp_1d_r', type='REAL(kind=dp)')
45 : #:endcall
46 :
47 15764922132 : PURE FUNCTION cp_1d_r_less_than(a, b) RESULT(res)
48 : REAL(kind=dp), INTENT(IN) :: a, b
49 : LOGICAL :: res
50 15764922132 : res = a < b
51 15764922132 : END FUNCTION cp_1d_r_less_than
52 :
53 4278716673 : #:call array_sort(prefix='cp_1d_i4', type='INTEGER(kind=int_4)')
54 : #:endcall
55 :
56 1806771735 : PURE FUNCTION cp_1d_i4_less_than(a, b) RESULT(res)
57 : INTEGER(kind=int_4), INTENT(IN) :: a, b
58 : LOGICAL :: res
59 1806771735 : res = a < b
60 1806771735 : END FUNCTION cp_1d_i4_less_than
61 :
62 147530662 : #:call array_sort(prefix='cp_1d_i8', type='INTEGER(kind=int_8)')
63 : #:endcall
64 :
65 58800012 : PURE FUNCTION cp_1d_i8_less_than(a, b) RESULT(res)
66 : INTEGER(kind=int_8), INTENT(IN) :: a, b
67 : LOGICAL :: res
68 58800012 : res = a < b
69 58800012 : END FUNCTION cp_1d_i8_less_than
70 :
71 : END MODULE cp_array_sort
|