Results 1 to 10 of 10

Thread: stack overflow error with FDHES

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Posts
    7

    stack overflow error with FDHES

    Hello,
    I have a problem with numerical Hessian routine FDHES. The program gives an error: Program Exception - stack overflow
    at the line where FDHES is called. I would appreciate if one can give me a hint where my problem is. The piece of code is below.
    Thanks!

    PROGRAM check_fcn
    INCLUDE 'link_fnl_shared.h'
    USE IMSL_LIBRARIES, ONLY: FDHES
    USE linear_operators
    IMPLICIT NONE
    INTEGER(4),PARAMETER nvr=2,npar=2*nvr+nvr*(nvr-1)/2 +1
    REAL(8) xs(nvr),bb(npar),HES(nvr,nvr),fstar

    !STARTING VALUES ARE: means and columns of cariance-covariance matrix
    bb(1)=0d0; bb(3)=0.5d0; bb(4)=0.01d0; bb(5)=0.5d0; bb(npar)=1d0
    xs=bb(1:2)
    CALL Hlnphi(nvr,xs,fstar)
    CALL FDHES(Hlnphi,xs,fstar,HES)

    CONTAINS

    SUBROUTINE Hlnphi(n,zz,lnphi)
    IMPLICIT NONE
    INTEGER(4),INTENT(IN) n
    REAL(8),INTENT(IN) zz(n)
    REAL(8) lnphi,phi0(1,1),z(n,1)
    REAL(8) trumu1(n,1),trusig1(n,n)
    REAL(8) trumu2(n,1),trusig2(n,n)
    REAL(8) trumu3(n,1),trusig3(n,n)
    z(:,1)=zz
    trumu1=1d0; trusig1=-3d0; trusig1(1,1)=5d0; trusig1(2,2)=5d0
    trumu2(1,1)=-1d0; trumu2(2,1)=1d0; trusig2=3d0; trusig2(1,1)=5d0; trusig2(2,2)=5d0
    trumu3(1,1)=0d0; trumu3(2,1)=-1d0; trusig3=0d0; trusig3(1,1)=1d0; trusig3(2,2)=2d0
    trusig1= .i. (0.5d0*trusig1) ; trusig2= .i. (0.5d0*trusig2); trusig3= .i. trusig3
    phi0 =0.25d0* &
    & sqrt(DET(trusig1))*exp(-matmul(matmul(transpose(z-trumu1),trusig1),(z-trumu1))/2d0)+ &
    & 0.25d0* &
    & sqrt(DET(trusig2))*exp(-matmul(matmul(transpose(z-trumu2),trusig2),(z-trumu2))/2d0)+ &
    & 0.5d0* &
    & sqrt(DET(trusig3))*exp(-matmul(matmul(transpose(z-trumu3),trusig3),(z-trumu3))/2d0)
    lnphi=-log(phi0(1,1))

    END SUBROUTINE Hlnphi

    END PROGRAM check_fcn

  2. #2
    Senior Member mecej4's Avatar
    Join Date
    Dec 2009
    Posts
    139
    Please disclose the compiler and IMSL versions used, and the platform.

  3. #3
    Junior Member
    Join Date
    Sep 2011
    Posts
    7
    Microsoft Visual Studio 2008, Intel® Visual Fortran Compiler Professional Edition 11.1, IMSL FNL 6.0

  4. #4
    Senior Member mecej4's Avatar
    Join Date
    Dec 2009
    Posts
    139
    Your program compiles with errors since three lines are missing double colons (those are lines with declarations of more than one attribute). After correcting those lines, I was able to compile and run the program with no errors (and no output).

  5. #5
    Junior Member
    Join Date
    Sep 2011
    Posts
    7
    If you mean:

    INTEGER(4),PARAMETER :: nvr=2,npar=2*nvr+nvr*(nvr-1)/2 +1
    REAL(8) :: xs(nvr),bb(npar),HES(nvr,nvr),fstar

    then that is what I originally have in my code. Forum didn't allow me to post to many colons as it refered to too many inserted imiges (I assume, smileys), so to post my code I removed them. Even with double colons the program still runs with the same error. Let me know if you referred to different double colons.

    I also think that the problem may be in the general settings of the compiler, but I cannot know where to fix.

  6. #6
    Junior Member
    Join Date
    Feb 2009
    Location
    Houston, TX
    Posts
    29
    Please tell us how you are compiling and linking.

  7. #7
    Junior Member
    Join Date
    Sep 2011
    Posts
    7
    I use Microsoft visual studio, I also add C:\Program Files\VNI\imsl\fnl600\IA32\lib in Linker -> general -> additional library dependencies.
    Let me know if I need to check for anything specific. The program is not fixed and gives me the same mistake.

  8. #8
    Junior Member
    Join Date
    Feb 2009
    Location
    Houston, TX
    Posts
    29
    Go to Project settings -> Configuration properties -> Fortran -> Coimmand Line

    Under Additional Options add:
    /F6000000

    This will increase the stack size.

  9. #9
    Junior Member
    Join Date
    Sep 2011
    Posts
    7
    It gives me the same error.

  10. #10
    Junior Member
    Join Date
    Feb 2009
    Location
    Houston, TX
    Posts
    29
    The problem may be because you have the function Hlnphi is in a contains and it is therefore local and unknown to FDHES. Try either creating an interface for function Hlnphi or declaring it External. For either case you may need to move the function outside of Program check_fcn.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •