! Program to set up the fcc lattice Program fcc Implicit none Real*8 :: box,xo(1000,3),b Integer :: l Open(10, file="fcc.dat") ! Input data Write(*,*) " Input the number of boxes along one direction (l)" Read(*,*) l Write(*,*) l ! The number of atoms is 4l^3 box=2.0d0**(2.0d0/3.0d0)*Dfloat(l) ! box size equal to fcc ground state Call Initializefcc(box,l,xo) End Program fcc !---------------------------------------------------------------! ! Subroutine to set up fcc lattice Subroutine Initializefcc(box,l,xo) Implicit None Real*8 xo(1000,3),b,x0(4,3),box Integer i,j,k,k1,k2, l,ip ! Setting up the four atom positions in one box b=box/DFloat(l) ! the size of the unit cell is the box length divided by l x0(:,:)=b/2.0d0; x0(1,:)=0.0d0; x0(2,3)=0.0d0; x0(3,2)=0.0d0; x0(4,1)=0.0d0 Do i=1,4 Write(*,*) x0(i,:) End Do ! Going through all boxes in the system ip=0 Do i=1,l Do j=1,l Do k=1,l Do k1=1,4 ip=ip+1 !ip=((i-1)*l**2+(j-1)*l+k-1)*4+k1 !this is how ip is related to loop variables however it is less efficient xo(ip,1) = x0(k1,1) + Float(i-1)*b xo(ip,2) = x0(k1,2) + Float(j-1)*b xo(ip,3) = x0(k1,3) + Float(k-1)*b EndDo EndDo EndDo End Do Do i=1,ip Write(10,*) xo(i,:) End Do End Subroutine