Skip to content

Commit

Permalink
Removing global
Browse files Browse the repository at this point in the history
  • Loading branch information
Anand committed Nov 11, 2024
1 parent c14e218 commit ea836f1
Show file tree
Hide file tree
Showing 20 changed files with 295 additions and 309 deletions.
14 changes: 0 additions & 14 deletions src/common/include/macros.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,6 @@
!$acc exit data delete(${', '.join(args)}$)
#:enddef DEALLOCATE

#:def ALLOCATE_GLOBAL(*args)
@:LOG({'@:ALLOCATE_GLOBAL(${re.sub(' +', ' ', ', '.join(args))}$)'})

allocate (${', '.join(args)}$)

#:enddef ALLOCATE_GLOBAL

#:def DEALLOCATE_GLOBAL(*args)
@:LOG({'@:DEALLOCATE_GLOBAL(${re.sub(' +', ' ', ', '.join(args))}$)'})

deallocate (${', '.join(args)}$)

#:enddef DEALLOCATE_GLOBAL

#:def ACC_SETUP_VFs(*args)
#ifdef _CRAYFTN
block
Expand Down
6 changes: 3 additions & 3 deletions src/common/m_helper.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ contains
rhol0 = rhoref
pl0 = pref
#ifdef MFC_SIMULATION
@:ALLOCATE_GLOBAL(pb0(nb), mass_n0(nb), mass_v0(nb), Pe_T(nb))
@:ALLOCATE_GLOBAL(k_n(nb), k_v(nb), omegaN(nb))
@:ALLOCATE_GLOBAL(Re_trans_T(nb), Re_trans_c(nb), Im_trans_T(nb), Im_trans_c(nb))
@:ALLOCATE(pb0(nb), mass_n0(nb), mass_v0(nb), Pe_T(nb))
@:ALLOCATE(k_n(nb), k_v(nb), omegaN(nb))
@:ALLOCATE(Re_trans_T(nb), Re_trans_c(nb), Im_trans_T(nb), Im_trans_c(nb))
#else
@:ALLOCATE(pb0(nb), mass_n0(nb), mass_v0(nb), Pe_T(nb))
@:ALLOCATE(k_n(nb), k_v(nb), omegaN(nb))
Expand Down
24 changes: 12 additions & 12 deletions src/common/m_variables_conversion.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,14 +621,14 @@ contains
!$acc enter data copyin(is1b, is1e, is2b, is2e, is3b, is3e)

#ifdef MFC_SIMULATION
@:ALLOCATE_GLOBAL(gammas (1:num_fluids))
@:ALLOCATE_GLOBAL(gs_min (1:num_fluids))
@:ALLOCATE_GLOBAL(pi_infs(1:num_fluids))
@:ALLOCATE_GLOBAL(ps_inf(1:num_fluids))
@:ALLOCATE_GLOBAL(cvs (1:num_fluids))
@:ALLOCATE_GLOBAL(qvs (1:num_fluids))
@:ALLOCATE_GLOBAL(qvps (1:num_fluids))
@:ALLOCATE_GLOBAL(Gs (1:num_fluids))
@:ALLOCATE(gammas (1:num_fluids))
@:ALLOCATE(gs_min (1:num_fluids))
@:ALLOCATE(pi_infs(1:num_fluids))
@:ALLOCATE(ps_inf(1:num_fluids))
@:ALLOCATE(cvs (1:num_fluids))
@:ALLOCATE(qvs (1:num_fluids))
@:ALLOCATE(qvps (1:num_fluids))
@:ALLOCATE(Gs (1:num_fluids))
#else
@:ALLOCATE(gammas (1:num_fluids))
@:ALLOCATE(gs_min (1:num_fluids))
Expand All @@ -655,7 +655,7 @@ contains
#ifdef MFC_SIMULATION

if (viscous) then
@:ALLOCATE_GLOBAL(Res(1:2, 1:maxval(Re_size)))
@:ALLOCATE(Res(1:2, 1:maxval(Re_size)))
do i = 1, 2
do j = 1, Re_size(i)
Res(i, j) = fluid_pp(Re_idx(i, j))%Re(i)
Expand All @@ -668,7 +668,7 @@ contains

if (bubbles) then
#ifdef MFC_SIMULATION
@:ALLOCATE_GLOBAL(bubrs(1:nb))
@:ALLOCATE(bubrs(1:nb))
#else
@:ALLOCATE(bubrs(1:nb))
#endif
Expand Down Expand Up @@ -1361,9 +1361,9 @@ contains
#endif

#ifdef MFC_SIMULATION
@:DEALLOCATE_GLOBAL(gammas, gs_min, pi_infs, ps_inf, cvs, qvs, qvps, Gs)
@:DEALLOCATE(gammas, gs_min, pi_infs, ps_inf, cvs, qvs, qvps, Gs)
if (bubbles) then
@:DEALLOCATE_GLOBAL(bubrs)
@:DEALLOCATE(bubrs)
end if
#else
@:DEALLOCATE(gammas, gs_min, pi_infs, ps_inf, cvs, qvs, qvps, Gs)
Expand Down
12 changes: 6 additions & 6 deletions src/simulation/m_acoustic_src.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ contains
subroutine s_initialize_acoustic_src
integer :: i, j !< generic loop variables

