2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! Copyright (C) 2001 PWSCF 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 rotate_and_add_d3 (phi, phi2, nat, isym, s, invs, irt, &
|
|
|
|
rtau, sxq)
|
|
|
|
!-----------------------------------------------------------------------
|
|
|
|
! Rotates a third order matrix (phi) in crystal coordinates according
|
|
|
|
! to the specified symmetry operation and add the rotated matrix
|
|
|
|
! to phi2. phi is left unmodified.
|
|
|
|
!
|
2004-06-26 01:25:37 +08:00
|
|
|
#include "f_defs.h"
|
2004-02-04 19:06:45 +08:00
|
|
|
USE kinds, only : DP
|
2003-02-08 00:04:36 +08:00
|
|
|
implicit none
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! input variables
|
|
|
|
!
|
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
integer :: nat, isym, s (3, 3, 48), invs (48), irt (48, nat)
|
2003-01-20 05:58:50 +08:00
|
|
|
! number of atoms in the unit cell
|
|
|
|
! index of the symm.op.
|
|
|
|
! the symmetry operations
|
|
|
|
! index of the inverse operations
|
|
|
|
! index of the rotated atom
|
|
|
|
|
2005-08-28 22:09:42 +08:00
|
|
|
complex (DP) :: phi (3, 3, 3, nat, nat, nat), phi2 (3, 3, 3, nat, nat, nat)
|
2003-01-20 05:58:50 +08:00
|
|
|
! the input d3dyn.mat.
|
|
|
|
! in crystal coordinates
|
|
|
|
! the rotated d3dyn.mat
|
|
|
|
! in crystal coordinates
|
2005-08-28 22:09:42 +08:00
|
|
|
real (DP) :: rtau (3, 48, nat), sxq (3)
|
2003-01-20 05:58:50 +08:00
|
|
|
! for each atom and rotation gives
|
|
|
|
! the R vector involved
|
|
|
|
! the rotated q involved in this sym.op
|
|
|
|
!
|
|
|
|
! local variables
|
|
|
|
!
|
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
integer :: na, nb, nc, sna, snb, snc, ism1, i, j, k, l, m, n
|
2003-01-20 05:58:50 +08:00
|
|
|
! counters on atoms
|
|
|
|
! indices of rotated atoms
|
|
|
|
! index of the inverse symm.op.
|
|
|
|
! generic counters
|
|
|
|
|
2005-08-28 22:09:42 +08:00
|
|
|
real (DP) :: arg
|
2003-01-20 05:58:50 +08:00
|
|
|
! argument of the phase
|
|
|
|
|
2005-08-28 22:09:42 +08:00
|
|
|
complex (DP) :: phase, work
|
2003-01-20 05:58:50 +08:00
|
|
|
! auxiliary variable
|
2005-08-28 22:09:42 +08:00
|
|
|
real (DP) :: tpi
|
2004-02-04 19:06:45 +08:00
|
|
|
parameter (tpi = 2.0_dp * 3.14159265358979_dp)
|
2003-01-20 05:58:50 +08:00
|
|
|
|
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
ism1 = invs(isym)
|
|
|
|
do nc = 1, nat
|
|
|
|
snc = irt(isym,nc)
|
|
|
|
do na = 1, nat
|
|
|
|
do nb = 1, nat
|
|
|
|
sna = irt(isym,na)
|
|
|
|
snb = irt(isym,nb)
|
2003-01-20 05:58:50 +08:00
|
|
|
arg = (sxq (1) * (rtau(1,isym,na) - rtau(1,isym,nb) ) &
|
|
|
|
+ sxq (2) * (rtau(2,isym,na) - rtau(2,isym,nb) ) &
|
|
|
|
+ sxq (3) * (rtau(3,isym,na) - rtau(3,isym,nb) ) ) * tpi
|
General cleanup of intrinsic functions:
conversion to real => DBLE
(including real part of a complex number)
conversion to complex => CMPLX
complex conjugate => CONJG
imaginary part => AIMAG
All functions are uppercase.
CMPLX is preprocessed by f_defs.h and performs an explicit cast:
#define CMPLX(a,b) cmplx(a,b,kind=DP)
This implies that 1) f_defs.h must be included whenever a CMPLX is present,
2) CMPLX should stay in a single line, 3) DP must be defined.
All occurrences of real, float, dreal, dfloat, dconjg, dimag, dcmplx
removed - please do not reintroduce any of them.
Tested only with ifc7 and g95 - beware unintended side effects
Maybe not the best solution (explicit casts everywhere would be better)
but it can be easily changed with a script if the need arises.
The following code might be used to test for possible trouble:
program test_intrinsic
implicit none
integer, parameter :: dp = selected_real_kind(14,200)
real (kind=dp) :: a = 0.123456789012345_dp
real (kind=dp) :: b = 0.987654321098765_dp
complex (kind=dp) :: c = ( 0.123456789012345_dp, 0.987654321098765_dp)
print *, ' A = ', a
print *, ' DBLE(A)= ', DBLE(a)
print *, ' C = ', c
print *, 'CONJG(C)= ', CONJG(c)
print *, 'DBLE(c),AIMAG(C) = ', DBLE(c), AIMAG(c)
print *, 'CMPLX(A,B,kind=dp)= ', CMPLX( a, b, kind=dp)
end program test_intrinsic
Note that CMPLX and REAL without a cast yield single precision numbers on
ifc7 and g95 !!!
git-svn-id: http://qeforge.qe-forge.org/svn/q-e/trunk/espresso@2133 c92efa57-630b-4861-b058-cf58834340f0
2005-08-27 01:44:42 +08:00
|
|
|
phase = CMPLX(cos(arg),-sin(arg))
|
2003-02-08 00:04:36 +08:00
|
|
|
do m = 1, 3
|
|
|
|
do i = 1, 3
|
|
|
|
do j = 1, 3
|
General cleanup of intrinsic functions:
conversion to real => DBLE
(including real part of a complex number)
conversion to complex => CMPLX
complex conjugate => CONJG
imaginary part => AIMAG
All functions are uppercase.
CMPLX is preprocessed by f_defs.h and performs an explicit cast:
#define CMPLX(a,b) cmplx(a,b,kind=DP)
This implies that 1) f_defs.h must be included whenever a CMPLX is present,
2) CMPLX should stay in a single line, 3) DP must be defined.
All occurrences of real, float, dreal, dfloat, dconjg, dimag, dcmplx
removed - please do not reintroduce any of them.
Tested only with ifc7 and g95 - beware unintended side effects
Maybe not the best solution (explicit casts everywhere would be better)
but it can be easily changed with a script if the need arises.
The following code might be used to test for possible trouble:
program test_intrinsic
implicit none
integer, parameter :: dp = selected_real_kind(14,200)
real (kind=dp) :: a = 0.123456789012345_dp
real (kind=dp) :: b = 0.987654321098765_dp
complex (kind=dp) :: c = ( 0.123456789012345_dp, 0.987654321098765_dp)
print *, ' A = ', a
print *, ' DBLE(A)= ', DBLE(a)
print *, ' C = ', c
print *, 'CONJG(C)= ', CONJG(c)
print *, 'DBLE(c),AIMAG(C) = ', DBLE(c), AIMAG(c)
print *, 'CMPLX(A,B,kind=dp)= ', CMPLX( a, b, kind=dp)
end program test_intrinsic
Note that CMPLX and REAL without a cast yield single precision numbers on
ifc7 and g95 !!!
git-svn-id: http://qeforge.qe-forge.org/svn/q-e/trunk/espresso@2133 c92efa57-630b-4861-b058-cf58834340f0
2005-08-27 01:44:42 +08:00
|
|
|
work = CMPLX(0.d0, 0.d0)
|
2003-02-08 00:04:36 +08:00
|
|
|
do k = 1, 3
|
|
|
|
do l = 1, 3
|
|
|
|
do n = 1, 3
|
2003-01-20 05:58:50 +08:00
|
|
|
work = work &
|
|
|
|
+ s(m,n,ism1) * s(i,k,ism1) * s(j,l,ism1) &
|
|
|
|
* phi(n,k,l,nc,na,nb) * phase
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
phi2(m,i,j,snc,sna,snb) = phi2(m,i,j,snc,sna,snb) + work
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
|
|
|
|
enddo
|
2003-02-08 00:04:36 +08:00
|
|
|
return
|
2003-01-20 05:58:50 +08:00
|
|
|
end subroutine rotate_and_add_d3
|