|
|
 |
 |
 |
 |
Fortran Programming Language
|
 |
 |
 |
 |
 |
 |
 |
 |
Cray pointer type in Sun's f95
Hello, this is perhaps a very specific question, but is there a way to force Sun's Fortran compiler to treat Cray pointer (not pointee) and the corresponding integer type as equal? Having done my development with the PGI compilers, I'm now getting tons of error messages from the Sun-compiler that Cray pointer types are not compatible with integers which I had used in the subroutine interfaces. I can rewrite the function calls to use the TRANSFER statement, but I would rather not ... Sebastian
On May 11, 5:15 pm, Sebastian Hanigk <han@in.tum.de> wrote: > Hello, > this is perhaps a very specific question, but is there a way to force > Sun's Fortran compiler to treat Cray pointer (not pointee) and the > corresponding integer type as equal? > Having done my development with the PGI compilers, I'm now getting tons > of error messages from the Sun-compiler that Cray pointer types are not > compatible with integers which I had used in the subroutine interfaces. > I can rewrite the function calls to use the TRANSFER statement, but I > would rather not ... > Sebastian
You can convert pointers to integers using INT. If you are compiling for a 64-bit machine, you will need to use the two argument form of INT where the second argument has the value 8. The program SUBROUTINE SUBR(I) PRINT '(Z8)', I END INTERFACE SUBROUTINE SUBR(I) END SUBROUTINE END INTERFACE POINTER(P, I) P = LOC(J) PRINT '(Z8, 2X, Z8)', P, LOC(J) CALL SUBR(INT(P)) END compiles without complaint. Bob Corbett
robert.corb @sun.com writes: > You can convert pointers to integers using INT. If you are compiling > for a 64-bit machine, you will need to use the two argument form of > INT where the second argument has the value 8. Works, but has a drawback (like my TRANSFER solution): a routine cannot modify the value of the pointer. I'm using some temporary integer variables with a range large enough to hold an address value. Sebastian
On May 12, 12:19 pm, Sebastian Hanigk <han@in.tum.de> wrote: > robert.corb @sun.com writes: > > You can convert pointers to integers using INT. If you are compiling > > for a 64-bit machine, you will need to use the two argument form of > > INT where the second argument has the value 8. > Works, but has a drawback (like my TRANSFER solution): a routine cannot > modify the value of the pointer. I'm using some temporary integer > variables with a range large enough to hold an address value.
The old-fashioned way works. Simply equivalence the pointer with an integer of the appropriate size and pass the integer in place of the pointer. Bob Corbett
robert.corb @sun.com writes: > The old-fashioned way works. Simply equivalence the pointer with an > integer of the appropriate size and pass the integer in place of the > pointer. Ah, thanks! I hadn't thought about EQUIVALENCE. I'm quite happy that the usage of Cray pointers in my code is soon to be gone; having access to a Solaris-based cluster enables me to use the Sun compiler suite extensively, so I'm using the F2003 C-interoperability facilities like C_F_POINTER instead. Sebastian
|
 |
 |
 |
 |
|