|
program make_spartan
USE IMAGE_MODULE
implicit none
!----------------------------------------------------------------------------------------------------------------------------------
! The purpose of this program is to read POSCAR
! or CONTCAR files and generate spartan input
! files.
!
! The names of the POSCAR or CONTCAR files
! should be listed in the file "filenames"
! along with names to use for the corresponding
! spartan input files.
!
!----------------------------------------------------------------------------------------------------------------------------------
! Declarations:
!----------------------------------------------------------------------------------------------------------------------------------
integer :: num_images
integer :: counter
type (model) :: mod
type (image) :: this_im
character (len=10) :: im_file, spar_file
print *, "How many images were made?"
print *, "Note: mkspartan will try to read two more files than the number of images"
read(unit=*,fmt=*) num_images
print *, "How many species are present in the model?"
read(unit=*,fmt=*) mod%num_spec
print *, "What is the total number of ions present?"
read(unit=*,fmt=*) mod%t_num_ions
open(unit=20, file="filenames", action="read", status="old")
counter = 0
do while (counter <= (num_images+1))
read(unit=20,fmt=*) im_file, spar_file
print *, "********************************************"
print *, "Starting Loop from Main"
print *, im_file, spar_file
call read_POSCAR(mod, counter, this_im, im_file, spar_file)
call write_POSCAR(mod, counter, this_im, im_file, spar_file)
counter = counter + 1
end do
close(unit=20)
end program make_images
!----------------------------------------------------------------------------------------------------------------------------------
subroutine read_POSCAR(mod, counter, this_im, im_file, spar_file)
USE IMAGE_MODULE
implicit none
type (model) :: mod
type (image) :: this_im
integer :: counter
integer :: a,b
character (len=10) :: im_file, spar_file
print *, "********************************************"
print *, "inside read_POSCAR"
print *, im_file, spar_file
open(unit=15,file=im_file, action="read", status="old")
read(unit=15,fmt=*) this_im%name
write(unit=*,fmt=*)"name is ", this_im%name
read(unit=15,fmt=*) this_im%scale
write(unit=*,fmt=*)"scale is ", this_im%scale
read(unit=15,fmt=*)((this_im%lattvec(a,b),b=1,3),a=1,3)
do a=1,3
write(unit=*,fmt=3)"latt_vec",(this_im%lattvec(a,b),b=1,3)
end do
3 format(A10,2x,3(1x,f12.6))
4 format(A10,2x,3(1x,f12.6),A10,2x,3(1x,A2))
read(unit=15,fmt=*)(this_im%num_atoms_of_species(a),a=1,mod%num_spec)
write(unit=*,fmt=5)(this_im%num_atoms_of_species(a),a,a=1,mod%num_spec)
5 format(1x, I2,' atoms of species',I2)
read(unit=15,fmt=*) this_im%seldyn
read(unit=15,fmt=*) this_im%direct
do a=1,mod%t_num_ions
read(unit=15,fmt=*)(this_im%coords(a,b),b=1,3),(this_im%dyn(a,b),b=1,3)
write(unit=*,fmt=4)"coord",(this_im%coords(a,b),b=1,3),"dynamics",(this_im%dyn(a,b),b=1,3)
end do
close(unit=15)
open(unit=14, file="batting_order", action="read", status="old")
do a=1,mod%t_num_ions
read(unit=14,fmt=*)this_im%atomic_mass(a)
end do
close(unit=14)
do a=1,mod%t_num_ions
this_im%sum(a,1) = (this_im%lattvec(1,1)+this_im%lattvec(2,1)+this_im%lattvec(3,1))
this_im%sum(a,2) = (this_im%lattvec(1,2)+this_im%lattvec(2,2)+this_im%lattvec(3,2))
this_im%sum(a,3) = (this_im%lattvec(1,3)+this_im%lattvec(2,3)+this_im%lattvec(3,3))
end do
this_im%coords_xyz = this_im%sum * this_im%coords
this_im%coords_done = this_im%scale * this_im%coords_xyz
do a=1,mod%t_num_ions
! write(unit=*,fmt=3)"done",(this_im%coords_done(a,b),b=1,3)
end do
return
end subroutine read_POSCAR
!----------------------------------------------------------------------------------------------------------------------------------
subroutine write_POSCAR(mod, counter, this_im, im_file, spar_file)
USE IMAGE_MODULE
implicit none
type (model) :: mod
type (image) :: this_im
character (len=10) :: im_file, spar_file
integer, intent(in) :: counter
integer :: a,b
print *, "********************************************"
print *, "inside write_POSCAR"
print *, counter
print *, im_file, spar_file
do a=1,mod%t_num_ions
! write(unit=*,fmt=3)"im",(this_im%coords_done(a,b),b=1,3)
end do
3 format(A10,2x,3(1x,f12.6))
4 format(A10,2x,3(1x,f12.6),A10,2x,3(1x,A2))
open(unit=16, file=spar_file, action="write", status="unknown")
write(unit=16, fmt=*) "HF DIRECT STO-3G"
write(unit=16, fmt=*) " "
write(unit=16, fmt=*) "0 1"
do a=1,mod%t_num_ions
write(unit=16, fmt=6) this_im%atomic_mass(a), (this_im%coords_done(a,b),b=1,3)
end do
write(unit=16, fmt=7) "endcart"
write(unit=16, fmt=*) " "
6 format(I3,2x,3(f12.6))
7 format(A7)
close(unit=16)
return
end subroutine write_POSCAR
!----------------------------------------------------------------------------------------------------------------------------------
MODULE IMAGE_MODULE
type model
integer :: num_spec
integer :: t_num_ions
end type model
type image
character (len=10) :: name, direct, seldyn
real :: scale
integer :: a,b
real,dimension(1:3,1:3) :: lattvec
integer,dimension(1:2) :: num_atoms_of_species
integer,dimension(1:48) :: atomic_mass
real,dimension(1:48,1:3) :: sum
real,dimension(1:48,1:3) :: coords
real,dimension(1:48,1:3) :: coords_xyz
real,dimension(1:48,1:3) :: coords_done
character (len=2),dimension(1:48,1:3) :: dyn
real,dimension(1:3) :: sum_pos
end type image
end MODULE IMAGE_MODULE
|