! ! ******* Fourier series of saw-tooth function for PLCM ******* ! subroutine fourexp( si_ex, z, t, D, hpl, ndeg ) implicit none real(8):: si_ex real(8):: z, t real(8):: D, hpl real(8):: s1, sall real(8):: pi integer:: ndeg integer:: i, n real(8),allocatable:: f(:) ! **** allocate **** allocate ( f( ndeg ) ) ! **** pi **** pi = 4.0d0 * atan( 1.0d0 ) ! **** calculate sin( n*pi*z/H )*exp( -(n*pi/H)**2*D*t ) **** do i = 1,ndeg f(i) = 2.0d0 / ( dfloat(i) * pi ) & & * sin( dfloat(i) * pi *z / hpl ) & & * exp( - ( dfloat( i ) * pi / hpl )**2 * D * t ) end do ! **** summation **** s1 = 0.0d0 do i = 1,ndeg s1 = s1 + f(i) end do si_ex = s1 return end subroutine fourexp