Skip to content

Commit c03d88d

Browse files
committed
adds backward compatibility for ocean load
1 parent 9ee442e commit c03d88d

File tree

1 file changed

+45
-23
lines changed

1 file changed

+45
-23
lines changed

src/specfem3D/prepare_oceans.f90

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -106,22 +106,30 @@ subroutine prepare_oceans()
106106
npoin_oceans = ipoin
107107

108108
! Assemble normals
109-
call assemble_MPI_scalar(NPROCTOT_VAL,NGLOB_CRUST_MANTLE, &
110-
normx, &
111-
num_interfaces_crust_mantle,max_nibool_interfaces_cm, &
112-
nibool_interfaces_crust_mantle,ibool_interfaces_crust_mantle, &
113-
my_neighbors_crust_mantle)
114-
call assemble_MPI_scalar(NPROCTOT_VAL,NGLOB_CRUST_MANTLE, &
115-
normy, &
116-
num_interfaces_crust_mantle,max_nibool_interfaces_cm, &
117-
nibool_interfaces_crust_mantle,ibool_interfaces_crust_mantle, &
118-
my_neighbors_crust_mantle)
119-
call assemble_MPI_scalar(NPROCTOT_VAL,NGLOB_CRUST_MANTLE, &
120-
normz, &
121-
num_interfaces_crust_mantle,max_nibool_interfaces_cm, &
122-
nibool_interfaces_crust_mantle,ibool_interfaces_crust_mantle, &
123-
my_neighbors_crust_mantle)
124-
109+
! note: having multiple MPI slices, the normal on a halo point that is shared between MPI slices might be slightly different
110+
! depending from which slice it is taken. to avoid such a jump, here we count its valence and average the normal
111+
! across different MPI slices.
112+
if (USE_OLD_VERSION_FORMAT) then
113+
! no assembly between different slices done
114+
continue
115+
else
116+
! assembles normal values from halo points
117+
call assemble_MPI_scalar(NPROCTOT_VAL,NGLOB_CRUST_MANTLE, &
118+
normx, &
119+
num_interfaces_crust_mantle,max_nibool_interfaces_cm, &
120+
nibool_interfaces_crust_mantle,ibool_interfaces_crust_mantle, &
121+
my_neighbors_crust_mantle)
122+
call assemble_MPI_scalar(NPROCTOT_VAL,NGLOB_CRUST_MANTLE, &
123+
normy, &
124+
num_interfaces_crust_mantle,max_nibool_interfaces_cm, &
125+
nibool_interfaces_crust_mantle,ibool_interfaces_crust_mantle, &
126+
my_neighbors_crust_mantle)
127+
call assemble_MPI_scalar(NPROCTOT_VAL,NGLOB_CRUST_MANTLE, &
128+
normz, &
129+
num_interfaces_crust_mantle,max_nibool_interfaces_cm, &
130+
nibool_interfaces_crust_mantle,ibool_interfaces_crust_mantle, &
131+
my_neighbors_crust_mantle)
132+
endif
125133

126134
! user info
127135
if (myrank == 0) then
@@ -150,21 +158,35 @@ subroutine prepare_oceans()
150158
do i = 1,NGLLX
151159
! get global point number
152160
iglob = ibool_crust_mantle(i,j,k,ispec)
161+
153162
! updates once
154163
if (.not. updated_dof_ocean_load(iglob)) then
155164
ipoin = ipoin + 1
165+
156166
! fills arrays
157167
ibool_ocean_load(ipoin) = iglob
158168
rmass_ocean_load_selected(ipoin) = rmass_ocean_load(iglob)
159-
! Make normal continuous
160-
if (valence(iglob) > 1.) then
161-
norm = sqrt(normx(iglob)**2 + normy(iglob)**2 + normz(iglob)**2)
162-
normal_ocean_load(1,ipoin) = normx(iglob) / norm
163-
normal_ocean_load(2,ipoin) = normy(iglob) / norm
164-
normal_ocean_load(3,ipoin) = normz(iglob) / norm
169+
170+
! normals
171+
if (USE_OLD_VERSION_FORMAT) then
172+
! old version compatibility
173+
! uses single point normal
174+
! note: this might lead to small jumps across MPI slices, i.e.,
175+
! having different normals on shared halo points depending from which slice it is taken
176+
normal_ocean_load(:,ipoin) = normal_top_crust_mantle(:,i,j,ispec2D)
165177
else
166-
normal_ocean_load(:,ipoin) = normal_top_crust_mantle(:,i,j,ispec2D)
178+
! considers assembled normals on halo points
179+
! Make normal continuous
180+
if (valence(iglob) > 1.) then
181+
norm = sqrt(normx(iglob)**2 + normy(iglob)**2 + normz(iglob)**2)
182+
normal_ocean_load(1,ipoin) = normx(iglob) / norm
183+
normal_ocean_load(2,ipoin) = normy(iglob) / norm
184+
normal_ocean_load(3,ipoin) = normz(iglob) / norm
185+
else
186+
normal_ocean_load(:,ipoin) = normal_top_crust_mantle(:,i,j,ispec2D)
187+
endif
167188
endif
189+
168190
! masks this global point
169191
updated_dof_ocean_load(iglob) = .true.
170192
endif

0 commit comments

Comments
 (0)