I use Intel visual Fortran 2013 + Microsoft Visual Studio 2008, when i run the code, i got the report "Aborting due to internal error"
Please help me out of here, thanks!
The code is :
subroutine d_tauchen(y,pi,rho,sigma,n,cover_tauchen)
use imsl_libraries
use shared_types
implicit none
integer, intent(in) :: n
real(data_type), intent(in) :: rho, sigma, cover_tauchen
real(data_type), dimension (n,n), intent(out) :: pi
real(data_type), dimension (n), intent(out) :: y
integer :: yc, tc, tcc
real(data_type) :: sigy, mu, upp, low
! Define the discrete states of the Markov chain
! variance of shock
sigy = sigma/sqrt(1.0-rho**2)
! set upper bound and lower bound of shocks
y(n) = cover_tauchen*sigy !%(sqrt(n)/sqrt(2.0))*sigy ! good for 0.007, increase later
y(1) = -y(n)
do yc = 2, n-1
y(yc) = y(1)+(y(n)-y(1))*(yc-1.0)/(n-1.0)
end do
! Compute the transition matrix
do tc = 1,n
mu = rho*y(tc)
upp = (y(2)+y(1))/2.0
upp = (upp-mu)/sigma
pi(tc,1) = D_ANORDF(upp)
low = (y(n)+y(n-1))/2.0
low = (low-mu)/sigma
pi(tc,n) = 1.0-D_ANORDF(low)
do tcc = 2, n-1
low = (y(tcc-1)+y(tcc))/2.0
upp = (y(tcc+1)+y(tcc))/2.0
low = (low-mu)/sigma
upp = (upp-mu)/sigma
pi(tc,tcc) = D_ANORDF(upp)-D_ANORDF(low)
end do
end do
open(unit=98,file='Tauchen.txt')
write(98,*) 'rho, sigma, n'
write(98,*) rho, sigma, n
write(98,*) 'Income States'
write(98,*) y(1:n)
write(98,*) 'Transition Matrix'
do tc=1,n
write(98,*) pi(tc,:)
end do
close(98)
end subroutine