Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

stack over flow 1

Status
Not open for further replies.

samiyare

Programmer
Dec 31, 2011
1
when i call the following subroutine , stack over flow error is occured.


i see others, with the help of intent(inout) solve this problem but i cant do it,
please help me

error :

First-chance exception at 0x004ff6e7 in ****.exe: 0xC00000FD: Stack overflow.
First-chance exception at 0x0055e065 in ****.exe: 0xC0000091: Floating-point overflow.


compiler : intel visual fortran 11



subroutine gradient_coefficient(real_cell, vir_cell,esuel,xc, yc, zc,grad_coeff1,grad_coeff2,grad_coeff3)

integer, intent(in) :: real_cell, vir_cell
integer, intent(in), dimension(1:4, 1:real_cell + vir_cell) :: &
esuel
real(kind = dbl), intent(in), dimension(1:real_cell + vir_cell) :: xc, yc, zc
real(kind = dbl), intent(out), dimension(1:4, 1:real_cell) :: &
grad_coeff1,grad_coeff2,grad_coeff3

integer :: j, k
real(kind = dbl) :: sie,alpha1,alpha2,alpha3

real(kind = dbl), dimension(1:4, 1:real_cell) :: &
dx,dy,dz

real(kind = dbl), dimension(1:real_cell) :: &
r11,r12,r13,r22,r23,r33
pause '2'
DO j=1,real_cell

DO k=1,4

DX(k,j)= xc(esuel(k,j))-xc(j)
DY(k,j)= yc(esuel(k,j))-yc(j)
DZ(k,j)= zc(esuel(k,j))-zc(j)
END DO

R11(J) = SQRT( DOT_PRODUCT( DX:),J),DX:),J) ) )
R12(J) = DOT_PRODUCT( DX:),J),DY:),J) ) /R11(J)
R13(J) = DOT_PRODUCT( DX:),J),DZ:),J) ) /R11(J)
R22(J) = SQRT( DOT_PRODUCT( DY:),J),DY:),J) ) - R12(J)**2 )
R23(J) = ( DOT_PRODUCT( DY:),J),DZ:),J) ) - R12(J)*R13(J) )/ R22(J)
R33(J) = SQRT( DOT_PRODUCT( DZ:),J),DZ:),J) ) - R13(J)**2-R23(J)**2 )
SIE= ( R12(J)*R23(J)-R13(J)*R22(J) )/(R11(J)*R22(J))

do k=1,4

alpha1= DX(k,j)/(R11(J)**2)
alpha2=(DY(k,j)-R12(J)*DX(k,j)/R11(J))/(R22(J)**2)
alpha3=(DZ(k,j)-R23(J)*DY(k,j)/R22(J)+SIE*DX(k,j))/(R33(J)**2)
grad_coeff1(k,j)=alpha1-r12(j)*alpha2/r11(j)+sie*alpha3
grad_coeff2(k,j)=alpha2-r23(j)*alpha3/r22(j)
grad_coeff3(k,j)=alpha3

end do

END DO


end subroutine gradient_coefficient

 
1) Put implicit none at the top of your routine. It will help spot spelling errors, if any

2) Print out the values of esuel(j,k) before you use them as indices into xc, yc and zc.

3) Print out the values of R?? after each calculation
 
A stack overflow sometimes occurs with too large automatic arrays like dx,dy,dz,r11,r12,r13,r22,r23,r33. Indeed, compilers often decide to allocate these arrays on the stack. On the contrary, allocatable arrays are always allocated on the heap.

It is normally possible to change the behavior of the compiler via options.

But if you don't want to depend on compiler options, then declare large local automatic arrays ALLOCATABLE and allocate them at the top of your subroutine.



François Jacq
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top