- #1

s_hy

- 61

- 0

i have codes for 1d fdtd maxwell equation. the problem i am facing right now is some error regarding the kind notation.

Code:

```
!1d fdtd Simulation in free space
subroutine fd1d01(f0,miu,delta,S,E0)
implicit none
real :: f0
real :: miu
real :: delta
real :: S
real :: E0
integer :: iinit
integer :: ilast
real :: Ca
real :: Da
integer (kind = 2) :: i
integer (kind = 5) :: n
real :: tdelta
real :: c
real,dimension(:,:),allocatable :: Ez
real,dimension(:,:),allocatable :: Hy
real, parameter :: pi = 3.14159265
real :: Cb
real :: Db
real :: lambda
real :: alpha
character(len=20) ::filename
allocate (Ez(-1:103,-1:503))
allocate (Hy(-1:103,-1:503))
f0 = 1.0
miu = 1.0
delta = 1.0
S = 1.0
E0 = 1.0
iinit = 0
ilast = 100
c = 3.e8
lambda = c/f0
print *,'lambda=',lambda
alpha = 0.04*lambda
print *,'alpha=',alpha
tdelta = 1.0*alpha/(S*c)
print*, 'tdelta=',tdelta
!initialization
do i = iinit,ilast
Ez(iinit+1/2,0) = 0
Hy(iinit+1,0) = 0
end do
Ca = 1.0
Cb = tdelta/(delta*alpha)
Da = 1.0
Db = tdelta/(miu*alpha)
!write (filename, "('ez',I3.3,'.dat')") n
!open (unit=130,file=filename)
do n = 1,500
write (filename, "('ez',I3.3,'.dat')") n
open (unit=130,file=filename)
do i = iinit+1,ilast
Ez(real(i-0.5,n+0.5)) = Ca*(Ez(real(i-0.5,n-0.5))) + Cb*(Hy(i,n)-Hy(i-1,n))
Hy(i,n+1) = Da*(Hy(i,n)) + Db*(Ez(real(i+0.5,n+0.5))-Ez(real(i-0.5,n+0.5)))
Write (130,*) i-0.5, Ez(real (i-0.5,n+0.5))
end do !i
!plane wave source
Ez(1./2+(ilast-iinit)/2,n) = E0*sin (2*pi*f0*n*tdelta)
close (unit=130)
end do !n
end SUBROUTINE fd1d01
```

the error as below:

Code:

```
subroutines.f90:15.17:
integer (kind = 5) :: n
1
Error: Kind 5 not supported for type INTEGER at (1)
subroutines.f90:62.4:
do n = 1,500
1
Error: Symbol 'n' at (1) has no IMPLICIT type
subroutines.f90:76.5:
Ez(1./2+(ilast-iinit)/2,n) = E0*sin (2*pi*f0*n*tdelta)
1
Warning: Extension: REAL array index at (1)
make: *** [subroutines.o] Error 1
```

can anyone advice me how to solve this problem.

thank you