Octopus
calc_mode_par.F90
Go to the documentation of this file.
1!! Copyright (C) 2002-2024 M. Marques, A. Castro, A. Rubio, G. Bertsch, A. Buccheri
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
30 use debug_oct_m
31 use global_oct_m
32
33 implicit none
34
35 private
36 public :: &
39
41 integer, public, parameter :: &
42 P_STRATEGY_SERIAL = 0, & !< single domain, all states, k-points on a single processor
43 p_strategy_domains = 1, &
44 p_strategy_states = 2, &
45 p_strategy_kpoints = 3, &
46 p_strategy_other = 4, &
48
49 integer, parameter :: default_parallelization_mask = ior(ibset(p_strategy_serial, p_strategy_domains - 1), &
50 ibset(p_strategy_serial, p_strategy_kpoints - 1))
51
72 private
73 integer :: par_mask = default_parallelization_mask
74 integer :: def_par_mask = default_parallelization_mask
75 logical :: scalapack_compat_ = .false.
76 contains
77 procedure :: set_parallelization => calc_mode_par_set_parallelization
78 procedure :: unset_parallelization => calc_mode_par_unset_parallelization
79 procedure :: set_scalapack_compat => calc_mode_par_set_scalapack_compat
80 procedure :: scalapack_compat => calc_mode_par_scalapack_compat
81 procedure :: parallel_mask => calc_mode_par_parallel_mask
82 procedure :: default_parallel_mask => calc_mode_par_default_parallel_mask
83 end type calc_mode_par_t
84
86 type(calc_mode_par_t) :: calc_mode_par
87
88contains
89
91 subroutine calc_mode_par_set_parallelization(this, par, default)
92 class(calc_mode_par_t), intent(inout) :: this
93 integer, intent(in) :: par
94 logical, intent(in) :: default
95
97
98 this%par_mask = ibset(this%par_mask, par - 1)
99 if (default) this%def_par_mask = ibset(this%def_par_mask, par - 1)
100
102
104
107 subroutine calc_mode_par_unset_parallelization(this, par)
108 class(calc_mode_par_t), intent(inout) :: this
109 integer, intent(in) :: par
110
112
113 this%par_mask = ibclr(this%par_mask, par - 1)
114 this%def_par_mask = ibclr(this%def_par_mask, par - 1)
115
117
119
123 class(calc_mode_par_t), intent(inout) :: this
124
126
127 this%scalapack_compat_ = .true.
128
130
132
135 logical pure function calc_mode_par_scalapack_compat(this) result(compat)
136 class(calc_mode_par_t), intent(in) :: this
137
138 compat = this%scalapack_compat_
139
141
143 integer pure function calc_mode_par_parallel_mask(this) result(par_mask)
144 class(calc_mode_par_t), intent(in) :: this
145
146 par_mask = this%par_mask
147
148 end function calc_mode_par_parallel_mask
149
153 integer pure function calc_mode_par_default_parallel_mask(this) result(par_mask)
154 class(calc_mode_par_t), intent(in) :: this
155
156 par_mask = this%def_par_mask
157
159
160end module calc_mode_par_oct_m
161
162!! Local Variables:
163!! mode: f90
164!! coding: utf-8
165!! End:
This module handles the calculation mode.
integer, parameter, public p_strategy_max
subroutine calc_mode_par_set_scalapack_compat(this)
Set that the current run mode requires division of states and domains to be compatible with scalapack...
subroutine calc_mode_par_set_parallelization(this, par, default)
Add a parallelization strategy to the list of possible ones.
integer, parameter, public p_strategy_kpoints
parallelization in k-points
integer, parameter, public p_strategy_other
something else like e-h pairs
logical pure function calc_mode_par_scalapack_compat(this)
Get whether the current run mode requires division of states and domains to be compatible with scalap...
integer pure function calc_mode_par_parallel_mask(this)
Get parallel mask.
integer, parameter, public p_strategy_domains
parallelization in domains
type(calc_mode_par_t), public calc_mode_par
Singleton instance of parallel calculation mode.
integer pure function calc_mode_par_default_parallel_mask(this)
Get the default parallel mask used for a calculation.
subroutine calc_mode_par_unset_parallelization(this, par)
Remove a parallelization strategy from the list of possible ones. It will also be removed from the de...
integer, parameter, public p_strategy_states
parallelization in states
Octopus Parallelization modes, stored concurrently in a bit representation.
int true(void)