module communicators integer,save :: gcomm,nloc,nproc ! integer, save :: phase,confg end module communicators module domain_confg use communicators integer, save :: l1s,l1e,l1d,l2s,l2e,l2d integer, save :: nl1,nl2 integer, save :: ng1,ng2,ngd1,ngd2 end module domain_confg subroutine setup_confg(n1,n2) use domain_confg integer n1,n2 ng1 = n1 ; ng2 = n2 ngd1 = ng1 ; ngd2 = ng2 nl1 = ngd1 ; nl2 = ngd2/nproc l1s = 1 ; l1d = ngd1 ; l1e = ng1 l2s = 1+nl2*nloc ; l2d = l2s+nl2-1 ; l2e = l2d return end subroutine setup_confg module domain_phase use communicators integer, save :: l1s,l1e,l1d,l2s,l2e,l2d integer, save :: nl1,nl2 integer, save :: ng1,ng2,ngd1,ngd2 end module domain_phase subroutine setup_phase(n1,n2) use domain_phase integer n1,n2 ng1 = 2*n2 ; ng2 = n1/2 ngd1 = ng1 ; ngd2 = ng2 nl1 = ngd1 ; nl2 = ngd2/nproc l1s = 1 ; l1d = l1s+nl1-1; l1e = l1d l2s = 1+nl2*nloc ; l2d = l2s+nl2-1 if (l2d.lt.ng2) then l2e = l2d else l2e = ng2 end if if (l2s.gt.ng2) then l2s = 0; l2e = 0 end if return end subroutine setup_phase module fft_stuff integer, save :: len1,len2,xc,np1,np2 real*8, allocatable, save :: work(:),trig1(:),trig2(:) real*8, save :: scale0,scale1,scale2 end module fft_stuff subroutine setup_fft() use domain_confg use fft_stuff integer isign,isys,nt len1 = ng1; len2 = ng2; xc = len1/2; np1 = xc/nproc; np2 = ngd2/nproc allocate(trig1(8*ng1)) ; trig1 = 0.0 allocate(trig2(16*ng2)) ; trig2 = 0.0 allocate(work(8*ngd1*ngd2/nproc)) ; work=0.0 nt = 1 isys = 0 isign = 0 scale0 = 1.0 scale1 = 1.0/float(len1) scale2 = 1.0/float(len2) ! call hgfft(isys,len1,scale0,work,work,trig1,work,isys) ! call ggfft(isys,len2,scale0,work,work,trig2,work,isys) ! call scfft1dui(ng1, trig1) ! call cfftm1di(ng2, trig2) call dzfft1dui(ng1, trig1) call zfftm1di(ng2, trig2) ! call dzfftf(ng1, trig1) ! call dzfftmf(ng2, trig2) ! call dzfft(isign,len1,scale0,work,work,trig1,work,isys) ! call zzfftm(isys,len2,nt,scale0,work,len2,work,len2,trig2,work,isys) ! call zzfft(isys,len2,scale0,work,work,trig2,work,isys) ! print *,'trig1 = ', trig1 ! print *,'trig2 = ', trig2 return end subroutine setup_fft module IO_cham integer, save, dimension(2):: arrdim,gdim,lstart,lend,gstart,gend integer, save:: nbytes end module IO_cham subroutine IO_cham_confg() use domain_confg use IO_cham nbytes = 8 gdim(1) = ngd1; gdim(2) = ngd2 arrdim(1) = nl1; arrdim(2) = nl2 lstart = 1 lend = arrdim gstart(1) = l1s; gstart(2) = l2s gend(1) = l1d; gend(2) = l2d return end subroutine IO_cham_confg subroutine IO_cham_phase() use domain_phase use IO_cham nbytes = 8 gdim(1) = ngd1; gdim(2) = ngd2 arrdim(1) = nl1; arrdim(2) = nl2 lstart = 1 lend = arrdim gstart(1) = l1s; gstart(2) = l2s gend(1) = l1d; gend(2) = l2d return end subroutine IO_cham_phase module wave_stuff integer, allocatable, save :: ind1(:),ind2(:) end module wave_stuff subroutine setup_wave() use domain_phase use wave_stuff ! ! NOTE the order of indices in phase space is Y X ! allocate(ind1(l1s:l1d+4)) ! read as kx allocate(ind2(l2s:l2d+4)) ! read as ky ind1 = 0; ind2=0 call wave_numbers(ind1,ind2) return end subroutine setup_wave module grid_stuff real*8, save :: safety,dx,dy,pi,twopi contains function get_np_for_xy(x,y) result(ip) use steps_stuff use domain_confg use communicators implicit none real*8,intent(in) :: x,y integer :: ip integer :: ierr real*8 :: ys,ye ! ************************ ! for vertical decomp only for now... ! ************************ do ip = 0,nproc-1 ys = (nl2*ip+0)*dy ye = nl2*(ip+1)*dy ! write(*,*)'in the ip loop',ys,ye if ((y>=ys).AND.(y lparticle_new end if np_last = np_last + 1 index = np_last end function get_new_p end module particle subroutine setup_output_particle(tnumber) use communicators use particle use particle_number use gband_stuff integer tnumber if(allocated(pwk1)) deallocate(pwk1) if(allocated(pwk2)) deallocate(pwk2) if(allocated(pwk3)) deallocate(pwk3) if(allocated(pwk4)) deallocate(pwk4) if(allocated(pwk5)) deallocate(pwk5) if(allocated(pwk6)) deallocate(pwk6) if(allocated(pwk7)) deallocate(pwk7) if(allocated(pwk8)) deallocate(pwk8) if(allocated(pwk9)) deallocate(pwk9) if(allocated(pwk10))deallocate(pwk10) allocate(pwk1(mypp(2))); pwk1 = 0.0 allocate(pwk2(mypp(2))); pwk2 = 0.0 allocate(pwk3(totpp(2))); pwk3 = 0.0 allocate(pwk4(totpp(2))); pwk4 = 0.0 allocate(pwk5(mymp(2))); pwk5 = 0.0 allocate(pwk6(mymp(2))); pwk6 = 0.0 allocate(pwk7(totmp(2))); pwk7 = 0.0 allocate(pwk8(totmp(2))); pwk8 = 0.0 if(tnumber .gt. 0) then allocate(pwk9(tnumber)); pwk9 = 0.0 allocate(pwk10(tnumber));pwk10= 0.0 endif return end subroutine setup_output_particle subroutine setup_output_gparticle use communicators use particle use particle_number use gband_stuff if(allocated(pwk1)) deallocate(pwk1) if(allocated(pwk2)) deallocate(pwk2) if(allocated(pwk3)) deallocate(pwk3) if(allocated(pwk4)) deallocate(pwk4) if(allocated(pwk5)) deallocate(pwk5) if(allocated(pwk6)) deallocate(pwk6) if(allocated(pwk7)) deallocate(pwk7) if(allocated(pwk8)) deallocate(pwk8) allocate(pwk1(mypp(2)+mymp(2))); pwk1 = 0.0 allocate(pwk2(mypp(2)+mymp(2))); pwk2 = 0.0 allocate(pwk3(totpp(2))); pwk3 = 0.0 allocate(pwk4(totpp(2))); pwk4 = 0.0 allocate(pwk5(mypp(2)+mymp(2))); pwk5 = 0.0 allocate(pwk6(mypp(2)+mymp(2))); pwk6 = 0.0 allocate(pwk7(totmp(2))); pwk7 = 0.0 allocate(pwk8(totmp(2))); pwk8 = 0.0 return end subroutine setup_output_gparticle subroutine setup_escape_particle use communicators use particle use particle_number use gband_stuff if(allocated(ewk1)) deallocate(ewk1) if(allocated(ewk2)) deallocate(ewk2) if(allocated(ewk3)) deallocate(ewk3) if(allocated(ewk4)) deallocate(ewk4) if(allocated(ewk5)) deallocate(ewk5) if(allocated(ewk6)) deallocate(ewk6) if(allocated(ewk7)) deallocate(ewk7) if(allocated(ewk8)) deallocate(ewk8) allocate(ewk1(myep(1))); ewk1 = 0.0 allocate(ewk2(myep(1))); ewk2 = 0.0 allocate(ewk3(myep(1))); ewk3 = 0.0 allocate(ewk4(myep(1))); ewk4 = 0.0 allocate(ewk5(totep(1))); ewk5 = 0.0 allocate(ewk6(totep(1))); ewk6 = 0.0 allocate(ewk7(totep(1))); ewk7 = 0.0 allocate(ewk8(totep(1))); ewk8 = 0.0 return end subroutine setup_escape_particle subroutine setup_particle use communicators use particle use particle_number use gband_stuff num_pp = 05 num_mp = 05 !if(allocated(ppx)) deallocate(ppx) !if(allocated(ppy)) deallocate(ppy) !if(allocated(mpx)) deallocate(mpx) !if(allocated(mpy)) deallocate(mpy) !if(allocated(tppy)) deallocate(tppy) !if(allocated(tmpx)) deallocate(tmpx) !if(allocated(tmpy)) deallocate(tmpy) if(allocated(mwk1x)) deallocate(mwk1x) if(allocated(mwk1y)) deallocate(mwk1y) if(allocated(mwk2x)) deallocate(mwk2x) if(allocated(mwk2y)) deallocate(mwk2y) if(allocated(myescp)) deallocate(myescp) if(allocated(tescp)) deallocate(tescp) if(allocated(ppcounts)) deallocate(ppcounts) if(allocated(mpcounts)) deallocate(mpcounts) if(allocated(tpcounts)) deallocate(tpcounts) if(allocated(ppindx)) deallocate(ppindx) if(allocated(ppindy)) deallocate(ppindy) if(allocated(mpindx)) deallocate(mpindx) if(allocated(mpindy)) deallocate(mpindy) if(allocated(tppindx))deallocate(tppindx) if(allocated(tppindy))deallocate(tppindy) if(allocated(tmpindx))deallocate(tmpindx) if(allocated(tmpindy))deallocate(tmpindy) !allocate(ppx(mypp(2))); ppx = 0.0 !allocate(ppy(mypp(2))); ppy = 0.0 !allocate(mpx(mymp(2))); mpx = 0.0 !allocate(mpy(mymp(2))); mpy = 0.0 !allocate(tmpx(totmp(2))); tmpx = 0.0 !allocate(tmpy(totmp(2))); tmpy = 0.0 allocate(mwk1x(mypp(1))); mwk1x = 0.0 allocate(mwk1y(mypp(1))); mwk1y = 0.0 allocate(mwk2x(mymp(1))); mwk2x = 0.0 allocate(mwk2y(mymp(1))); mwk2y = 0.0 allocate(tescp(totep(1))); tescp = 0.0 allocate(ppcounts(nproc)); ppcounts=0 allocate(mpcounts(nproc)); mpcounts=0 allocate(tpcounts(nproc)); tpcounts=0 allocate(ppindx(mypp(1))); ppindx = 0 allocate(ppindy(mypp(1))); ppindy = 0 allocate(mpindx(mymp(1))); mpindx = 0 allocate(mpindy(mymp(1))); mpindy = 0 allocate(tppindx(totpp(1))); tppindx = 0 allocate(tppindy(totpp(1))); tppindy = 0 allocate(tmpindx(totmp(1))); tmpindx = 0 allocate(tmpindy(totmp(1))); tmpindy = 0 return end subroutine setup_particle subroutine setup_particle1 use communicators use particle use particle_number use gband_stuff if(allocated(rk3u1)) deallocate(rk3u1) if(allocated(rk3u2)) deallocate(rk3u2) if(allocated(rk3v1)) deallocate(rk3v1) if(allocated(rk3v2)) deallocate(rk3v2) if(allocated(rk3x1)) deallocate(rk3x1) if(allocated(rk3x2)) deallocate(rk3x2) if(allocated(rk3y1)) deallocate(rk3y1) if(allocated(rk3y2)) deallocate(rk3y2) allocate(rk3u1(mypp(2)+mymp(2))); rk3u1 = 0. allocate(rk3u2(mypp(2)+mymp(2))); rk3u2 = 0. allocate(rk3v1(mypp(2)+mymp(2))); rk3v1 = 0. allocate(rk3v2(mypp(2)+mymp(2))); rk3v2 = 0. allocate(rk3x1(mypp(2)+mymp(2))); rk3x1 = 0. allocate(rk3y1(mypp(2)+mymp(2))); rk3y1 = 0. allocate(rk3x2(mypp(2)+mymp(2))); rk3x2 = 0. allocate(rk3y2(mypp(2)+mymp(2))); rk3y2 = 0. return end subroutine setup_particle1 !************************************************* subroutine file_name(f1,f2,n,dot) !----------------------------------------------------------- ! This routine is used to generate numbered filenames. ! ! if f1='banana' and n=12 then on exit ! f2='banana0012' !----------------------------------------------------------- logical dot ! character*1 name(4) integer nn(4),i,i0,n character(len=80) :: f1,f2 !------------------------- nn(1) = n/1000 nn(2) = (n - nn(1)*1000)/100 nn(3) = (n - nn(1)*1000 - nn(2)*100)/10 nn(4) = (n - nn(1)*1000 - nn(2)*100 - nn(3)*10) ! do i=1,4 name(i) = char(48+nn(i)) enddo ! i0=index(f1,' ')-1 if (dot) then f2 = f1(1:i0)//'.'//name(1)//name(2)//name(3)//name(4) else f2 = f1(1:i0)//name(1)//name(2)//name(3)//name(4) end if ! return end subroutine file_name