@:ALLOCATE_GLOBAL(loc_acoustic(1:3, 1:num_source), mag(1:num_source), dipole(1:num_source), support(1:num_source), length(1:num_source), height(1:num_source), wavelength(1:num_source), frequency(1:num_source), gauss_sigma_dist(1:num_source), gauss_sigma_time(1:num_source), foc_length(1:num_source), aperture(1:num_source), npulse(1:num_source), pulse(1:num_source), dir(1:num_source), delay(1:num_source), element_polygon_ratio(1:num_source), rotate_angle(1:num_source), element_spacing_angle(1:num_source), num_elements(1:num_source), element_on(1:num_source))
@:ALLOCATE(loc_acoustic(1:3, 1:num_source), mag(1:num_source), dipole(1:num_source), support(1:num_source), length(1:num_source), height(1:num_source), wavelength(1:num_source), frequency(1:num_source), gauss_sigma_dist(1:num_source), gauss_sigma_time(1:num_source), foc_length(1:num_source), aperture(1:num_source), npulse(1:num_source), pulse(1:num_source), dir(1:num_source), delay(1:num_source), element_polygon_ratio(1:num_source), rotate_angle(1:num_source), element_spacing_angle(1:num_source), num_elements(1:num_source), element_on(1:num_source))
do i = 1, num_source
do j = 1, 3
loc_acoustic(j, i) = acoustic(i)%loc(j)
Expand Down Expand Up @@ -103,9 +103,9 @@ contains
end do
!$acc update device(loc_acoustic, mag, dipole, support, length, height, wavelength, frequency, gauss_sigma_dist, gauss_sigma_time, foc_length, aperture, npulse, pulse, dir, delay, element_polygon_ratio, rotate_angle, element_spacing_angle, num_elements, element_on)

@:ALLOCATE_GLOBAL(mass_src(0:m, 0:n, 0:p))
@:ALLOCATE_GLOBAL(mom_src(1:num_dims, 0:m, 0:n, 0:p))
@:ALLOCATE_GLOBAL(E_src(0:m, 0:n, 0:p))
@:ALLOCATE(mass_src(0:m, 0:n, 0:p))
@:ALLOCATE(mom_src(1:num_dims, 0:m, 0:n, 0:p))
@:ALLOCATE(E_src(0:m, 0:n, 0:p))

end subroutine s_initialize_acoustic_src

Expand Down Expand Up @@ -370,8 +370,8 @@ contains
dim = 3
end if

@:ALLOCATE_GLOBAL(source_spatials_num_points(1:num_source))
@:ALLOCATE_GLOBAL(source_spatials(1:num_source))
@:ALLOCATE(source_spatials_num_points(1:num_source))
@:ALLOCATE(source_spatials(1:num_source))

do ai = 1, num_source
! First pass: Count the number of points for each source
Expand Down
8 changes: 4 additions & 4 deletions src/simulation/m_body_forces.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ contains
if (n > 0) then
! Simulation is 3D
if (p > 0) then
@:ALLOCATE_GLOBAL (rhoM(-buff_size:buff_size + m, &
@:ALLOCATE (rhoM(-buff_size:buff_size + m, &
-buff_size:buff_size + n, &
-buff_size:buff_size + p))
! Simulation is 2D
else
@:ALLOCATE_GLOBAL (rhoM(-buff_size:buff_size + m, &
@:ALLOCATE (rhoM(-buff_size:buff_size + m, &
-buff_size:buff_size + n, &
0:0))
end if
! Simulation is 1D
else
@:ALLOCATE_GLOBAL (rhoM(-buff_size:buff_size + m, &
@:ALLOCATE (rhoM(-buff_size:buff_size + m, &
0:0, &
0:0))
end if
Expand Down Expand Up @@ -173,7 +173,7 @@ contains

subroutine s_finalize_body_forces_module

@:DEALLOCATE_GLOBAL(rhoM)
@:DEALLOCATE(rhoM)

end subroutine s_finalize_body_forces_module

Expand Down
18 changes: 9 additions & 9 deletions src/simulation/m_bubbles.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ contains

integer :: l

@:ALLOCATE_GLOBAL(rs(1:nb))
@:ALLOCATE_GLOBAL(vs(1:nb))
@:ALLOCATE(rs(1:nb))
@:ALLOCATE(vs(1:nb))
if (.not. polytropic) then
@:ALLOCATE_GLOBAL(ps(1:nb))
@:ALLOCATE_GLOBAL(ms(1:nb))
@:ALLOCATE(ps(1:nb))
@:ALLOCATE(ms(1:nb))
end if

do l = 1, nb
Expand All @@ -66,11 +66,11 @@ contains
@:ALLOCATE(divu%sf(idwbuff(1)%beg:idwbuff(1)%end, idwbuff(2)%beg:idwbuff(2)%end, idwbuff(3)%beg:idwbuff(3)%end))
@:ACC_SETUP_SFs(divu)

@:ALLOCATE_GLOBAL(bub_adv_src(0:m, 0:n, 0:p))
@:ALLOCATE_GLOBAL(bub_r_src(0:m, 0:n, 0:p, 1:nb))
@:ALLOCATE_GLOBAL(bub_v_src(0:m, 0:n, 0:p, 1:nb))
@:ALLOCATE_GLOBAL(bub_p_src(0:m, 0:n, 0:p, 1:nb))
@:ALLOCATE_GLOBAL(bub_m_src(0:m, 0:n, 0:p, 1:nb))
@:ALLOCATE(bub_adv_src(0:m, 0:n, 0:p))
@:ALLOCATE(bub_r_src(0:m, 0:n, 0:p, 1:nb))
@:ALLOCATE(bub_v_src(0:m, 0:n, 0:p, 1:nb))
@:ALLOCATE(bub_p_src(0:m, 0:n, 0:p, 1:nb))
@:ALLOCATE(bub_m_src(0:m, 0:n, 0:p, 1:nb))

end subroutine s_initialize_bubbles_module

Expand Down
Loading

0 comments on commit ea836f1

Please sign in to comment.