如何使2个Fortran子例程具有相同的输出文件?

时间:2018-09-10 05:07:54

标签: fortran vmd

我需要编写两个圆的数据的代码才能将其导出为动画(vmd)。这应该给我大约6000个数据(每圈3000个)。

当我运行程序时,它仅写入第一个圆的数据。 如何将两组数据写入同一文件? 这是我使用的代码

       Program circulo
       implicit double precision(A-H,O-Z)
       Character*4 W1,W6
       Character*4 W2,W7   
       Open(3,file='circular.xyz',access='append',action='readwrite')
       open(9,file='circular.dat',form='formatted',action='readwrite')
       Call Circular1
       Call Circular2
       Stop
       End 
c*******************************************************************************

       Subroutine Circular1
       implicit double precision(A-H,O-Z)
       Dimension x(9000),y(9000),z(9000)
       Character*4 W1,W6
       W1='Rb'
       W6='   '
       Natomos = 1


       rewind(3)
       rewind(9)

       write(6,*) 'dame el valor del radio'
       read(5,*)Radio
       write(6,*) 'dame el valor del angulo inicial'
       read(5,*) Phio
       write(6,*) 'dame el valor de la velocidad angular'
       read(5,*) wo
       write(6,*) 'dame el valor de la aceleracion angular'
       read(5,*) alpha
       write(6,*) 'Estoy trabajando'

       Pi      = 3.1416
       Fact    = Pi/180.0d0
       Phio    = Phio*Fact
       Nciclos = 3000
       t       = 0.0
       dt      =0.005
       do i = 1,Nciclos
            write(3,*)Natomos
            write(3,*)
            Phi  = Phio + wo*t +.5*alpha*t*t
            x(i) = Radio*cos(Phi)
            y(i) = Radio*sin(Phi)
            z(i) = 0.0
            t    = t + dt
            write(9,23)x(i),y(i)
            write(3,12)w1,w6,x(i),y(i),z(i)       
       end do
23     FORMAT(2F15.6)
12     FORMAT(A4,A8,3F22.6)

       close(9)
       close(3)

       RETURN
       END subroutine
c**************************************************************************

       Subroutine Circular2
       implicit double precision(A-H,O-Z)
       Dimension a(9000),b(9000),c(9000)
       Character*4 W2,W7
       W2='Hg'
       W7='   '
       Natomos = 1


       rewind(3)
       rewind(9)

       write(6,*) 'dame el valor del radio2'
       read(5,*)Radio2
       write(6,*) 'dame el valor del angulo inicial2'
       read(5,*) Phio2
       write(6,*) 'dame el valor de la velocidad angular2'
       read(5,*) wo2
       write(6,*) 'dame el valor de la aceleracion angular2'
       read(5,*) alpha2
       write(6,*) 'Estoy trabajando'

       Pi      = 3.1416
       Fact    = Pi/180.0d0
       Phio2    = Phio2*Fact
       Nciclos = 3000
       t       = 0.0
       dt      =0.005
       do i = 1,Nciclos
            write(3,*)Natomos
            write(3,*)
            Phi  = Phio2 + wo2*t +.5*alpha2*t*t
            a(i) = Radio2*cos(Phi)
            b(i) = Radio2*sin(Phi)
            c(i) = 0.0
            t    = t + dt
            write(9,23)a(i),b(i)
            write(3,12)w2,w7,a(i),b(i),c(i)       
       end do
23     FORMAT(2F15.6)
12     FORMAT(A4,A8,3F22.6)

       close(9)
       close(3)

       RETURN
       END subroutine

0 个答案:

没有答案