Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Array constructors

IanH
Honored Contributor III
721 Views

Zero sized array constructors for derived types used to work, didn't they?  They syntax for them appears to be in the compiler docs.

[fortran]PROGRAM WhereDidZeroSizedArrayConstructorsGo
  IMPLICIT NONE
 
  TYPE :: my_type
  END TYPE my_type
  TYPE(my_type), ALLOCATABLE :: array(:)
 
  array = [ my_type :: ]
  PRINT *, SIZE(array)
END PROGRAM WhereDidZeroSizedArrayConstructorsGo
[/fortran]

[plain]>ifort /check:all /warn:all /standard-semantics ArrayConstructors.f90
Intel(R) Visual Fortran Compiler XE for applications running on IA-32, Version 13.0.1.119 Build 20121008
Copyright (C) 1985-2012 Intel Corporation.  All rights reserved.

ArrayConstructors.f90(8): error #5082: Syntax error, found '::' when expecting one of: , (/ : ]
  array = [ my_type :: ]
--------------------^
ArrayConstructors.f90(8): error #6478: A type-name must not be used as a variable.   [MY_TYPE]
  array = [ my_type :: ]
------------^
compilation aborted for ArrayConstructors.f90 (code 1)[/plain]

Or am I imagining things?  I would have sworn that they were in active use in our code base, but now I can't find any examples.

Yours in deluded confusion,

IanH

0 Kudos
1 Reply
Steven_L_Intel1
Employee
721 Views
We don't yet support this with derived types - it's already on our list. We do support it with intrinsic types, for example: [integer::]
0 Kudos
Reply