Octopus
states_elec_group.F90
Go to the documentation of this file.
1!! Copyright (C) 2002-2006 M. Marques, A. Castro, A. Rubio, G. Bertsch
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
22
24 use batch_oct_m
25 use debug_oct_m
26 use global_oct_m
31 use mpi_oct_m
32
33 implicit none
34
35 private
36
37 public :: &
41
50 !
52 ! Components are public by default
53 type(wfs_elec_t), allocatable :: psib(:, :)
54 integer :: nblocks
55 integer :: block_start
56 integer :: block_end
57 integer, allocatable :: iblock(:)
58 integer, allocatable :: block_range(:, :)
59 integer, allocatable :: block_size(:)
60 logical, allocatable :: block_is_local(:, :)
61 integer, allocatable :: block_node(:)
62 type(MPI_Win), allocatable :: rma_win(:, :)
64 logical :: block_initialized = .false.
65 end type states_elec_group_t
66
67contains
68
69 ! ---------------------------------------------------------
71 !
72 subroutine states_elec_group_end(this, d)
73 type(states_elec_group_t), intent(inout) :: this
74 type(states_elec_dim_t), intent(in) :: d
75
76 integer :: ib, iq
77
78 push_sub(states_elec_group_end)
79
80 if (this%block_initialized) then
81 do ib = 1, this%nblocks
82 do iq = d%kpt%start, d%kpt%end
83 if (this%block_is_local(ib, iq)) then
84 call this%psib(ib, iq)%end()
85 end if
86 end do
87 end do
88
89 safe_deallocate_a(this%psib)
90
91 safe_deallocate_a(this%iblock)
92 safe_deallocate_a(this%block_range)
93 safe_deallocate_a(this%block_size)
94 safe_deallocate_a(this%block_is_local)
95 safe_deallocate_a(this%block_node)
96 this%block_initialized = .false.
97 end if
98
100 end subroutine states_elec_group_end
101
102 !---------------------------------------------------------
104 !
105 subroutine states_elec_group_copy(d, group_in, group_out, copy_data, special)
106 type(states_elec_dim_t), intent(in) :: d
107 type(states_elec_group_t), intent(in) :: group_in
108 type(states_elec_group_t), intent(inout) :: group_out
109 logical, optional, intent(in) :: copy_data
110 logical, optional, intent(in) :: special
111
112 integer :: qn_start, qn_end, ib, iqn
113
114 push_sub(states_elec_group_copy)
115
116 call states_elec_group_end(group_out, d)
117
118 group_out%nblocks = group_in%nblocks
119 group_out%block_start = group_in%block_start
120 group_out%block_end = group_in%block_end
121 group_out%block_initialized = group_in%block_initialized
122
123 if (group_out%block_initialized) then
124
125 assert(allocated(group_in%psib))
126
127 qn_start = d%kpt%start
128 qn_end = d%kpt%end
129
130 safe_allocate(group_out%psib(1:group_out%nblocks, qn_start:qn_end))
131
132 do iqn = qn_start, qn_end
133 do ib = group_out%block_start, group_out%block_end
134 call group_in%psib(ib, iqn)%copy_to(group_out%psib(ib, iqn), &
135 copy_data = optional_default(copy_data, .true.), special = special)
136 end do
137 end do
138
139 safe_allocate_source_a(group_out%iblock, group_in%iblock)
140 safe_allocate_source_a(group_out%block_range, group_in%block_range)
141 safe_allocate_source_a(group_out%block_size, group_in%block_size)
142 safe_allocate_source_a(group_out%block_is_local, group_in%block_is_local)
143 safe_allocate_source_a(group_out%block_node, group_in%block_node)
144 safe_allocate_source_a(group_out%rma_win, group_in%rma_win)
145
146 end if
154!! Local Variables:
155!! mode: f90
156!! coding: utf-8
157!! End:
This module implements batches of mesh functions.
Definition: batch.F90:133
This module handles spin dimensions of the states and the k-point distribution.
This module handles groups of electronic batches and their parallel distribution.
subroutine, public states_elec_group_copy(d, group_in, group_out, copy_data, special)
make a copy of a group
subroutine, public states_elec_group_end(this, d)
finalize the local blocks of wave functions and release local arrays
int true(void)