66submodule(subdomain_m) subdomain_s
77 use assert_m
88 use julienne_m, only : bin_t
9- use intrinsic_array_m, only : intrinsic_array_t
109 implicit none
1110
1211 real , allocatable :: halo_x(:,:,:)[:]
3736 dy_ = dx_
3837 dz_ = dx_
3938
40- call_assert_diagnose (num_subdomains <= nx- nx_boundaries, " subdomain_t%define: num_subdomains <= nx-nx_boundaries " , intrinsic_array_t([nx, num_subdomains]) )
39+ call_assert (num_subdomains <= nx- nx_boundaries)
4140
4241 me = this_image()
4342 num_subdomains = num_images()
8281 end procedure
8382
8483 module procedure laplacian
85- integer i, j, k;
84+ integer i, j, k
8685 real , allocatable :: halo_west(:,:), halo_east(:,:)
8786
8887 call_assert(allocated (rhs% s_))
8988 call_assert(allocated (halo_x))
9089
9190 allocate (laplacian_rhs% s_(my_nx, ny, nz))
92- halo_west = merge (halo_x(west,:,:), rhs% s_(1 ,:,:), me/= 1 )
91+ halo_west = merge (halo_x(west,:,:), rhs% s_(1 ,:,:), me/= 1 ) ! conditionally use halo value
9392 i = my_internal_west
9493 call_assert_describe(i+1 <= my_nx, " laplacian: westernmost subdomain too small" )
95-
94+ ! Compute Laplacians throughout the low-x boundary subdomain using non-allocatable associations:
9695 associate( laplacian_phi = > laplacian_rhs% s_, inbox = > halo_west, phi= >rhs% s_)
9796#if HAVE_2018_LOCALITY_SPECIFIERS
9897 do concurrent(j= 2 :ny-1 , k= 2 :nz-1 ) &
99- default(none) shared(laplacian_phi, inbox, phi, dx_, dy_, dz_, i)
98+ default(none) shared(laplacian_phi, inbox, phi, dx_, dy_, dz_, i) ! Fortran 2018 loacality specifiers
10099#else
101- do concurrent(j= 2 :ny-1 , k= 2 :nz-1 )
100+ do concurrent(j= 2 :ny-1 , k= 2 :nz-1 )
102101#endif
103102 laplacian_phi(i,j,k) = (inbox(j,k ) - 2 * phi(i,j,k) + phi(i+1 ,j ,k ))/ dx_** 2 + &
104103 (phi(i,j-1 ,k ) - 2 * phi(i,j,k) + phi(i ,j+1 ,k ))/ dy_** 2 + &
105104 (phi(i,j ,k-1 ) - 2 * phi(i,j,k) + phi(i ,j ,k+1 ))/ dz_** 2
106105 end do
107106 end associate
108-
109- associate(laplacian_phi = > laplacian_rhs% s_, phi= >rhs% s_)
107+ ! Compute Laplacians throughout non-boundary subdomains with non-allocatable associations:
108+ associate(laplacian_phi = > laplacian_rhs% s_, phi= >rhs% s_)
110109#if HAVE_2018_LOCALITY_SPECIFIERS
111110 do concurrent(i= my_internal_west+1 :my_internal_east-1 , j= 2 :ny-1 , k= 2 :nz-1 ) &
112- default(none) shared(laplacian_phi, phi, dx_, dy_, dz_)
111+ default(none) shared(laplacian_phi, phi, dx_, dy_, dz_) ! Fortran 2018 locality specifiers
113112#else
114113 do concurrent(i= my_internal_west+1 :my_internal_east-1 , j= 2 :ny-1 , k= 2 :nz-1 )
115114#endif
119118 end do
120119 end associate
121120
122- halo_east = merge (halo_x(east,:,:), rhs% s_(my_nx,:,:), me/= num_subdomains)
121+ halo_east = merge (halo_x(east,:,:), rhs% s_(my_nx,:,:), me/= num_subdomains) ! conditionally use halo value
123122 i = my_internal_east
124123 call_assert_describe(i-1 > 0 , " laplacian: easternmost subdomain too small" )
125-
124+ ! Compute Laplacians throughout the high-x boundary subdomain using non-allocatable associations:
126125 associate(laplacian_phi = > laplacian_rhs% s_, inbox = > halo_east, phi= >rhs% s_)
127126#if HAVE_2018_LOCALITY_SPECIFIERS
128- do concurrent(j= 2 :ny-1 , k= 2 :nz-1 ) &
129- default(none) shared(laplacian_phi, inbox, phi, dx_, dy_, dz_, i)
127+ do concurrent(j= 2 :ny-1 , k= 2 :nz-1 ) & ! compute Laplacian in low-x boundary subdomain
128+ default(none) shared(laplacian_phi, inbox, phi, dx_, dy_, dz_, i) ! Fortran 2018 locality specifiers
130129#else
131- do concurrent(j= 2 :ny-1 , k= 2 :nz-1 )
130+ do concurrent(j= 2 :ny-1 , k= 2 :nz-1 ) ! compute Laplacian in low-x boundary subdomain
132131#endif
133132 laplacian_phi(i,j,k) = (phi(i-1 ,j ,k ) - 2 * phi(i,j,k) + inbox( j ,k ))/ dx_** 2 + &
134133 (phi(i ,j-1 ,k ) - 2 * phi(i,j,k) + phi(i ,j+1 ,k ))/ dy_** 2 + &
135134 (phi(i ,j ,k-1 ) - 2 * phi(i,j,k) + phi(i ,j ,k+1 ))/ dz_** 2
136135 end do
137136 end associate
138137
139- laplacian_rhs% s_(:, 1 ,:) = 0 . ! y-direction low boundary
140- laplacian_rhs% s_(:,ny,:) = 0 . ! y-direction high boundary
141- laplacian_rhs% s_(:,:, 1 ) = 0 . ! z-direction low boundary
142- laplacian_rhs% s_(:,:,nz) = 0 . ! z-direction high boundary
143- if (me== 1 ) laplacian_rhs% s_(1 ,:,:) = 0 . ! x-direction low boundary
144- if (me== num_subdomains) laplacian_rhs% s_(my_nx,:,:) = 0 . ! x-direction high boundary
138+ laplacian_rhs% s_(:, 1 ,:) = 0 . ! low-y boundary
139+ laplacian_rhs% s_(:,ny,:) = 0 . ! high-y boundary
140+ laplacian_rhs% s_(:,:, 1 ) = 0 . ! low-z boundary
141+ laplacian_rhs% s_(:,:,nz) = 0 . ! high-z boundary
142+
143+ if (me== 1 ) laplacian_rhs% s_(1 ,:,:) = 0 . ! low-x boundary
144+ if (me== num_subdomains) laplacian_rhs% s_(my_nx,:,:) = 0 . ! high-x boundary
145145 end procedure
146146
147147 module procedure multiply
@@ -246,4 +246,4 @@ subroutine exchange_halo(s)
246246
247247 end procedure
248248
249- end submodule subdomain_s
249+ end submodule subdomain_s
0 commit comments