Skip to content

Commit ec56e8f

Browse files
committed
Split array for reference evaluation
1 parent 3bd0e87 commit ec56e8f

File tree

2 files changed

+33
-34
lines changed

2 files changed

+33
-34
lines changed

src/Fortran_libraries/MHD_src/sph_MHD/const_diffusive_profile.f90

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@
2424
!! type(fdm2_center_mat), intent(in) :: fdm2_center
2525
!! type(phys_data), intent(in) :: rj_fld
2626
!! type(band_matrix_type), intent(in) :: band_s00_poisson
27-
!! subroutine cal_reference_source(sph_rj, band_s00_poisson, &
28-
!! & ref_source, ref_local)
27+
!! subroutine cal_reference_source(sph_rj, sc_prop, &
28+
!! & band_s00_poisson, ref_source, ref_local)
2929
!! type(sph_rj_grid), intent(in) :: sph_rj
30+
!! type(scalar_property), intent(in) :: sc_prop
3031
!! type(band_matrix_type), intent(in) :: band_s00_poisson
3132
!! real(kind = kreal), intent(in) &
3233
!! & :: ref_source(0:sph_rj%nidx_rj(1))
@@ -66,7 +67,7 @@ module const_diffusive_profile
6667
!
6768
subroutine s_const_diffusive_profile(sph_rj, r_2nd, &
6869
& sc_prop, sph_bc, bcs_S, fdm2_center, band_s00_poisson, &
69-
& reftemp_r, refgrad_r, ref_local)
70+
& reftemp_r, refgrad_r, ref_local, grad_local)
7071
!
7172
use calypso_mpi
7273
use calypso_mpi_real
@@ -87,48 +88,48 @@ subroutine s_const_diffusive_profile(sph_rj, r_2nd, &
8788
real(kind=kreal), intent(inout) :: reftemp_r(0:sph_rj%nidx_rj(1))
8889
real(kind=kreal), intent(inout) :: refgrad_r(0:sph_rj%nidx_rj(1))
8990
real(kind = kreal), intent(inout) &
90-
& :: ref_local(0:sph_rj%nidx_rj(1),0:1)
91+
& :: ref_local(0:sph_rj%nidx_rj(1))
92+
real(kind = kreal), intent(inout) &
93+
& :: grad_local(0:sph_rj%nidx_rj(1))
9194
!
9295
integer(kind = kint_gl) :: num64
9396
! integer :: k
9497
!
9598
if(sph_rj%idx_rj_degree_zero .gt. 0) then
9699
!$omp parallel workshare
97-
ref_local(0:sph_rj%nidx_rj(1),0) &
98-
& = ref_local(0:sph_rj%nidx_rj(1),0) &
99-
& * (sc_prop%coef_source / sc_prop%coef_diffuse)
100+
ref_local(0:sph_rj%nidx_rj(1)) = ref_local(0:sph_rj%nidx_rj(1)) &
101+
& * (sc_prop%coef_source / sc_prop%coef_diffuse)
100102
!$omp end parallel workshare
101103
!
102104
call set_ICB_scalar_boundary_1d &
103-
& (sph_rj, sph_bc, bcs_S%ICB_Sspec, ref_local(0,0))
105+
& (sph_rj, sph_bc, bcs_S%ICB_Sspec, ref_local(0))
104106
call set_CMB_scalar_boundary_1d &
105-
& (sph_rj, sph_bc, bcs_S%CMB_Sspec, ref_local(0,0))
107+
& (sph_rj, sph_bc, bcs_S%CMB_Sspec, ref_local(0))
106108
!
107109
! do k = 0, sph_rj%nidx_rj(1)
108-
! write(*,*) k, 'RHS', ref_local(k,0)
110+
! write(*,*) k, 'RHS', ref_local(k)
109111
! end do
110112
!
111-
call lubksb_3band_ctr(band_s00_poisson, ref_local(0,0))
113+
call lubksb_3band_ctr(band_s00_poisson, ref_local(0))
112114
! call s_cal_sol_reftemp_BiCGSTAB &
113-
! & (band_s00_poisson, ref_local(0,0))
115+
! & (band_s00_poisson, ref_local(0))
114116
!
115117
! do k = 0, sph_rj%nidx_rj(1)
116-
! write(*,*) k, 'Solution', ref_local(k,0)
118+
! write(*,*) k, 'Solution', ref_local(k)
117119
! end do
118120
!
119121
call fill_scalar_1d_external(sph_bc, sph_rj%inod_rj_center, &
120-
& sph_rj%nidx_rj(1), ref_local(0,0))
122+
& sph_rj%nidx_rj(1), ref_local(0))
121123
!
122124
call cal_sph_nod_gradient_1d(sph_bc%kr_in, sph_bc%kr_out, &
123125
& sph_rj%nidx_rj(1), r_2nd%fdm(1)%dmat, &
124-
& ref_local(0,0), ref_local(0,1))
126+
& ref_local(0), grad_local(0))
125127
!
126128
call sel_ICB_radial_grad_1d_scalar &
127129
& (sph_rj, sph_bc, bcs_S%ICB_Sspec, fdm2_center, &
128-
& ref_local(0,0), ref_local(0,1))
130+
& ref_local, grad_local)
129131
call sel_CMB_radial_grad_1d_scalar &
130-
& (sph_rj, sph_bc, bcs_S%CMB_Sspec, &
131-
& ref_local(0,0), ref_local(0,1))
132+
& (sph_rj, sph_bc, bcs_S%CMB_Sspec, ref_local, grad_local)
132133
end if
133134
!
134135
!$omp parallel workshare
@@ -137,9 +138,9 @@ subroutine s_const_diffusive_profile(sph_rj, r_2nd, &
137138
!$omp end parallel workshare
138139
!
139140
num64 = sph_rj%nidx_rj(1) + 1
140-
call calypso_mpi_allreduce_real(ref_local(0,0), reftemp_r, &
141+
call calypso_mpi_allreduce_real(ref_local(0), reftemp_r, &
141142
& num64, MPI_SUM)
142-
call calypso_mpi_allreduce_real(ref_local(0,1), refgrad_r, &
143+
call calypso_mpi_allreduce_real(grad_local(0), refgrad_r, &
143144
& num64, MPI_SUM)
144145
!
145146
end subroutine s_const_diffusive_profile
@@ -243,7 +244,7 @@ subroutine gradient_of_radial_reference(sph_rj, r_2nd, &
243244
real(kind=kreal), intent(inout) :: refgrad_r(0:sph_rj%nidx_rj(1))
244245
!
245246
!
246-
call fill_scalar_1d_external(sph_bc, sph_rj%inod_rj_center, &
247+
call fill_scalar_1d_external(sph_bc, sph_rj%inod_rj_center, &
247248
& sph_rj%nidx_rj(1), reftemp_r(0))
248249
!
249250
call cal_sph_nod_gradient_1d(sph_bc%kr_in, sph_bc%kr_out, &
@@ -260,10 +261,11 @@ end subroutine gradient_of_radial_reference
260261
!
261262
! -----------------------------------------------------------------------
262263
!
263-
subroutine cal_reference_source(sph_rj, band_s00_poisson, &
264-
& ref_source, ref_local)
264+
subroutine cal_reference_source(sph_rj, sc_prop, &
265+
& band_s00_poisson, ref_source, ref_local)
265266
!
266267
type(sph_rj_grid), intent(in) :: sph_rj
268+
type(scalar_property), intent(in) :: sc_prop
267269
type(band_matrix_type), intent(in) :: band_s00_poisson
268270
!
269271
real(kind = kreal), intent(in) &
@@ -288,6 +290,11 @@ subroutine cal_reference_source(sph_rj, band_s00_poisson, &
288290
k = sph_rj%nidx_rj(1)
289291
ref_local(k) = band_s00_poisson%mat(3,k-1) * ref_source(k-1) &
290292
& + band_s00_poisson%mat(2,k ) * ref_source(k)
293+
!
294+
!$omp parallel workshare
295+
ref_local(0:sph_rj%nidx_rj(1)) = ref_local(0:sph_rj%nidx_rj(1)) &
296+
& * (sc_prop%coef_diffuse / sc_prop%coef_source)
297+
!$omp end parallel workshare
291298
!
292299
end subroutine cal_reference_source
293300
!

src/Fortran_libraries/MHD_src/sph_MHD/const_radial_references.f90

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ subroutine const_diffusive_profiles(sph_rj, sc_prop, &
104104
call s_const_diffusive_profile(sph_rj, r_2nd, sc_prop, &
105105
& sph_bc_S, bcs_S, fdm2_center, band_s00_poisson, &
106106
& ref_field%d_fld(1,iref_scalar), ref_field%d_fld(1,iref_grad), &
107-
& ref_local)
107+
& ref_local(0,0), ref_local(0,1))
108108
deallocate(ref_local)
109109
!
110110
end subroutine const_diffusive_profiles
@@ -177,16 +177,8 @@ subroutine const_reference_source(sph_rj, sc_prop, &
177177
!
178178
if(iref_source*iref_scalar .le. 0) return
179179
if(sph_rj%idx_rj_degree_zero .gt. 0) then
180-
if(iref_source .gt. 0) then
181-
call cal_reference_source(sph_rj, band_s00_poisson, &
182-
& ref_field%d_fld(1,iref_scalar), ref_local)
183-
!
184-
!$omp parallel workshare
185-
ref_local(0:sph_rj%nidx_rj(1)) &
186-
& = ref_local(0:sph_rj%nidx_rj(1)) &
187-
& * (sc_prop%coef_diffuse / sc_prop%coef_source)
188-
!$omp end parallel workshare
189-
end if
180+
call cal_reference_source(sph_rj, sc_prop, band_s00_poisson, &
181+
& ref_field%d_fld(1,iref_scalar), ref_local)
190182
end if
191183
!
192184
num64 = sph_rj%nidx_rj(1) + 1

0 commit comments

Comments
 (0)