read(5,"(a)")jj 改为: read(5,"(a)",ioStat=zz)jj if(zz/=0)exit 如果你不加任何判断,5号文件读取结束时,程序接着读取,就会出错。后面的代码自然无法执行。 |
楚香饭 发表于 2022-1-21 20:31 我就是像从文件5中摘取出来一些东西,然后进行统计,再写入6中,但是我在进行完 write(9,500)i,atomtyp,q,x,y,z endif endif enddo 这一步后,我想再写点命令就运行不了了,只有把write(22,*)'1',' 1000cddd'放在do read(5,"(a)")jj if(index(jj,"ATOM") > 0) then i=i+1 read(jj(32:),"(a)")kk的前面才能运行,请老师赐教这是为啥呢 |
楚香饭 发表于 2022-1-21 20:31 [Fortran] 纯文本查看 复制代码 program PDBtodata implicit none character chr1*6,chr2*2,chr3*6,chr4*4,chr5*8,header*80,atmnam*8,ww*200,xx*80,cc*80,& vv*80,nn*80,sss*100 character elmname*3,tt*5 character filename*12,kk*50,jj*200 character*10 bb(3) integer i,j,atomtypes,atomtyp,atomser,natom,nf,R,zz,o,gg,mm,n(9),ntype,ios integer:: date_time(8) real(kind=8) a,b,c,xlo,xhi,ylo,yhi,zlo,zhi,alpha,beta,gamma,& xy,xz,yz,charge,mass(1:7),lx,ly,lz,x,y,z,q,qq,ff real(kind=8), parameter :: pi=3.1415926 write(*,*)'filename: ' read(*,*)filename open(5,file=filename,status='old') open(6,file='105.data') open(7,file='data') open(8,file='da2222ta') open(9,file='da333333ta') open(15,file='dqa') open(20,file='fort.7',status='old') write(6,*) xlo=0.0 ylo=0.0 zlo=0.0 mass=0.0 atomtyp=0 q=0.0 read(5,*) read(5,*) read(5,*)chr3,a,b,c,alpha,beta,gamma,chr4 alpha=(alpha/180.0)*Pi beta=(beta/180.0)*Pi gamma=(gamma/180.0)*Pi lx=a xy=b*dcos(gamma) xz=c*dcos(beta) ly=dsqrt(b*b-xy*xy) yz=(b*c*dcos(alpha)-xy*xz)/ly lz=dsqrt(c*c-xz*xz-yz*yz) xhi=lx yhi=ly zhi=lz write(6,*)'1',' 1000cddd' write(6,*)xlo,xhi,'xlo xhi' write(6,*)ylo,yhi,'ylo yhi' write(6,*)zlo,zhi,'zlo zhi' write(6,*) write(6,*)xy,xz,yz,'xy xz yz' write(6,*) mass(1)=12.011150 mass(2)=1.007970 mass(3)=15.999400 mass(4)=14.006700 mass(7)=26.981539 write(6,*)'Masses' write(6,*) do i=1,6 read(5,*) enddo write(6,*)'1',' 1000cddd' do read(5,"(a)")jj if(index(jj,"ATOM") > 0) then i=i+1 read(jj(32:),"(a)")kk kk=adjustl(kk) read(kk,*)x,y,z,ff,charge,elmname if (index(elmname,"C") > 0) then atomtyp=1 else if (index(elmname,"H") > 0) then atomtyp=2 else if (index(elmname,"O") > 0) then atomtyp=3 else if (index(elmname,"N") > 0) then else if (index(elmname,"Al") > 0) then atomtyp=5 write(9,500)i,atomtyp,q,x,y,z endif endif enddo 200 FORMAT(I6,A8) 300 FORMAT(I6,A12) 500 FORMAT(I6,I3,F9.6,3F15.9) close(5) close(6) if(.true.) then open(22,file='105.data') write(22,*)'1',' 1000cddd' endif end |
代码看不全,所以逻辑也不好分析。 不保密的话,把全部代码给出来。 |
捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )
GMT+8, 2024-5-9 03:55