summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/vect/vect-gems.f90
blob: 66e878d3deec76e9dda905f325affa12c6a84241 (plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
! { dg-do compile }
! { dg-require-effective-target vect_double }

MODULE UPML_mod

IMPLICIT NONE

PUBLIC UPMLupdateE

PRIVATE

real(kind=8), dimension(:,:,:), allocatable :: Dx_ilow

real(kind=8), dimension(:), allocatable :: aye, aze
real(kind=8), dimension(:), allocatable :: bye, bze
real(kind=8), dimension(:), allocatable :: fxh, cxh

real(kind=8) :: epsinv
real(kind=8) :: dxinv, dyinv, dzinv

integer :: xstart, ystart, zstart, xstop, ystop, zstop

CONTAINS

SUBROUTINE UPMLupdateE(nx,ny,nz,Hx,Hy,Hz,Ex,Ey,Ez)

integer, intent(in) :: nx, ny, nz
real(kind=8), intent(inout),                                                &
         dimension(xstart:xstop+1,ystart:ystop+1,zstart:zstop+1) :: Ex, Ey, Ez
real(kind=8), intent(inout),                                                &
         allocatable :: Hx(:,:,:), Hy(:,:,:), Hz(:,:,:)

integer :: i, j, k
real(kind=8) :: Dxold, Dyold, Dzold

do k=zstart+1,zstop
  do j=ystart+1,ystop
    do i=xstart+1,0

      Dxold = Dx_ilow(i,j,k)

      Dx_ilow(i,j,k) = aye(j) * Dx_ilow(i,j,k) +                              &
                       bye(j) * ((Hz(i,j,k  )-Hz(i,j-1,k))*dyinv +            &
                                 (Hy(i,j,k-1)-Hy(i,j,k  ))*dzinv)

      Ex(i,j,k) = aze(k) * Ex(i,j,k) +                                        &
                  bze(k) * (cxh(i)*Dx_ilow(i,j,k) - fxh(i)*Dxold) * epsinv
    end do
  end do
end do

END SUBROUTINE UPMLupdateE

END MODULE UPML_mod

! { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect"  } }
! { dg-final { cleanup-tree-dump "vect" } }
! { dg-final { cleanup-modules "upml_mod" } }