program xyzgjf !xyz转成gjf
implicit none
integer::i,j,k,l,base,ierr
character(len=20)::name,name1,a(1),b,c,d
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
name1=trim(name)
if (i>=1) then
Open(base+i,file='name1.xyz_i')
Open(11,file='name1.gjf')
Do j=1,1
read(base+i,*)
End Do
else
Open(12,file='name1.xyz')
Open(11,file='name1.gjf')
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
42.19 KB, 下载次数: 0
1crn.xyz_1等文件传不上去,麻烦各位老师将此文件测试后,再改为1crn.xyz_1试一试 ...
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
珊瑚虫 发表于 2015-11-18 10:20
看了一下你得程序发现了两个问题:
1.你得程序中没有判断有多少个文件,你在问题表述中说 “有一系列文件要 ...
978142355 发表于 2015-11-18 15:11
暂时功能未完全实现,等实现了,我将代码粘贴出来,方便以后的人。先谢谢你提供的思路。 ...
Program xyzgjf !xyz converts to gjf
Implicit none
Integer::i,j,ierr,k,l,m
Character(len=20)::a(1),name,name2,b,c,d
Real(8)::x,y,z
b='%chk=name.chk'
c='#p B3LYP/6-31G opt '
d='Title Card Required'
k=0
l=1
write(*,*) 'Input the name of coordination(e.g.1crn or 1crn.xyz_n):'
Read(*,*) name
name2=trim(name(:index(name,'.')))//'gjf'
Open(12,file=name)
Open(13,file=name2)
Do i=1,1
read(12,*)
End Do
write(13,"(a20,/,a20,/,/,a20,/,/,I1,1x,I1 )") b,c,d,k,l
Do
Read(12,'(8x,a1,2x,f12.6,f12.6,f12.6)',Iostat=ierr) a(1),x,y,z
If(ierr==0) then
write(13,'(1x,a,14x,f12.6,2x,f12.6,2x,f12.6)') trim(a(1)),x,y,z
End If
if (ierr/=0) exit
End Do
Close(12)
Close(13)
End
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |