- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can I declare pointer locations in a structure constructor? I have two structures that refer to the same structure array by a pointer, and I would like to set these up at compile time.
My example code looks like thus:
but it doesn't compile (CVF 6.6 on Windows XP). The sticking point is in the %loc() or loc() initialisations for the pointers - can this be done? Any suggestions welcome!
All the best,
Eddie
My example code looks like thus:
program TestExtractSpec
!
implicit none
!
! declarations
!
type :: Descriptor
integer(4) vartype ! Type of variable
character*80 Name ! Name of variable
end type
!
type :: ExtractSpec
integer(4) start ! Start of variable in record
integer(4) length ! Length of variable
type(Descriptor), pointer :: description ! Associated information
end type
!
type :: OutputSpec
Integer(4) location ! Column number
type(Descriptor), pointer :: description ! Associated information
end type
!
! data
!
type (Descriptor), dimension(2) :: Descriptors = (/ &
Descriptor(1, "Hello 1"), &
Descriptor(2, "Hello 2") /)
!
type (ExtractSpec), dimension(2) :: twoRecordSpecs = (/ &
ExtractSpec(18, 16, %LOC(Descriptors(1))), &
ExtractSpec(61, 16, %LOC(Descriptors(2))) /)
!
type (OutputSpec), dimension(2) :: twoPrintSpecs = (/ &
OutputSpec(2, loc(Descriptors(1))), &
OutputSpec(1, loc(Descriptors(2))) /)
!
! more stuff
!
end program
but it doesn't compile (CVF 6.6 on Windows XP). The sticking point is in the %loc() or loc() initialisations for the pointers - can this be done? Any suggestions welcome!
All the best,
Eddie
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Not like that - Fortran 90 pointers aren't compatible with %LOC. I think the only pointer you can use in a constructor is NULL().
Steve
Steve
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