Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29267 Discussions

error using the IMSL subroutine QDNG for integration

yuezhanwei
Beginner
1,288 Views
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
0 Kudos
5 Replies
yuezhanwei
Beginner
1,288 Views
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.
0 Kudos
mecej4
Honored Contributor III
1,288 Views
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.
0 Kudos
yuezhanwei
Beginner
1,288 Views
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.
0 Kudos
mecej4
Honored Contributor III
1,288 Views
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
[fortran]ERRREL = 1e-4
CALL QDNG (F, A, B, ERRABS, ERRREL, RESULT1,ERREST) 
[/fortran]
and compiling with

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]
0 Kudos
Steven_L_Intel1
Employee
1,288 Views
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.
0 Kudos
Reply