- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Maybe someone else (me?) already posted a similar question, but I got tired of browsing page results in the new (global) forum search, so I apologize for that.
Is there any way, as of Fortran 95, to get the correct lower bounds in a pointer to the component of a derived type array? None of the options I tried in the code below seem to work ---with the last option (The Fortran 2003 way, according to MR&C), I get "error #6731: Object is not a pointer object". Maybe that feature is not yet implemented, but the error message is not helpful at all.
program test
implicit none
type :: t2
integer :: c
end type
type :: t1
type(t2), allocatable :: b(:,:)
end type
type(t1), target :: a
integer, pointer :: c(:,:)
allocate (a%b(-1:100, 0:100))
c => a%b%c
print *, LBOUND(c)
print *, UBOUND(c)
read *
c => a%b(:,:)%c
print *, LBOUND(c)
print *, UBOUND(c)
read *
c => a%b(-1:,0:)%c
print *, LBOUND(c)
print *, UBOUND(c)
c(-1:,0:) => a%b%c
print *, LBOUND(c)
print *, UBOUND(c)
end program test
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
john.f90:28:
c(-1:,0:) => a%b%c
1
Error: Pointer bounds remapping at (1) is not yet implemented in gfortran
________________________________________________
Of several compilers I tried, none accepted it, and only this one deviates from "not a pointer object."
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
john.f90:28:
c(-1:,0:) => a%b%c
1
Error: Pointer bounds remapping at (1) is not yet implemented in gfortran
________________________________________________
Of several compilers I tried, none accepted it, and only this one deviates from "not a pointer object."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a%b%c is an invalid syntax given the types
a%b is a type(t2) array
a%b(index)%cwould bea reference to a scalar integer
integer, pointer :: c(:,:)
...
c => a%b%c ! (integer array pointer) => (integer scalar)
Not correct (unless the compiler implicitly sets cwith bounds of(1:1))
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a%b%c is an invalid syntax given the types
If a%b%c is invalid, doesn't that defeat the purpose of using derived types in an array programming language? I've always considered it correct, by analogy with, say A(:) versus A (i.e., slice versus whole array). So, if a%b(:,:)%c is valid, then a%b%c should also be valid... Or, can it be that a%b(:,:)%c is invalid as well?
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page