-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathendgame.F90
executable file
·221 lines (208 loc) · 10.4 KB
/
endgame.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
!-------
! endgame program that compute the drift, growth and fragmentation
! of grain(s) in a given disc with one or multiple snow line(s)
!-------
program endgame
use config
use initial, only: init
use evolve, only: evol
use functions, only: rho_g,epsi,press
integer :: k = 0
integer :: count = 0
integer :: skip(200) = 0
write (6,"('>',115('_'),'<')")
write(6,40)
40 format(/, &
6x,'@@@@@@@@@@@% /@@@@ @@@@@ @@@@@@@@&, @@@@@ @ @@@ @@@@@ @@@@@ @@@@@@@@@@@@',/, &
6x,'&@@ @% @@@@% @, .@@ .@@@ @@@ @@ &&@@@ @@@@@ @@@@* @@@ @',/, &
6x,'&@@ @. @#/@@@ @, .@@ ,@@ @@@ @ .@ @@ @@*@@( *@ @@* @@@ ',/, &
6x,'&@@@@@@ @# @@@ @, .@@ @@* @@& @@@@@@@ @@ @@@ @ @@* @@@@@@@',/, &
6x,'&@@ @ @ @# @@@ @, .@@ ,@@ @@@ @@@@@ @, @@@ @@ @@@ @@ @@* @@@ /@ @.',/, &
6x,'&@@ @@ @# @@@#@, .@@ @@@ .@@/ @@# @@ .@@& @@ @@&@ @@* @@@ .@',/, &
6x,'@@@@@@@@@@@@ /@@@@ ,@@@, @@@@@@@@@@@ @@@@@@@@*@# @@@@& &&@@@@* @@@@ &@@ @@@@@@ &@@@@@@@@@@@',/ &
6x,' ',/ &
6x,'By Arnaud Vericel. ',/)
write (6,"('>',115('_'),'<')")
!- init everything
call init()
!- open output files and overwrite them if they already exist
if (end_only==0) then
do k=1,ndust
inquire(file=output(k), exist=iexist(k))
if (iexist(k)) then
open(unit=k+100,file=output(k),form="formatted",status="old",action="write")
else
open(unit=k+100,file=output(k),form="formatted",status="new",action="write")
endif
enddo
endif
do while (t .le. tmax)
do k=1,ndust
if (skip(k) == 1) cycle
call evol(r(k),s(k),dsdt(k),vd(k),vdri(k),vvi(k),St(k),vrelonvfrag(k),rho(k),iam(k),iwas(k),iacc(k))
if (r(k) < racc) skip(k) = 1
enddo
t = t + dt
step = step + 1
steptot = nmax * nsteps
if (end_only==0) then
do k=1,ndust
if (mod(step,nsteps*nmax/ndumps) == 0) then
write(k+100,*) t/years,",",r(k)/au,",",abs(vd(k)),",",vdri(k),",",vvi(k),",",s(k),",",&
dsdt(k)*years*1000,",",St(k),",",vrelonvfrag(k),",",rho(k),",",rho_g(r(k)),",",epsi(r(k)),",",press(r(k))
endif
enddo
endif
ntic = int(100 * real(step) / real(steptot))
do k = nprev + 1, ntic
if (mod(k,10) == 0) then
if (k .ne. 100) then
write(0,'(i2,a)',advance='no') k,'%'
else
write(0,'(i3,a,/)',advance='no') k,'%'
#ifdef THANOS
write(0,*) 'Is it done ?'
call sleep(1)
write(0,*) 'Yes.'
call sleep(1)
write(0,*) 'What did it cost ?'
call sleep(2)
write(0,*) 'Everything.'
call sleep(1)
#endif
endif
else
write(0,'(a)',advance='no') '-'
endif
enddo
nprev = ntic
enddo
do k=1,ndust
close(k+100)
enddo
do k=1,ndust
if (isort==1) then
call system('mv ' // output(k) // ' ' // adjustl(trim(dir)))
elseif (end_only==0) then
call system('mv ' // output(k) // ' buffer/')
endif
enddo
if (isort==1) then
call system('cp dust.in ' // ' ' // adjustl(trim(dir)))
call system('mv dust.dat ' // ' ' // adjustl(trim(dir)))
call system('cp disc.in' // ' ' // adjustl(trim(dir)))
call system('cp columns' // ' ' // adjustl(trim(dir)))
elseif (end_only==0) then
call system('cp dust.in buffer/')
call system('mv dust.dat buffer/')
call system('cp disc.in buffer/')
call system('cp columns buffer/')
endif
!- if end_only, print final state to csv file
if (end_only==1) then
open(unit=444, file='particle_accretion.csv', access='append', status='old')
do i=1,ndust
write(444,*) p,",", &
q,",", &
mdisc,",", &
racc,",", &
rin,",", &
rout,",", &
r0,",", &
T0,",", &
alpha,",", &
phi,",", &
w,",", &
epsi0,",", &
epsimax,",", &
rho(i),",", &
vfrag,",", &
vfragin,",", &
vfragout,",", &
rsnow,",", &
rbump,",", &
igrow,",", &
ifrag,",", &
isnow,",", &
ibump,",", &
r_init(i),",", &
s_init(i),",", &
nmax,",", &
iacc(i)
enddo
close(unit=444)
endif
#ifdef THANOS
write(6,50)
50 format(/, &
6x,'**************/**,,,,,,,,,,,,,**//////*,,,,,,**,**,,,,,,,,,,,,*,,,,,,,,,,,,,,,,,,,,,,,,,,',/, &
6x,'************(*,,,,,,,,,,,,,,,,,,,,,,*,,.,*,**,,,*,,,,,,,,,,*,,,*,,,,,,,,,,,,,,,,,,,,,,,,,',/, &
6x,'**********//,,,,,,,,,,,,,.,,,,,,,,,..,....*,,,,*,,,,,,,,,,,,,,,,**,,,,,,,,,,,,,,,,,,,,,,,',/, &
6x,'*********#***,**,,,,,,,,,,,.,.,,,***,,***,*,,,.,,,,,,,,,,,,,,,,****,,,,,,,,,,,,,,,,,,,,,,',/, &
6x,'********/********,,,,,,.....,,,,,,,,,,,,.,,,,,*,,,,*,.,..,,,,,,****/,,,,,,,,,,,,,,,,,,,,,',/, &
6x,'*******/**/******,,,,..,,,,,,,,,,,,,,*****,,.,,,,,**..,,.,,,.,*,,***/,,,,,,,,,,,,,,,,,,,,',/, &
6x,'******/**/******,,,,,,,,,,,,,,,,,,,,,,.,,*,,,,,,,,**.,,.,.,,,,*,,,****,,,,,,,,,,,,,,,,,,,',/, &
6x,'*****#**********,,,,,,,,,,,,,.......,,,,,,,.,,,,,,,*...,...,,,,,,,,****,,,,,,,,,,,,,,,,,,',/, &
6x,'*****#***********,,,,,*,,,.....................,,,,,,,.......,,,,,,,**/*,,,,,,,,,,,,,,,,,',/, &
6x,'****/#********,,,,,,,**,,..,.......,...............,,,,,.....,,,,,,,,*/**,,,,,,,,,,,,,,,,',/, &
6x,'****##*****,***,,,,,,,*,,..,...,,,,.....,............,,,,.,**,,,,,,,,/(**,***,,,,,,,,,,,,',/, &
6x,'****#((********,,,.,,,,,,,,,,,,........,.,,,...........,*/*,,,,,,,,,,,.,..,...*,,,,,,,,,,',/, &
6x,'****##**********,,,,*,,............,................,,***,,,,,,,,,,,,,,,,.......,,,,,,,,,',/, &
6x,'****(%****/***,**,,,**,.................,...........,*,,...,,,,,,,,,**,..,..,,*.,,,,,,,,,',/, &
6x,'*****%//****,,,,,,,,**,,................,...........,.......,,,,,*****,*,.,....,,*,,,,,,,',/, &
6x,'*****##**,,,,.......,*,,.....................................,,,,**,,*,,,.,,....,,,,,,,,,',/, &
6x,'*****%**,,,,,,.......,,.........................,...........,,,**,,,,,***.......,.*,,,,,,',/, &
6x,'*****(*****,,,.......,,..........................,,........,,****,,,,,***,,,,*,,*,,,,,,,,',/, &
6x,'******(*,**,,.......,**,,,.................................,,,*,,,,,,,****,,,,**.*,,,,,,,',/, &
6x,'*******(**,,**,....*/*,,,,,.............................,,,,,,,,,,,,,,,****.,,*,,/,,,,,,,',/, &
6x,'*******#**,****,,****,,,,,......,.......................,,,,,,,,,,,,,,,,,**...,*/*,,,,,,,',/, &
6x,'*******(%*******/***...,,,.,............................,*,,,.,,,,,,,,,,,,*,...,*/,,,,,,,',/, &
6x,'*******(*******,/*,.*..,*,.............................,,,,,,.,,,,,,,,,,,,,*,.,***/,,,,,,',/, &
6x,'******(#********,,..***,,..,,..........................,,,,,,,,,,,.,,,,,,,**/..,***/,,,,*',/, &
6x,'******/#********,..,**,*,...,*...........................,,,,,,,,,,,,,,,,****,..****/*,*,',/, &
6x,'/******#*,******..,,****,...,*,............................,..,,,,,,,,,,,,****..,***/(*,,',/, &
6x,'********(*****,,..,,,***,..,*..............................,,,..,,,,,,,,,,,***,..,****(,,',/, &
6x,'****//*//((***,,..,,***,,,,.................................,,*...,,,,,,,,,,***..,,,**/(,',/, &
6x,'///*/*///*//,*,,.,,,,*,,,,,..................................,,*,,.,,,..,,,,,,,,...**/*/(',/, &
6x,'///////////(***,.,*,*,.,...,,*,,...,..........................,*,,,,,.,,,,,,,,,,....,,,,(',/, &
6x,'///////////*(*,,.*,**,.,***,,.,,...............................,*.,*,,,,,,,,,.,..........',/, &
6x,'///////////**(*,.*,,,,*/**.,...................................,*,,,,,*,*,,,.............',/, &
6x,'//////////***(*,,*,,.**,.,.,,...................................,*,,,,***,...............',/, &
6x,'/////////****//,.*,.**,,....,...................................,*,,,*,,.................',/, &
6x,'/////////*****/*,,,,,,,.,...,,..,.,,............................,,.,,....................',/, &
6x,'///////////***(*,,,,,,,,.,,,,,,..,,,..............................,......................',/, &
6x,'///////////***/(,,*,,,,,,,,,,,,..,,,,....................................................',/, &
6x,'/////////////*/(*,,,,,,,*,,,.,,,..,,.....................................................',/, &
6x,'/////////////////,,,,,,,,,,,.,,...,,.....................................................',/, &
6x,'//////////////***/,,,,,,,,,........,.....................................................',/, &
6x,'//////////////*****,,,,,,,,,...,.....,...................................................',/, &
6x,'//////////////***..*,,,.,,.,....,....,,..................................................',/, &
6x,'///////////////*...(,,,.,,.,,...,,....,..................................................',/, &
6x,'////////////////,...,.,.,,..,....,,......................................................',/, &
6x,'////////////////*...*,,,.,,.,,....,......................................................',/, &
6x,'/////////////////,...,,,,.,,.............................................................',/, &
6x,'/////////////////*.....,,,...............................................................',/, &
6x,'/////////////////*.........,,.......................................... .................',/, &
6x,'//////////////////..........,,,,,,.,.....................................................',/)
#endif
do k = 1,ndust
if (iacc(k)==0) count = count + 1
enddo
if (count >= 1) then
#ifdef THANOS
write(6,*) ''
write(6,'(a,i2,a,i2,a)') '"Reality can be whatever I want:',count,' out of ',ndust,' grain(s) are still in the disc."'
write(6,*) ''
if (count == ndust/2) write(6,'(a)') 'YOUUUU.... should have gone for the HEAD ! **SNAP**'
#else
write(6,'(i3,a,i3,a,f6.1,a)') count,' out of ',ndust,' grain(s) are still in the disc after ',tmax/years/1000, ' kyrs.'
#endif
else
#ifdef THANOS
write(6,*) 'Reality is often disapointing: all the grains have been accreted.'
#else
write(6,*) 'All the grains have been accreted.'
#endif
endif
close(2)
end program endgame