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 if (.not. allocated(dest)) then
92 safe_allocate_type(wfs_elec_t, dest)
93 else
94 message(1) = "Internal error: destination batch in wfs_elec_clone_to has been previously allocated."
95 call messages_fatal(1)
96 end if
97
98 select type (dest)
99 class is (wfs_elec_t)
100 call this%copy_to(dest, pack, copy_data, new_np, special, dest_type)
101 class default
102 message(1) = "Internal error: imcompatible batches in wfs_elec_clone_to."
103 call messages_fatal(1)
104 end select
105
106 pop_sub(wfs_elec_clone_to)
107 end subroutine wfs_elec_clone_to
108
110 subroutine wfs_elec_clone_to_array(this, dest, n_batches, pack, copy_data, new_np, special, dest_type)
111 class(wfs_elec_t), intent(in) :: this
112 class(batch_t), allocatable, intent(out) :: dest(:)
113 integer, intent(in) :: n_batches
114 logical, optional, intent(in) :: pack
115 logical, optional, intent(in) :: copy_data
116 integer, optional, intent(in) :: new_np
117 logical, optional, intent(in) :: special
119 type(type_t), optional, intent(in) :: dest_type
120
121 integer :: ib
122
124
125 if (.not. allocated(dest)) then
126 safe_allocate_type_array(wfs_elec_t, dest, (1:n_batches))
127 else
128 message(1) = "Internal error: destination batch in wfs_elec_clone_to_array has been previously allocated."
129 call messages_fatal(1)
130 end if
131
132 select type (dest)
133 class is (wfs_elec_t)
134 do ib = 1, n_batches
135 call this%copy_to(dest(ib), pack, copy_data, new_np, special, dest_type)
136 end do
137 class default
138 message(1) = "Internal error: incompatible batches in wfs_elec_clone_to_array."
139 call messages_fatal(1)
140 end select
144
145
147 subroutine wfs_elec_copy_to(this, dest, pack, copy_data, new_np, special, dest_type)
148 class(wfs_elec_t), intent(in) :: this
149 class(batch_t), intent(out) :: dest
150 logical, optional, intent(in) :: pack
151 logical, optional, intent(in) :: copy_data
152 integer, optional, intent(in) :: new_np
153 logical, optional, intent(in) :: special
154 type(type_t), optional, intent(in) :: dest_type
158 select type (dest)
159 class is (wfs_elec_t)
160 dest%ik = this%ik
161 dest%has_phase = this%has_phase
162 call this%batch_t%copy_to(dest%batch_t, pack, copy_data, new_np, special=special, dest_type=dest_type)
163 class default
164 message(1) = "Internal error: incompatible batches in wfs_elec_copy_to."
165 call messages_fatal(1)
166 end select
167
168 pop_sub(wfs_elec_copy_to)
169 end subroutine wfs_elec_copy_to
170
172 subroutine wfs_elec_copy_data_to(this, np, dest, async)
173 class(wfs_elec_t), intent(in) :: this
174 integer, intent(in) :: np
175 class(batch_t), intent(inout) :: dest
176 logical, optional, intent(in) :: async
177
178 push_sub(wfs_elec_copy_data_to)
179
180 select type (dest)
181 class is (wfs_elec_t)
182 dest%ik = this%ik
183 dest%has_phase = this%has_phase
184 call this%batch_t%copy_data_to(np, dest%batch_t, async)
185 class default
186 message(1) = "Internal error: incompatible batches in wfs_elec_copy_data_to."
187 call messages_fatal(1)
188 end select
189
190 pop_sub(wfs_elec_copy_data_to)
191 end subroutine wfs_elec_copy_data_to
192
193 !--------------------------------------------------------------
198 subroutine wfs_elec_check_compatibility_with(this, target, only_check_dim, type_check)
199 class(wfs_elec_t), intent(in) :: this
200 class(batch_t), intent(in) :: target
201 logical, optional, intent(in) :: only_check_dim
202 logical, optional, intent(in) :: type_check
203
206 select type (target)
207 class is (wfs_elec_t)
208 assert(this%ik == target%ik)
209 assert(this%has_phase .eqv. target%has_phase)
210 class default
211 message(1) = "Internal error: imcompatible batches in wfs_elec_check_compatibility_with."
212 call messages_fatal(1)
213 end select
214 call this%batch_t%check_compatibility_with(target, only_check_dim, type_check)
215
218
219 !--------------------------------------------------------------
221 !
222 subroutine wfs_elec_end(this, copy)
223 class(wfs_elec_t), intent(inout) :: this
224 logical, optional, intent(in) :: copy
225
226 push_sub(wfs_elec_end)
227
228 this%ik = -1
229 this%has_phase = .false.
230 call this%batch_t%end(copy)
231
232 pop_sub(wfs_elec_end)
233 end subroutine wfs_elec_end
234
235
236#include "real.F90"
237#include "wfs_elec_inc.F90"
238#include "undef.F90"
239
240#include "complex.F90"
241#include "wfs_elec_inc.F90"
242#include "undef.F90"
243
244end module wfs_elec_oct_m
245
246!! Local Variables:
247!! mode: f90
248!! coding: utf-8
249!! 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:161
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
Definition: messages.F90:409
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:570
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:380
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:206
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:546
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:402
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:243
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:268
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:426
subroutine wfs_elec_end(this, copy)
finalze the object and the contained batch
Definition: wfs_elec.F90:318
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:294
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:524
Class defining batches of mesh functions.
Definition: batch.F90:161
batches of electronic states
Definition: wfs_elec.F90:141