Print 2

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

program main 3 continue

common numrow,numcol
open(unit=5,file='a.txt',status='old') do 4 i=1,nrf
open(unit=6,file='x.out') x=lrfp(i,1)
read(5,*)numpar,maxstp,iseed y=lrfp(i,2)
read(5,*)numrow,numcol,isour,jsour reactr(x,y)=2
read(5,*)nabs,nes,nrf 4 continue

do 1 i=1,nabs do 5 i=1,numrow
read(5,*)(labp(i,j),j=1,2) write(6,*)(reactr(i,j),j=1,numcol)
1 continue 5 continue
end
do 2 i=1,nes
read(5,*)(lesp(i,j),j=1,2) integer function simulate(reactr,isourn,jsourn,maxstp,iseed,flag)
2 continue c simulate simulates one particle at a time and returns to main values to
compute the % that is absorbed, the percentage that escapes; and the
do 3 i=1,nrf percentage that remains.
read(5,*)(lrfp(i,j),j=1,2) integer isourn,jsourn,maxstp,iseen,flag,jnew,inew,i,fflag
3 continue integer isourt,jsourt
real y
write(6,*)'in a',numrow,' by',numcol,' array' integer reactr(25,25)
write(6,*)'with a source at position (',isour,',',jsour,')' integer stepnum
call build(numrow,numcol,isour,jsour,nabs,labp,nes,lesp,nrf,+lrfp,reactr) stepnum=0
isourt=isourn
flag=1 jsourt=jsourn
do 4 i=1,numpar inew=isourt
ret=simulate(reactr,isour,jsour,maxstp,iseed,flag) jnew=jsourt
if (i.gt.0.0) then
flag=0 do 1 i=1,maxstp
end if y=urand(iseed)
if (ret.lt.0) then if (y.ge.0.0 .and. y.le. .25) then
abscnt=abscnt+1 jnew=jsourt+1 move right
else if(ret.gt.0) then else if(y.gt..25.and.y.le..50) then
esccnt=esccnt+1 inew=isourt-1 move up
else if(ret.eq.0) then else if(y.gt..50.and.y.le..75) then
remcnt=remcnt+1 jnew=jsourt-1 move left
end if else
4 continue inew=isourt+1 move down
end if
peresc=(real(esccnt)/real(numpar))*100. if((inew.eq.0).or.(jnew.eq.0)) then
perabs=(real(abscnt)/real(numpar))*100. write(6,*)'error to the max'
perrem=(real(remcnt)/real(numpar))*100. end if
write(6,*)'the percentage of particles that escaped is',peresc,'%' if(inew.eq.(numrow+1) .or. jnew.eq.(numcol+1)) then
write(6,*)'the percentage of particles that were absorbed is',perabs,'%' write(6,*)'error to the max'
write(6,*)'the percentage of particles that remain is',perrem,'%' end if
end if (flag.eq.1) then
write(6,*)stepnum,' ',y,' ',inew,'
subroutine build(numrow,numcol,isour,jsour,nabs,labp,nes,lesp,nrf,+lrfp,reactr) ',jnew
c subroutine builds the reactor array by assigning abs pts, esc pts & ref pts. end if
if (reactr(inew,jnew).eq.2.0) then
integer numpar,maxstp,iseed,numrow,numcol,isour,jsour,nabs stepnum=stepnum+2
integer nes,nrf,i,j inew=isourt
integer x,y jnew=jsourt
integer reactr(25,25) else
integer labp(625,25) stepnum=stepnum+1
integer lesp(625,25) end if
integer lrfp(625,25) if (reactr(inew,jnew).eq.-1.0) then
fflag=-stepnum
do 1 i=1,numrow goto 9
do 1 j=1,numcol end if
reactr(i,j)=0 if (reactr(inew,jnew).eq.1.0) then
1 continue fflag=stepnum
goto 9
do 2 i=1,nabs end if
x=labp(i,1) if (stepnum.eq.maxstp+1) then
y=labp(i,2) fflag=0
reactr(x,y)=-1 goto 9
2 continue end if
isourt=inew
do 3 i=1,nes jsourt=jnew
x=lesp(i,1) 1 continue
y=lesp(i,2) 9 simulate = fflag
reactr(x,y)=1 Return end

You might also like