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, &
37
45 !
46 type, extends(batch_t) :: wfs_elec_t
47 private
48 integer, public :: ik
52 logical, public :: has_phase
56 contains
57 procedure :: clone_to => wfs_elec_clone_to
58 procedure :: clone_to_array => wfs_elec_clone_to_array
59 procedure :: copy_to => wfs_elec_copy_to
60 procedure :: copy_data_to => wfs_elec_copy_data_to
61 procedure :: check_compatibility_with => wfs_elec_check_compatibility_with
62 procedure :: end => wfs_elec_end
63 end type wfs_elec_t
64
65 !--------------------------------------------------------------
66 interface wfs_elec_init
67 module procedure dwfs_elec_init_with_memory_3
68 module procedure zwfs_elec_init_with_memory_3
69 module procedure dwfs_elec_init_with_memory_2
70 module procedure zwfs_elec_init_with_memory_2
71 end interface wfs_elec_init
72
73contains
74
75 !--------------------------------------------------------------
79 subroutine wfs_elec_clone_to(this, dest, pack, copy_data, new_np, special, dest_type)
80 class(wfs_elec_t), intent(in) :: this
81 class(batch_t), allocatable, intent(out) :: dest
82 logical, optional, intent(in) :: pack
83 logical, optional, intent(in) :: copy_data
84 integer, optional, intent(in) :: new_np
85 logical, optional, intent(in) :: special
87 type(type_t), optional, intent(in) :: dest_type
88
89 push_sub(wfs_elec_clone_to)
90
91 safe_allocate_type(wfs_elec_t, dest)
92
93 select type (dest)
94 class is (wfs_elec_t)
95 call this%copy_to(dest, pack, copy_data, new_np, special, dest_type)
96 class default
97 message(1) = "Internal error: imcompatible batches in wfs_elec_clone_to."
98 call messages_fatal(1)
99 end select
100
101 pop_sub(wfs_elec_clone_to)
102 end subroutine wfs_elec_clone_to
103
105 subroutine wfs_elec_clone_to_array(this, dest, n_batches, pack, copy_data, new_np, special, dest_type)
106 class(wfs_elec_t), intent(in) :: this
107 class(batch_t), allocatable, intent(out) :: dest(:)
108 integer, intent(in) :: n_batches
109 logical, optional, intent(in) :: pack
110 logical, optional, intent(in) :: copy_data
111 integer, optional, intent(in) :: new_np
112 logical, optional, intent(in) :: special
114 type(type_t), optional, intent(in) :: dest_type
115
116 integer :: ib
117
119
120 assert(n_batches > 0)
121
122 safe_allocate_type_array(wfs_elec_t, dest, (1:n_batches))
123
124 select type (dest)
125 class is (wfs_elec_t)
126 do ib = 1, n_batches
127 call this%copy_to(dest(ib), pack, copy_data, new_np, special, dest_type)
128 end do
129 class default
130 message(1) = "Internal error: incompatible batches in wfs_elec_clone_to_array."
131 call messages_fatal(1)
132 end select
133
135 end subroutine wfs_elec_clone_to_array
136
137
139 subroutine wfs_elec_copy_to(this, dest, pack, copy_data, new_np, special, dest_type)
140 class(wfs_elec_t), intent(in) :: this
141 class(batch_t), intent(out) :: dest
142 logical, optional, intent(in) :: pack
143 logical, optional, intent(in) :: copy_data
144 integer, optional, intent(in) :: new_np
145 logical, optional, intent(in) :: special
146 type(type_t), optional, intent(in) :: dest_type
148 push_sub(wfs_elec_copy_to)
149
150 select type (dest)
151 class is (wfs_elec_t)
152 dest%ik = this%ik
153 dest%has_phase = this%has_phase
154 call this%batch_t%copy_to(dest%batch_t, pack, copy_data, new_np, special=special, dest_type=dest_type)
155 class default
156 message(1) = "Internal error: incompatible batches in wfs_elec_copy_to."
158 end select
159
160 pop_sub(wfs_elec_copy_to)
161 end subroutine wfs_elec_copy_to
162
164 subroutine wfs_elec_copy_data_to(this, np, dest, async)
165 class(wfs_elec_t), intent(in) :: this
166 integer, intent(in) :: np
167 class(batch_t), intent(inout) :: dest
168 logical, optional, intent(in) :: async
169
170 push_sub(wfs_elec_copy_data_to)
171
172 select type (dest)
173 class is (wfs_elec_t)
174 dest%ik = this%ik
175 dest%has_phase = this%has_phase
176 call this%batch_t%copy_data_to(np, dest%batch_t, async)
177 class default
178 message(1) = "Internal error: incompatible batches in wfs_elec_copy_data_to."
179 call messages_fatal(1)
180 end select
181
182 pop_sub(wfs_elec_copy_data_to)
183 end subroutine wfs_elec_copy_data_to
184
185 !--------------------------------------------------------------
190 subroutine wfs_elec_check_compatibility_with(this, target, only_check_dim, type_check)
191 class(wfs_elec_t), intent(in) :: this
192 class(batch_t), intent(in) :: target
193 logical, optional, intent(in) :: only_check_dim
194 logical, optional, intent(in) :: type_check
195
197
198 select type (target)
199 class is (wfs_elec_t)
200 assert(this%ik == target%ik)
201 assert(this%has_phase .eqv. target%has_phase)
202 class default
203 message(1) = "Internal error: imcompatible batches in wfs_elec_check_compatibility_with."
204 call messages_fatal(1)
205 end select
206 call this%batch_t%check_compatibility_with(target, only_check_dim, type_check)
207
210
211 !--------------------------------------------------------------
213 !
214 subroutine wfs_elec_end(this, copy)
215 class(wfs_elec_t), intent(inout) :: this
216 logical, optional, intent(in) :: copy
217
218 push_sub(wfs_elec_end)
219
220 this%ik = -1
221 this%has_phase = .false.
222 call this%batch_t%end(copy)
223
224 pop_sub(wfs_elec_end)
225 end subroutine wfs_elec_end
226
227
228#include "real.F90"
229#include "wfs_elec_inc.F90"
230#include "undef.F90"
231
232#include "complex.F90"
233#include "wfs_elec_inc.F90"
234#include "undef.F90"
235
236end module wfs_elec_oct_m
237
238!! Local Variables:
239!! mode: f90
240!! coding: utf-8
241!! 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:562
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:175
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:372
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:201
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:538
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:394
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:235
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:260
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:418
subroutine wfs_elec_end(this, copy)
finalze the object and the contained batch
Definition: wfs_elec.F90:310
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:286
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:516
Class defining batches of mesh functions.
Definition: batch.F90:161
batches of electronic states
Definition: wfs_elec.F90:141