-
Notifications
You must be signed in to change notification settings - Fork 0
/
echo.f90
313 lines (261 loc) · 10.4 KB
/
echo.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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
! *****************************************************************************
! * *
! * ECHO-QGP *
! * *
! * Version: 1.5.0-alpha *
! * *
! * Copyright (C) 2015 The ECHO-QGP team *
! * *
! * File: echo.f90 *
! * *
! * License: GPL version 2.0 (Please, read the file LICENSE.TXT) *
! * *
! * This program is free software; you can redistribute it and/or *
! * modify it under the terms of the GNU General Public License *
! * as published by the Free Software Foundation; either version 2 *
! * of the License, or (at your option) any later version. *
! * *
! * This program is distributed in the hope that it will be useful, *
! * but WITHOUT ANY WARRANTY; without even the implied warranty of *
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
! * GNU General Public License for more details. *
! * *
! * You should have received a copy of the GNU General Public License *
! * along with this program; if not, write to the Free Software *
! * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
! * Boston, MA 02110-1301, USA. *
! * *
! * Authors: Luca Del Zanna ([email protected]) *
! * Gabriele Inghirami ([email protected]) *
! * *
! * Contributors: *
! * *
! * Acknowledgments: *
! * *
! *****************************************************************************
program echo
!-- ECHO, main file
use parallel
use common
use evolve
use out
use eos
use system_eqgp, only: system_setup, system_metric
use hypersurface
implicit none
integer :: iout,ilog,iter,irk,i1,i2,irate,hypout
real(8) :: dt,tlog,time ! time is real execution time, not simulation time
real(8) :: maximum_dt=-1. !maximum timestep passed as argument (called maxdt)
integer :: error_flag
!-- Initializing processes
call parallel_start()
call common_get_all_parameters()
if(init_type .eq. GLAUBER_MONTECARLO) then
id_of_the_run=events_start
else
events_start=1
events_stop=1
id_of_the_run=events_stop
end if
if(maximum_dt .gt. 0) maxdt=maximum_dt
dt=maxdt
if(tmin .gt. tmax) then
write(*,*) 'Sorry, but it is not possible to choose an ending time smaller than the initial time...'
call exit(1)
end if
call system_setup(coordinates, system_metric, viscosity,nv,nu,nov,nou)
call parallel_grid_setup(nx,ny,nz,mx,my,mz,ix0,ix1,ix2,iy0,iy1,iy2,iz0,iz1,iz2)
call common_alloc
!-- Zeroth order bcs
!
call set_eos_pointers(eqstate, eos_energy, eos_pressure, eos_sound)
if (( eqstate .eq. 3) .and. (id_of_the_run .eq. events_start)) then
call read_data_from_tabulated_file(entries, eos_tab_name, temperature_array, energy_density_array, pressure_array,&
& sound_speed_array, min_en_dens, max_en_dens)
end if
call find_przero(przero, enezero,error_flag)
if(prl) call MPI_Bcast(przero, 1, mpi_realtype, 0, icomm, ierr)
if(error_flag .gt. 0) then
write(*,*) "Sorry, but I'm not able to find the pressure corresponding to the minimum energy density enezero..."
errcode=error_flag
write(*,*) "Error code is: ", errcode
run_crashed=.true.
return
end if
call evolve_alloc
call out_alloc
if (pe0) then
print*
write(*,"(3x,20a)") 'ECHO-QGP STARTED'
print*
end if
!-- Loop over different initial conditions
do while(id_of_the_run .le. events_stop)
!-- Initial conditions
iter=0; iout=1; hypout=0
v=0.
u=0.
vnewstep=0.
unewstep=0.
uold=0.
vold=0.
deriv=0.
run_crashed=.false.
errcode=0
call init()
if(pe0) then
write(*,'(a11,i4,a7,i4,a4,i4)') 'RUN NUMBER ',id_of_the_run,' - RUN ',id_of_the_run-events_start+1,' OF ',events_stop-&
&events_start+1
write(*,*) 'Initializations done...'
end if
if(.not. restarted_run) then
t=tmin !already into init, here just for clearness
timeold=t
timeinterval=0
call system_metric()
call out_grid
if(pe0) then
write(*,*) 'Grid computed...'
if(out_freeze) call get_hysufile_ready()
write(*,*) 'Files for hypersurface computation written...'
end if
call out_vars_summary()
if(pe0) write(*,*) 'Summary of variables written...'
call out_vars(iout,0)
if(pe0) then
write(*,*) 'Copying the parameter file into the output directory...'
call out_copy_tools
end if
!since we just starde probably it is not useful to dump data now
!if (restart_type .ne. 0) call out_dump(iout)
iout=iout+1
if(out_freeze) hypout=hypout+1
else
if(pe0) then
if(out_freeze) call get_hysufile_ready()
end if
call out_restart(iout)
call system_metric()
iout=iout+1
restarted_run=.false. ! to avoid another restarting in case of multiple runs, e.g. with Glauber-MC initial conditions
end if
tout=t+dtout
tlog=t+dtlog
if(t .eq. tmin) then
thyp=tmin
else !alternative active when the program is restarted
thyp=t+freeze_time_interval
end if
!-- Main cycle
call system_clock(i1)
do
if (t>=tmax) exit
if (temp_end .gt. 0) call check_temp()
if (temp_check .eq. 1) exit
if(mhd) then
vnewstep=v(:,:,:,krh:kbz)
unewstep=u(:,:,:,krh:kbz)
if(rmhd) then
vnewstep=v(:,:,:,krh:kez)
unewstep=u(:,:,:,krh:kez)
end if
else
vnewstep=v(:,:,:,krh:kpr)
unewstep=u(:,:,:,krh:kpr)
end if
do irk=1,nrk
call evolve_main(irk,dt)
if(run_crashed) exit
end do
if(run_crashed) exit
timeold=t
t=t+dt
g_cov_3_old=g_cov(3) !we keep track of the old value of g_cov(3) for computing time derivatives
call system_metric() !we update the metric tensor soon after time updating
iter=iter+1
if (t>=tlog) then
call system_clock(i2,irate)
time=real(i2-i1,8)/real(irate,8)
if(pe0) then
open (10,file='log')
if((init_type .eq. GLAUBER_MONTECARLO) .and. (avg_events .eq. 1)) then
write (10,'(a31,i4,a4,i4)') 'RUN AVERAGING I.C. FROM EVENT ',events_start,' TO ',events_stop
else
write (10,'(a11,i4,a4,i4)') 'RUN NUMBER ',id_of_the_run,' - RUN ',id_of_the_run-events_start+1,' OF ',events_stop&
&-events_start+1
end if
write (10,'(3x,a,f15.8)') 'Simulation time:',t
write (10,'(3x,a,f15.8)') 'Real time (sec):',time
write (10,'(3x,a,i15 )') 'Iterations :',iter
if(time .gt. 0.) write (10,'(3x,a,f15.8)') 'Iterations/sec :',iter/time
close (10)
end if
ilog=ilog+1
tlog=tlog+dtlog
if (tlog > tmax) tlog=tmax
end if
timeinterval=dt
vold=vnewstep
uold=unewstep
if ((t>tout) .or. ((tout-t) .lt. 1.e-10))then
tout=tout+dtout
if((abs(tout-tmax) .lt. 1.e-10) .or. (tout .gt. tmax)) tout=tmax
call out_vars(iout,1)
!we dump the data for restarting now only if freezeout hypersurface is not computed
if((restart_type .ne. 0) .and. (.not. out_freeze)) call out_dump(iout)
iout=iout+1
end if
if(out_freeze) then
if((t>thyp) .or. ((thyp-t) .lt. 1.e-10))then
thyp=thyp+freeze_time_interval
if((abs(thyp-tmax) .lt. 1.e-10) .or. (thyp .gt. tmax)) thyp=tmax
call out_hyp(hypout)
if(restart_type .ne. 0) call out_dump(iout-1)
hypout=hypout+1
end if
end if
end do
if((.not. run_crashed) .and. (temp_check .eq. 1)) then
if(pe0) then
if(freeze_type .eq. 0) then
print*,'Temperature is under the value established for stopping the simulation'
else
print*,'Energy density is under the value established for stopping the simulation'
end if
print*,'Printing variables again before leaving'
end if
call out_vars(iout,1)
if(out_freeze) call out_hyp(hypout)
if(restart_type .ne. 0) call out_dump(iout)
end if
call system_clock(i2,irate)
time=real(i2-i1,8)/real(irate,8)
!-- Closing processes
if(run_crashed) then
if (pe0) then
print*
print*,'RUN CRASHED BEFORE FINISHING...'
print*
print '(3x,a,f15.8)','Simulation time:',t
print '(3x,a,f15.8)','Real time (sec):',time
print '(3x,a,i15 )','Iterations :',iter
print '(3x,a,f15.8)','Iterations/sec :',iter/time
print*
end if
else
if (pe0) then
print*
print*,'RUN FINISHED'
print*
print '(3x,a,f15.8)','Simulation time:',t
print '(3x,a,f15.8)','Real time (sec):',time
print '(3x,a,i15 )','Iterations :',iter
print '(3x,a,f15.8)','Iterations/sec :',iter/time
print*
end if
end if
id_of_the_run=id_of_the_run+1
end do ! end of loop over runs
call parallel_end
end program echo
! *****************************************************************************