Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29280 Discussions

ALLOCATABLE components of derived types

gfthomas8
Novice
760 Views
Apparantly CVF 6.6B has support for ALLOCATABLE components of derived types. Does anyone have a code snippet showing how to avail of this F2K feature? (I've looked in the HTML and samples folder but I didn't come across anything relevant.)

Thank you,
Gerry T.
0 Kudos
2 Replies
james1
Beginner
760 Views
Here is an example:
program allcomp
implicit none
type stuff
  integer length
  integer, allocatable :: value(:)
end type stuff
real h
integer max_fields, i, j
type (stuff), allocatable :: fields(:)

call RANDOM_SEED ()
max_fields = 20

! allocate data structure, random number of
! values per field

ALLOCATE (fields(max_fields))
do i = 1, max_fields
  call RANDOM_NUMBER (h)
  fields(i)%length = FLOOR(h*9.) + 1
  ALLOCATE (fields(i)%value(fields(i)%length))
end do

! initialize each existing value to its index

do i = 1, max_fields
  do j = 1, fields(i)%length
    fields(i)%value(j) = j
  end do
end do

! show what we have

do i = 1, max_fields
  j = fields(i)%length
  print "((x,i1))", fields(i)%value(1:j)
end do

end program allcomp
James
0 Kudos
gfthomas8
Novice
760 Views
James:

Your sample is much appreciated.
I dug up ftp://ftp.nag.co.uk/sc22wg5/N1351-N1400/N1379.pdf which might be of interest.

Ciao,
Gerry T.
0 Kudos
Reply