- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to use the IMSL library for a numerical integration. I got an error when replicating the example from the user's guide. The code is below. The error says "Program exception. access violation". I have set the program option to include the path to the IMSL library and have used other IMSL subroutine without any problem. Can someone point out what's wrong? Thank you very much.
PROGRAM main
INCLUDE 'link_fnl_static.h'
!DEC$ OBJCOMMENT LIB:'libiomp5md.lib'
IMPLICIT NONE
INTEGER NOUT
REAL A, ABS, B, ERRABS, ERREST, ERROR, EXACT, EXP, F, RESULT1
INTRINSIC ABS, EXP
EXTERNAL F
! Get output unit number
CALL UMACH (2, NOUT)
! Set limits of integration
A = 0.0
B = 2.0
! Set error tolerances
ERRABS = 0.0
CALL QDNG (F, A, B, RESULT1) !, ERRABS=ERRABS, ERREST=ERREST)
! Print results
EXACT = 1.0 + EXP(2.0)
ERROR = ABS(RESULT1-EXACT)
WRITE (NOUT,99999) RESULT1, EXACT, ERREST, ERROR
99999 FORMAT (' Computed =', F8.3, 13X, ' Exact =', F8.3, /, /, &
' Error estimate =', 1PE10.3, 6X, 'Error =', 1PE10.3)
END
!
REAL FUNCTION F (X)
REAL X
REAL EXP
INTRINSIC EXP
F = X*EXP(X)
RETURN
END
PROGRAM main
INCLUDE 'link_fnl_static.h'
!DEC$ OBJCOMMENT LIB:'libiomp5md.lib'
IMPLICIT NONE
INTEGER NOUT
REAL A, ABS, B, ERRABS, ERREST, ERROR, EXACT, EXP, F, RESULT1
INTRINSIC ABS, EXP
EXTERNAL F
! Get output unit number
CALL UMACH (2, NOUT)
! Set limits of integration
A = 0.0
B = 2.0
! Set error tolerances
ERRABS = 0.0
CALL QDNG (F, A, B, RESULT1) !, ERRABS=ERRABS, ERREST=ERREST)
! Print results
EXACT = 1.0 + EXP(2.0)
ERROR = ABS(RESULT1-EXACT)
WRITE (NOUT,99999) RESULT1, EXACT, ERREST, ERROR
99999 FORMAT (' Computed =', F8.3, 13X, ' Exact =', F8.3, /, /, &
' Error estimate =', 1PE10.3, 6X, 'Error =', 1PE10.3)
END
!
REAL FUNCTION F (X)
REAL X
REAL EXP
INTRINSIC EXP
F = X*EXP(X)
RETURN
END
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can someone help or simply run this code on your computer to see if you get the same error? I am using intel visual fortran XE 2011 composer. I just tried that I cannot run other integration subroutine neither and got the same error. It seems to be a problem with the setup. Appreciate any suggestion.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You called QDNG with the F77 interface (since the OPTIONAL/KEYWORD arguments are listed after the begin-comment mark ('!'). The F77 signature of this routine is
CALL QDNG (F, A, B, ERRABS, ERRREL, RESULT, ERREST)
All arguments must be present if you use this interface.
CALL QDNG (F, A, B, ERRABS, ERRREL, RESULT, ERREST)
All arguments must be present if you use this interface.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a lot. Following your suggestion, I now got rid of the error. When I used the exact command you suggested, the code works except that the integration subroutine exceeds the maximal number of steps and I was suggested a different subroutine QDAGS. Thank you very much.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you did not specify a value for either ERRREL or ERRABS, and both happened to contain zero, the routine would not be able to meet the specified (infinite!) accuracy requirement.
With the following modification to your source
ifort /MD quad.f90 c:imsl_dll.lib c:imsls_err.lib
I get
[fortran]ERRREL = 1e-4 CALL QDNG (F, A, B, ERRABS, ERRREL, RESULT1,ERREST)and compiling with
[/fortran]
ifort /MD quad.f90 c:imsl_dll.lib c:imsls_err.lib
I get
[bash] Computed = 8.389 Exact = 8.389 Error estimate = 5.000E-05 Error = 9.537E-07
[/bash]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You also left out two lines that were in the manual, though on the preceding page so it was easy to overlook:
USE QDNG_INT
USE UMACH_INT
That was why you had the initial problem. You would not use these lines if calling the Fortran 77 interface.
USE QDNG_INT
USE UMACH_INT
That was why you had the initial problem. You would not use these lines if calling the Fortran 77 interface.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page