-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcal_vis.f90
executable file
·36 lines (31 loc) · 1.01 KB
/
cal_vis.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
subroutine vis ( dt, work)
!---------------------------------------------------------------
! Calculate viscous term for time advancement
! exp (-nu*k^2*dt)
! Optimized for vectorization (Dmitry, Feb 1, 2008)
!---------------------------------------------------------------
use share_vars
implicit none
integer :: kx, kx_max, ky, ky_max
real (kind=pr), dimension (0:nx-1, 0:ny-1), intent(out) :: work
real (kind=pr), intent (in) :: dt
real (kind=pr) :: coefx, coefy
kx_max = (nx/2-1)
ky_max = (ny/2-1)
coefx = - dt * nu * scalex
coefy = - dt * nu * scaley
!$omp parallel do private(kx,ky)
do ky = 0, ky_max
do kx = 0, kx_max
work (2*kx, 2*ky) = exp( coefx * real(kx**2) + coefy * real(ky**2) )
enddo
enddo
!$omp end parallel do
!$omp parallel do private(kx,ky)
do ky=0,ny/2-1
work (1:nx-1:2,2*ky) = work (0:nx-2:2,2*ky)
work (0:nx-2:2,2*ky+1) = work (0:nx-2:2,2*ky)
work (1:nx-1:2,2*ky+1) = work (0:nx-2:2,2*ky)
end do
!$omp end parallel do
end subroutine vis