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

Use of a module function name as a parameter of IMSL function

lotus
Beginner
513 Views

Hi.

My environments are as follows

IVF 9.1 pro.

MS Visual studio 2005 standard edition

I met compilation error when using a module function name as a parameter of IMSL function (QDAWO).

Of course, if I changed the location of the function f(x) to external, the code runs well.

I think the answer is simple, but I cann't find solution.

Please give me some clue.

!-----sample code from IMSL manual------

[cpp]
include 'link_f90_static.h'

module test_mod
USE QDAWO_INT
USE UMACH_INT
USE CONST_INT

contains
REAL FUNCTION F (X)
REAL X
REAL ALOG
INTRINSIC ALOG
IF (X .EQ. 0.) THEN
F = 0.0
ELSE
F = ALOG(X)
END IF
RETURN
END function
subroutine calc()
INTEGER IWEIGH, NOUT
REAL A, ABS, B, ERRABS, ERREST, ERROR, &
EXACT, F, OMEGA, PI, RESULT
INTRINSIC ABS
! EXTERNAL F
! Get output unit number
CALL UMACH (2, NOUT)
! Set limits of integration
A = 0.0
B = 1.0
! Weight function = sin(10.*pi*x)
IWEIGH = 2
PI = CONST('PI')
OMEGA = 10.*PI
! Set error tolerances
ERRABS = 0.0
CALL QDAWO (F, A, B, IWEIGH, OMEGA, RESULT, ERRABS=ERRABS, &
ERREST=ERREST)
! Print results
EXACT = -0.1281316
ERROR = ABS(RESULT-EXACT)
WRITE (NOUT,99999) RESULT, EXACT, ERREST, ERROR
99999 FORMAT (' Computed =', F8.3, 13X, ' Exact =', F8.3, /, /, &
' Error estimate =', 1PE10.3, 6X, 'Error =', 1PE10.3)
end subroutine
end module

program main
use test_mod
call calc
END program main

[/cpp]



!---------end smaple code-------

0 Kudos
2 Replies
Steven_L_Intel1
Employee
513 Views

You declared F as REAL inside CALC. This hid the module procedure F. Remove F from the REAL declaration in CALC (and, of course, the EXTERNAL F) and it should work.

0 Kudos
lotus
Beginner
513 Views

Thank you for really fast answer.

lotus

0 Kudos
Reply