In Fortran2003 program, I want to create a derived type that includes an allocatable array with asynchronous
attribute:
module async_in_type
type async_array
integer, dimension(:), allocatable, asynchronous :: a
end type async_array
end module async_in_type
When I try to compile the code above with GCC, I get the following error message:
$ gfortran -c -Wall -Wextra async_in_type.F90
GNU Fortran (GCC) 4.10.0 20140718 (experimental)
async_in_type.F90:3.52:
integer, dimension(:), allocatable, asynchronous :: a
1
Error: Attribute at (1) is not allowed in a TYPE definition
With NAG Fortran the message is similar:
$ nagfor -c async_in_type.F90
NAG Fortran Compiler Release 6.0(Hibiya)
Product NPL6A60NA for x86-64 Linux
Error: async_in_type.F90, line 3: Syntax error
detected at ,@ASYNCHRONOUS
[NAG Fortran Compiler pass 1 error termination, 1 error]
What is the reason for such restriction? Is it possible to overcome this restriction?
The compiler message is exact and very clear, let me repeat it:
So it simply isn't allowed by the standard.
You must put the
asynchronous
attribute to the variables of typeasync_in_type
.