- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a lot,
Fabrizio

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