46 subroutine get_cfl(time_step, nn_loc, loc_n_num, nm, tm, pm, sdeg, &
47 xx_loc, yy_loc, zz_loc, cs_nnz_loc, cs_loc, &
48 time_step_cfl, fmax, deltat_fixed, &
49 mpi_comm, mpi_np, mpi_id, b_failCFL)
57 character*3 :: deltat_fixed
59 integer*4 :: nm, im, nn_loc, cs_nnz_loc, mpi_comm, mpi_np, mpi_err
60integer*4 :: nel_loc, ic1, ic2, n1, n2, istart, ifin
61 integer*4 :: ie, i, j, nn, mcode, smcode, sdeg_deltat_cfl, sdeg_npoints
63 integer*4,
dimension(1) :: pos, pos2
64 integer*4,
dimension(nm) :: tm, sdeg
65 integer*4,
dimension(nn_loc) :: loc_n_num
67 integer*4,
dimension(0:cs_nnz_loc) :: cs_loc
69 real*8 :: time_step, time_step_cfl, fmax
70 real*8 :: length_min,length,vs_length_min,vs_length,length_vp_min
71 real*8 :: percent_deltat
72 real*8 :: num_of_points,vs_npoints,vp_deltat_cfl
73 real*8 :: rho,lambda,mu,vs,vp
74 real*8 :: x1_length_vp_min,y1_length_vp_min,z1_length_vp_min
75 real*8 :: x2_length_vp_min,y2_length_vp_min,z2_length_vp_min
77 real*8,
dimension(:),
allocatable :: ct,ww
78 real*8,
dimension(:),
allocatable :: time_step_glo, vs_length_glo
79 real*8,
dimension(nn_loc) :: xx_loc, yy_loc, zz_loc
81 real*8,
dimension(:,:),
allocatable :: dd
82 real*8,
dimension(nm,4) :: pm
84 logical :: b_failCFL, b_CFL_failure = .false.
86 nel_loc = cs_loc(0) - 1
96 im = cs_loc(cs_loc(ie -1) +0)
104 vp = dsqrt((lambda+2*mu)/rho)
106 n1 = nn*nn*(1 -1) +nn*(1 -1) +1
107 n2 = nn*nn*(nn -1) +nn*(nn -1) +nn
111 istart = cs_loc(ie -1) +n1
112 ifin = cs_loc(ie -1) +n2
122 do ic1 = istart, ifin
123 do ic2 = ic1 + 1, ifin
125 if(cs_loc(ic1) .ne. 0 .and. cs_loc(ic2) .ne. 0)
then
127 length=dsqrt((xx_loc(cs_loc(ic1))-xx_loc(cs_loc(ic2
128 (yy_loc(cs_loc(ic1))-yy_loc(cs_loc(ic2
129 (zz_loc(cs_loc(ic1))-zz_loc(cs_loc(ic2
131 length_vp = length/vp
135 if (length_vp_min .gt. length_vp)
then
136 length_vp_min = length_vp
137 x1_length_vp_min = xx_loc(cs_loc(ic1))
138 y1_length_vp_min = yy_loc(cs_loc(ic1))
139 z1_length_vp_min = zz_loc(cs_loc(ic1))
140 x2_length_vp_min = xx_loc(cs_loc(ic2))
141 y2_length_vp_min = yy_loc(cs_loc(ic2))
142 z2_length_vp_min = zz_loc(cs_loc(ic2))
144 sdeg_deltat_cfl = smcode
149 vs_length = vs/length
151 if (vs_length_min .gt. vs_length)
then
152 vs_length_min = vs_length
154 sdeg_npoints = smcode
167 nn = sdeg_deltat_cfl + 1
172 time_step_cfl = length_vp_min
174 allocate(time_step_glo(mpi_np),vs_length_glo(mpi_np))
176 call mpi_barrier(mpi_comm, mpi_err)
177 call mpi_allgather(time_step_cfl, 1, speed_double, time_step_glo
178 call mpi_allgather(vs_length_min, 1, speed_double, vs_length_glo
180 pos = minloc(time_step_glo)
181 pos2 = minloc(vs_length_glo)
183 deallocate(time_step_glo, vs_length_glo)
185 if((mpi_id + 1) .eq. pos(1))
then
188 write(*,
'(A)')
'--------Stability for time advancing algorithm --------'
189 write(*,
'(A,E12.4)')
'Mininum distance beteween grid nodes :'
190 write(*,
'(A,E12.4)')
'Vp for CFL condition :', vp_deltat_cfl
191 write(*,
'(A,E12.4,E12.4,E12.4)')
'Min. node 1 : ',x1_length_vp_min
192 write(*,
'(A,E12.4,E12.4,E12.4)')
'Min. node 2 : ',x2_length_vp_min
193 write(*,
'(A)')
'-------------------------------------------------------'
195 if (time_step.le.time_step_cfl)
then
196 percent_deltat=time_step/time_step_cfl*100
197 if (percent_deltat.le.1)
then
198 write(*,
'(A,E12.4)')
'WARNING!!! deltat CFL ='
200 write(*,
'(A,F6.2,A)')
'You are using ',percent_deltat
201 '% of critical time step.'
202 write(*,
'(A)')
'This time step is excedingly lower the deltat CFL'
203 if (deltat_fixed.eq.
'not')
then
204 write(*,
'(A)')
'deltat chosen will be substituted with 10% of deltat CFL'
205 time_step=time_step_cfl*0.1
206 write(*,
'(A,E12.4)')
'deltat chosen :'
208 elseif (percent_deltat.le.25)
then
209 write(*,
'(A,E12.4)')
'OK!!! deltat CFL ='
211 write(*,
'(A,F6.2,A)')
'You are using ',percent_deltat
212 '% of critical time step.'
214 write(*,
'(A,E12.4)')
'WARNING!!! deltat CFL ='
216 write(*,
'(A,F6.2,A)')
'You are using ',percent_deltat
217 '% of critical time step.'
218 write(*,
'(A)')
'This could be not enough for the correct working of ABC'
219 if (deltat_fixed.eq.
'not')
then
220 write(*,
'(A)')
'deltat chosen will be substituted with 20% of deltat CFL'
221 time_step=time_step_cfl*0.2
222 write(*,
'(A,E12.4)')
'deltat chosen :'
226 elseif (time_step .gt. time_step_cfl)
then
227 write(*,
'(2X,A,E12.4)')
'ERROR!!! deltat CFL = ',
228 time_step_cfl,
' < deltat = ',time_step
229 write(*,
'(A)')
'The time advancing scheme will be unstable!'
230 if (deltat_fixed.eq.
'not')
then
231 write(*,
'(A)')
'deltat chosen will be substituted with 20% of deltat CFL'
232 time_step=time_step_cfl*0.2
233 write(*,
'(A,E12.4)')
'deltat chosen :',time_step
235 b_cfl_failure = .true.
239 write(*,
'(A)')
'-------------------------------------------------------'
242 if (b_failcfl .and. b_cfl_failure)
then
243 write(*,*)
'CFL does NOT hold, asked to quit. Program finished.'
244 call mpi_finalize(mpi_err)
252 call mpi_barrier(mpi_comm, mpi_err)
254 allocate(ct(nn),ww(nn),dd(nn,nn))
257 num_of_points = vs_length_min*(ct(1)-ct(nn))/(ct(int(nn/2))-ct(int
262 if((mpi_id + 1) .eq. pos2(1))
then
263 write(*,
'(A)')
'-----------Number of points per wave length------------'
265 write(*,
'(A,E12.4)')
'Minum vs wrt max frequency :',vs_npoints
266 write(*,
'(A,E12.4)')
'Points per wavelength :',num_of_points
272 call mpi_barrier(mpi_comm, mpi_err)
276 end subroutine get_cfl
subroutine make_lgl_nw(nb_pnt, xq, wq, dd)
Makes Gauss-Legendre-Lobatto nodes, weigths and spectral derivatives.
integer, parameter exit_cfl