SPEED
SPEED.f90
Go to the documentation of this file.
1! Copyright (C) 2012 The SPEED FOUNDATION
2! Author: Ilario Mazzieri
3!
4! This file is part of SPEED.
5!
6! SPEED is free software; you can redistribute it and/or modify it
7! under the terms of the GNU Affero General Public License as
8! published by the Free Software Foundation, either version 3 of the
9! License, or (at your option) any later version.
10!
11! SPEED is distributed in the hope that it will be useful, but
12! WITHOUT ANY WARRANTY; without even the implied warranty of
13! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14! Affero General Public License for more details.
15!
16! You should have received a copy of the GNU Affero General Public License
17! along with SPEED. If not, see <http://www.gnu.org/licenses/>.
18
28
29! Here starts the code SPEED
30
31 program speed
32
33 use max_var
34 use str_mesh
36 use dgjump
37 use speed_par
38 use speed_par_dg
39
40 implicit none
41
42 include 'SPEED.MPI'
43
44
45!*****************************************************************************************************************
46
47 allocate(mpi_stat(speed_status_size))
48 mpi_comm = speed_comm
49
51
52 start = mpi_wtime()
53
54 if (mpi_id.eq.0) then
55 write(*,'(A)')''
56 write(*,'(A)')''
57 write(*,'(A)')'*******************************************************'
58 write(*,'(A)')'* *'
59 write(*,'(A)')'* SPEED *'
60 write(*,'(A)')'* SPectral Elements in Elastodynamics *'
61 write(*,'(A)')'* with Discontinuous Galerkin *'
62 write(*,'(A)')'* *'
63 write(*,'(A)''* PoliMi, 2012, All Rights Reserved *'
64 write(*,'(A)')'* *'
65 write(*,'(A)')'*******************************************************'
66 write(*,'(A)')''
67 write(*,'(A)')''
68 endif
69
70!***********************************************************************************
71! READ INPUT FILES AND ALLOCATE VARIABLES
72!***********************************************************************************
73
74
75 call read_input_files()
76
77
78!***********************************************************************************
79! PARTITION OF THE GRID AND GENERATION OF LOCAL CONNECTIVITY
80!***********************************************************************************
81
82
83 allocate(elem_domain(nelem)); elem_domain = mpi_id;
84 call make_partition_and_mpi_files()
85
86
87!***********************************************************************************
88! START SETUP 4 MPI COMUNICATION (ONLY BETWEEN CONFORMING REGIONS)
89!***********************************************************************************
90
91
93
94
95!***********************************************************************************
96! NEW SPECTRAL LOCAL CONNECTIVITY
97!***********************************************************************************
98
99
101
102
103!*****************************************************************************************
104! BUILD SEISMIC MOMENT
105!*****************************************************************************************
106
107 if (srcmodflag.eq.0) then
108 call make_seismic_moment_or_explosive_source()
109 elseif (srcmodflag.eq.1) then
110 call make_seismic_moment_pointsources_nhfault()
111 endif
112
113
114!*****************************************************************************************
115! DAMPING
116!*****************************************************************************************
117
119
120 if (damping_type .eq. 1) then !Kosloff & Kosloff damping
121 do im = 1,nmat
122 if (abs(prop_mat(im,4)) .gt. 10e-5) then
124 endif
125 enddo
126
127 if(mpi_id.eq.0 .and. make_damping_yes_or_not .eq. 1) then
128 write(*,'(A)')
129 write(*,'(A)') '----------------Building the Damping matrix---------------'
130 endif
131
132 if(mpi_id.eq.0 .and. make_damping_yes_or_not .eq. 0) then
133 write(*,'(A)')
134 write(*,'(A)')'----------------Building the Damping matrix---------------'
135 write(*,'(A)')'ATT: There are no materials with damping defined on'
136 endif
137
138 elseif(damping_type .eq. 2) then !Standard Linear Solid damping
139 if(mpi_id.eq.0) then
140 write(*,'(A)')
141 write(*,'(A)') '------------Computing anelastic coefficients-----------'
142 endif
143 !Assume 3 SLS for a range ~ [fmax/10, fmax*10] Hz
145
146 y_lambda=0.d0; y_mu=0.d0;
147
148 if (fmax .ne. 0.d0) &
151
152 ! Check coefficient signs
153 if (b_failoncoeffs) then
154 do im = 1, nmat
155 do i = 1, n_sls
156 if (y_lambda(im,i) .lt. 0.d0 .or. y_mu(im,i) .lt. 0) then
157 call mpi_finalize(mpi_ierr)
158 if (mpi_id .eq. 0) write(*,'(A)') 'NEGATIVE anelastic coefficient found, program ended.'
159 if (mpi_ierr.ne.0) write(*,'(A,I6)')'MPI Finalization error - proc : ',mpi_id
160 call exit(exit_anelastic)
161 endif
162 enddo
163
164 enddo
165
166 endif
167 elseif(damping_type .eq. 3) then !Rayleigh damping
168 if(mpi_id.eq.0) then
169 write(*,'(A)')
170 write(*,'(A)') '------------Computing Rayleigh coefficients-----------'
171 endif
172 allocate(a0_ray(nmat),a1_ray(nmat))
173 a0_ray = 1.d0; a1_ray = 1.d0;
174
175
176 if (fmax .ne. 0.d0) &
177 call make_rayleigh_coefficients(nmat, a0_ray, a1_ray, prop_mat, qs, fmax,mpi_id)
178
179 endif
180
181
182!*****************************************************************************************
183! Not Honoring Enhanced (Reading Material properties from Tomo File)
184!*****************************************************************************************
185 if (nmat_nhe .gt. 0) then
186 call make_nh_enhanced()
187 call mpi_barrier(mpi_comm, mpi_ierr)
188 endif
189
190
191!***********************************************************************************
192! FIND OSCILLATOR POSITION
193!***********************************************************************************
194 if (sdofflag.eq.1) then
196 endif
197!*****************************************************************************************
198! BUILD LOAD MATRIX AND SEISMIC MOMENT TENSOR OR EXPLOSIVE SOURCE
199!*****************************************************************************************
200
201
202 call make_load_matrix()
203
204
205!**************************************************************************************
206! FIND MONITORED NODES (PGM & MLST input files) + deallocate(elem_domain)
207!**************************************************************************************
208
209
211 deallocate(elem_domain); !Should we deallocate the elem_domain?
212
213
214!*****************************************************************************************
215! CASES 4 NOT HONORING
216!*****************************************************************************************
217
218
219 if(n_case .gt. 0) then
220
221 if (mpi_id.eq.0) write(*,'(A)')'----------------Making not-honoring case---------------'
222
224
225 if(mpi_id .eq.0) then
226 start1=mpi_wtime()
227 endif
228
234
235
236
237
238 ncase = 1
239 CALL mpi_barrier(mpi_comm, mpi_ierr)
240
241 if (mpi_id.eq.0) then
242 start2=mpi_wtime()
243 write(*,'(A)')
244 write(*,'(A,F20.3,A)')'Set-up time CASE = ',start2-start1,' s'
245 write(*,'(A)')'Made.'
246 endif
247
248 else
249
250 ncase = 0
251
252 endif
253
254!*****************************************************************************************
255! RANDOMIZED PARAMETERS
256!*****************************************************************************************
257 if (nmat_rnd .gt. 0) then
259
264
265 endif
266
267
268!*****************************************************************************************
269! SETUP FOR BOUNDARY CONDITIONS
270!*****************************************************************************************
271
272
273 call make_boundary_conditions()
274
275
276!*****************************************************************************************
277! SETUP FOR DG - INTERFACE CONDITIONS
278!*****************************************************************************************
279
280
281 call make_dg_interface_conditions()
282
283
284!***********************************************************************************************
285! COMPUTE CFL CONDITION
286!***********************************************************************************************
287
288 if (mpi_id.eq.0) write(*,'(A)')
289 if (mpi_id.eq.0) write(*,'(A)')'------------Setting calculation parameters-------------'
290
291
292
293 if(n_case .gt. 0) then
294
295
296 call get_cfl4cases(deltat, nnod_loc, local_node_num, &
303
304 else if (nmat_nhe.gt.0) then
305 call get_cfl4nhe(deltat, nnod_loc, local_node_num, &
312 else
313
314 call get_cfl(deltat, nnod_loc, local_node_num, &
319 endif
320
321
322 nts = int((tstop -tstart) / deltat)
323 tstop = tstart + dfloat(nts)*deltat
324 if (mpi_id.eq.0) then
325 write(*,'(A,I15)') 'Number of time-steps : ',nts
326 write(*,'(A,E14.5)')'Start time : ',tstart
327 write(*,'(A,E14.5)')'Final time : ',tstop
328 endif
329
330!**************************************************************************************
331! SETUP FOR SNAPSHOTS
332!**************************************************************************************
333
334! if (nsnaps.gt.0) then
335! do i = 1, nsnaps
336! itersnap(i) = int((tsnap(i) - tstart) / deltat)
337! if (itersnap(i) .lt. 0) itersnap(i) = 0
338! if (itersnap(i) .gt. nts) itersnap(i) = nts
339! enddo
340
341! initial_snap = 1
342! if(tstart .gt. 0.d0) then
343! allocate(set_initial_snap(nsnaps))
344! set_initial_snap = tstart - tsnap
345
346! do i = 2, nsnaps
347! if(set_initial_snap(i) .lt. set_initial_snap(i-1) .and. set_initial_snap(i) .ge. 0) then
348! initial_snap = i
349! endif
350! enddo
351! deallocate(set_initial_snap)
352! endif
353! endif
354
355!***********************************************************************************
356! WRITE MESH VTK
357!***********************************************************************************
358 !call WRITE_VTK_MESH(nnod_loc, local_node_num, nmat, tag_mat, prop_mat, &
359 !sdeg_mat, xx_spx_loc, yy_spx_loc, zz_spx_loc, con_nnz_loc, con_spx_loc, mpi_id)
360
361!**************************************************************************************
362! END SETUP
363!**************************************************************************************
364
365 finish = mpi_wtime()
367
368 if (mpi_id.eq.0) then
369 write(*,'(A)')
370 write(*,'(A)')'-------------------------------------------------------'
371 write(*,'(A,F20.4,A)')'Set-up time = ',time_in_seconds,' s'
372 write(*,'(A)')'-------------------------------------------------------'
373 write(*,'(A)')
374 endif
375
376 if (b_setuponly) then
377 call mpi_finalize(mpi_ierr)
378 if (mpi_ierr.ne.0) write(*,'(A,I6)')'MPI Finalization error - proc : ',mpi_id
379 if (mpi_id .eq. 0) then
380 write(*, '(A)') 'Set-up ended. Program finished.'
381 endif
382 call exit(exit_setup)
383 endif
384
385!**************************************************************************************
386! TIME INTEGRATION
387!**************************************************************************************
388
389 if (mpi_id.eq.0) then
390 write(*,'(A)')
391 write(*,'(A)')'------------Beginning of the time-loop-----------------'
392 write(*,'(A)')
393 endif
394
395
396 call time_loop(el_new)
397
398!**************************************************************************************
399! FINALIZE AND DEALLOCATE MEMORY
400!**************************************************************************************
401
402 call mpi_finalize(mpi_ierr)
403
404 if (mpi_ierr.ne.0) write(*,'(A,I6)')'MPI Finalization error - proc : ',mpi_id
405
406 if ((mpi_id.eq.0).and.(opt_out_data.gt.0)) then
407 write(*,'(A)'); write(*,'(A)') 'Print output'
408 endif
409
411
412 if (mpi_id.eq.0) write(*,'(A)')
413 if (mpi_id.eq.0) write(*,'(A)')'Bye.'
414
415 call exit(exit_normal)
416
417 end program speed
418
419
420
421
subroutine deallocate_variables()
Deallocates variables.
subroutine find_monitor_position()
Find monitor position an writes MLST.input or MPGM.
subroutine initialization(comm, np, id, ierr)
Inizialization for parallel computation.
subroutine make_anelastic_coefficients(nmat, n_sls, prop_mat, qs,
Compute anelastic coefficients for Standard Linear Solid model USE THE LIBRARY QR_SOLVE!
subroutine make_nh_enhanced()
...Not-Honoring Enhanced (NHE) Implementation
subroutine make_nothonoring(loc_n_num, nn_loc, n_case, tag_case, val_case, tol_case, cs_nnz_loc, cs_loc, nm, tag_mat, sdeg_mat, xs_loc, ys_loc, zs_loc, zs_elev, zs_all, vs, thick, sub_tag_all, mpi_id)
Makes not-honoring technique.
subroutine make_random_param(loc_n_num, nn_loc, nmat_rnd, rand_mat, xs_loc, ys_loc, zs_loc, lambda_rnd, mu_rnd, rho_rnd, mpi_id)
...
subroutine make_setup_mpi_conforming()
Defines buffers for MPI communication.
subroutine make_spx_grid_with_loc_numeration()
Makes local spectral grids with nodes numbered according to the new local numeration.
subroutine read_input_files()
Reads input files and allocates memory.
subroutine read_system_position()
Reads oscillator position and writes SYSLST.input file.
Contains structure for jump matrices.
Definition MODULES.f90:155
Set maximal bounds.
Definition MODULES.f90:54
Contains SPEED paramters (used in MAKE_DG_INTERFACE_CONDITIONS)
Definition MODULES.f90:498
type(el4loop), dimension(:), allocatable el_new
Definition MODULES.f90:507
Contains SPEED PARAMETERS used in (SPEED, READ_INPUT_FILES, MAKE_PARTION_AND_MPI_FILES,...
Definition MODULES.f90:207
real *8, dimension(:), allocatable frequency_range
Definition MODULES.f90:437
real *8, dimension(:), allocatable qs
Definition MODULES.f90:437
integer *4 nmat
Definition MODULES.f90:269
real *8, dimension(:), allocatable tol_case
Definition MODULES.f90:408
integer *4, dimension(:), allocatable val_case
Definition MODULES.f90:335
real *8 start2
Definition MODULES.f90:393
real *8, dimension(:,:), allocatable y_mu
Definition MODULES.f90:438
real *8, dimension(:,:), allocatable prop_mat
Definition MODULES.f90:463
integer *4 opt_out_data
Definition MODULES.f90:308
character *3 deltat_fixed
Definition MODULES.f90:250
integer *4 con_nnz_loc
Definition MODULES.f90:269
real *8, dimension(:), allocatable vs_tria
Definition MODULES.f90:408
integer *4 nmat_nhe
Definition MODULES.f90:269
integer *4 damping_type
Definition MODULES.f90:303
integer *4, dimension(:), allocatable tag_case
Definition MODULES.f90:335
integer *4 nelem
Definition MODULES.f90:269
real *8, dimension(:), allocatable zz_spx_loc
Definition MODULES.f90:408
integer *4 i
Definition MODULES.f90:263
real *8, dimension(:,:), allocatable y_lambda
Definition MODULES.f90:438
real *8, dimension(:), allocatable lambda_nhe
Definition MODULES.f90:446
real *8, dimension(:), allocatable a1_ray
Definition MODULES.f90:439
real *8, dimension(:), allocatable yy_spx_loc
Definition MODULES.f90:408
integer *4 sdofflag
Definition MODULES.f90:298
real *8 finish
Definition MODULES.f90:393
integer *4, parameter n_sls
Definition MODULES.f90:304
real *8 deltat
Definition MODULES.f90:393
real *8, dimension(:), allocatable thick
Definition MODULES.f90:408
logical b_failoncoeffs
Definition MODULES.f90:220
real *8 time_in_seconds
Definition MODULES.f90:393
real *8 fmax
Definition MODULES.f90:393
real *8, dimension(:), allocatable mu_rnd
Definition MODULES.f90:443
real *8, dimension(:), allocatable qp
Definition MODULES.f90:437
integer *4 mpi_comm
Definition MODULES.f90:308
real *8, dimension(:), allocatable a0_ray
Definition MODULES.f90:439
integer *4, dimension(:), allocatable local_node_num
Definition MODULES.f90:322
real *8 tstop
Definition MODULES.f90:393
integer *4 mpi_ierr
Definition MODULES.f90:298
integer *4, dimension(:), allocatable rand_mat
Definition MODULES.f90:375
integer *4, dimension(:), allocatable sdeg_mat
Definition MODULES.f90:335
logical b_setuponly
Definition MODULES.f90:224
integer *4 nts
Definition MODULES.f90:269
integer *4, dimension(:), allocatable mpi_stat
Definition MODULES.f90:368
integer *4 n_case
Definition MODULES.f90:269
integer *4, dimension(:), allocatable con_spx_loc
Definition MODULES.f90:322
integer *4, dimension(:), allocatable sub_tag_all
Definition MODULES.f90:335
real *8 tstart
Definition MODULES.f90:393
real *8, dimension(:), allocatable zs_elev
Definition MODULES.f90:408
real *8, dimension(:), allocatable zs_all
Definition MODULES.f90:408
integer *4, dimension(:), allocatable tag_mat
Definition MODULES.f90:335
integer *4 mpi_np
Definition MODULES.f90:308
real *8 start
Definition MODULES.f90:393
real *8 deltat_cfl
Definition MODULES.f90:393
integer *4 ncase
Definition MODULES.f90:308
integer *4 srcmodflag
Definition MODULES.f90:298
integer *4 mpi_id
Definition MODULES.f90:308
integer *4 nmat_rnd
Definition MODULES.f90:269
real *8, dimension(:), allocatable rho_rnd
Definition MODULES.f90:443
integer *4 nnod_loc
Definition MODULES.f90:269
real *8, dimension(:), allocatable xx_spx_loc
Definition MODULES.f90:408
real *8 start1
Definition MODULES.f90:393
real *8, dimension(:), allocatable lambda_rnd
Definition MODULES.f90:443
integer *4 make_damping_yes_or_not
Definition MODULES.f90:298
integer *4, dimension(:), allocatable elem_domain
Definition MODULES.f90:322
integer *4 im
Definition MODULES.f90:263
logical b_failcfl
Definition MODULES.f90:227
real *8, dimension(:), allocatable mu_nhe
Definition MODULES.f90:446
real *8, dimension(:), allocatable rho_nhe
Definition MODULES.f90:446
Contains mesh structure (scratch)
Definition MODULES.f90:67
Contains mesh structure for DG interface elements.
Definition MODULES.f90:84