Commit 4636bca6 authored by degironc's avatar degironc

KS_Solvers directory has been created with three subdirectories:

KS_Solvers/CG, KS_Solvers/Davidson, KS_Solvers/Davidson_RCI.
Two are currently used by QE, the third one implements the Davidson
diagonalization within the Reverse Communication Interface paradigm,
courtesy of Micael Oliveira.

KS_Solvers routines depend only on lower level libraries, notably UtilXlib, 
LAXlib, (SCA)LAPACK, and BLAS.

reorganization can be improved. For instance some duplicated routines like
cdiaghg and rdiaghg could/should be moved in LAXlib. This could reduce the need
to include  KS_Solvers directories in the link step of many codes.    

Minimal changes to calling sequence have been made, essentially just adding
h_psi,s_psi,g_psi and h_1psi,s_1psi routines names as arguments (with a
specific calling sequence ihardcode inside the routines that agree with PWSCF one). 
This could be avoided adopting the RCI paradigm.

Compiled in serial and parallel, 177/182 pw tests passed (3 that were failing 
even before on my laptop pw-berry, pw-langevin, pw-pawatom + 2 unknown==not tested), 
12 /17 cp tests passed (some o2-us-para-pbe-X fail but the same was for the 
original version)

I assume the modified calling procedure is working and the problem lies somewhere else.
 
Randomly tested some examples in pw, ph, pwcond and it seams to work.

Please report any problem.





