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

Point of confusion: LOC() page in IFort 15 manual

mecej4
Honored Contributor III
1,208 Views

The documentation for the non-standard LOC() function in the IFort 15 manual at https://software.intel.com/en-us/compiler_15.0_ug_f contains example code containing Cray pointers, and readers who may have never heard of Cray pointers may find the code confusing. Perhaps the adjective 'Cray' can be added to the word 'pointer' in the comments in the code to obviate this confusion.

0 Kudos
7 Replies
Steven_L_Intel1
Employee
1,208 Views

Well, we don't call them Cray pointers - we call them "integer pointers". Cray doesn't want you to call them Cray pointers either, but accept that everyone does. I will suggest an edit to this text.

0 Kudos
Steven_L_Intel1
Employee
1,208 Views

Wow - that example has a LOT more wrong than just what we call the pointer. Neither the Fortran code nor the C code would even compile, and the example itself is ridiculous. I will come up with something better.

0 Kudos
mecej4
Honored Contributor III
1,208 Views

The buggy example code (square brackets for Fortran dimensions; setting an integer equal to a float array in the C function; the non-use of the array VAR associated with the integer pointer; expecting the local array a[] in the C function to remain allocated after leaving the C function) is the same as it was in the CVF 6 reference manual!

0 Kudos
Steven_L_Intel1
Employee
1,208 Views

Not surprising.... We have a project underway to take all of the manual examples and put them in a test suite. You didn't mention that the example works only for 32-bit.

0 Kudos
Steven_L_Intel1
Employee
1,208 Views

And the example goes back further than that - it came from the Microsoft Fortran PowerStation reference, with the same errors.

0 Kudos
andrew_4619
Honored Contributor III
1,208 Views

Steve Lionel (Intel) wrote:

And the example goes back further than that - it came from the Microsoft Fortran PowerStation reference, with the same errors.

I binned a box of stuff last year and one of the contents was the Powerstation 1.0 manual. I almost wish I had kept it to have a laugh now and again. Actually Powerstation was a big plus when it came our as it gave access to extended memory :-)

0 Kudos
Steven_L_Intel1
Employee
1,208 Views

I have asked that the example be replaced with this:

    ! Example of using the LOC intrinsic
    integer :: array(2) = [10,20]
    integer :: t
    pointer (p,t) ! Integer pointer extension
                      ! p is pointer, t is pointee (target)
                      ! This declares p as an address-sized integer
    
    p = loc(array(1)) ! Address of array(1)
    print *, t ! Prints 10
    p = loc(array(2)) ! Address of array(2)
    print *, t ! Prints 20

I also suggested adding text recommending use of the ISO_C_BINDING functions instead, though those are not a direct replacement for LOC (and integer pointers).

0 Kudos
Reply