IMPLICIT DOUBLE PRECISION (A-H,O-Z) dimension a(5000,3),b(3,3),ab(5000,3),w(5000) read(5,*) n write(6,*)n do i=1,n read(5,*)(a(i,j),j=1,3) enddo read(5,*) read(5,*)(w(i),i=1,n) do i=1,3 read(5,*)(b(i,j),j=1,3) enddo sum=0.d0 do i=1,n sum=sum+w(i) enddo do i=1,n w(i)=w(i)/sum enddo do 100 i=1,n do 350 j=1,3 ab(i,j)=0.d0 c by multi. a factor of 2.d0 for ab, we are in the unit of pi/a -------- do k=1,3 c Lisa's original code is c ab(i,j)=ab(i,j)+a(i,k)*b(k,j)*2.d0 c which is wrong: A * {H(1,:), H(2,:), H(3,:)} are the three c lattice vectors; G = H^(-1), so 2*pi/A *{G(:,1), G(:,2), G(:,3)} c are the three reciprocal vectors. ab(i,j)=ab(i,j)+a(i,k)*b(j,k)*2.d0 enddo 350 continue write(6,10) (ab(i,j),j=1,3),w(i) c for high accuracy 10 format(4f18.14) 100 continue end