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 21!> This module uses a module-scope global object to allow calculation modes 22!! to set the available parallelization strategies and whether the layout 23!! must be compatible with ScaLAPACK, and to allow this information to be 24!! accessed elsewhere. It does not, and should not, contain the definitions 25!! of the calculation modes themselves, to avoid writing code explicitly 26!! dependent on the calculation mode elsewhere. 27module calc_mode_par_oct_m 28 use global_oct_m 29 use messages_oct_m 30 use multicomm_oct_m 31 32 implicit none 33 34 private 35 public :: & 36 calc_mode_par_t, & 37 calc_mode_par_init, & 38 calc_mode_par_end, & 39 calc_mode_par_set_parallelization, & 40 calc_mode_par_unset_parallelization, & 41 calc_mode_par_parallel_mask, & 42 calc_mode_par_default_parallel_mask, & 43 calc_mode_par_set_scalapack_compat, & 44 calc_mode_par_scalapack_compat 45 46 type calc_mode_par_t 47 private 48 integer :: par_mask 49 integer :: def_par_mask 50 logical :: scalapack_compat 51 end type calc_mode_par_t 52 53 type(calc_mode_par_t) :: this 54 55contains 56 57 ! ---------------------------------------------------------- 58 !> Set domains and kpoints as possible parallelization strategies. 59 !> Set domains as default parallelization strategy. 60 subroutine calc_mode_par_init() 61 ! no push_sub because this routine is called before everything 62 ! is fully initialized for the debugging stack 63 64 this%par_mask = 0 65 this%par_mask = ibset(this%par_mask, P_STRATEGY_DOMAINS - 1) 66 this%par_mask = ibset(this%par_mask, P_STRATEGY_KPOINTS - 1) 67 68 this%def_par_mask = 0 69 this%def_par_mask = ibset(this%def_par_mask, P_STRATEGY_DOMAINS - 1) 70 this%def_par_mask = ibset(this%def_par_mask, P_STRATEGY_KPOINTS - 1) 71 72 this%scalapack_compat = .false. 73 end subroutine calc_mode_par_init 74 75 ! ----------------------------------------------------- 76 77 subroutine calc_mode_par_end() 78 79 end subroutine calc_mode_par_end 80 81 ! ----------------------------------------------------- 82 !> Add a parallelization strategy to the list of possible ones. 83 !> Make it default also if default = .true. 84 subroutine calc_mode_par_set_parallelization(par, default) 85 integer, intent(in) :: par 86 logical, intent(in) :: default 87 88 this%par_mask = ibset(this%par_mask, par - 1) 89 if(default) this%def_par_mask = ibset(this%def_par_mask, par - 1) 90 91 end subroutine calc_mode_par_set_parallelization 92 93 ! ----------------------------------------------------- 94 !> Remove a parallelization strategy from the list of possible ones. 95 !> It will also be removed from the default. 96 subroutine calc_mode_par_unset_parallelization(par) 97 integer, intent(in) :: par 98 99 this%par_mask = ibclr(this%par_mask, par - 1) 100 this%def_par_mask = ibclr(this%def_par_mask, par - 1) 101 102 end subroutine calc_mode_par_unset_parallelization 103 104 ! ----------------------------------------------------- 105 106 !> Defines that the current run mode requires division of states 107 !! and domains to be compatible with scalapack. 108 subroutine calc_mode_par_set_scalapack_compat() 109 this%scalapack_compat = .true. 110 end subroutine calc_mode_par_set_scalapack_compat 111 112 ! ----------------------------------------------------- 113 114 !> Whether the current run mode requires divisions compatible with 115 !! scalapack. 116 logical pure function calc_mode_par_scalapack_compat() result(compat) 117 compat = this%scalapack_compat 118 end function calc_mode_par_scalapack_compat 119 120 ! ----------------------------------------------------- 121 122 integer function calc_mode_par_parallel_mask() result(par_mask) 123 PUSH_SUB(calc_mode_par_parallel_mask) 124 125 par_mask = this%par_mask 126 127 POP_SUB(calc_mode_par_parallel_mask) 128 end function calc_mode_par_parallel_mask 129 130 ! ----------------------------------------------------- 131 !> This function returns the default modes used for a calculation, 132 !! that might be different from the modes available. 133 integer function calc_mode_par_default_parallel_mask() result(par_mask) 134 PUSH_SUB(calc_mode_par_default_parallel_mask) 135 136 par_mask = this%def_par_mask 137 138 POP_SUB(calc_mode_par_default_parallel_mask) 139 end function calc_mode_par_default_parallel_mask 140 141end module calc_mode_par_oct_m 142 143!! Local Variables: 144!! mode: f90 145!! coding: utf-8 146!! End: 147