Multidip  1.0
Multi-photon matrix elements
multidip_util.f90
Go to the documentation of this file.
1 ! Copyright 2023
2 !
3 ! For a comprehensive list of the developers that contributed to these codes
4 ! see the UK-AMOR website.
5 !
6 ! This file is part of UKRmol-out (UKRmol+ suite).
7 !
8 ! UKRmol-out is free software: you can redistribute it and/or modify
9 ! it under the terms of the GNU General Public License as published by
10 ! the Free Software Foundation, either version 3 of the License, or
11 ! (at your option) any later version.
12 !
13 ! UKRmol-out is distributed in the hope that it will be useful,
14 ! but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ! GNU General Public License for more details.
17 !
18 ! You should have received a copy of the GNU General Public License
19 ! along with UKRmol-out (in source/COPYING). Alternatively, you can also visit
20 ! <https://www.gnu.org/licenses/>.
21 !
29 
30  use precisn_gbl, only: wp
31 
32  implicit none
33 
34  interface find_column
35  procedure find_column_i
36  procedure find_column_c
37  end interface
38 
39  interface append_column
40  procedure append_column_i
41  procedure append_column_c
42  end interface
43 
44 contains
45 
46  integer function find_column_i (table, column) result (idx)
47 
48  integer, allocatable, intent(in) :: table(:, :)
49  integer, intent(in) :: column(:)
50  integer :: icol
51 
52  idx = 0
53 
54  if (allocated(table)) then
55  do icol = 1, size(table, 2)
56  if (all(table(:, icol) == column(:))) then
57  idx = icol
58  return
59  end if
60  end do
61  end if
62 
63  end function find_column_i
64 
65 
66  integer function find_column_c (table, column) result (idx)
67 
68  complex(wp), allocatable, intent(in) :: table(:, :)
69  complex(wp), intent(in) :: column(:)
70  integer :: icol
71 
72  idx = 0
73 
74  if (allocated(table)) then
75  do icol = 1, size(table, 2)
76  if (all(table(:, icol) == column(:))) then
77  idx = icol
78  return
79  end if
80  end do
81  end if
82 
83  end function find_column_c
84 
85 
86  integer function append_column_i (table, column) result (n)
87 
88  integer, allocatable, intent(inout) :: table(:, :)
89  integer, intent(in) :: column(:)
90  integer, allocatable :: old_table(:, :)
91  integer :: m
92 
93  m = size(column)
94  if (.not. allocated(table)) then
95  n = 1
96  allocate (table(m, n))
97  table(:, n) = column(:)
98  else
99  call move_alloc(table, old_table)
100  n = 1 + size(old_table, 2)
101  allocate (table(m, n))
102  table(:, 1:n-1) = old_table(:, :)
103  table(:, n) = column(:)
104  end if
105 
106  end function append_column_i
107 
108 
109  integer function append_column_c (table, column) result (n)
110 
111  complex(wp), allocatable, intent(inout) :: table(:, :)
112  complex(wp), intent(in) :: column(:)
113  complex(wp), allocatable :: old_table(:, :)
114  integer :: m
115 
116  m = size(column)
117  if (.not. allocated(table)) then
118  n = 1
119  allocate (table(m, n))
120  table(:, n) = column(:)
121  else
122  n = 1 + size(table, 2)
123  call move_alloc(table, old_table)
124  allocate (table(m, n))
125  table(:, 1:n-1) = old_table(:, :)
126  table(:, n) = column(:)
127  end if
128 
129  end function append_column_c
130 
131 end module multidip_util
Auxiliary routines.
integer function find_column_i(table, column)
integer function append_column_i(table, column)
integer function find_column_c(table, column)
integer function append_column_c(table, column)