Skip to content

Commit ebb78bd

Browse files
authored
Merge pull request SPECFEM#1800 from danielpeter/devel
updates submodule path, mesh output and scripts
2 parents 61cef0c + 50bfec6 commit ebb78bd

File tree

10 files changed

+381
-55
lines changed

10 files changed

+381
-55
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
url = https://github.com/wjlei1990/pycmt3d
1010
[submodule "external_libs/ROCm-HIP-CPU"]
1111
path = external_libs/ROCm-HIP-CPU
12-
url = git@github.com:ROCm/HIP-CPU.git
12+
url = https://github.com/ROCm/HIP-CPU.git

EXAMPLES/applications/Mount_StHelens/convert_lonlat2utm.pl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,14 @@ sub geo2utm {
8787
#my($PI=pi);
8888
my($degrad)=pi/180.;
8989
my($raddeg)=180.0/pi;
90-
my($semimaj)=6378206.4;
91-
my($semimin)=6356583.8;
90+
91+
# Clarke 1866
92+
#my($semimaj)=6378206.4;
93+
#my($semimin)=6356583.8;
94+
# WGS84 (World Geodetic System 1984)
95+
my($semimaj)=6378137.0;
96+
my($semimin)=6356752.314245;
97+
9298
my($scfa)=0.9996;
9399

94100
#! some extracts about UTM:

src/generate_databases/calc_jacobian.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ subroutine calc_jacobian(myrank,xix_elem,xiy_elem,xiz_elem, &
9595
enddo
9696
write(filename,'(a,i6.6,a)') trim(OUTPUT_FILES)//'/error_proc',myrank,'_element_with_invalid_jacobian'
9797
call write_VTK_data_points_elem(NGNOD,xelm,yelm,zelm,jacobian,filename)
98-
print *,' written out:',trim(filename)
98+
print *,' written out: ',trim(filename)
9999
print *,'Please check your mesh...'
100100
call exit_MPI(myrank,'Error negative or null 3D Jacobian found')
101101
endif

src/generate_databases/create_regions_mesh.f90

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ end subroutine crm_ext_allocate_arrays
959959

960960
subroutine crm_ext_setup_jacobian(nodes_coords_ext_mesh, nnodes_ext_mesh, elmnts_ext_mesh, nelmnts_ext_mesh)
961961

962-
use constants, only: myrank,NDIM,NGLLX,NGLLY,NGLLZ,CUSTOM_REAL,MAX_STRING_LEN,OUTPUT_FILES
962+
use constants, only: myrank,NDIM,NGLLX,NGLLY,NGLLZ,CUSTOM_REAL,MAX_STRING_LEN,OUTPUT_FILES,HUGEVAL,IMAIN
963963

964964
use generate_databases_par, only: NGNOD
965965

@@ -987,6 +987,9 @@ subroutine crm_ext_setup_jacobian(nodes_coords_ext_mesh, nnodes_ext_mesh, elmnts
987987
double precision, dimension(NGNOD) :: xelm,yelm,zelm
988988
double precision,parameter :: threshold_zero = 1.e-25
989989

990+
! stats
991+
real(kind=CUSTOM_REAL) :: jacobian_min,jacobian_min_glob,jacobian_max,jacobian_max_glob
992+
990993
! debug
991994
logical, parameter :: DEBUG_ELEMENT = .false.
992995
character(len=MAX_STRING_LEN) :: filename
@@ -1002,6 +1005,9 @@ subroutine crm_ext_setup_jacobian(nodes_coords_ext_mesh, nnodes_ext_mesh, elmnts
10021005
xix_regular = 0.0_CUSTOM_REAL
10031006
jacobian_regular = 0.0_CUSTOM_REAL
10041007

1008+
jacobian_min = +HUGEVAL
1009+
jacobian_max = -HUGEVAL
1010+
10051011
! determines regular elements
10061012
do ispec = 1, nspec
10071013
do ia = 1,NGNOD
@@ -1023,6 +1029,10 @@ subroutine crm_ext_setup_jacobian(nodes_coords_ext_mesh, nnodes_ext_mesh, elmnts
10231029
etaxstore(1,1,1,ispec_irreg),etaystore(1,1,1,ispec_irreg),etazstore(1,1,1,ispec_irreg), &
10241030
gammaxstore(1,1,1,ispec_irreg),gammaystore(1,1,1,ispec_irreg),gammazstore(1,1,1,ispec_irreg), &
10251031
jacobianstore(1,1,1,ispec_irreg),xelm,yelm,zelm,dershape3D)
1032+
1033+
! stats
1034+
if (minval(jacobianstore(:,:,:,ispec_irreg)) < jacobian_min) jacobian_min = minval(jacobianstore(:,:,:,ispec_irreg))
1035+
if (maxval(jacobianstore(:,:,:,ispec_irreg)) > jacobian_max) jacobian_max = maxval(jacobianstore(:,:,:,ispec_irreg))
10261036
else
10271037
! sets flag for regular elements
10281038
any_regular_elem = .true.
@@ -1035,7 +1045,7 @@ subroutine crm_ext_setup_jacobian(nodes_coords_ext_mesh, nnodes_ext_mesh, elmnts
10351045
if (myrank == 0 .and. ispec == 1) then
10361046
write(filename,'(a,i6.6,a)') trim(OUTPUT_FILES)//'/proc',myrank,'_debug_element'
10371047
call write_VTK_data_points_elem(NGNOD,xelm,yelm,zelm,dble(jacobianstore(1,1,1,ispec_irreg)),filename)
1038-
print *,' written out:',trim(filename)
1048+
print *,' written out: ',trim(filename)
10391049
endif
10401050
endif
10411051
enddo
@@ -1100,6 +1110,20 @@ subroutine crm_ext_setup_jacobian(nodes_coords_ext_mesh, nnodes_ext_mesh, elmnts
11001110
! saves regular values
11011111
xix_regular = xix_reg(1,1,1)
11021112
jacobian_regular = jacobian_reg(1,1,1)
1113+
1114+
! stats
1115+
if (jacobian_regular < jacobian_min) jacobian_min = jacobian_regular
1116+
if (jacobian_regular > jacobian_max) jacobian_max = jacobian_regular
1117+
1118+
endif
1119+
1120+
! stats info
1121+
call min_all_cr(jacobian_min,jacobian_min_glob)
1122+
call max_all_cr(jacobian_max,jacobian_max_glob)
1123+
if (myrank == 0) then
1124+
write(IMAIN,*) ' mesh jacobian: min/max = ',jacobian_min_glob,'/',jacobian_max_glob
1125+
write(IMAIN,*)
1126+
call flush_IMAIN()
11031127
endif
11041128

11051129
end subroutine crm_ext_setup_jacobian

src/generate_databases/save_arrays_solver.F90

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,9 @@ subroutine save_arrays_solver_files()
457457

458458
! local parameters
459459
real(kind=CUSTOM_REAL), dimension(:,:,:,:), allocatable :: v_tmp
460+
real(kind=CUSTOM_REAL), dimension(:), allocatable :: tmp_elem
460461
integer,dimension(:),allocatable :: v_tmp_i
461-
integer :: ier,i,j
462+
integer :: ier,i,j,ispec,ispec_irreg
462463
integer, dimension(:), allocatable :: iglob_tmp
463464
integer :: inum, num_points
464465
character(len=MAX_STRING_LEN) :: filename
@@ -687,6 +688,48 @@ subroutine save_arrays_solver_files()
687688
xstore_unique,ystore_unique,zstore_unique,ibool, &
688689
qkappa_attenuation_store,filename)
689690

691+
692+
! outputs jacobian
693+
if (SAVE_MESH_FILES_ADDITIONAL) then
694+
v_tmp(:,:,:,:) = 0.0_CUSTOM_REAL
695+
! minimum jacobian per element
696+
allocate(tmp_elem(nspec), stat=ier)
697+
if (ier /= 0) stop 'Error allocating temporary tmp_elem array'
698+
tmp_elem(:) = 0.0_CUSTOM_REAL
699+
do ispec = 1,nspec
700+
ispec_irreg = irregular_element_number(ispec)
701+
! irregular_element_number is 0 only if the element is regular
702+
if (ispec_irreg /= 0) then
703+
! irregular element
704+
v_tmp(:,:,:,ispec) = jacobianstore(:,:,:,ispec_irreg)
705+
! minimum jacobian
706+
tmp_elem(ispec) = minval(jacobianstore(:,:,:,ispec_irreg))
707+
else
708+
! regular element
709+
v_tmp(:,:,:,ispec) = jacobian_regular
710+
! minimum jacobian
711+
tmp_elem(ispec) = jacobian_regular
712+
endif
713+
enddo
714+
! bin file output
715+
!open(unit=IOUT,file=prname(1:len_trim(prname))//'jacobian.bin',status='unknown',form='unformatted',iostat=ier)
716+
!if (ier /= 0) stop 'error opening file jacobian.bin'
717+
!write(IOUT) v_tmp
718+
!close(IOUT)
719+
! VTK file output
720+
!filename = prname(1:len_trim(prname))//'jacobian'
721+
!call write_VTK_data_gll_cr(nspec,nglob_unique, &
722+
! xstore_unique,ystore_unique,zstore_unique,ibool, &
723+
! v_tmp,filename)
724+
! VTU file output - minimum jacobian values per element
725+
filename = prname(1:len_trim(prname))//'jacobian_min'
726+
call write_VTU_data_elem_cr_binary(nspec,nglob_unique, &
727+
xstore_unique,ystore_unique,zstore_unique,ibool, &
728+
tmp_elem,filename)
729+
! free memory
730+
deallocate(tmp_elem)
731+
endif
732+
690733
! frees temporary array
691734
deallocate(v_tmp)
692735

src/shared/check_mesh_resolution.f90

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ subroutine check_mesh_resolution(NSPEC_AB,NGLOB_AB,ibool,xstore,ystore,zstore, &
9898
! checks if IMAIN is opened for writing out
9999
inquire(unit=IMAIN,opened=IMAIN_opened)
100100

101-
! note: this routine can take a long time for large meshes...
101+
! note: this routine can take a long time for large meshes...
102102
if (myrank == 0 .and. IMAIN_opened) then
103103
write(IMAIN,*) "Mesh resolution:"
104104
call flush_IMAIN()
@@ -170,7 +170,7 @@ subroutine check_mesh_resolution(NSPEC_AB,NGLOB_AB,ibool,xstore,ystore,zstore, &
170170
call max_all_i(NGLOB_AB,NGLOB_AB_global_max)
171171
call sum_all_i(NGLOB_AB,NGLOB_AB_global_sum)
172172

173-
! outputs infos
173+
! outputs infos
174174
if (myrank == 0 .and. IMAIN_opened) then
175175
write(IMAIN,*)
176176
write(IMAIN,*) '********'
@@ -287,9 +287,6 @@ subroutine check_mesh_resolution(NSPEC_AB,NGLOB_AB,ibool,xstore,ystore,zstore, &
287287
if (DT_PRESENT) then
288288
cmax = vel_max * DT / distance_min
289289
cmax_glob = max(cmax_glob,cmax)
290-
291-
! debug: for vtk output
292-
if (SAVE_MESH_FILES) tmp1(ispec) = cmax
293290
endif
294291

295292
! suggested timestep
@@ -303,7 +300,18 @@ subroutine check_mesh_resolution(NSPEC_AB,NGLOB_AB,ibool,xstore,ystore,zstore, &
303300
dt_suggested_glob = min(dt_suggested_glob, dt_suggested)
304301

305302
! debug: for vtk output
306-
if (SAVE_MESH_FILES) tmp2(ispec) = pmax
303+
if (SAVE_MESH_FILES) then
304+
! Courant/suggested DT number
305+
if (DT_PRESENT) then
306+
! Courant number
307+
tmp1(ispec) = cmax
308+
else
309+
! suggested dt
310+
tmp1(ispec) = dt_suggested
311+
endif
312+
! minimum period
313+
tmp2(ispec) = pmax
314+
endif
307315
enddo
308316

309317
! Vp velocity
@@ -520,10 +528,15 @@ subroutine check_mesh_resolution(NSPEC_AB,NGLOB_AB,ibool,xstore,ystore,zstore, &
520528
call flush_IMAIN()
521529
endif
522530

523-
! Courant number
531+
! Courant/suggested DT number
524532
if (DT_PRESENT) then
533+
! Courant number
525534
filename = 'res_Courant_number'
526535
call write_checkmesh_data_hdf5(filename,tmp1)
536+
else
537+
! suggested DT
538+
filename = 'res_dt_suggested'
539+
call write_checkmesh_data_hdf5(filename,tmp1)
527540
endif
528541

529542
! minimum period estimate
@@ -541,12 +554,19 @@ subroutine check_mesh_resolution(NSPEC_AB,NGLOB_AB,ibool,xstore,ystore,zstore, &
541554
call flush_IMAIN()
542555
endif
543556

544-
! Courant number
557+
! Courant/suggested DT number
545558
if (DT_PRESENT) then
559+
! Courant number
546560
filename = trim(prname)//'res_Courant_number'
547561
call write_VTU_data_elem_cr_binary(NSPEC_AB,NGLOB_AB, &
548562
xstore,ystore,zstore,ibool, &
549563
tmp1,filename)
564+
else
565+
! suggested DT
566+
filename = trim(prname)//'res_dt_suggested'
567+
call write_VTU_data_elem_cr_binary(NSPEC_AB,NGLOB_AB, &
568+
xstore,ystore,zstore,ibool, &
569+
tmp1,filename)
550570
endif
551571
! minimum period estimate
552572
filename = trim(prname)//'res_minimum_period'

src/shared/utm_geo.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ subroutine utm_geo(rlon4,rlat4,rx4,ry4,iway)
219219
! (Universal) Transverse Mercator projection
220220
!
221221
! page 61, eq. 3-21 for M
222-
f1 = (1.d0 - e2/4.d0 - 3.d0*e4/64.d0 - 5.d0*e6/256d0)*rlat
222+
f1 = (1.d0 - e2/4.d0 - 3.d0*e4/64.d0 - 5.d0*e6/256.d0)*rlat
223223
f2 = 3.d0*e2/8.d0 + 3.d0*e4/32.d0 + 45.d0*e6/1024.d0
224224
f2 = f2 * sin(2.d0*rlat)
225225
! corrected: using .. + 45 e6 / 1024 instead of .. * 45 e6 / 1024

0 commit comments

Comments
 (0)