- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have a question about the function c_loc() of iso_c_binding,
[bash]real(c_double),dimension(:), pointer :: temp1,temp2
allocate(temp1(f_sp%sizeknots))
allocate(temp2(f_sp%sizecoefs))
f_sp%knots=c_loc(temp1)[/bash]
what exactly is a associated scalar pointer, and why the compiler tolerate this instead of c_loc(temp1(1)) ?
Thanks
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The C_LOC here returns a TYPE(C_PTR) containing the location (address) of its argument. Since temp1 is a pointer and the dummy argument to C_LOC is not, you get the location of the first storage element of the thing pointed to by temp1, which would be the same as if temp1(1) was specified.
In Fortran 2003, C_LOC could be specified for "interoperable" arguments only, and temp1 is not that. But Fortran 2008 relaxed the rule to remove the requirement that the argument be interoperable. Intel Fortran does not check this requirement (and is not required to.)
An "associated scalar pointer" is a pointer to a scalar that is associated, since pointer arrays are not interoperable. Fortran 2003 lists that as one of the acceptable argument types for C_LOC, but Fortran 2008, as I said above, relaxes that.
In Fortran 2003, C_LOC could be specified for "interoperable" arguments only, and temp1 is not that. But Fortran 2008 relaxed the rule to remove the requirement that the argument be interoperable. Intel Fortran does not check this requirement (and is not required to.)
An "associated scalar pointer" is a pointer to a scalar that is associated, since pointer arrays are not interoperable. Fortran 2003 lists that as one of the acceptable argument types for C_LOC, but Fortran 2008, as I said above, relaxes that.
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