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: | 113 |
Nodes: | 8 (1 / 7) |
Uptime: | 152:58:49 |
Calls: | 2,504 |
Calls today: | 1 |
Files: | 8,703 |
Messages: | 1,929,466 |