program mass centre
implicit real*8 (a-h,o-z)
c qa: coordinations of atom
dimension qa(10000,3)
c ns: number of atoms
dimension ns(10000)
c qcm: coordinations of mass centre
dimension qcm(3)
c wa: mass of atoms
dimension wa(10000)
c u1,u2 are useless
character::u1(10000)
character::u2(10000)
parameter(N=14.00672)
parameter(H=1.00795)
parameter(C=12.01078)
open(1,file='tmp100.txt')
open(2,file='mass_centre')
do i=1,10000
do j=1,3
read(1,*)u1(i),u2(2),ns(i),qa(i,j)
enddo
enddo
do i=1,10000
do j=1,3
write(2,*)ns(i),qa(i,1:10000)
enddo
enddo
close(2)
end
439.45 KB, 下载次数: 18
program mascentre
implicit none
Integer , parameter :: N = 10000
Real(8) :: qa(N,3)
Integer :: ns(N) , i
character::u
open(11,file='tmp100.txt')
open(12,file='mass_centre.txt')
do i=1,N
read(11,*) u ,u , ns(i),qa(i,:)
write(12,'(i6,3(f13.6,1x))') ns(i) , qa(i,:)
enddo
close(11)
close(12)
end program mascentre
vvt 发表于 2017-7-7 11:34
这个需求可以很简单的实现,楼主您写复杂了。
如果后面不再需要,ns 和 qa 都可以不用数组。
[mw_shl_code= ...
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |