[問題]請問如何作次數未知的加法?
以下是程式碼
CALL JUMP(DSMAX(MAT),DS) ! Determines segment length.
CALL STEP(DS,DSEF,NCROSS) ! Moves particle to end of step.
WRITE(17,*) N,MIN(DS,DSEF) ! 決定把DS 跟 DSEF的最小值寫入檔案
但是現在有一個問題是, 我想把每一顆粒子的總距離加起來,即是
第一顆的總距離,及第二顆的總距離
例如
1 1.451336171889607E-007
1 1.625982843357572E-007
1 7.786647901384987E-008
1 6.001349813026089E-008
1 2.501697761188227E-008
2 1.989400815159079E-008
2 3.863321521894446E-008
2 2.358943701411900E-008
可是在N=1時 有5個小距離
N=2 有3個小距離
在程式裡要如何知道每一次所有的小距離,然後相加起來
得到各別的N總距離
謝謝
N=0 ! Shower counter.
C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C ------------------------ Shower simulation starts here.
C
101 CONTINUE
N=N+1.0D0
C
C ********** Set the initial state of the primary particle.
C
KPAR=KPARP
X=X0
Y=Y0
Z=Z0
E=E0
CALL GCONE(U,V,W) ! Initial direction.
C
C **** Check if the trajectory intersects the material system.
C
CALL LOCATE
IF(MAT.EQ.0) THEN
CALL STEP(1.0D30,DSEF,NCROSS)
IF(MAT.EQ.0) THEN ! The particle does not enter the system.
PRIM(1)=PRIM(1)+1.0D0
GO TO 105
ENDIF
ENDIF
C
C ************ Primary particle counters.
C
ILB(1)=1 ! Identifies primary particles.
ILB(2)=0
ILB(3)=0
ILB(4)=0
ILB(5)=0
DO IC=1,7
COL(IC)=0.0D0 ! Numbers of events.
ENDDO
DO I=1,NBOD
EDEP(I)=0.0D0 ! Energy deposited in each body.
ENDDO
C ---------------------------------------------------------------------
C ------------------------ Track simulation begins here.
C COMMON/TRACK/E,X,Y,Z,U,V,W,WGHT,KPAR,IBODY,MAT,ILB(5)
CALL CLEANS ! Cleans the secondary stack.
102 CONTINUE
CALL START ! Starts simulation in current medium.
C
103 CONTINUE
CALL JUMP(DSMAX(MAT),DS) ! Determines segment length.
CALL STEP(DS,DSEF,NCROSS) ! Moves particle to end of step.
WRITE(17,*) N,MIN(DS,DSEF)
DS0=DS0+MIN(DS,DSEF)
WRITE(36,*) N,DS0
! DDSS=DDSS+MIN(DS,DSEF)
C
IF(MAT.EQ.0) THEN ! The particle has left the material system.
IEXIT=1 ! Labels emerging particles.
GO TO 104 ! Exit.
ENDIF
C
IF(NCROSS.GT.0) GO TO 102 ! The particle crossed an interface.
C
CALL KNOCK(DE,ICOL) ! Simulates the interaction event.
COL(ICOL)=COL(ICOL)+1.0D0 ! The interaction is counted.
EDEP(IBODY)=EDEP(IBODY)+DE ! Deposited energy counter.
IF(E.LT.EABS(KPAR,mat)) THEN ! The particle has been absorbed.
IEXIT=2 ! Labels absorbed particles.
GO TO 104 ! Exit.
ENDIF
GO TO 103
C ------------------------ The simulation of the track ends here.
C ---------------------------------------------------------------------
104 CONTINUE
C
C ************ Increment particle counters.
C
IF(ILB(1).EQ.1) THEN
PRIM(IEXIT)=PRIM(IEXIT)+1.0D0
DO KC=1,6
AVNI(KC,IEXIT)=AVNI(KC,IEXIT)+COL(KC)
AVNI2(KC,IEXIT)=AVNI2(KC,IEXIT)+COL(KC)**2
ENDDO
ELSE
SEC(KPAR,IEXIT)=SEC(KPAR,IEXIT)+1.0D0
C
C ------------------------ The simulation of the shower ends here.
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C
C **** Energies deposited in different bodies.
C
DO KB=1,NBOD
EDEPT(KB)=EDEPT(KB)+EDEP(KB)
VEDEPT(KB)=VEDEPT(KB)+EDEP(KB)**2
ENDDO
C **** Deposited energy distributions in selected bodies or groups of
C bodies (specific of each geometry).
C In this case, EDEP(1,*) = Energy in body 1.
EDISTR=EDEP(1)
IF(EDISTR.GT.1.0D0) THEN
ICH=1.0D0+EDISTR/DEBIN
ICH=MIN(NCHD,ICH)
EDEPD(1,ICH)=EDEPD(1,ICH)+1.0D0
ENDIF
C
105 CONTINUE
C
C ---- End the simulation after the alloted time or after completing
C DSIMS showers.
CALL TIMER(TSEC)
IF(TSEC.LT.TSECA.AND.N.LT.NTOT) GO TO 101
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.114.106.110
→
12/09 17:40, , 1F
12/09 17:40, 1F
→
12/09 17:42, , 2F
12/09 17:42, 2F
※ 編輯: nestea911399 來自: 140.114.106.110 (12/09 18:21)
推
12/09 18:22, , 3F
12/09 18:22, 3F
→
12/09 18:23, , 4F
12/09 18:23, 4F
→
12/09 18:26, , 5F
12/09 18:26, 5F
推
12/09 18:27, , 6F
12/09 18:27, 6F
→
12/09 18:32, , 7F
12/09 18:32, 7F
→
12/09 18:32, , 8F
12/09 18:32, 8F
→
12/09 18:33, , 9F
12/09 18:33, 9F
推
12/09 18:38, , 10F
12/09 18:38, 10F
→
12/09 18:41, , 11F
12/09 18:41, 11F
→
12/09 19:06, , 12F
12/09 19:06, 12F
→
12/09 19:08, , 13F
12/09 19:08, 13F
推
12/09 19:16, , 14F
12/09 19:16, 14F
→
12/09 19:16, , 15F
12/09 19:16, 15F
→
12/09 21:15, , 16F
12/09 21:15, 16F
推
12/10 00:23, , 17F
12/10 00:23, 17F
→
12/10 00:25, , 18F
12/10 00:25, 18F
→
12/10 00:25, , 19F
12/10 00:25, 19F
推
12/10 00:32, , 20F
12/10 00:32, 20F
→
12/10 00:34, , 21F
12/10 00:34, 21F
→
12/10 00:44, , 22F
12/10 00:44, 22F
推
12/10 02:29, , 23F
12/10 02:29, 23F
推
12/10 10:12, , 24F
12/10 10:12, 24F
→
12/10 12:54, , 25F
12/10 12:54, 25F
→
12/10 23:25, , 26F
12/10 23:25, 26F
推
12/11 00:00, , 27F
12/11 00:00, 27F
→
12/11 11:06, , 28F
12/11 11:06, 28F
Fortran 近期熱門文章
PTT數位生活區 即時熱門文章