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

real precision conversion

fbisetti
Beginner
573 Views

Hi all,

I have a question about the generic elemental function REAL(a[,kind])

Does the function work element by element if the input argument 'a' is an array? In other words, does the following work correctly?

! -- code start

real(4) :: x(10)
real(8) :: y(10)

call random_number(y); x=real(y,4)

! -- code end

If this works, does it work regardless of the number of dimensions of the array (1D, 2D, ...)?

The reason that I'm asking it that I got a SEGFAULT when trying to something similar in a code, but in other occasions, it seemed to work fine. This left me confused and I wanted to check. The language reference document doesn't seem to mention the shape of the input argument.

Thanks a lot,
Fabrizio



0 Kudos
2 Replies
Steven_L_Intel1
Employee
573 Views
REAL is elemental, so if you pass it an array argument of any shape it will return an array of the same shape. The manual says it is elemental and thus you need to go read what that means.
0 Kudos
fbisetti
Beginner
573 Views

Thanks a lot,

Fabrizio

0 Kudos
Reply