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

Passing argument of real*4 to a function where argument required in real *8

acobulareddy
Beginner
810 Views

I am trying to call a function f1(a). by using

CALL F1(A)

In this functionA is a REAL *4

where as in F1 Function argument required is REAL*8

When A goes into F1 it is showing as some null data.

Currently I am calling F1(A) as F1(DBLE(A)). which is solving the problem.

Is there any setting that I need to make it passed with out using DBLE function.

Thanks for your help
Chandra.

0 Kudos
3 Replies
Steven_L_Intel1
Employee
810 Views

No. Fortran requires that arguments match in type, kind and rank. Use of DBLE is certainly one approach, and perhaps the most reasonable. If the called function writes back to the argument, however, you'll want another solution, such as assigning to a variable of the matching type and then passing that.

0 Kudos
TimP
Honored Contributor III
810 Views
Quoting - acobulareddy
Currently I am calling F1(A) as F1(DBLE(A)).


You have chosena normal f77 way of doing this. If you mean, is there a way to emulate platforms of 35 years ago where you could pass a single precision value to a double precision argument with a relativeerror of about 1e-6 (taking a big risk in the case where the value is modified), the answer is no.

0 Kudos
jimdempseyatthecove
Honored Contributor III
810 Views
Quoting - acobulareddy

I am trying to call a function f1(a). by using

CALL F1(A)

In this functionA is a REAL *4

where as in F1 Function argument required is REAL*8

When A goes into F1 it is showing as some null data.

Currently I am calling F1(A) as F1(DBLE(A)). which is solving the problem.

Is there any setting that I need to make it passed with out using DBLE function.

Thanks for your help
Chandra.


You can do this using generic interface. You would create a generic interface for F1 and then two specific interfaces such ason as F1_single and F1_double where one accepts the single precision argument and the other accepts the double precision argument. The IVFdocumentation illustrates how do do this.

Jim Dempsey

0 Kudos
Reply