git-svn-id: http://qeforge.qe-forge.org/svn/q-e/trunk/espresso@13644 c92efa57-630b-4861-b058-cf58834340f0
parent 2d1e7794
......@@ -3,7 +3,8 @@
include ../../make.inc
# location of needed modules and included files (if any)
MODFLAGS= $(MOD_FLAG)../../iotk/src $(MOD_FLAG)../../FFTXlib $(MOD_FLAG)../../LAXlib $(MOD_FLAG)../../UtilXlib $(MOD_FLAG)../../Modules $(MOD_FLAG).
MODFLAGS= $(MOD_FLAG)../../iotk/src $(MOD_FLAG)../../FFTXlib $(MOD_FLAG)../../LAXlib $(MOD_FLAG)../../UtilXlib \
$(MOD_FLAG)../../KS_Solvers/CG $(MOD_FLAG)../../KS_Solvers/Davidson $(MOD_FLAG)../../Modules $(MOD_FLAG).
IFLAGS=
FOBJS = \
......@@ -119,7 +120,7 @@ entropy.o
QEMODS=../../Modules/libqemod.a
QEFFT=../../FFTXlib/libqefft.a
QELA=../../LAXlib/libqela.a
QELA=../../KS_Solvers/CG/libcg.a ../../KS_Solvers/Davidson/libdavid.a ../../LAXlib/libqela.a
UTIL=../../UtilXlib/libutil.a
TLDEPS= bindir mods libs libiotk
......
......@@ -25,7 +25,7 @@ subroutine bforceion(fion,tfor,ipol,qmatinv,bec0,becdr,gqq,evalue)
use ions_base, only : nax, na, nsp
use uspp_param, only: nvb, ish
use kinds, only : dp
use constants
use constants, only :
use cell_base, only: at, alat
use uspp_param, only: nh, nhm
use uspp, only : nhsa=> nkb
......
......@@ -33,7 +33,7 @@ subroutine dforceb(c0, i, betae, ipol, bec0, ctabin, gqq, gqqm, qmat, dq2, df)
use gvecw, only: ngw
use parameters
use electrons_base, only: nx => nbspx, n => nbsp, nspin, f
use constants
use constants, only :
use ions_base, only : nat, nax, na, nsp
use cell_base, only: at, alat
use uspp_param, only: nh, nhm, nvb, ish
......@@ -237,7 +237,7 @@ subroutine dforceb(c0, i, betae, ipol, bec0, ctabin, gqq, gqqm, qmat, dq2, df)
function enberry( detq, ipol )
use constants
use constants, only :
use kinds, only: dp
use cell_base, only: alat, at
USE electrons_base, ONLY : nspin
......
This diff is collapsed.
......@@ -21,7 +21,7 @@ subroutine qqberry2( gqq,gqqm, ipol)
use core
use gvecw, only: ngw
use gvect, only: mill
use constants
use constants, only: fpi
use ions_base, only: nax, na, nsp
use cell_base, only: at, alat
use gvect, only: g, gg
......
......@@ -52,7 +52,6 @@ test0.o : fft_param.o
test0.o : fft_scalar.o
test0.o : fft_support.o
test0.o : fft_types.o
fft_stick.o : ../include/c_defs.h
fft_stick.o : fftw.c
fftw.o :
fftw.o :
......@@ -8,8 +8,8 @@ IFLAGS=-I../../include
# location of needed modules
MODFLAGS= $(MOD_FLAG)../../iotk/src $(MOD_FLAG)../../Modules \
$(MOD_FLAG)../../PHonon/Gamma/ $(MOD_FLAG)../../PHonon/PH/ \
$(MOD_FLAG)../../PW/src $(MOD_FLAG)../../FFTXlib \
$(MOD_FLAG)../../LAXlib $(MOD_FLAG)../../UtilXlib $(MOD_FLAG)../pw4gww \
$(MOD_FLAG)../../PW/src $(MOD_FLAG)../../KS_Solvers/Davidson $(MOD_FLAG)../../KS_Solvers/CG \
$(MOD_FLAG)../../FFTXlib $(MOD_FLAG)../../LAXlib $(MOD_FLAG)../../UtilXlib $(MOD_FLAG)../pw4gww \
$(MOD_FLAG)../gww $(MOD_FLAG).
BSEOBJS = \
......@@ -49,7 +49,8 @@ qpcorrections.o
#zvscal_test.o\
QEMODS = ../../Modules/libqemod.a ../../FFTXlib/libqefft.a ../../LAXlib/libqela.a ../../UtilXlib/libutil.a
QEMODS = ../../Modules/libqemod.a ../../FFTXlib/libqefft.a ../../KS_Solvers/CG/libcg.a ../../KS_Solvers/Davidson/libdavid.a \
../../LAXlib/libqela.a ../../UtilXlib/libutil.a
PWOBJS = ../../PW/src/libpw.a
PW4GWWOBJ = ../pw4gww/fft_custom.o ../pw4gww/stop_pp.o ../pw4gww/mp_wave_parallel.o
GWWOBJ = ../gww/libgww.a ../minpack/minpacklib.a
......
......@@ -8,6 +8,7 @@ IFLAGS=
# location of needed modules
MODFLAGS= $(MOD_FLAG)../../iotk/src $(MOD_FLAG)../../Modules \
$(MOD_FLAG)../../KS_Solvers/CG $(MOD_FLAG)../../KS_Solvers/Davidson \
$(MOD_FLAG)../../FFTXlib $(MOD_FLAG)../../LAXlib $(MOD_FLAG)../../UtilXlib $(MOD_FLAG)../pw4gww $(MOD_FLAG).
GWWOBJS = \
......@@ -46,7 +47,8 @@ times_gw.o \
vcprim.o
QEMODS = ../../Modules/libqemod.a ../../FFTXlib/libqefft.a ../../LAXlib/libqela.a ../../UtilXlib/libutil.a
QEMODS = ../../Modules/libqemod.a ../../FFTXlib/libqefft.a \
../../KS_Solvers/CG/libcg.a ../../KS_Solvers/Davidson/libdavid.a ../../LAXlib/libqela.a ../../UtilXlib/libutil.a
LIBMIN= ../minpack/minpacklib.a
......
......@@ -10,6 +10,7 @@ IFLAGS=-I../../include
# location of needed modules
MODFLAGS= $(MOD_FLAG)../../iotk/src $(MOD_FLAG)../../Modules \
$(MOD_FLAG)../../PHonon/PH $(MOD_FLAG)../../LR_Modules $(MOD_FLAG)../../PW/src \
$(MOD_FLAG)../../KS_Solvers/CG $(MOD_FLAG)../../KS_Solvers/Davidson \
$(MOD_FLAG)../../LAXlib $(MOD_FLAG)../../FFTXlib $(MOD_FLAG)../../UtilXlib $(MOD_FLAG).
HEADOBJS = \
......@@ -20,7 +21,8 @@ openfilq.o \
phq_readin.o \
solve_head.o
QEMODS = ../../Modules/libqemod.a ../../FFTXlib/libqefft.a ../../LAXlib/libqela.a ../../UtilXlib/libutil.a
QEMODS = ../../Modules/libqemod.a ../../KS_Solvers/CG/libcg.a ../../KS_Solvers/Davidson/libdavid.a \
../../FFTXlib/libqefft.a ../../LAXlib/libqela.a ../../UtilXlib/libutil.a
LIBPWPH = ../../PHonon/PH/libph.a ../..//LR_Modules/liblrmod.a ../../PW/src/libpw.a
LIBMIN= ../minpack/minpacklib.a
......
......@@ -8,6 +8,7 @@ IFLAGS=-I../../include
# location of needed modules
MODFLAGS= $(MOD_FLAG)../../iotk/src $(MOD_FLAG)../../Modules \
$(MOD_FLAG)../../KS_Solvers/Davidson $(MOD_FLAG)../../KS_Solvers/CG \
$(MOD_FLAG)../../PW/src $(MOD_FLAG)../../FFTXlib $(MOD_FLAG)../../LAXlib $(MOD_FLAG)../../UtilXlib $(MOD_FLAG).
PW4GWWOBJS = \
......@@ -49,7 +50,8 @@ hpsi_pw4gww.o \
cgsolve_all_gamma.o \
realus.o
QEMODS = ../../Modules/libqemod.a ../../FFTXlib/libqefft.a ../../LAXlib/libqela.a ../../UtilXlib/libutil.a
QEMODS = ../../Modules/libqemod.a ../../KS_Solvers/Davidson/libdavid.a ../../KS_Solvers/CG/libcg.a \
../../FFTXlib/libqefft.a ../../LAXlib/libqela.a ../../UtilXlib/libutil.a
PWOBJS = ../../PW/src/libpw.a
LIBMIN= ../minpack/minpacklib.a
......
# Makefile for DAVID
include ../../make.inc
# location of needed modules and included files (if any)
MODFLAGS= $(MOD_FLAG) ../../ELPA/src $(MOD_FLAG) ../../LAXlib $(MOD_FLAG) ../../UtilXlib $(MOD_FLAG).
CG = cdiaghg.o \
ccgdiagg.o \
rdiaghg.o \
rcgdiagg.o \
mp_bands.o \
export_gstart_2_cg.o \
set_mpi_comm_4_cg.o \
cg_param.o \
rotate_wfc_gamma.o \
rotate_wfc_k.o
all : libcg.a
libcg.a: $(CG)
$(AR) $(ARFLAGS) $@ $?
$(RANLIB) $@
clean :
- /bin/rm -f *.o *.a *.d *.i *~ *_tmp.f90 *.mod *.L *.x
# .PHONY forces execution of a rule irrespective of the presence of an
# updated file with the same name of the rule. In this way, the script
# that generates version.f90 always runs, updating the version if you
# execute "svn update". The update_version script takes care of not
# changing the file if the svn version did not change
.PHONY: all clean
include make.depend
......@@ -11,22 +11,23 @@
! define __VERBOSE to print a message after each eigenvalue is computed
!
!----------------------------------------------------------------------------
SUBROUTINE ccgdiagg( npwx, npw, nbnd, npol, psi, e, btype, precondition, &
SUBROUTINE ccgdiagg( hs_1psi, s_1psi, &
npwx, npw, nbnd, npol, psi, e, btype, precondition, &
ethr, maxter, reorder, notconv, avg_iter )
!----------------------------------------------------------------------------
!
! ... "poor man" iterative diagonalization of a complex hermitian matrix
! ... through preconditioned conjugate gradient algorithm
! ... Band-by-band algorithm with minimal use of memory
! ... Calls h_1psi and s_1psi to calculate H|psi> and S|psi>
! ... Calls hs_1psi and s_1psi to calculate H|psi> + S|psi> and S|psi>
! ... Works for generalized eigenvalue problem (US pseudopotentials) as well
!
USE constants, ONLY : pi
USE kinds, ONLY : DP
USE mp_bands, ONLY : intra_bgrp_comm
USE mp, ONLY : mp_sum
USE constants, ONLY : pi
USE cg_param, ONLY : DP
USE mp_bands_cg, ONLY : intra_bgrp_comm, inter_bgrp_comm, set_bgrp_indices
USE mp, ONLY : mp_sum
#if defined(__VERBOSE)
USE io_global, only : stdout
USE cg_param, ONLY : stdout
#endif
!
IMPLICIT NONE
......@@ -43,9 +44,10 @@ SUBROUTINE ccgdiagg( npwx, npw, nbnd, npol, psi, e, btype, precondition, &
!
! ... local variables
!
INTEGER :: i, j, m, iter, moved
COMPLEX(DP), ALLOCATABLE :: hpsi(:), spsi(:), lagrange(:), &
g(:), cg(:), scg(:), ppsi(:), g0(:)
INTEGER :: i, j, m, m_start, m_end, iter, moved
COMPLEX(DP), ALLOCATABLE :: lagrange(:)
COMPLEX(DP), ALLOCATABLE :: hpsi(:), spsi(:), g(:), cg(:), &
scg(:), ppsi(:), g0(:)
REAL(DP) :: psi_norm, a0, b0, gg0, gamma, gg, gg1, &
cg0, e0, es(2)
REAL(DP) :: theta, cost, sint, cos2t, sin2t
......@@ -56,7 +58,9 @@ SUBROUTINE ccgdiagg( npwx, npw, nbnd, npol, psi, e, btype, precondition, &
! ... external functions
!
REAL (DP), EXTERNAL :: ddot
!
EXTERNAL hs_1psi, s_1psi
! hs_1psi( npwx, npw, psi, hpsi, spsi )
! s_1psi( npwx, npw, psi, spsi )
!
CALL start_clock( 'ccgdiagg' )
!
......@@ -111,7 +115,6 @@ SUBROUTINE ccgdiagg( npwx, npw, nbnd, npol, psi, e, btype, precondition, &
cg = ZERO
g0 = ZERO
ppsi = ZERO
lagrange = ZERO
!
! ... calculate S|psi>
!
......@@ -119,7 +122,11 @@ SUBROUTINE ccgdiagg( npwx, npw, nbnd, npol, psi, e, btype, precondition, &
!
! ... orthogonalize starting eigenfunction to those already calculated
!
CALL ZGEMV( 'C', kdim, m, ONE, psi, kdmx, spsi, 1, ZERO, lagrange, 1 )
call set_bgrp_indices(m,m_start,m_end); !write(*,*) m,m_start,m_end
lagrange = ZERO
if(m_start.le.m_end) &
CALL ZGEMV( 'C', kdim, m_end-m_start+1, ONE, psi(1,m_start), kdmx, spsi, 1, ZERO, lagrange(m_start), 1 )
CALL mp_sum( lagrange( 1:m ), inter_bgrp_comm )
!
CALL mp_sum( lagrange( 1:m ), intra_bgrp_comm )
!
......@@ -129,8 +136,7 @@ SUBROUTINE ccgdiagg( npwx, npw, nbnd, npol, psi, e, btype, precondition, &
!
psi(:,m) = psi(:,m) - lagrange(j) * psi(:,j)
!
psi_norm = psi_norm - &
( DBLE( lagrange(j) )**2 + AIMAG( lagrange(j) )**2 )
psi_norm = psi_norm - ( DBLE( lagrange(j) )**2 + AIMAG( lagrange(j) )**2 )
!
END DO
!
......@@ -140,7 +146,7 @@ SUBROUTINE ccgdiagg( npwx, npw, nbnd, npol, psi, e, btype, precondition, &
!
! ... calculate starting gradient (|hpsi> = H|psi>) ...
!
CALL h_1psi( npwx, npw, psi(1,m), hpsi, spsi )
CALL hs_1psi( npwx, npw, psi(1,m), hpsi, spsi )
!
! ... and starting eigenvalue (e = <y|PHP|y> = <psi|H|psi>)
!
......@@ -171,7 +177,7 @@ SUBROUTINE ccgdiagg( npwx, npw, nbnd, npol, psi, e, btype, precondition, &
!
g(:) = g(:) - es(1) * ppsi(:)
!
! ... e1 = <y| S P^2 PHP|y> / <y| S S P^2|y> ensures that
! ... e1 = <y| S P^2 PHP|y> / <y| S S P^2|y> ensures that
! ... <g| S P^2|y> = 0
! ... orthogonalize to lowest eigenfunctions (already calculated)
!
......@@ -179,8 +185,11 @@ SUBROUTINE ccgdiagg( npwx, npw, nbnd, npol, psi, e, btype, precondition, &
!
CALL s_1psi( npwx, npw, g(1), scg(1) )
!
CALL ZGEMV( 'C', kdim, ( m - 1 ), ONE, psi, &
kdmx, scg, 1, ZERO, lagrange, 1 )
lagrange(1:m-1) = ZERO
call set_bgrp_indices(m-1,m_start,m_end); !write(*,*) m-1,m_start,m_end
if(m_start.le.m_end) &
CALL ZGEMV( 'C', kdim, m_end-m_start+1, ONE, psi(1,m_start), kdmx, scg, 1, ZERO, lagrange(m_start), 1 )
CALL mp_sum( lagrange( 1:m-1 ), inter_bgrp_comm )
!
CALL mp_sum( lagrange( 1:m-1 ), intra_bgrp_comm )
!
......@@ -245,7 +254,7 @@ SUBROUTINE ccgdiagg( npwx, npw, nbnd, npol, psi, e, btype, precondition, &
!
! ... |scg> is S|cg>
!
CALL h_1psi( npwx, npw, cg(1), ppsi(1), scg(1) )
CALL hs_1psi( npwx, npw, cg(1), ppsi(1), scg(1) )
!
cg0 = ddot( kdim2, cg(1), 1, scg(1), 1 )
!
......@@ -296,7 +305,6 @@ SUBROUTINE ccgdiagg( npwx, npw, nbnd, npol, psi, e, btype, precondition, &
! ... new estimate of the eigenvalue
!
e(m) = MIN( es(1), es(2) )
!
! ... upgrade |psi>
!
psi(:,m) = cost * psi(:,m) + sint / cg0 * cg(:)
......@@ -326,14 +334,12 @@ SUBROUTINE ccgdiagg( npwx, npw, nbnd, npol, psi, e, btype, precondition, &
IF ( iter >= maxter ) notconv = notconv + 1
!
avg_iter = avg_iter + iter + 1
!
! ... reorder eigenvalues if they are not in the right order
! ... ( this CAN and WILL happen in not-so-special cases )
!
IF ( m > 1 .AND. reorder ) THEN
!
IF ( e(m) - e(m-1) < - 2.D0 * ethr_m ) THEN
!
! ... if the last calculated eigenvalue is not the largest...
!
DO i = m - 2, 1, - 1
......
This diff is collapsed.
!
! Copyright (C) Quantum ESPRESSO group
!
! This file is distributed under the terms of the
! GNU General Public License. See the file `License'
! in the root directory of the present distribution,
! or http://www.gnu.org/copyleft/gpl.txt .
!
MODULE cg_param
#if defined(__MPI)
#if defined(__MPI_MODULE)
USE mpi
#else
INCLUDE 'mpif.h'
#endif
#endif
INTEGER, PARAMETER :: DP = selected_real_kind(14,200)
INTEGER, PARAMETER :: stdout = 6 ! unit connected to standard output
LOGICAL :: gamma_only =.false.
LOGICAL :: use_para_diag =.false.
END MODULE cg_param
This diff is collapsed.
!
! Copyright (C) 2002-2006 Quantum ESPRESSO group
! This file is distributed under the terms of the
! GNU General Public License. See the file `License'
! in the root directory of the present distribution,
! or http://www.gnu.org/copyleft/gpl.txt .
!
!----------------------------------------------------------------------------
MODULE constants
!----------------------------------------------------------------------------
!
USE cg_param, ONLY : DP
!
! ... The constants needed everywhere
!
IMPLICIT NONE
!
SAVE
!
! ... Mathematical constants
!
REAL(DP), PARAMETER :: pi = 3.14159265358979323846_DP
REAL(DP), PARAMETER :: tpi = 2.0_DP * pi
REAL(DP), PARAMETER :: fpi = 4.0_DP * pi
REAL(DP), PARAMETER :: sqrtpi = 1.77245385090551602729_DP
REAL(DP), PARAMETER :: sqrtpm1= 1.0_DP / sqrtpi
REAL(DP), PARAMETER :: sqrt2 = 1.41421356237309504880_DP
!
! ... Physical constants, SI (NIST CODATA 2006), Web Version 5.1
! http://physics.nist.gov/constants
REAL(DP), PARAMETER :: H_PLANCK_SI = 6.62606896E-34_DP ! J s
REAL(DP), PARAMETER :: K_BOLTZMANN_SI = 1.3806504E-23_DP ! J K^-1
REAL(DP), PARAMETER :: ELECTRON_SI = 1.602176487E-19_DP ! C
REAL(DP), PARAMETER :: ELECTRONVOLT_SI = 1.602176487E-19_DP ! J
REAL(DP), PARAMETER :: ELECTRONMASS_SI = 9.10938215E-31_DP ! Kg
REAL(DP), PARAMETER :: HARTREE_SI = 4.35974394E-18_DP ! J
REAL(DP), PARAMETER :: RYDBERG_SI = HARTREE_SI/2.0_DP ! J
REAL(DP), PARAMETER :: BOHR_RADIUS_SI = 0.52917720859E-10_DP ! m
REAL(DP), PARAMETER :: AMU_SI = 1.660538782E-27_DP ! Kg
REAL(DP), PARAMETER :: C_SI = 2.99792458E+8_DP ! m sec^-1
REAL(DP), PARAMETER :: MUNOUGHT_SI = fpi*1.0E-7_DP ! N A^-2
REAL(DP), PARAMETER :: EPSNOUGHT_SI = 1.0_DP / (MUNOUGHT_SI * &
C_SI**2) ! F m^-1
!
! ... Physical constants, atomic units:
! ... AU for "Hartree" atomic units (e = m = hbar = 1)
! ... RY for "Rydberg" atomic units (e^2=2, m=1/2, hbar=1)
!
REAL(DP), PARAMETER :: K_BOLTZMANN_AU = K_BOLTZMANN_SI / HARTREE_SI
REAL(DP), PARAMETER :: K_BOLTZMANN_RY = K_BOLTZMANN_SI / RYDBERG_SI
!
! ... Unit conversion factors: energy and masses
!
REAL(DP), PARAMETER :: AUTOEV = HARTREE_SI / ELECTRONVOLT_SI
REAL(DP), PARAMETER :: RYTOEV = AUTOEV / 2.0_DP
REAL(DP), PARAMETER :: AMU_AU = AMU_SI / ELECTRONMASS_SI
REAL(DP), PARAMETER :: AMU_RY = AMU_AU / 2.0_DP
!
! ... Unit conversion factors: atomic unit of time, in s and ps
!
REAL(DP), PARAMETER :: AU_SEC = H_PLANCK_SI/tpi/HARTREE_SI
REAL(DP), PARAMETER :: AU_PS = AU_SEC * 1.0E+12_DP
!
! ... Unit conversion factors: pressure (1 Pa = 1 J/m^3, 1GPa = 10 Kbar )
!
REAL(DP), PARAMETER :: AU_GPA = HARTREE_SI / BOHR_RADIUS_SI ** 3 &
/ 1.0E+9_DP
REAL(DP), PARAMETER :: RY_KBAR = 10.0_DP * AU_GPA / 2.0_DP
!
! ... Unit conversion factors: 1 debye = 10^-18 esu*cm
! ... = 3.3356409519*10^-30 C*m
! ... = 0.208194346 e*A
! ... ( 1 esu = (0.1/c) Am, c=299792458 m/s)
!
REAL(DP), PARAMETER :: DEBYE_SI = 3.3356409519_DP * 1.0E-30_DP ! C*m
REAL(DP), PARAMETER :: AU_DEBYE = ELECTRON_SI * BOHR_RADIUS_SI / &
DEBYE_SI
!
REAL(DP), PARAMETER :: eV_to_kelvin = ELECTRONVOLT_SI / K_BOLTZMANN_SI
REAL(DP), PARAMETER :: ry_to_kelvin = RYDBERG_SI / K_BOLTZMANN_SI
!
! .. Unit conversion factors: Energy to wavelength
!
REAL(DP), PARAMETER :: EVTONM = 1E+9_DP * H_PLANCK_SI * C_SI / &
&ELECTRONVOLT_SI
REAL(DP), PARAMETER :: RYTONM = 1E+9_DP * H_PLANCK_SI * C_SI / RYDBERG_SI
!
! Speed of light in atomic units
!
REAL(DP), PARAMETER :: C_AU = C_SI / BOHR_RADIUS_SI * AU_SEC
!
! ... zero up to a given accuracy
!
REAL(DP), PARAMETER :: eps4 = 1.0E-4_DP
REAL(DP), PARAMETER :: eps6 = 1.0E-6_DP
REAL(DP), PARAMETER :: eps8 = 1.0E-8_DP
REAL(DP), PARAMETER :: eps12 = 1.0E-12_DP
REAL(DP), PARAMETER :: eps14 = 1.0E-14_DP
REAL(DP), PARAMETER :: eps16 = 1.0E-16_DP
REAL(DP), PARAMETER :: eps24 = 1.0E-24_DP
REAL(DP), PARAMETER :: eps32 = 1.0E-32_DP
!
REAL(DP), PARAMETER :: gsmall = 1.0E-12_DP
!
REAL(DP), PARAMETER :: e2 = 2.0_DP ! the square of the electron charge
REAL(DP), PARAMETER :: degspin = 2.0_DP ! the number of spins per level
!
!!!!!! COMPATIBIILITY
!
REAL(DP), PARAMETER :: BOHR_RADIUS_CM = BOHR_RADIUS_SI * 100.0_DP
REAL(DP), PARAMETER :: BOHR_RADIUS_ANGS = BOHR_RADIUS_CM * 1.0E8_DP
REAL(DP), PARAMETER :: ANGSTROM_AU = 1.0_DP/BOHR_RADIUS_ANGS
REAL(DP), PARAMETER :: DIP_DEBYE = AU_DEBYE
REAL(DP), PARAMETER :: AU_TERAHERTZ = AU_PS
REAL(DP), PARAMETER :: AU_TO_OHMCMM1 = 46000.0_DP ! (ohm cm)^-1
REAL(DP), PARAMETER :: RY_TO_THZ = 1.0_DP / AU_TERAHERTZ / FPI
REAL(DP), PARAMETER :: RY_TO_GHZ = RY_TO_THZ*1000.0_DP
REAL(DP), PARAMETER :: RY_TO_CMM1 = 1.E+10_DP * RY_TO_THZ / C_SI
!
REAL(DP), PARAMETER :: AVOGADRO = 6.02214129D+23
END MODULE constants
! perl script to create a program to list the available constants:
! extract with: grep '^!XX!' constants.f90 | sed 's,!XX!,,' > mkconstlist.pl
! then run: perl mkconstlist.pl constants.f90 > testme.f90
! and compile and run: testme.f90
!XX!#!/usr/bin/perl -w
!XX!
!XX!use strict;
!XX!
!XX!print <<EOF
!XX!! list all available constants and derived values
!XX!
!XX!PROGRAM list_constants
!XX!
!XX! USE kinds, ONLY : DP
!XX! USE constants
!XX!
!XX!EOF
!XX!;
!XX!
!XX!while(<>) {
!XX! if ( /REAL\s*\(DP\)\s*,\s*PARAMETER\s*::\s*([a-zA-Z_0-9]+)\s*=.*$/ ) {
!XX! print " WRITE (*,'(A18,G24.17)') '$1:',$1\n";
!XX! }
!XX!}
!XX!
!XX!print <<EOF
!XX!
!XX!END PROGRAM list_constants
!XX!EOF
!XX!;
!XX!
This diff is collapsed.
!
! Copyright (C) 2001-2015 Quantum ESPRESSO group
! This file is distributed under the terms of the
! GNU General Public License. See the file `License'
! in the root directory of the present distribution,
! or http://www.gnu.org/copyleft/gpl.txt .
!
!----------------------------------------------------------------------------
SUBROUTINE export_gstart_2_cg(gstart_)
!----------------------------------------------------------------------------
!
USE mp_bands_cg, ONLY : gstart
!
IMPLICIT NONE
!
INTEGER, INTENT(IN) :: gstart_
!
gstart = gstart_
!
END SUBROUTINE export_gstart_2_cg
ccgdiagg.o : ../../UtilXlib/mp.o
ccgdiagg.o : cg_param.o
ccgdiagg.o : constants.o
ccgdiagg.o : mp_bands.o
cdiaghg.o : ../../LAXlib/la_types.o
cdiaghg.o : ../../LAXlib/mp_diag.o
cdiaghg.o : ../../LAXlib/ptoolkit.o
cdiaghg.o : ../../LAXlib/zhpev_drv.o
cdiaghg.o : ../../UtilXlib/mp.o
cdiaghg.o : cg_param.o
cdiaghg.o : mp_bands.o
constants.o : cg_param.o
export_gstart_2_cg.o : mp_bands.o
mp_bands.o : ../../UtilXlib/mp.o
mp_bands.o : ../../UtilXlib/parallel_include.o
rcgdiagg.o : ../../UtilXlib/mp.o
rcgdiagg.o : cg_param.o
rcgdiagg.o : constants.o
rcgdiagg.o : mp_bands.o
rdiaghg.o : ../../LAXlib/dspev_drv.o
rdiaghg.o : ../../LAXlib/la_types.o
rdiaghg.o : ../../LAXlib/mp_diag.o
rdiaghg.o : ../../UtilXlib/mp.o
rdiaghg.o : cg_param.o
rdiaghg.o : mp_bands.o
rotate_wfc_gamma.o : ../../LAXlib/la_types.o
rotate_wfc_gamma.o : ../../LAXlib/mp_diag.o
rotate_wfc_gamma.o : ../../LAXlib/ptoolkit.o
rotate_wfc_gamma.o : ../../UtilXlib/mp.o
rotate_wfc_gamma.o : cg_param.o
rotate_wfc_gamma.o : mp_bands.o
rotate_wfc_k.o : ../../LAXlib/la_types.o
rotate_wfc_k.o : ../../LAXlib/mp_diag.o
rotate_wfc_k.o : ../../LAXlib/ptoolkit.o
rotate_wfc_k.o : ../../UtilXlib/mp.o
rotate_wfc_k.o : cg_param.o
rotate_wfc_k.o : mp_bands.o
set_mpi_comm_4_cg.o : ../../LAXlib/mp_diag.o
set_mpi_comm_4_cg.o : ../../UtilXlib/mp.o
set_mpi_comm_4_cg.o : cg_param.o
set_mpi_comm_4_cg.o : mp_bands.o
!
! Copyright (C) 2013 Quantum ESPRESSO group
! This file is distributed under the terms of the
! GNU General Public License. See the file `License'
! in the root directory of the present distribution,
! or http://www.gnu.org/copyleft/gpl.txt .
!
!----------------------------------------------------------------------------
MODULE mp_bands_cg
!----------------------------------------------------------------------------
!
USE mp, ONLY : mp_barrier, mp_bcast, mp_size, mp_rank, mp_comm_split
USE parallel_include
!
IMPLICIT NONE
SAVE
!
! ... Band groups (processors within a pool of bands)
! ... Subdivision of pool group, used for parallelization over bands
!
INTEGER :: nbgrp = 1 ! number of band groups
INTEGER :: nproc_bgrp = 1 ! number of processors within a band group
INTEGER :: me_bgrp = 0 ! index of the processor within a band group
INTEGER :: root_bgrp = 0 ! index of the root processor within a band group
INTEGER :: my_bgrp_id = 0 ! index of my band group
INTEGER :: root_bgrp_id = 0 ! index of root band group
INTEGER :: inter_bgrp_comm = 0 ! inter band group communicator
INTEGER :: intra_bgrp_comm = 0 ! intra band group communicator
! Next variable is .T. if band parallelization is performed inside H\psi
! and S\psi, .F. otherwise (band parallelization can be performed outside
! H\psi and S\psi, though)
LOGICAL :: use_bgrp_in_hpsi = .FALSE.
!
! ... "task" groups (for band parallelization of FFT)
!
INTEGER :: ntask_groups = 1 ! number of proc. in an orbital "task group"
!
#if defined (__MPI)
! ... variable gstart2 must be properly set to be used with the real algorithm
!
INTEGER :: gstart = -1 ! variable not set yet
#else
INTEGER :: gstart = 2 ! appropriate value for serial execution
#endif
CONTAINS
!
!----------------------------------------------------------------------------
SUBROUTINE mp_start_bands( nband_, ntg_, parent_comm )
!---------------------------------------------------------------------------
!
! ... Divide processors (of the "parent_comm" group) into nband_ pools
! ... Requires: nband_, read from command line
! ... parent_comm, typically processors of a k-point pool
! ... (intra_pool_comm)
!
IMPLICIT NONE
!
INTEGER, INTENT(IN) :: nband_, parent_comm
INTEGER, INTENT(IN), OPTIONAL :: ntg_
!
INTEGER :: parent_nproc = 1, parent_mype = 0
!
#if defined (__MPI)
!
parent_nproc = mp_size( parent_comm )
parent_mype = mp_rank( parent_comm )
!
! ... nband_ must have been previously read from command line argument
! ... by a call to routine get_command_line
!
nbgrp = nband_
!
IF ( nbgrp < 1 .OR. nbgrp > parent_nproc ) CALL errore( 'mp_start_bands',&
'invalid number of band groups, out of range', 1 )
IF ( MOD( parent_nproc, nbgrp ) /= 0 ) CALL errore( 'mp_start_bands', &
'n. of band groups must be divisor of parent_nproc', 1 )
!
! set logical flag so that band parallelization in H\psi is allowed
! (can be disabled before calling H\psi if not desired)
!
use_bgrp_in_hpsi = ( nbgrp > 1 )
!
! ... Set number of processors per band group
!
nproc_bgrp = parent_nproc / nbgrp
!
! ... set index of band group for this processor ( 0 : nbgrp - 1 )
!
my_bgrp_id = parent_mype / nproc_bgrp
!
! ... set index of processor within the image ( 0 : nproc_image - 1 )
!
me_bgrp = MOD( parent_mype, nproc_bgrp )
!
CALL mp_barrier( parent_comm )
!
! ... the intra_bgrp_comm communicator is created
!
CALL mp_comm_split( parent_comm, my_bgrp_id, parent_mype, intra_bgrp_comm )
!
CALL mp_barrier( parent_comm )
!
! ... the inter_bgrp_comm communicator is created
!
CALL mp_comm_split( parent_comm, me_bgrp, parent_mype, inter_bgrp_comm )
!
IF ( PRESENT(ntg_) ) THEN