Octopus
wfs_elec.F90
Go to the documentation of this file.
1!! Copyright (C) 2019 M. Oliveira
2!!
3!! This program is free software; you can redistribute it and/or modify
4!! it under the terms of the GNU General Public License as published by
5!! the Free Software Foundation; either version 2, or (at your option)
6!! any later version.
7!!
8!! This program is distributed in the hope that it will be useful,
9!! but WITHOUT ANY WARRANTY; without even the implied warranty of
10!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11!! GNU General Public License for more details.
12!!
13!! You should have received a copy of the GNU General Public License
14!! along with this program; if not, write to the Free Software
15!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16!! 02110-1301, USA.
17!!
18
19#include "global.h"
20
21module wfs_elec_oct_m
22 use batch_oct_m
23 use debug_oct_m
24 use global_oct_m
27 use types_oct_m
28
29 implicit none
30
31 private
32 public :: &
33 wfs_elec_t, &
39
47 !
48 type, extends(batch_t) :: wfs_elec_t
49 private
50 integer, public :: ik
54 logical, public :: has_phase
58 contains
59 procedure :: clone_to => wfs_elec_clone_to
60 procedure :: clone_to_array => wfs_elec_clone_to_array
61 procedure :: copy_to => wfs_elec_copy_to
62 procedure :: copy_data_to => wfs_elec_copy_data_to
63 procedure :: check_compatibility_with => wfs_elec_check_compatibility_with
64 procedure :: end => wfs_elec_end
65 end type wfs_elec_t
66
67 !--------------------------------------------------------------
68 interface wfs_elec_init
69 module procedure dwfs_elec_init_with_memory_3
70 module procedure zwfs_elec_init_with_memory_3
71 module procedure swfs_elec_init_with_memory_3
72 module procedure cwfs_elec_init_with_memory_3
73 module procedure dwfs_elec_init_with_memory_2
74 module procedure zwfs_elec_init_with_memory_2
75 module procedure swfs_elec_init_with_memory_2
76 module procedure cwfs_elec_init_with_memory_2
77 end interface wfs_elec_init
78
79contains
80
81 !--------------------------------------------------------------
85 subroutine wfs_elec_clone_to(this, dest, pack, copy_data, new_np, special, dest_type)
86 class(wfs_elec_t), intent(in) :: this
87 class(batch_t), allocatable, intent(out) :: dest
88 logical, optional, intent(in) :: pack
89 logical, optional, intent(in) :: copy_data
90 integer, optional, intent(in) :: new_np
91 logical, optional, intent(in) :: special
93 type(type_t), optional, intent(in) :: dest_type
94
95 push_sub(wfs_elec_clone_to)
96
97 safe_allocate_type(wfs_elec_t, dest)
98
99 select type (dest)
100 class is (wfs_elec_t)
101 call this%copy_to(dest, pack, copy_data, new_np, special, dest_type)
102 class default
103 message(1) = "Internal error: imcompatible batches in wfs_elec_clone_to."
104 call messages_fatal(1)
105 end select
106
107 pop_sub(wfs_elec_clone_to)
108 end subroutine wfs_elec_clone_to
109
111 subroutine wfs_elec_clone_to_array(this, dest, n_batches, pack, copy_data, new_np, special, dest_type)
112 class(wfs_elec_t), intent(in) :: this
113 class(batch_t), allocatable, intent(out) :: dest(:)
114 integer, intent(in) :: n_batches
115 logical, optional, intent(in) :: pack
116 logical, optional, intent(in) :: copy_data
117 integer, optional, intent(in) :: new_np
118 logical, optional, intent(in) :: special
120 type(type_t), optional, intent(in) :: dest_type
121
122 integer :: ib
123
125
126 assert(n_batches > 0)
127
128 safe_allocate_type_array(wfs_elec_t, dest, (1:n_batches))
129
130 select type (dest)
131 class is (wfs_elec_t)
132 do ib = 1, n_batches
133 call this%copy_to(dest(ib), pack, copy_data, new_np, special, dest_type)
134 end do
135 class default
136 message(1) = "Internal error: incompatible batches in wfs_elec_clone_to_array."
137 call messages_fatal(1)
138 end select
139
141 end subroutine wfs_elec_clone_to_array
142
145 subroutine wfs_elec_copy_to(this, dest, pack, copy_data, new_np, special, dest_type)
146 class(wfs_elec_t), intent(in) :: this
147 class(batch_t), intent(out) :: dest
148 logical, optional, intent(in) :: pack
149 logical, optional, intent(in) :: copy_data
150 integer, optional, intent(in) :: new_np
151 logical, optional, intent(in) :: special
152 type(type_t), optional, intent(in) :: dest_type
153
156 select type (dest)
157 class is (wfs_elec_t)
158 dest%ik = this%ik
159 dest%has_phase = this%has_phase
160 call this%batch_t%copy_to(dest%batch_t, pack, copy_data, new_np, special=special, dest_type=dest_type)
161 class default
162 message(1) = "Internal error: incompatible batches in wfs_elec_copy_to."
164 end select
165
166 pop_sub(wfs_elec_copy_to)
167 end subroutine wfs_elec_copy_to
168
170 subroutine wfs_elec_copy_data_to(this, np, dest, async)
171 class(wfs_elec_t), intent(in) :: this
172 integer, intent(in) :: np
173 class(batch_t), intent(inout) :: dest
174 logical, optional, intent(in) :: async
175
176 push_sub(wfs_elec_copy_data_to)
177
178 select type (dest)
179 class is (wfs_elec_t)
180 dest%ik = this%ik
181 dest%has_phase = this%has_phase
182 call this%batch_t%copy_data_to(np, dest%batch_t, async)
183 class default
184 message(1) = "Internal error: incompatible batches in wfs_elec_copy_data_to."
185 call messages_fatal(1)
186 end select
187
188 pop_sub(wfs_elec_copy_data_to)
189 end subroutine wfs_elec_copy_data_to
190
191 !--------------------------------------------------------------
196 subroutine wfs_elec_check_compatibility_with(this, target, only_check_dim, type_check)
197 class(wfs_elec_t), intent(in) :: this
198 class(batch_t), intent(in) :: target
199 logical, optional, intent(in) :: only_check_dim
200 logical, optional, intent(in) :: type_check
201
203
204 select type (target)
205 class is (wfs_elec_t)
206 assert(this%ik == target%ik)
207 assert(this%has_phase .eqv. target%has_phase)
208 class default
209 message(1) = "Internal error: imcompatible batches in wfs_elec_check_compatibility_with."
210 call messages_fatal(1)
211 end select
212 call this%batch_t%check_compatibility_with(target, only_check_dim, type_check)
213
216
217 !--------------------------------------------------------------
219 !
220 subroutine wfs_elec_end(this, copy)
221 class(wfs_elec_t), intent(inout) :: this
222 logical, optional, intent(in) :: copy
223
224 push_sub(wfs_elec_end)
225
226 this%ik = -1
227 this%has_phase = .false.
228 call this%batch_t%end(copy)
229
230 pop_sub(wfs_elec_end)
231 end subroutine wfs_elec_end
232
233
234#include "real.F90"
235#include "wfs_elec_inc.F90"
236#include "undef.F90"
237
238#include "complex.F90"
239#include "wfs_elec_inc.F90"
240#include "undef.F90"
241
242#include "real32.F90"
243#include "wfs_elec_inc.F90"
244#include "undef.F90"
245
246#include "complex32.F90"
247#include "wfs_elec_inc.F90"
248#include "undef.F90"
249
250end module wfs_elec_oct_m
251
252!! Local Variables:
253!! mode: f90
254!! coding: utf-8
255!! End:
This module implements batches of mesh functions.
Definition: batch.F90:135
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
Definition: messages.F90:162
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
Definition: messages.F90:410
subroutine, public zwfs_elec_init(this, dim, st_start, st_end, np, ik, special, packed)
initialize an empty wfs_elec_t object
Definition: wfs_elec.F90:568
subroutine wfs_elec_clone_to(this, dest, pack, copy_data, new_np, special, dest_type)
clone to another wfs_elec_t object
Definition: wfs_elec.F90:181
subroutine dwfs_elec_init_with_memory_3(this, dim, st_start, st_end, psi, ik)
initialize a wfs_elec_t object with given memory
Definition: wfs_elec.F90:378
subroutine, public cwfs_elec_init(this, dim, st_start, st_end, np, ik, special, packed)
initialize an empty wfs_elec_t object
Definition: wfs_elec.F90:864
subroutine wfs_elec_clone_to_array(this, dest, n_batches, pack, copy_data, new_np, special, dest_type)
Clone the data to multiple wfs_elec_t objects.
Definition: wfs_elec.F90:207
subroutine zwfs_elec_init_with_memory_2(this, dim, st_start, st_end, psi, ik)
initialize a wfs_elec_t object with given memory
Definition: wfs_elec.F90:544
subroutine dwfs_elec_init_with_memory_2(this, dim, st_start, st_end, psi, ik)
initialize a wfs_elec_t object with given memory
Definition: wfs_elec.F90:400
subroutine swfs_elec_init_with_memory_3(this, dim, st_start, st_end, psi, ik)
initialize a wfs_elec_t object with given memory
Definition: wfs_elec.F90:670
subroutine wfs_elec_copy_to(this, dest, pack, copy_data, new_np, special, dest_type)
copy a contained batch to another (existing) wfs_elec_t object
Definition: wfs_elec.F90:241
subroutine wfs_elec_copy_data_to(this, np, dest, async)
copy the data of the contained batch to another (existing) wfs_elec_t object
Definition: wfs_elec.F90:266
subroutine, public dwfs_elec_init(this, dim, st_start, st_end, np, ik, special, packed)
initialize an empty wfs_elec_t object
Definition: wfs_elec.F90:424
subroutine cwfs_elec_init_with_memory_3(this, dim, st_start, st_end, psi, ik)
initialize a wfs_elec_t object with given memory
Definition: wfs_elec.F90:818
subroutine wfs_elec_end(this, copy)
finalze the object and the contained batch
Definition: wfs_elec.F90:316
subroutine, public swfs_elec_init(this, dim, st_start, st_end, np, ik, special, packed)
initialize an empty wfs_elec_t object
Definition: wfs_elec.F90:716
subroutine swfs_elec_init_with_memory_2(this, dim, st_start, st_end, psi, ik)
initialize a wfs_elec_t object with given memory
Definition: wfs_elec.F90:692
subroutine cwfs_elec_init_with_memory_2(this, dim, st_start, st_end, psi, ik)
initialize a wfs_elec_t object with given memory
Definition: wfs_elec.F90:840
subroutine wfs_elec_check_compatibility_with(this, target, only_check_dim, type_check)
check whether the object is compatible with a target object
Definition: wfs_elec.F90:292
subroutine zwfs_elec_init_with_memory_3(this, dim, st_start, st_end, psi, ik)
initialize a wfs_elec_t object with given memory
Definition: wfs_elec.F90:522
Class defining batches of mesh functions.
Definition: batch.F90:164
batches of electronic states
Definition: wfs_elec.F90:143