program test
type mytype (n)
integer, len :: n
end type mytype
contains
subroutine sub (u, v)
type (mytype(n=*)), intent (out) :: u
integer, intent (out) :: v(0:)
! gfortran does not accept the following declaration for x
! "Dummy argument ‘u’ at (1) cannot be INTENT(OUT)"
integer :: x(u%n), y(size(v))
end subroutine sub
end program test
Le 08/11/2021 à 18:18, Bastiaan Braams a écrit :
program testdeclaring u as intent(out) tells the compiler that it could
type mytype (n)
integer, len :: n
end type mytype
contains
subroutine sub (u, v)
type (mytype(n=*)), intent (out) :: u
integer, intent (out) :: v(0:)
! gfortran does not accept the following declaration for x
! "Dummy argument ‘u’ at (1) cannot be INTENT(OUT)"
integer :: x(u%n), y(size(v))
end subroutine sub
end program test
uninitialised upon entering the routine, thus that the declaration
x(u%n) could not be "resolved".
Using the intent() specifier has also the purpose enabling compile-time checks.
--
"...sois ouvert aux idées des autres pour peu qu'elles aillent dans le même sens que les tiennes.", ST sur fr.bio.medecine
The following code fails to compile under gfortran 10.3.1, and I don't have convenient access to another compiler. Is it a gfortran issue or am I missing something in the language specification?
..
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 159 |
Nodes: | 16 (0 / 16) |
Uptime: | 98:58:47 |
Calls: | 3,209 |
Files: | 10,563 |
Messages: | 3,009,783 |