嵌套循环的问题,第二个循环中的重现

时间:2018-02-21 16:16:12

标签: fortran openmp gfortran

我遇到的问题是:我需要一个并行的嵌套循环。为简化起见,代码如下:

    do i=1,nelectron

     trigger=0

     do step=1,nt
        if(step==1)then
            call maxwellian(vx1_new,vy1_new,vz1_new,vt)       
        end if
        vx1_old=vx1_new
        vy1_old=vy1_new
        vz1_old=vz1_new
        x_old=x_new
        y_old=y_new

        call moveparticle(vx1_old,vy1_old,vz1_old,dt,step)
        call boundary(x_new,y_new,step+1)

        if(mod(step-1,100)==0)then
           ntrap((step-1)/100)=ntrap((step-1)/100)+1
        endif

        if(trigger==1)then
           energy_out=energy_out+energy
           go to 10
        endif
        call energy_track(x_new,y_new,vx1_new,vy1_new,vz1_new,step)
        call track_current(x_new,y_new,vx1_new,vy1_new,vz1_new,step)

        call collision(melectron,mh2,vx1_new,vy1_new,vz1_new,step+1)

     end do
     10   call datadump(step)
   enddo 

如何将i分配给不同的线程,而在每个线程上j循环已经完成。

0 个答案:

没有答案