-
Notifications
You must be signed in to change notification settings - Fork 220
/
get_MPI_cutplanes_xi.f90
178 lines (131 loc) · 5.06 KB
/
get_MPI_cutplanes_xi.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
!=====================================================================
!
! S p e c f e m 3 D V e r s i o n 1 . 4
! ---------------------------------------
!
! Dimitri Komatitsch and Jeroen Tromp
! Seismological Laboratory - California Institute of Technology
! (c) California Institute of Technology September 2006
!
! 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.
!
!=====================================================================
subroutine get_MPI_cutplanes_xi(myrank,prname,nspec,iMPIcut_xi,ibool, &
xstore,ystore,zstore,mask_ibool,npointot, &
NSPEC2D_A_ETA,NSPEC2D_B_ETA)
! this routine detects cut planes along xi
! In principle the left cut plane of the first slice
! and the right cut plane of the last slice are not used
! in the solver except if we want to have periodic conditions
implicit none
include "constants.h"
integer nspec,myrank
integer NSPEC2D_A_ETA,NSPEC2D_B_ETA
logical iMPIcut_xi(2,nspec)
integer ibool(NGLLX,NGLLY,NGLLZ,nspec)
double precision xstore(NGLLX,NGLLY,NGLLZ,nspec)
double precision ystore(NGLLX,NGLLY,NGLLZ,nspec)
double precision zstore(NGLLX,NGLLY,NGLLZ,nspec)
! logical mask used to create arrays iboolleft_xi and iboolright_xi
integer npointot
logical mask_ibool(npointot)
! global element numbering
integer ispec
! MPI cut-plane element numbering
integer ispecc1,ispecc2,npoin2D_xi,ix,iy,iz
integer nspec2Dtheor1,nspec2Dtheor2
! processor identification
character(len=150) prname
! theoretical number of surface elements in the buffers
! cut planes along xi=constant correspond to ETA faces
nspec2Dtheor1 = NSPEC2D_A_ETA
nspec2Dtheor2 = NSPEC2D_B_ETA
! write the MPI buffers for the left and right edges of the slice
! and the position of the points to check that the buffers are fine
!
! determine if the element falls on the left MPI cut plane
!
! global point number and coordinates left MPI cut-plane
open(unit=10,file=prname(1:len_trim(prname))//'iboolleft_xi.txt',status='unknown')
! erase the logical mask used to mark points already found
mask_ibool(:) = .false.
! nb of global points shared with the other slice
npoin2D_xi = 0
! nb of elements in this cut-plane
ispecc1=0
do ispec=1,nspec
if(iMPIcut_xi(1,ispec)) then
ispecc1=ispecc1+1
! loop on all the points in that 2-D element, including edges
ix = 1
do iy=1,NGLLY
do iz=1,NGLLZ
! select point, if not already selected
if(.not. mask_ibool(ibool(ix,iy,iz,ispec))) then
mask_ibool(ibool(ix,iy,iz,ispec)) = .true.
npoin2D_xi = npoin2D_xi + 1
write(10,*) ibool(ix,iy,iz,ispec),xstore(ix,iy,iz,ispec), &
ystore(ix,iy,iz,ispec),zstore(ix,iy,iz,ispec)
endif
enddo
enddo
endif
enddo
! put flag to indicate end of the list of points
write(10,*) '0 0 0. 0. 0.'
! write total number of points
write(10,*) npoin2D_xi
close(10)
! compare number of surface elements detected to analytical value
if(ispecc1 /= nspec2Dtheor1 .and. ispecc1 /= nspec2Dtheor2) &
call exit_MPI(myrank,'error MPI cut-planes detection in xi=left')
!
! determine if the element falls on the right MPI cut plane
!
! global point number and coordinates right MPI cut-plane
open(unit=10,file=prname(1:len_trim(prname))//'iboolright_xi.txt',status='unknown')
! erase the logical mask used to mark points already found
mask_ibool(:) = .false.
! nb of global points shared with the other slice
npoin2D_xi = 0
! nb of elements in this cut-plane
ispecc2=0
do ispec=1,nspec
if(iMPIcut_xi(2,ispec)) then
ispecc2=ispecc2+1
! loop on all the points in that 2-D element, including edges
ix = NGLLX
do iy=1,NGLLY
do iz=1,NGLLZ
! select point, if not already selected
if(.not. mask_ibool(ibool(ix,iy,iz,ispec))) then
mask_ibool(ibool(ix,iy,iz,ispec)) = .true.
npoin2D_xi = npoin2D_xi + 1
write(10,*) ibool(ix,iy,iz,ispec),xstore(ix,iy,iz,ispec), &
ystore(ix,iy,iz,ispec),zstore(ix,iy,iz,ispec)
endif
enddo
enddo
endif
enddo
! put flag to indicate end of the list of points
write(10,*) '0 0 0. 0. 0.'
! write total number of points
write(10,*) npoin2D_xi
close(10)
! compare number of surface elements detected to analytical value
if(ispecc2 /= nspec2Dtheor1 .and. ispecc2 /= nspec2Dtheor2) &
call exit_MPI(myrank,'error MPI cut-planes detection in xi=right')
end subroutine get_MPI_cutplanes_xi