1* *************************************** 2* * * 3* * fcoord_to_real * 4* * * 5* *************************************** 6* 7* This routine converts from fractional coordinates to real 8* coordinates. 9* 10* Entry - nion 11* a(3,3): lattice vectors 12* ion: fractional coordinates 13* Exit - 14* ion: real coordinates 15* 16 17 subroutine fcoord_to_real(nion,ion) 18 implicit none 19 integer nion 20 real*8 ion(3,*) 21 22c **** local variables **** 23 integer i,j 24 real*8 tion(3) 25 real*8 a(3,3) 26 27* *** external functions **** 28 real*8 lattice_unita 29 external lattice_unita 30 31 do j=1,3 32 do i=1,3 33 a(i,j) = lattice_unita(i,j) 34 end do 35 end do 36 37 do i=1,nion 38 tion(1) = ion(1,i) 39 tion(2) = ion(2,i) 40 tion(3) = ion(3,i) 41 42 ion(1,i) = a(1,1)*tion(1) 43 > + a(1,2)*tion(2) 44 > + a(1,3)*tion(3) 45 ion(2,i) = a(2,1)*tion(1) 46 > + a(2,2)*tion(2) 47 > + a(2,3)*tion(3) 48 ion(3,i) = a(3,1)*tion(1) 49 > + a(3,2)*tion(2) 50 > + a(3,3)*tion(3) 51 end do 52 53 return 54 end 55 56 57* *************************************** 58* * * 59* * fcoord_to_frac * 60* * * 61* *************************************** 62* 63* This routine converts from real coordinates to fractional 64* coordinates. 65* 66* Entry - nion 67* a(3,3): lattice vectors 68* ion: real coordinates 69* Exit - 70* ion: fractional coordinates 71 72 subroutine fcoord_to_frac(nion,ion) 73 implicit none 74 integer nion 75 real*8 ion(3,*) 76 77* **** local variables **** 78 integer i,j 79 real*8 a(3,3),b(3,3),volume 80 real*8 tion(3) 81 82* *** external functions **** 83 real*8 lattice_unita 84 external lattice_unita 85 86 do j=1,3 87 do i=1,3 88 a(i,j) = lattice_unita(i,j) 89 end do 90 end do 91 92 b(1,1) = a(2,2)*a(3,3) - a(3,2)*a(2,3) 93 b(2,1) = a(3,2)*a(1,3) - a(1,2)*a(3,3) 94 b(3,1) = a(1,2)*a(2,3) - a(2,2)*a(1,3) 95 b(1,2) = a(2,3)*a(3,1) - a(3,3)*a(2,1) 96 b(2,2) = a(3,3)*a(1,1) - a(1,3)*a(3,1) 97 b(3,2) = a(1,3)*a(2,1) - a(2,3)*a(1,1) 98 b(1,3) = a(2,1)*a(3,2) - a(3,1)*a(2,2) 99 b(2,3) = a(3,1)*a(1,2) - a(1,1)*a(3,2) 100 b(3,3) = a(1,1)*a(2,2) - a(2,1)*a(1,2) 101 volume = a(1,1)*b(1,1) 102 > + a(2,1)*b(2,1) 103 > + a(3,1)*b(3,1) 104 105 volume = 1.0d0/volume 106 call dscal(9,volume,b,1) 107 108 109 do i=1,nion 110 tion(1) = ion(1,i) 111 tion(2) = ion(2,i) 112 tion(3) = ion(3,i) 113 ion(1,i) = b(1,1)*tion(1) 114 > + b(2,1)*tion(2) 115 > + b(3,1)*tion(3) 116 117 ion(2,i) = b(1,2)*tion(1) 118 > + b(2,2)*tion(2) 119 > + b(3,2)*tion(3) 120 121 ion(3,i) = b(1,3)*tion(1) 122 > + b(2,3)*tion(2) 123 > + b(3,3)*tion(3) 124 125 end do 126 127 return 128 end 129 130 131c $Id$ 132