Skip to content

Commit 3f6ebf5

Browse files
committed
Add Doxygen docstrings and more comments
1 parent bd7523a commit 3f6ebf5

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/simulation/m_acoustic_src.fpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,11 @@ contains
136136
real(kind(0d0)) :: frequency_local, gauss_sigma_time_local
137137
real(kind(0d0)) :: mass_src_diff, mom_src_diff
138138
real(kind(0d0)) :: source_temporal
139-
real(kind(0d0)), dimension(1:num_broadband_freq) :: period_BB, sl_BB, ffre_BB, phi_rn ! broadband source variables
140-
real(kind(0d0)) :: sum_BB
139+
real(kind(0d0)), dimension(1:num_broadband_freq) :: period_BB !< period of each sine wave in broadband source
140+
real(kind(0d0)), dimension(1:num_broadband_freq) :: sl_BB !< spectral level at each frequency
141+
real(kind(0d0)), dimension(1:num_broadband_freq) :: ffre_BB !< source term corresponding to each frequency
142+
real(kind(0d0)), dimension(1:num_broadband_freq) :: phi_rn !< random phase shift for each frequency
143+
real(kind(0d0)) :: sum_BB !< total source term for the broadband wave
141144

142145
integer :: i, j, k, l, q !< generic loop variables
143146
integer :: ai !< acoustic source index
@@ -173,16 +176,21 @@ contains
173176

174177
num_points = source_spatials_num_points(ai) ! Use scalar to force firstprivate to prevent GPU bug
175178

176-
call random_number(phi_rn(1:100))
179+
call random_number(phi_rn(1:num_broadband_freq))
180+
! Ensure all the ranks have the same random phase shift
177181
call s_mpi_send_random_number(phi_rn)
178182
sum_BB = 0d0
179183

180-
!$acc loop
184+
!$acc loop seq
181185
do k = 1, num_broadband_freq
182-
period_BB(k) = 1d0/(broadband_freq_lowest + k*broadband_bandwidth) ! Acoustic period of the wave at each discrete frequency
183-
sl_BB(k) = broadband_spectral_level_constant*mag(ai) + k*mag(ai)/broadband_spectral_level_growth_rate ! Spectral level at each frequency
184-
ffre_BB(k) = dsqrt((2d0*sl_BB(k)*broadband_bandwidth))*cos((sim_time)*2.d0*pi/period_BB(k) + 2d0*pi*phi_rn(k)) ! Source term corresponding to each frequencies
185-
sum_BB = sum_BB + ffre_BB(k) ! Total source term for the broadband wave
186+
! Acoustic period of the wave at each discrete frequency
187+
period_BB(k) = 1d0/(broadband_freq_lowest + k*broadband_bandwidth)
188+
! Spectral level at each frequency
189+
sl_BB(k) = broadband_spectral_level_constant*mag(ai) + k*mag(ai)/broadband_spectral_level_growth_rate
190+
! Source term corresponding to each frequencies
191+
ffre_BB(k) = dsqrt((2d0*sl_BB(k)*broadband_bandwidth))*cos((sim_time)*2d0*pi/period_BB(k) + 2d0*pi*phi_rn(k))
192+
! Sum up the source term of each frequency to obtain the total source term for broadband wave
193+
sum_BB = sum_BB + ffre_BB(k)
186194
end do
187195

188196
!$acc parallel loop gang vector default(present) private(myalpha, myalpha_rho)

0 commit comments

Comments
 (0)