[Fortran] 纯文本查看 复制代码
program xyzgjf !xyz转成gjf
implicit none
integer::i,j,k,l,base,ierr
character(len=20)::a(1),b,c,d
character(len=100)::name,name1,name2
real(kind=kind(0.0d0))::x,y,z
b='%chk=name.chk'
c='#p B3LYP/6-31G opt '
d='Title Card Required' !b,c,d 是写在gjf的前几行的
k=0
l=1
base=12
write(*,*)'Input the name of file:'
read(*,*) name
i=3
if (i>=1) then
write(name2,*)i
name1=trim(adjustl(name))//'.xyz_'//trim(adjustl(name2))
Open(base+i,file=trim(adjustl(name1)))
name1=trim(adjustl(name))//'.gjf'
Open(11,file=trim(adjustl(name1)))
Do j=1,1
read(base+i,*)
End Do
else
name1=trim(adjustl(name))//'.xyz'
Open(12,file=trim(adjustl(name1)))
name1=trim(adjustl(name))//'.gjf'
Open(11,file=trim(adjustl(name1)))
Do j=1,1
read(12,*)
End Do
End If
write(11,"(a20,/,a20,/,/,a20,/,/,I1,1x,I1 )") b,c,d,k,l
Do
If (i>=1) then
Read(base+i,'(8x,a1,2x,f12.6,f12.6,f12.6)',Iostat=ierr) a(1),x,y,z
If(ierr==0) then
write(11,'(1x,a,14x,f12.6,2x,f12.6,2x,f12.6)') trim(a(1)),x,y,z
End If
else
Read(12,'(8x,a1,2x,f12.6,f12.6,f12.6)',Iostat=ierr) a(1),x,y,z
If(ierr==0) then
write(11,'(1x,a,14x,f12.6,2x,f12.6,2x,f12.6)') trim(a(1)),x,y,z
End If
End If
If (ierr/=0) exit
End Do
Close(11)
Close(12)
Close(base+i)
End