@@ -102,6 +102,9 @@ subroutine sample_Dist(this,distparam,nparam,flagdist,geom,grid,Flagbc,ib,Nb)
102102 else if (flagdist.eq. 166 ) then
103103 ! read in an initial distribution with format from IMPACT-T
104104 call read_Dist(this,nparam,distparam,ib)
105+ else if (flagdist.eq. 167 ) then
106+ ! read in an initial distribution with format from IMPACT-T
107+ call readimpz_Dist(this,nparam,distparam,ib)
105108 else if (flagdist.eq. 24 ) then
106109 call readParmela_Dist(this,nparam,distparam,geom,grid,Flagbc)
107110 else if (flagdist.eq. 25 ) then
@@ -1053,6 +1056,117 @@ subroutine readold_Dist(this,nparam,distparam,ib)
10531056
10541057 end subroutine readold_Dist
10551058
1059+ subroutine readimpz_Dist (this ,nparam ,distparam ,ib )
1060+ implicit none
1061+ include ' mpif.h'
1062+ type (BeamBunch), intent (inout ) :: this
1063+ integer , intent (in ) :: nparam,ib
1064+ double precision , dimension (nparam) :: distparam
1065+ integer :: i,j,jlow,jhigh,avgpts,myid,nproc,ierr,nptot,nleft
1066+ double precision , dimension (9 ) :: tmptcl
1067+ double precision :: sum1,sum2
1068+ character * 12 name1
1069+ character * 13 name2
1070+ character * 14 name3
1071+ integer :: k,l
1072+ real * 8 :: rcpgammai,xl,gam0,betai
1073+
1074+ call MPI_COMM_RANK(MPI_COMM_WORLD,myid,ierr)
1075+ call MPI_COMM_SIZE(MPI_COMM_WORLD,nproc,ierr)
1076+
1077+ name1 = ' partclx.data'
1078+ name2 = ' partclxx.data'
1079+ name3 = ' partclxxx.data'
1080+
1081+ if (ib.eq. 1 ) then
1082+ open (unit= 12 ,file= ' partcl.data' ,status= ' old' )
1083+ else if (ib.lt. 10 ) then
1084+ name1(7 :7 ) = char (ib+48 )
1085+ open (unit= 12 ,file= name1,status= ' old' )
1086+ else if (ib.lt. 100 ) then
1087+ i = ib/ 10
1088+ j = ib - 10 * i
1089+ name2(7 :7 ) = char (i+48 )
1090+ name2(8 :8 ) = char (j+48 )
1091+ open (unit= 12 ,file= name2,status= ' old' )
1092+ else if (ib.lt. 1000 ) then
1093+ i = ib/ 100
1094+ j = ib - 100 * i
1095+ k = j/ 10
1096+ l = j - 10 * k
1097+ name3(7 :7 ) = char (i+48 )
1098+ name3(8 :8 ) = char (k+48 )
1099+ name3(9 :9 ) = char (l+48 )
1100+ open (unit= 12 ,file= name3,status= ' old' )
1101+ else
1102+ print * ," over maximum # of input particle files:...."
1103+ stop
1104+ endif
1105+
1106+ sum1 = 0.0
1107+ sum2 = 0.0
1108+
1109+ read (12 ,* )nptot,gam0,xl
1110+
1111+ if (nptot.ne. this% Npt) then
1112+ print * ," Error: Total particle # in the partcl.data file is different from that in the ImpactT.in file."
1113+ stop
1114+ endif
1115+
1116+ avgpts = nptot/ nproc
1117+ nleft = nptot - avgpts* nproc
1118+ if (myid.lt. nleft) then
1119+ avgpts = avgpts+1
1120+ jlow = myid* avgpts + 1
1121+ jhigh = (myid+1 )* avgpts
1122+ else
1123+ jlow = myid* avgpts + 1 + nleft
1124+ jhigh = (myid+1 )* avgpts + nleft
1125+ endif
1126+ allocate (this% Pts1(9 ,avgpts))
1127+ this% Pts1 = 0.0
1128+ ! jlow = myid*avgpts + 1
1129+ ! jhigh = (myid+1)*avgpts
1130+ print * ," avgpts, jlow, and jhigh: " ,avgpts,jlow,jhigh
1131+ do j = 1 , nptot
1132+ read (12 ,* )tmptcl(1 :9 )
1133+ rcpgammai = 1.0d0 / (gam0- tmptcl(6 ))
1134+ betai = sqrt (1.0d0 - rcpgammai* rcpgammai* (1 + tmptcl(2 )** 2 + &
1135+ tmptcl(4 )** 2 ) )
1136+
1137+ sum1 = sum1 + tmptcl(1 )
1138+ sum2 = sum2 + tmptcl(3 )
1139+ if ( (j.ge. jlow).and. (j.le. jhigh) ) then
1140+ i = j - jlow + 1
1141+ this% Pts1(1 ,i) = (tmptcl(1 )- tmptcl(2 )* tmptcl(5 )* rcpgammai)* xl
1142+ this% Pts1(2 ,i) = tmptcl(2 )
1143+ this% Pts1(3 ,i) = (tmptcl(3 )- tmptcl(4 )* tmptcl(5 )* rcpgammai)* xl
1144+ this% Pts1(4 ,i) = tmptcl(4 )
1145+ this% Pts1(5 ,i) = - betai* tmptcl(5 )* xl
1146+ this% Pts1(6 ,i) = betai/ rcpgammai
1147+ this% Pts1(7 ,i) = tmptcl(7 )
1148+ this% Pts1(8 ,i) = tmptcl(8 )
1149+ this% Pts1(9 ,i) = tmptcl(9 )
1150+ endif
1151+ ! if(myid.eq.0) print*,i,sum1,sum2
1152+ enddo
1153+ print * ," sumx1,sumy1: " ,sum1/ nptot,sum2/ nptot
1154+
1155+ close (12 )
1156+
1157+ this% Nptlocal = avgpts
1158+ ! change length to the dimensionless unit
1159+ do i = 1 , avgpts
1160+ this% Pts1(1 ,i) = this% Pts1(1 ,i)/ Scxlt + distparam(6 )
1161+ this% Pts1(2 ,i) = this% Pts1(2 ,i) + distparam(7 )
1162+ this% Pts1(3 ,i) = this% Pts1(3 ,i)/ Scxlt + distparam(13 )
1163+ this% Pts1(4 ,i) = this% Pts1(4 ,i) + distparam(14 )
1164+ this% Pts1(5 ,i) = this% Pts1(5 ,i)/ Scxlt + distparam(20 )
1165+ this% Pts1(6 ,i) = this% Pts1(6 ,i) + distparam(21 )
1166+ enddo
1167+
1168+ end subroutine readimpz_Dist
1169+
10561170 subroutine readParmela_Dist (this ,nparam ,distparam ,geom ,grid ,Flagbc )
10571171 implicit none
10581172 include ' mpif.h'
0 commit comments