fcode 发表于 2015-11-24 12:26 老大,这确实是我所需要的,还是你厉害啊。我在你写的这个代码中,有一项我不太懂,那就是pack(z,z/=0),虽然我也猜到了它的用途,不过它具体的用法和意思是什么? |
也许这个代码是你需要的 [Fortran] 纯文本查看 复制代码 Program removezero Implicit none Integer::i,j Character(len=20)::name,name1,name2,name3(2),name4(1) Real(kind=kind(0.0d0))::a,b,c Integer::d,e,f,g,h,k,ierr write(*,*) 'Input the name of xyz:' Read(*,*) name name1=trim(adjustl(name))//'.xyz' name2=trim(adjustl(name))//'1.xyz' Open(12,file=name1) Open(13,file=name2) Do i=1,1 read(12,*) name3(1),name3(2) write(13,"(2x,a,2x,a)") trim(name3(1)),trim(name3(2)) End Do Do read(12,*,iostat=ierr) k,name4(1),a,b,c,d,e,f,g,h If(ierr==0) then If (f==0 .or. g==0 .or. h==0 ) cycle write(13,"(2x,I4,2x,a2,2x,F12.6,f12.6,f12.6,2x,I4,2x,I4,2x,I4,2x,I4,2x,I4)")k,& trim(name4(1)),a,b,c,d,e,f,g,h End if If(ierr/=0) exit End Do Read(*,*) Close(12) Close(13) End |
捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )
GMT+8, 2024-11-25 02:58