Quantcast
Channel: Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2583

associate contruct vs. accessing directly the type components

$
0
0

Hi,

I am unable to compile the following code:

$ ifort -c tst.f90

tst.f90(27): error #6780: A dummy argument with the INTENT(IN) attribute shall not be defined nor become undefined.   [AT1]

   call at1%set_x()

--------^

compilation aborted for tst.f90 (code 1)

Using the complete reference  a%p%set_x()  instead of the associate construct works. Is this the correct behaviour or an error by ifort?

module m
 implicit none

 type :: t1
  real :: x
 contains
  procedure, pass(var) :: set_x
 end type t1

 type :: t2
  type(t1), pointer :: p => null()
 end type t2

contains

 pure subroutine set_x(var)
  class(t1), intent(inout) :: var
   var%x = 2.0
 end subroutine set_x

 subroutine s(a)
  type(t2), intent(in) :: a

   !call a%p%set_x() ! accepted

   associate( at1 => a%p ) ! not accepted
   call at1%set_x()
   end associate

 end subroutine s

end module m

 


Viewing all articles
Browse latest Browse all 2583

Trending Articles



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