Quantcast
Channel: Intel® Software - Intel® Visual Fortran Compiler for Windows*
Viewing all articles
Browse latest Browse all 5691

TARGET question

$
0
0

I have some code which is supposed to set up a structure foo of type t_stuff.  This type contains two allocatable arrays, boxes and stres.  One of these types has a pointer to the other:

!-----------------------------------------------------------------
      module data_n

      type :: t_box
        integer                  :: num
      end type t_box

      type :: t_str
        integer                  :: num
        type(t_box), pointer     :: begin
        type(t_box), pointer     :: end
      end type t_str

      type :: t_stuff
        type(t_box), allocatable :: boxes(:)
        type(t_str), allocatable :: stres(:)
      end type t_stuff

      end module data_n
!-----------------------------------------------------------------

      program test
      use data_n
      implicit none

      type(t_stuff) :: foo

      allocate(foo%boxes(2))
      allocate(foo%stres(1))

      foo%stres(1)%begin => foo%boxes(1)
      foo%stres(1)%end   => foo%boxes(2)

      end
When I compile this I get:

bb.f90(31): error #6796: The variable must have the TARGET attribute or be a subobject of an object with the TARGET attribute, or it must have the POINTER attribute.   [FOO]
      foo%stres(1)%begin => foo%boxes(1)
----------------------------^
bb.f90(32): error #6796: The variable must have the TARGET attribute or be a subobject of an object with the TARGET attribute, or it must have the POINTER attribute.   [FOO]
      foo%stres(1)%end   => foo%boxes(2)
----------------------------^

 

If I put the TARGET specifier in the t_stuff definition it complains too:

bb.f90(15): error #6516: This attribute specification is not valid for a component definition statement.   [TARGET]
        type(t_box), allocatable, target :: boxes(:)
----------------------------------^

How do I do this properly?

 


Viewing all articles
Browse latest Browse all 5691

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>